public MainForm() { InitializeComponent(); // Populate the drive list foreach (var drive in DriveInfo.GetDrives().Where(d => d.IsReady)) { tree.Items.Add($"{drive.Name.Trim ('\\')} - {drive.VolumeLabel}", ImageLoader.Get("drive.png")).Tag = drive.Name; } tree.SelectedItem = tree.Items.First(); // Select the first available drive SetSelectedDirectory((string)tree.Items.First().Tag); }
private void SetSelectedDirectory(string directory) { current_directory = directory; view.Items.Clear(); var directories = 0; var files = 0; var tree_item = tree.SelectedItem; try { foreach (var d in Directory.EnumerateDirectories(directory).Take(30)) { view.Items.Add(new ListViewItem { Text = Path.GetFileName(d), Image = ImageLoader.Get("folder-closed.png"), Tag = "Directory" }); } directories = view.Items.Count; if (!tree_item.HasChildren) { tree_item.Items.AddRange(view.Items.Select(l => new TreeViewItem(l.Text) { Image = ImageLoader.Get("folder.png"), Tag = Path.Combine(current_directory, l.Text) })); } foreach (var f in Directory.EnumerateFiles(directory).Take(50)) { view.Items.Add(new ListViewItem { Text = Path.GetFileName(f), Image = ImageLoader.Get("new.png") }); } files = view.Items.Count - directories; statusbar.Text = $"{directories} directories, {files} files"; } catch (UnauthorizedAccessException) { // Ignore statusbar.Text = "Unable to open directory due to permissions"; } Text = "Explore Sample - " + directory; }
private void SetSelectedDirectory(string directory) { current_directory = directory; view.Items.Clear(); var directories = 0; var files = 0; try { foreach (var d in Directory.EnumerateDirectories(directory).Take(30)) { view.Items.Add(new ListViewItem { Text = Path.GetFileName(d), Image = ImageLoader.Get("folder-closed.png"), Tag = "Directory" }); } directories = view.Items.Count; foreach (var f in Directory.EnumerateFiles(directory).Take(50)) { view.Items.Add(new ListViewItem { Text = Path.GetFileName(f), Image = ImageLoader.Get("new.png") }); } files = view.Items.Count - directories; statusbar.Text = $"{directories} directories, {files} files"; statusbar.Invalidate(); } catch (UnauthorizedAccessException) { // Ignore statusbar.Text = "Unable to open directory due to permissions"; statusbar.Invalidate(); } view.Invalidate(); Text = "Explore Sample - " + directory; titlebar.Text = "Explore Sample - " + directory; titlebar.Invalidate(); }
private void InitializeComponent() { //SuspendLayout (); // ListView view = new ListView { Dock = DockStyle.Fill }; view.ItemDoubleClicked += View_ItemDoubleClicked; Controls.Add(view); // TreeControl tree = new TreeView { Dock = DockStyle.Left }; tree.Style.Border.Top.Width = 0; tree.Style.Border.Left.Width = 0; tree.Style.Border.Bottom.Width = 0; tree.ItemSelected += Tree_ItemSelected; Controls.Add(tree); // RibbonControl ribbon = new Ribbon(); var home_tab = ribbon.TabPages.Add("Home"); var group1 = new RibbonItemGroup { Text = "Home" }; group1.Items.Add(new RibbonItem("Parent Folder", ImageLoader.Get("folder-up.png"), new EventHandler(ParentFolder_Clicked))); var group2 = new RibbonItemGroup { Text = "Actions" }; group2.Items.Add(new RibbonItem("New Folder", ImageLoader.Get("folder-add.png"), new EventHandler(NotImplemented_Clicked))); group2.Items.Add(new RibbonItem("Search", ImageLoader.Get("search.png"), new EventHandler(NotImplemented_Clicked))); group2.Items.Add(new RibbonItem("Delete", ImageLoader.Get("delete-red.png"), new EventHandler(ShowButtonForm_Clicked))); home_tab.Groups.Add(group1); home_tab.Groups.Add(group2); var share_tab = ribbon.TabPages.Add("Share"); var share_group = new RibbonItemGroup { Text = "Send" }; share_group.Items.Add(new RibbonItem("Email", ImageLoader.Get("mail.png"), new EventHandler(NotImplemented_Clicked))); share_group.Items.Add(new RibbonItem("Zip", ImageLoader.Get("compress.png"), new EventHandler(NotImplemented_Clicked))); share_group.Items.Add(new RibbonItem("Burn DVD", ImageLoader.Get("cd-burn.png"), new EventHandler(NotImplemented_Clicked))); share_group.Items.Add(new RibbonItem("Print", ImageLoader.Get("print.png"), new EventHandler(NotImplemented_Clicked))); share_tab.Groups.Add(share_group); var view_tab = ribbon.TabPages.Add("View"); var group3 = new RibbonItemGroup { Text = "Themes" }; group3.Items.Add(new RibbonItem("Default", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked))); group3.Items.Add(new RibbonItem("Green", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked))); group3.Items.Add(new RibbonItem("Orange", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked))); group3.Items.Add(new RibbonItem("Purple", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked))); group3.Items.Add(new RibbonItem("Hotdog Stand", ImageLoader.Get("swatches.png"), new EventHandler(ThemeButton_Clicked))); view_tab.Groups.Add(group3); Controls.Add(ribbon); // StatusBar statusbar = new StatusBar(); Controls.Add(statusbar); // TitleBar titlebar = new FormTitleBar { Text = "Explore Sample", Image = ImageLoader.Get("layout-folder-pane.png") }; Controls.Add(titlebar); //ResumeLayout (); }
private void InitializeComponent() { //SuspendLayout (); // ListView view = Controls.Add(new ListView { Dock = DockStyle.Fill }); view.ItemDoubleClicked += View_ItemDoubleClicked; // TreeControl tree = Controls.Add(new TreeView { Dock = DockStyle.Left }); tree.Style.Border.Top.Width = 0; tree.Style.Border.Left.Width = 0; tree.Style.Border.Bottom.Width = 0; tree.ItemSelected += Tree_ItemSelected; // RibbonControl ribbon = Controls.Add(new Ribbon()); var home_tab = ribbon.TabPages.Add("Home"); var group1 = home_tab.Groups.Add("Home"); group1.Items.Add("Parent Folder", ImageLoader.Get("folder-up.png"), new EventHandler <MouseEventArgs> (ParentFolder_Clicked)); var group2 = home_tab.Groups.Add("Actions"); group2.Items.Add("New Folder", ImageLoader.Get("folder-add.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); group2.Items.Add("Search", ImageLoader.Get("search.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); group2.Items.Add("Delete", ImageLoader.Get("delete-red.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); var share_tab = ribbon.TabPages.Add("Share"); var share_group = share_tab.Groups.Add("Send"); share_group.Items.Add("Email", ImageLoader.Get("mail.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); share_group.Items.Add("Zip", ImageLoader.Get("compress.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); share_group.Items.Add("Burn DVD", ImageLoader.Get("cd-burn.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); share_group.Items.Add("Print", ImageLoader.Get("print.png"), new EventHandler <MouseEventArgs> (NotImplemented_Clicked)); var view_tab = ribbon.TabPages.Add("View"); var group3 = view_tab.Groups.Add("Themes"); group3.Items.Add("Default", ImageLoader.Get("swatches.png"), new EventHandler <MouseEventArgs> (ThemeButton_Clicked)); group3.Items.Add("Green", ImageLoader.Get("swatches.png"), new EventHandler <MouseEventArgs> (ThemeButton_Clicked)); group3.Items.Add("Orange", ImageLoader.Get("swatches.png"), new EventHandler <MouseEventArgs> (ThemeButton_Clicked)); group3.Items.Add("Purple", ImageLoader.Get("swatches.png"), new EventHandler <MouseEventArgs> (ThemeButton_Clicked)); group3.Items.Add("Hotdog Stand", ImageLoader.Get("swatches.png"), new EventHandler <MouseEventArgs> (ThemeButton_Clicked)); // StatusBar statusbar = Controls.Add(new StatusBar()); Text = "Explore Sample"; Image = ImageLoader.Get("layout-folder-pane.png"); //ResumeLayout (); }