public override ArrayList GetMyComputerContent () { string[] logical_drives = Directory.GetLogicalDrives (); ArrayList my_computer_content_arraylist = new ArrayList (); foreach (string drive in logical_drives) { FSEntry fsEntry = new FSEntry (); fsEntry.FileType = FSEntry.FSEntryType.Device; fsEntry.FullName = drive; fsEntry.Name = drive; fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("harddisk/harddisk"); fsEntry.Attributes = FileAttributes.Directory; fsEntry.MainTopNode = GetMyComputerFSEntry (); my_computer_content_arraylist.Add (fsEntry); string contain_string = fsEntry.FullName + "://"; if (!MWFVFS.MyComputerDevicesPrefix.Contains (contain_string)) MWFVFS.MyComputerDevicesPrefix.Add (contain_string, fsEntry); } my_computer_content_arraylist.Add (GetMyComputerPersonalFSEntry ()); return my_computer_content_arraylist; }
public override ArrayList GetMyNetworkContent () { ArrayList fsEntries = new ArrayList (); foreach (MasterMount.Mount mount in masterMount.Network_devices) { FSEntry fsEntry = new FSEntry (); fsEntry.FileType = FSEntry.FSEntryType.Network; fsEntry.FullName = mount.mount_point; fsEntry.FsType = mount.fsType; fsEntry.DeviceShort = mount.device_short; fsEntry.Name = "Network (" + mount.fsType + ", " + mount.device_short + ")"; switch (mount.fsType) { case MasterMount.FsTypes.nfs: fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("nfs/nfs"); break; case MasterMount.FsTypes.smbfs: fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("smb/smb"); break; case MasterMount.FsTypes.ncpfs: fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("network/network"); break; case MasterMount.FsTypes.cifs: fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("network/network"); break; default: break; } fsEntry.Attributes = FileAttributes.Directory; fsEntry.MainTopNode = GetMyNetworkFSEntry (); fsEntries.Add (fsEntry); } return fsEntries; }
public WinFileSystem () { desktopFSEntry = new FSEntry (); desktopFSEntry.Attributes = FileAttributes.Directory; desktopFSEntry.FullName = MWFVFS.DesktopPrefix; desktopFSEntry.Name = "Desktop"; desktopFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesDesktop); desktopFSEntry.FileType = FSEntry.FSEntryType.Directory; desktopFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("desktop/desktop"); desktopFSEntry.LastAccessTime = DateTime.Now; recentlyusedFSEntry = new FSEntry (); recentlyusedFSEntry.Attributes = FileAttributes.Directory; recentlyusedFSEntry.FullName = MWFVFS.RecentlyUsedPrefix; recentlyusedFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesRecentDocuments); recentlyusedFSEntry.Name = "Recently Used"; recentlyusedFSEntry.FileType = FSEntry.FSEntryType.Directory; recentlyusedFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("recently/recently"); recentlyusedFSEntry.LastAccessTime = DateTime.Now; personalFSEntry = new FSEntry (); personalFSEntry.Attributes = FileAttributes.Directory; personalFSEntry.FullName = MWFVFS.PersonalPrefix; personalFSEntry.Name = "Personal"; personalFSEntry.MainTopNode = GetDesktopFSEntry (); personalFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesPersonal); personalFSEntry.FileType = FSEntry.FSEntryType.Directory; personalFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("directory/home"); personalFSEntry.LastAccessTime = DateTime.Now; mycomputerpersonalFSEntry = new FSEntry (); mycomputerpersonalFSEntry.Attributes = FileAttributes.Directory; mycomputerpersonalFSEntry.FullName = MWFVFS.MyComputerPersonalPrefix; mycomputerpersonalFSEntry.Name = "Personal"; mycomputerpersonalFSEntry.MainTopNode = GetMyComputerFSEntry (); mycomputerpersonalFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesPersonal); mycomputerpersonalFSEntry.FileType = FSEntry.FSEntryType.Directory; mycomputerpersonalFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("directory/home"); mycomputerpersonalFSEntry.LastAccessTime = DateTime.Now; mycomputerFSEntry = new FSEntry (); mycomputerFSEntry.Attributes = FileAttributes.Directory; mycomputerFSEntry.FullName = MWFVFS.MyComputerPrefix; mycomputerFSEntry.Name = "My Computer"; mycomputerFSEntry.MainTopNode = GetDesktopFSEntry (); mycomputerFSEntry.FileType = FSEntry.FSEntryType.Directory; mycomputerFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("workplace/workplace"); mycomputerFSEntry.LastAccessTime = DateTime.Now; mynetworkFSEntry = new FSEntry (); mynetworkFSEntry.Attributes = FileAttributes.Directory; mynetworkFSEntry.FullName = MWFVFS.MyNetworkPrefix; mynetworkFSEntry.Name = "My Network"; mynetworkFSEntry.MainTopNode = GetDesktopFSEntry (); mynetworkFSEntry.FileType = FSEntry.FSEntryType.Directory; mynetworkFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("network/network"); mynetworkFSEntry.LastAccessTime = DateTime.Now; }
public UnixFileSystem () { personal_folder = ThemeEngine.Current.Places (UIIcon.PlacesPersonal); recently_used_path = Path.Combine (personal_folder, ".recently-used"); full_kde_recent_document_dir = personal_folder + "/.kde/share/apps/RecentDocuments"; desktopFSEntry = new FSEntry (); desktopFSEntry.Attributes = FileAttributes.Directory; desktopFSEntry.FullName = MWFVFS.DesktopPrefix; desktopFSEntry.Name = "Desktop"; desktopFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesDesktop); desktopFSEntry.FileType = FSEntry.FSEntryType.Directory; desktopFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("desktop/desktop"); desktopFSEntry.LastAccessTime = DateTime.Now; recentlyusedFSEntry = new FSEntry (); recentlyusedFSEntry.Attributes = FileAttributes.Directory; recentlyusedFSEntry.FullName = MWFVFS.RecentlyUsedPrefix; recentlyusedFSEntry.Name = "Recently Used"; recentlyusedFSEntry.FileType = FSEntry.FSEntryType.Directory; recentlyusedFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("recently/recently"); recentlyusedFSEntry.LastAccessTime = DateTime.Now; personalFSEntry = new FSEntry (); personalFSEntry.Attributes = FileAttributes.Directory; personalFSEntry.FullName = MWFVFS.PersonalPrefix; personalFSEntry.Name = "Personal"; personalFSEntry.MainTopNode = GetDesktopFSEntry (); personalFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesPersonal); personalFSEntry.FileType = FSEntry.FSEntryType.Directory; personalFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("directory/home"); personalFSEntry.LastAccessTime = DateTime.Now; mycomputerpersonalFSEntry = new FSEntry (); mycomputerpersonalFSEntry.Attributes = FileAttributes.Directory; mycomputerpersonalFSEntry.FullName = MWFVFS.MyComputerPersonalPrefix; mycomputerpersonalFSEntry.Name = "Personal"; mycomputerpersonalFSEntry.MainTopNode = GetMyComputerFSEntry (); mycomputerpersonalFSEntry.RealName = ThemeEngine.Current.Places (UIIcon.PlacesPersonal); mycomputerpersonalFSEntry.FileType = FSEntry.FSEntryType.Directory; mycomputerpersonalFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("directory/home"); mycomputerpersonalFSEntry.LastAccessTime = DateTime.Now; mycomputerFSEntry = new FSEntry (); mycomputerFSEntry.Attributes = FileAttributes.Directory; mycomputerFSEntry.FullName = MWFVFS.MyComputerPrefix; mycomputerFSEntry.Name = "My Computer"; mycomputerFSEntry.MainTopNode = GetDesktopFSEntry (); mycomputerFSEntry.FileType = FSEntry.FSEntryType.Directory; mycomputerFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("workplace/workplace"); mycomputerFSEntry.LastAccessTime = DateTime.Now; mynetworkFSEntry = new FSEntry (); mynetworkFSEntry.Attributes = FileAttributes.Directory; mynetworkFSEntry.FullName = MWFVFS.MyNetworkPrefix; mynetworkFSEntry.Name = "My Network"; mynetworkFSEntry.MainTopNode = GetDesktopFSEntry (); mynetworkFSEntry.FileType = FSEntry.FSEntryType.Directory; mynetworkFSEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("network/network"); mynetworkFSEntry.LastAccessTime = DateTime.Now; }
// return an ArrayList with FSEntry objects public override ArrayList GetMyComputerContent () { ArrayList my_computer_content_arraylist = new ArrayList (); if (masterMount.ProcMountAvailable) { masterMount.GetMounts (); foreach (MasterMount.Mount mount in masterMount.Block_devices) { FSEntry fsEntry = new FSEntry (); fsEntry.FileType = FSEntry.FSEntryType.Device; fsEntry.FullName = mount.mount_point; fsEntry.Name = "HDD (" + mount.fsType + ", " + mount.device_short + ")"; fsEntry.FsType = mount.fsType; fsEntry.DeviceShort = mount.device_short; fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("harddisk/harddisk"); fsEntry.Attributes = FileAttributes.Directory; fsEntry.MainTopNode = GetMyComputerFSEntry (); my_computer_content_arraylist.Add (fsEntry); if (!MWFVFS.MyComputerDevicesPrefix.Contains (fsEntry.FullName + "://")) MWFVFS.MyComputerDevicesPrefix.Add (fsEntry.FullName + "://", fsEntry); } foreach (MasterMount.Mount mount in masterMount.Removable_devices) { FSEntry fsEntry = new FSEntry (); fsEntry.FileType = FSEntry.FSEntryType.RemovableDevice; fsEntry.FullName = mount.mount_point; bool is_dvd_cdrom = mount.fsType == MasterMount.FsTypes.usbfs ? false : true; string type_name = is_dvd_cdrom ? "DVD/CD-Rom" : "USB"; string mime_type = is_dvd_cdrom ? "cdrom/cdrom" : "removable/removable"; fsEntry.Name = type_name +" (" + mount.device_short + ")"; fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType (mime_type); fsEntry.FsType = mount.fsType; fsEntry.DeviceShort = mount.device_short; fsEntry.Attributes = FileAttributes.Directory; fsEntry.MainTopNode = GetMyComputerFSEntry (); my_computer_content_arraylist.Add (fsEntry); string contain_string = fsEntry.FullName + "://"; if (!MWFVFS.MyComputerDevicesPrefix.Contains (contain_string)) MWFVFS.MyComputerDevicesPrefix.Add (contain_string, fsEntry); } } my_computer_content_arraylist.Add (GetMyComputerPersonalFSEntry ()); return my_computer_content_arraylist; }
protected virtual FSEntry GetDirectoryFSEntry (DirectoryInfo dirinfo, FSEntry topFolderFSEntry) { FSEntry fs = new FSEntry (); fs.Attributes = dirinfo.Attributes; fs.FullName = dirinfo.FullName; fs.Name = dirinfo.Name; fs.MainTopNode = topFolderFSEntry; fs.FileType = FSEntry.FSEntryType.Directory; fs.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("inode/directory"); fs.LastAccessTime = dirinfo.LastAccessTime; return fs; }
protected virtual FSEntry GetFileFSEntry (FileInfo fileinfo) { // *sigh* FileInfo gives us no usable information for links to directories // so, return null if ((fileinfo.Attributes & FileAttributes.Directory) == FileAttributes.Directory) return null; FSEntry fs = new FSEntry (); fs.Attributes = fileinfo.Attributes; fs.FullName = fileinfo.FullName; fs.Name = fileinfo.Name; fs.FileType = FSEntry.FSEntryType.File; fs.IconIndex = MimeIconEngine.GetIconIndexForFile (fileinfo.FullName); fs.FileSize = fileinfo.Length; fs.LastAccessTime = fileinfo.LastAccessTime; return fs; }
public FileViewListViewItem (FSEntry fsEntry) { this.fsEntry = fsEntry; ImageIndex = fsEntry.IconIndex; Text = fsEntry.Name; switch (fsEntry.FileType) { case FSEntry.FSEntryType.Directory: SubItems.Add (String.Empty); SubItems.Add ("Directory"); SubItems.Add (fsEntry.LastAccessTime.ToShortDateString () + " " + fsEntry.LastAccessTime.ToShortTimeString ()); break; case FSEntry.FSEntryType.File: long fileLen = 1; try { if (fsEntry.FileSize > 1024) fileLen = fsEntry.FileSize / 1024; } catch (Exception) { fileLen = 1; } SubItems.Add (fileLen.ToString () + " KB"); SubItems.Add ("File"); SubItems.Add (fsEntry.LastAccessTime.ToShortDateString () + " " + fsEntry.LastAccessTime.ToShortTimeString ()); break; case FSEntry.FSEntryType.Device: SubItems.Add (String.Empty); SubItems.Add ("Device"); SubItems.Add (fsEntry.LastAccessTime.ToShortDateString () + " " + fsEntry.LastAccessTime.ToShortTimeString ()); break; case FSEntry.FSEntryType.RemovableDevice: SubItems.Add (String.Empty); SubItems.Add ("RemovableDevice"); SubItems.Add (fsEntry.LastAccessTime.ToShortDateString () + " " + fsEntry.LastAccessTime.ToShortTimeString ()); break; default: break; } }
public FSEntry ChangeDirectory (string folder) { if (folder == MWFVFS.DesktopPrefix) { currentTopFolder = MWFVFS.DesktopPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetDesktopFSEntry (); } else if (folder == MWFVFS.PersonalPrefix) { currentTopFolder = MWFVFS.PersonalPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetPersonalFSEntry (); } else if (folder == MWFVFS.MyComputerPersonalPrefix) { currentTopFolder = MWFVFS.MyComputerPersonalPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetMyComputerPersonalFSEntry (); } else if (folder == MWFVFS.RecentlyUsedPrefix) { currentTopFolder = MWFVFS.RecentlyUsedPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetRecentlyUsedFSEntry (); } else if (folder == MWFVFS.MyComputerPrefix) { currentTopFolder = MWFVFS.MyComputerPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetMyComputerFSEntry (); } else if (folder == MWFVFS.MyNetworkPrefix) { currentTopFolder = MWFVFS.MyNetworkPrefix; currentTopFolderFSEntry = currentFolderFSEntry = GetMyNetworkFSEntry (); } else { bool found = false; foreach (DictionaryEntry entry in MWFVFS.MyComputerDevicesPrefix) { FSEntry fsEntry = entry.Value as FSEntry; if (folder == fsEntry.FullName) { currentTopFolder = entry.Key as string; currentTopFolderFSEntry = currentFolderFSEntry = fsEntry; found = true; break; } } if (!found) { currentFolderFSEntry = GetDirectoryFSEntry (new DirectoryInfo (folder), currentTopFolderFSEntry); } } return currentFolderFSEntry; }
protected override void OnDoubleClick (EventArgs e) { if (SelectedItems.Count > 0) { FileViewListViewItem listViewItem = SelectedItems [0] as FileViewListViewItem; FSEntry fsEntry = listViewItem.FSEntry; if ((fsEntry.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { ChangeDirectory (null, fsEntry.FullName); EventHandler eh = (EventHandler)(Events [MDirectoryChangedEvent]); if (eh != null) eh (this, EventArgs.Empty); } else { currentFSEntry = fsEntry; EventHandler eh = (EventHandler)(Events [MSelectedFileChangedEvent]); if (eh != null) eh (this, EventArgs.Empty); eh = (EventHandler)(Events [MForceDialogEndEvent]); if (eh != null) eh (this, EventArgs.Empty); return; } } base.OnDoubleClick (e); }
protected override void OnClick (EventArgs e) { if (!MultiSelect) { if (SelectedItems.Count > 0) { FileViewListViewItem listViewItem = SelectedItems [0] as FileViewListViewItem; FSEntry fsEntry = listViewItem.FSEntry; if (fsEntry.FileType == FSEntry.FSEntryType.File) { currentFSEntry = fsEntry; EventHandler eh = (EventHandler)(Events [MSelectedFileChangedEvent]); if (eh != null) eh (this, EventArgs.Empty); } } } base.OnClick (e); }
private void DoOneFSEntry (FSEntry fsEntry) { if (!ShowHiddenFiles) if (fsEntry.Name.StartsWith (".") || (fsEntry.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) return; FileViewListViewItem listViewItem = new FileViewListViewItem (fsEntry); Items.Add (listViewItem); }
public void ChangeDirectory (object sender, string folder, string filter) { if (folder == MWFVFS.DesktopPrefix || folder == MWFVFS.RecentlyUsedPrefix) folderUpToolBarButton.Enabled = false; else folderUpToolBarButton.Enabled = true; foreach (IUpdateFolder iuf in registered_senders) { iuf.CurrentFolder = folder; } if (should_push) PushDir (); else should_push = true; currentFolderFSEntry = vfs.ChangeDirectory (folder); currentFolder = folder; if (currentFolder.IndexOf ("://") != -1) currentRealFolder = currentFolderFSEntry.RealName; else currentRealFolder = currentFolder; BeginUpdate (); Items.Clear (); SelectedItems.Clear (); if (folder == MWFVFS.RecentlyUsedPrefix) { old_view = View; View = View.Details; old_menuitem_index = previousCheckedMenuItemIndex; UpdateMenuItems (detailsMenutItem); do_update_view = true; } else if (View != old_view && do_update_view) { UpdateMenuItems (menuItemView.MenuItems [old_menuitem_index]); View = old_view; do_update_view = false; } EndUpdate (); try { UpdateFileView (filter); } catch (Exception e) { if (should_push) PopDir (); MessageBox.Show (e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void CreateNewFolder () { if (currentFolder == MWFVFS.MyComputerPrefix || currentFolder == MWFVFS.RecentlyUsedPrefix) return; FSEntry fsEntry = new FSEntry (); fsEntry.Attributes = FileAttributes.Directory; fsEntry.FileType = FSEntry.FSEntryType.Directory; fsEntry.IconIndex = MimeIconEngine.GetIconIndexForMimeType ("inode/directory"); fsEntry.LastAccessTime = DateTime.Now; // FIXME: when ListView.LabelEdit is available use it // listViewItem.BeginEdit(); TextEntryDialog ted = new TextEntryDialog (); ted.IconPictureBoxImage = MimeIconEngine.LargeIcons.Images.GetImage (fsEntry.IconIndex); string folder = String.Empty; if (currentFolderFSEntry.RealName != null) folder = currentFolderFSEntry.RealName; else folder = currentFolder; string tmp_filename = "New Folder"; if (Directory.Exists (Path.Combine (folder, tmp_filename))) { int i = 1; if (XplatUI.RunningOnUnix) { tmp_filename = tmp_filename + "-" + i; } else { tmp_filename = tmp_filename + " (" + i + ")"; } while (Directory.Exists (Path.Combine (folder, tmp_filename))) { i++; if (XplatUI.RunningOnUnix) { tmp_filename = "New Folder" + "-" + i; } else { tmp_filename = "New Folder" + " (" + i + ")"; } } } ted.FileName = tmp_filename; if (ted.ShowDialog () == DialogResult.OK) { string new_folder = Path.Combine (folder, ted.FileName); if (vfs.CreateFolder (new_folder)) { fsEntry.FullName = new_folder; fsEntry.Name = ted.FileName; FileViewListViewItem listViewItem = new FileViewListViewItem (fsEntry); BeginUpdate (); Items.Add (listViewItem); EndUpdate (); listViewItem.EnsureVisible (); } } }