public void display(DirectoryInfo directoryInfo, String filter = Filters.any) { using (new ListViewUpdate(this)) { if (!smallImageCache.Images.ContainsKey(directoryImageKey)) { smallImageCache.Images.Add(directoryImageKey, IconUtilities.loadSmallIconAssociatedWithDirectory(directoryInfo.FullName)); } Items.Clear(); Items.Add(currentDirectory(directoryInfo)); DirectoryInfo parentDirectoryInfo = directoryInfo.Parent; if (null != parentDirectoryInfo) { Items.Add(parentDirectory(parentDirectoryInfo)); } if (directoryInfo.Exists) { foreach (FileSystemInfo fileSystemInfo in directoryInfo.EnumerateFileSystemInfos(filter)) { if (fileSystemInfo.Attributes.HasFlag(FileAttributes.Hidden)) { continue; } FileInfo fileInfo = fileSystemInfo as FileInfo; if (null != fileInfo) { Items.Add(file(fileInfo)); } else { Items.Add(subDirectory((DirectoryInfo)(fileSystemInfo))); } } } AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } }
public MainForm() { Text = "ReSearcher"; Icon = IconUtilities.loadCurrentModuleIcon(); StartPosition = FormStartPosition.CenterScreen; Size = new Size( (int)(Screen.PrimaryScreen.Bounds.Width * 0.6f), (int)(Screen.PrimaryScreen.Bounds.Height * 0.6f) ); // assemble UI components // extension methods are in use here to provide a fluent and elegant component hierarchy this.appendControls( tabControl = new TabControl() { Dock = DockStyle.Fill, Padding = new Point(24, 4) }, statusStrip = new StatusStrip(), new ToolStripPanel() { Dock = DockStyle.Top }.withControls( new ToolStrip().withItems( new ToolStripButton() { Text = "Search..." }.withAction(search), new ToolStripSeparator(), new ToolStripButton() { Text = "Browse..." }.withAction(browse), new ToolStripButton() { Text = "Open..." }.withAction(open), new ToolStripSeparator(), new ToolStripButton() { Text = "Download..." }.withAction(download) ) ), MainMenuStrip = new MenuStrip() { Dock = DockStyle.Top }.withItems( new ToolStripMenuItem() { Text = "ReSearcher" }.withDropDownItems( new ToolStripMenuItem() { Text = "Search..." }.withAction(search), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "Browse..." }.withAction(browse), new ToolStripMenuItem() { Text = "Open..." }.withAction(open), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "Download..." }.withAction(download), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "Settings" }.withAction(showSettings), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "Quit" }.withAction(quit) ), new ToolStripMenuItem() { Text = "Tab" }.withDropDownItems( new ToolStripMenuItem() { Text = "Close" }.withAction(closeSelectedTab) ), new ToolStripMenuItem() { Text = "Help" }.withDropDownItems( new ToolStripMenuItem() { Text = "Help table of contents" }.withAction(showHelp), new ToolStripMenuItem() { Text = "Help index" }.withAction(showHelpIndex), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "Help online" }.withAction(showHelpOnline), new ToolStripSeparator(), new ToolStripMenuItem() { Text = "About" }.withAction(showHelpAbout) ) ) ); }