「VCS/FileMan」の編集履歴(バックアップ)一覧はこちら

VCS/FileMan - (2012/12/04 (火) 22:54:11) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

|開発環境|Microsoft Visual C# 2010 Express (SP1)| |実行環境|Microsoft Windows XP Home Edition (SP3)| |プロジェクトの種類|Windows フォーム アプリケーション| |プロジェクト名|FileMan| Form Form1 Size:800, 600 Text:FileMan メニューとツール バー/ToolStrip toolStrip1 toolStripTextBox1 コンポーネント/ImageList imageList1 ColorDepth:Depth32Bit コンテナー/SplitContainer splitContainer1 FixedPanel:Panel1 Panel1 コモン コントロール/TreeView treeView1 Dock:Fill ImageList:imageList1 Panel2 コモン コントロール/ListView listView1 Dock:Fill SmallImageList:imageList1 参考 -[[ファイルからアイコンを抽出して、ImageListへ登録: C#研究所>http://acha-ya.cocolog-nifty.com/blog/2010/12/imagelist-7ecb.html]] -[[初心者プログラマの憂鬱>http://ameblo.jp/yomoko0/theme-10018669371.html]] Form1.cs #highlight(c#){{ using System; using System.Drawing; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; namespace FileMan { public partial class Form1 : Form { [DllImport("Shell32.dll", CharSet = CharSet.Auto)] extern static uint ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phiconLarge, IntPtr[] phiconSmall, uint nIcons); bool ImageAddIcon(string dllPath, ImageList orderImageList) { uint iconCnt = ExtractIconEx(dllPath, -1, null, null, 1); if (iconCnt == 0) return false; IntPtr[] hIcon = new IntPtr[iconCnt]; uint getCnt; if (orderImageList.ImageSize.Width <= SystemInformation.SmallIconSize.Width && orderImageList.ImageSize.Height <= SystemInformation.SmallIconSize.Height) { getCnt = ExtractIconEx(dllPath, 0, null, hIcon, iconCnt); } else { getCnt = ExtractIconEx(dllPath, 0, hIcon, null, iconCnt); } if (getCnt < 1) return false; for (int idx = 0; idx < getCnt; idx++) { if (hIcon[idx] != IntPtr.Zero) { using (Icon icon = Icon.FromHandle(hIcon[idx])) { orderImageList.Images.Add(icon); } } } return true; } public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // 画像リストにアイコンを追加 ImageAddIcon(@"C:\WINDOWS\system32\SHELL32.dll", imageList1); // ドライブ一覧 string[] drives = Environment.GetLogicalDrives(); foreach (string drv in drives) { TreeNode node = new TreeNode(drv, 7, 7); treeView1.Nodes.Add(node); node.Nodes.Add(""); } // リストビューの設定 listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; listView1.Columns.Add("名前", 200); listView1.Columns.Add("サイズ", 100, HorizontalAlignment.Right); listView1.Columns.Add("更新日時", 100); } private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeNode treeNode = e.Node; string path = treeNode.FullPath; treeNode.Nodes.Clear(); DirectoryInfo dirInfo = new DirectoryInfo(path); try { foreach (DirectoryInfo di in dirInfo.GetDirectories()) { TreeNode node = new TreeNode(di.Name, 3, 4); treeNode.Nodes.Add(node); DirectoryInfo subDir = new DirectoryInfo(di.FullName); if (subDir.GetDirectories().Length > 0) { node.Nodes.Add(""); } } } catch { } } private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { toolStripTextBox1.Text = e.Node.FullPath; TreeNode treeNode = e.Node; string path = treeNode.FullPath; listView1.Items.Clear(); DirectoryInfo dirInfo = new DirectoryInfo(path); try { string[] line = new string[3]; foreach (DirectoryInfo di in dirInfo.GetDirectories()) { line[0] = di.Name; ListViewItem item = new ListViewItem(line, 3); listView1.Items.Add(item); } foreach (FileInfo fi in dirInfo.GetFiles()) { line[0] = fi.Name; ListViewItem item = new ListViewItem(line, 70); listView1.Items.Add(item); } } catch { } } } } }}
|開発環境|Microsoft Visual C# 2010 Express (SP1)| |実行環境|Microsoft Windows XP Home Edition (SP3)| |プロジェクトの種類|Windows フォーム アプリケーション| |プロジェクト名|FileMan| Form Form1 Size:800, 600 Text:FileMan メニューとツール バー/ToolStrip toolStrip1 toolStripTextBox1 コンポーネント/ImageList imageList1 ColorDepth:Depth32Bit コンテナー/SplitContainer splitContainer1 FixedPanel:Panel1 Panel1 コモン コントロール/TreeView treeView1 Dock:Fill ImageList:imageList1 Panel2 コモン コントロール/ListView listView1 Dock:Fill SmallImageList:imageList1 参考 -[[ファイルからアイコンを抽出して、ImageListへ登録: C#研究所>http://acha-ya.cocolog-nifty.com/blog/2010/12/imagelist-7ecb.html]] -[[初心者プログラマの憂鬱>http://ameblo.jp/yomoko0/theme-10018669371.html]] Form1.cs #highlight(c#){{ using System; using System.Drawing; using System.Globalization; using System.IO; using System.Runtime.InteropServices; using System.Windows.Forms; namespace FileMan { public partial class Form1 : Form { [DllImport("Shell32.dll", CharSet = CharSet.Auto)] extern static uint ExtractIconEx(string lpszFile, int nIconIndex, IntPtr[] phiconLarge, IntPtr[] phiconSmall, uint nIcons); bool ImageAddIcon(string dllPath, ImageList orderImageList) { uint iconCnt = ExtractIconEx(dllPath, -1, null, null, 1); if (iconCnt == 0) return false; IntPtr[] hIcon = new IntPtr[iconCnt]; uint getCnt; if (orderImageList.ImageSize.Width <= SystemInformation.SmallIconSize.Width && orderImageList.ImageSize.Height <= SystemInformation.SmallIconSize.Height) { getCnt = ExtractIconEx(dllPath, 0, null, hIcon, iconCnt); } else { getCnt = ExtractIconEx(dllPath, 0, hIcon, null, iconCnt); } if (getCnt < 1) return false; for (int idx = 0; idx < getCnt; idx++) { if (hIcon[idx] != IntPtr.Zero) { using (Icon icon = Icon.FromHandle(hIcon[idx])) { orderImageList.Images.Add(icon); } } } return true; } public Form1() { InitializeComponent(); // 画像リストにアイコンを追加 ImageAddIcon(@"C:\WINDOWS\system32\SHELL32.dll", imageList1); // リストビューの設定 listView1.View = View.Details; listView1.FullRowSelect = true; listView1.GridLines = true; listView1.Columns.Add("名前", 300); listView1.Columns.Add("サイズ", 80, HorizontalAlignment.Right); listView1.Columns.Add("更新日時", 120); } private void Form1_Load(object sender, EventArgs e) { // ドライブ一覧 string[] drives = Environment.GetLogicalDrives(); foreach (string drv in drives) { string path = drv.TrimEnd('\\'); DriveInfo di = new DriveInfo(path); int index; switch (di.DriveType) { case DriveType.Removable: index = 6; break; case DriveType.Fixed: index = 7; break; case DriveType.Network: index = 9; break; case DriveType.CDRom: index = 11; break; case DriveType.Ram: index = 12; break; default: continue; } TreeNode node = new TreeNode(path, index, index); treeView1.Nodes.Add(node); node.Nodes.Add(""); } } private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { TreeNode treeNode = e.Node; string path = treeNode.FullPath + '\\'; treeNode.Nodes.Clear(); DirectoryInfo dirInfo = new DirectoryInfo(path); try { foreach (DirectoryInfo di in dirInfo.GetDirectories()) { TreeNode node = new TreeNode(di.Name, 3, 4); treeNode.Nodes.Add(node); DirectoryInfo subDir = new DirectoryInfo(di.FullName); if (subDir.GetDirectories().Length > 0) { node.Nodes.Add(""); } } } catch { } } private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode treeNode = e.Node; string path = treeNode.FullPath + '\\'; toolStripTextBox1.Text = path; listView1.Items.Clear(); DirectoryInfo dirInfo = new DirectoryInfo(path); try { string[] line = new string[3]; foreach (DirectoryInfo di in dirInfo.GetDirectories()) { line[0] = di.Name; line[2] = di.CreationTime.ToString(@"yyyy/MM/dd\ HH:mm:ss"); ListViewItem item = new ListViewItem(line, 3); listView1.Items.Add(item); } foreach (FileInfo fi in dirInfo.GetFiles()) { line[0] = fi.Name; line[1] = fi.Length.ToString("N0"); line[2] = fi.LastWriteTime.ToString(@"yyyy/MM/dd\ HH:mm:ss"); ListViewItem item = new ListViewItem(line, 70); listView1.Items.Add(item); } } catch { } } } } }}

表示オプション

横に並べて表示:
変化行の前後のみ表示: