private void CreateComboList () { real_parent = null; DirComboBoxItem selection = null; if (currentPath == MWFVFS.RecentlyUsedPrefix) { mainParentDirComboBoxItem = recentlyUsedDirComboboxItem; selection = recentlyUsedDirComboboxItem; } else if (currentPath == MWFVFS.DesktopPrefix) { selection = desktopDirComboboxItem; mainParentDirComboBoxItem = desktopDirComboboxItem; } else if (currentPath == MWFVFS.PersonalPrefix) { selection = personalDirComboboxItem; mainParentDirComboBoxItem = personalDirComboboxItem; } else if (currentPath == MWFVFS.MyComputerPrefix) { selection = myComputerDirComboboxItem; mainParentDirComboBoxItem = myComputerDirComboboxItem; } else if (currentPath == MWFVFS.MyNetworkPrefix) { selection = networkDirComboboxItem; mainParentDirComboBoxItem = networkDirComboboxItem; } else { foreach (DirComboBoxItem dci in myComputerItems) { if (dci.Path == currentPath) { mainParentDirComboBoxItem = selection = dci; break; } } } BeginUpdate (); Items.Clear (); Items.Add (recentlyUsedDirComboboxItem); Items.Add (desktopDirComboboxItem); Items.Add (personalDirComboboxItem); Items.Add (myComputerDirComboboxItem); Items.AddRange (myComputerItems); Items.Add (networkDirComboboxItem); if (selection == null) real_parent = CreateFolderStack (); if (real_parent != null) { int local_indent = 0; if (real_parent == desktopDirComboboxItem) local_indent = 1; else if (real_parent == personalDirComboboxItem || real_parent == networkDirComboboxItem) local_indent = 2; else local_indent = 3; selection = AppendToParent (local_indent, real_parent); } EndUpdate (); if (selection != null) SelectedItem = selection; }
private DirComboBoxItem AppendToParent (int nr_indents, DirComboBoxItem parentDirComboBoxItem) { DirComboBoxItem selection = null; int index = Items.IndexOf (parentDirComboBoxItem) + 1; int xPos = indent * nr_indents; while (folderStack.Count != 0) { DirectoryInfo dii = folderStack.Pop () as DirectoryInfo; DirComboBoxItem dci = new DirComboBoxItem (imageList, 5, dii.Name, dii.FullName, xPos); Items.Insert (index, dci); index++; selection = dci; xPos += indent; } return selection; }
public DirComboBox (MWFVFS vfs) { this.vfs = vfs; SuspendLayout (); DrawMode = DrawMode.OwnerDrawFixed; imageList.ColorDepth = ColorDepth.Depth32Bit; imageList.ImageSize = new Size (16, 16); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesRecentDocuments, 16)); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesDesktop, 16)); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesPersonal, 16)); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesMyComputer, 16)); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.PlacesMyNetwork, 16)); imageList.Images.Add (ThemeEngine.Current.Images (UIIcon.NormalFolder, 16)); imageList.TransparentColor = Color.Transparent; recentlyUsedDirComboboxItem = new DirComboBoxItem (imageList, 0, "Recently used", MWFVFS.RecentlyUsedPrefix, 0); desktopDirComboboxItem = new DirComboBoxItem (imageList, 1, "Desktop", MWFVFS.DesktopPrefix, 0); personalDirComboboxItem = new DirComboBoxItem (imageList, 2, "Personal folder", MWFVFS.PersonalPrefix, indent); myComputerDirComboboxItem = new DirComboBoxItem (imageList, 3, "My Computer", MWFVFS.MyComputerPrefix, indent); networkDirComboboxItem = new DirComboBoxItem (imageList, 4, "My Network", MWFVFS.MyNetworkPrefix, indent); ArrayList al = this.vfs.GetMyComputerContent (); foreach (FSEntry fsEntry in al) { myComputerItems.Add (new DirComboBoxItem (MimeIconEngine.LargeIcons, fsEntry.IconIndex, fsEntry.Name, fsEntry.FullName, indent * 2)); } al.Clear (); al = null; mainParentDirComboBoxItem = myComputerDirComboboxItem; ResumeLayout (false); }