void FileSystemObjectInfo_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (this.FileSystemInfo is DirectoryInfo) { if (string.Equals(e.PropertyName, "IsExpanded", StringComparison.CurrentCultureIgnoreCase)) { RaiseBeforeExpand(); if (this.IsExpanded) { this.ImageSource = FolderManager.GetImageSource(this.FileSystemInfo.FullName, ItemState.Open); if (this.HasDummy()) { RaiseBeforeExplore(); this.RemoveDummy(); this.ExploreDirectories(); this.ExploreFiles(); RaiseAfterExplore(); } } else { this.ImageSource = FolderManager.GetImageSource(this.FileSystemInfo.FullName, ItemState.Close); } RaiseAfterExpand(); } } }
public FileSystemObjectInfo(FileSystemInfo info) { if (this is DummyFileSystemObjectInfo) { return; } Children = new ObservableCollection <FileSystemObjectInfo>(); FileSystemInfo = info; if (info is DirectoryInfo) { ImageSource = FolderManager.GetImageSource( info.FullName, ItemState.Close); AddDummy(); } else if (info is FileInfo) { ImageSource = FileManager.GetImageSource(info.FullName); } PropertyChanged += new PropertyChangedEventHandler( FileSystemObjectInfo_PropertyChanged); CmdDelete = new DelegateCommand(p => OnDeleteEvent()); }
void FileSystemObjectInfo_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (FileSystemInfo is DirectoryInfo) { if (string.Equals(e.PropertyName, nameof(IsExpanded), StringComparison.CurrentCultureIgnoreCase)) { RaiseBeforeExpand(); if (IsExpanded) { ImageSource = FolderManager.GetImageSource(FileSystemInfo.FullName, ItemState.Open); if (HasDummy()) { RaiseBeforeExplore(); if (!(Drive?.IsReady == false)) { RemoveDummy(); ExploreDirectories(); ExploreFiles(); } RaiseAfterExplore(); } } else { ImageSource = FolderManager.GetImageSource(FileSystemInfo.FullName, ItemState.Close); } RaiseAfterExpand(); } } }
public static ImageSource GetImageSource(string directory, ItemState folderType) { try { return(FolderManager.GetImageSource(directory, new Size(16, 16), folderType)); } catch { throw; } }
public DriveInformation(DriveInfo drive) { DriveIcon = FolderManager.GetImageSource(drive.RootDirectory.FullName, new Size(300, 300), ItemState.Undefined); Name = drive.Name; Format = drive.DriveFormat; Type = drive.DriveType.ToString(); TotalFreeSpace = drive.TotalFreeSpace; TotalSize = drive.TotalSize; UsedSpace = drive.TotalSize - drive.TotalFreeSpace; UsagePercentage = 100 - (int)Math.Round((double)drive.TotalFreeSpace / (double)drive.TotalSize * 100); Information = $"{Name} ({Format}, {Type})\r\n" + $" * Total Space : {FileManager.GetFileSize(TotalSize)}\r\n" + $" * Free Space : {FileManager.GetFileSize(TotalFreeSpace)}\r\n" + $" * Used Space : {FileManager.GetFileSize(UsedSpace)} ({UsagePercentage}%)"; }
public SyncObjectInfo(FileSystemInfo info) { // Children = new ObservableCollection<SyncObjectInfo>(); SyncItemInfo = info; // this.filelist = filelist; if (info is DirectoryInfo) { ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); // AddDummy(); } else if (info is FileInfo) { ImageSource = FileManager.GetImageSource(info.FullName); } PropertyChanged += new PropertyChangedEventHandler(FileSystemObjectInfo_PropertyChanged); }
public FileSystemObjectInfo(FileSystemInfo info) { if (this is DummyFileSystemObjectInfo) { return; } this.Children = new ObservableCollection <FileSystemObjectInfo>(); this.FileSystemInfo = info; if (info is DirectoryInfo) { this.ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); this.AddDummy(); } else if (info is FileInfo) { this.ImageSource = FileManager.GetImageSource(info.FullName); } this.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(FileSystemObjectInfo_PropertyChanged); }
//public ObservableCollection<object> Children //{ // get; // private set; //} public void LoadChildren() { try { foreach (string directory in Directory.GetDirectories(this.FullPath)) { System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(directory); DirectoryInfo i = new DirectoryInfo(directory, directoryInfo.Name) { DefaultImageSrc = FolderManager.GetImageSource(directory, ShellManager.ItemState.Close), //Icons.GetImage(directory,Icons.IconSize.Large,Icons.FolderType.Closed ), ExpandedImageSrc = FolderManager.GetImageSource(directory, ShellManager.ItemState.Open), //Icons.GetImage(directory,Icons.IconSize.Large, Icons.FolderType.Open), Root = Root, }; StyleManager.SetTheme(i, new FluentTheme()); i.Click += Folder_Click; i.Expanded += Folder_Expanded; //if (Directory.GetDirectories(directory).Length > 0) // i.IsExpanded = true; Items.Add(i); } var files = Directory.GetFiles(this.FullPath); foreach (string file in files) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(file); FileInfo i = new FileInfo(file, fileInfo.Name) { DefaultImageSrc = FileManager.GetImageSource(file),//Icons.GetImage(file, Icons.IconSize.Large), Root = Root }; StyleManager.SetTheme(i, new FluentTheme()); i.DoubleClick += File_DoubleClick; Items.Add(i); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public FileSystemEntity(FileSystemInfo info) { if (this is DummyFileSystemEntity) { return; } this.Children = new ObservableCollection <FileSystemEntity>(); this.FileSystemInfo = info; if (info is DirectoryInfo) { this.ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); this.PopulateDetails(); } else if (info is FileInfo) { this.ImageSource = FileManager.GetImageSource(info.FullName); } this.PropertyChanged += FileSystemEntity_PropertyChanged; }
public FileSystemObjectInfo(FileSystemInfo info) { if (this is DummyFileSystemObjectInfo) { return; } GripVisible = File.Exists(info.FullName) ? Visibility.Visible : Visibility.Collapsed; Children = new ObservableCollection <FileSystemObjectInfo>(); FileSystemInfo = info; if (info is DirectoryInfo) { ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); AddDummy(); } else if (info is FileInfo) { ImageSource = FileManager.GetImageSource(info.FullName); } PropertyChanged += new PropertyChangedEventHandler(FileSystemObjectInfo_PropertyChanged); }
public FileSystemObjectInfo(FileSystemInfo info, ref ListView filelist) { if (this is DummyFileSystemObjectInfo) { return; } Children = new ObservableCollection <FileSystemObjectInfo>(); FileSystemInfo = info; this.filelist = filelist; if (info is DirectoryInfo) { ImageSource = FolderManager.GetImageSource(info.FullName, ItemState.Close); AddDummy(); } else if (info is FileInfo) { ImageSource = FileManager.GetImageSource(info.FullName); } PropertyChanged += new PropertyChangedEventHandler(FileSystemObjectInfo_PropertyChanged); }
void FileSystemObjectInfo_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (FileSystemInfo is DirectoryInfo) { if (string.Equals(e.PropertyName, "IsExpanded", StringComparison.CurrentCultureIgnoreCase)) { RaiseBeforeExpand(); if (IsExpanded) { ImageSource = FolderManager.GetImageSource(FileSystemInfo.FullName, ItemState.Open); if (HasDummy()) { RaiseBeforeExplore(); RemoveDummy(); ExploreDirectories(); // ExploreFiles(); RaiseAfterExplore(); } } else { ImageSource = FolderManager.GetImageSource(FileSystemInfo.FullName, ItemState.Close); } RaiseAfterExpand(); } else if (string.Equals(e.PropertyName, "IsSelect", StringComparison.CurrentCultureIgnoreCase)) { filelist.Items.Clear(); if (IsSelect) { try { var dirs = ((DirectoryInfo)FileSystemInfo).GetDirectories(); foreach (DirectoryInfo f in dirs) { // filelist.Items.Add(new FileSystemObjectInfo(f, ref filelist)); filelist.Items.Add(new SyncObjectInfo(f)); } } catch (UnauthorizedAccessException) { } try { var files = ((DirectoryInfo)FileSystemInfo).GetFiles(); foreach (FileInfo f in files) { // filelist.Items.Add(new FileSystemObjectInfo(f, ref filelist)); filelist.Items.Add(new SyncObjectInfo(f)); } } catch (UnauthorizedAccessException) { } } } else if (string.Equals(e.PropertyName, "IsSelectItem", StringComparison.CurrentCultureIgnoreCase)) { if (this.IsSelectItem) { this.IsChecked = !this.IsChecked; } } } //else if (FileSystemInfo is FileInfo // && string.Equals(e.PropertyName, "IsSelectItem", StringComparison.CurrentCultureIgnoreCase)) //{ // if (this.IsSelectItem) // this.IsChecked = !this.IsChecked; //} }