protected override void OnViewChange() { base.OnViewChange(); _inLabelEdit = false; availableFieldsTreeColumns.ViewEditor = ViewEditor; availableFieldsTreeColumns.RootColumn = ViewInfo.ParentColumn; availableFieldsTreeColumns.SublistId = ViewInfo.SublistId; availableFieldsTreeColumns.CheckedColumns = ListColumnsInView(); IList <DisplayColumn> gridColumns = ImmutableList.ValueOf(ViewEditor.ViewInfo.DisplayColumns.Where(col => !col.ColumnSpec.Hidden)); if (gridColumns.Count != VisibleColumns.Count) { gridColumns = VisibleColumns; } ListViewHelper.ReplaceItems(listViewColumns, gridColumns.Select(MakeListViewColumnItem).ToArray()); if (null != SelectedPaths) { var selectedIndexes = VisibleColumns .Select((col, index) => new KeyValuePair <DisplayColumn, int>(col, index)) .Where(kvp => SelectedPaths.Contains(kvp.Key.PropertyPath)) .Select(kvp => kvp.Value); ListViewHelper.SelectIndexes(listViewColumns, selectedIndexes); } UpdateButtons(); }
/// <summary> /// Initializes a new instance of the <see cref="ViewModelMain"/> class. /// </summary> public ViewModelMain() { this.paths = new SelectedPaths(); this.displayFolder = new OpenFolder(); this.iconFile = new OpenFile(@"Select the icon file.", @"Icon Files (*.ico)|*.ico"); this.ExecuteCommand = new RelayCommand(this.Execute, this.CanExecute); this.FolderPathBrowserCommand = new RelayCommand(this.FolderPathBrowser); this.FilePathBrowserCommand = new RelayCommand(this.FilePathBrowser); }
/// <summary> /// Writes the text file to display the custom folder icon. /// </summary> /// <param name="paths">Reference to the SelectedPaths class.</param> public static void WriteFile(SelectedPaths paths) { // Updated Method to write file string fileName = paths.IsFolderPathRoot ? "\\autorun.inf" : "\\desktop.ini"; string fileContents = paths.IsFolderPathRoot ? CreateAutorunInfContents(paths.RelativePath, paths.DriveName) : CreateDesktopIniContents(paths.RelativePath); using (StreamWriter outputFile = new StreamWriter(paths.FolderPath + fileName)) { outputFile.Write(fileContents); } }
private SelectedPaths CreateSelectedPaths(string type = "") { SelectedPaths selectedPaths; if (type == "populated") { selectedPaths = new SelectedPaths() { FolderPath = "C:\\", IconPath = "C:\\icon.ico", DriveName = "DriveName" }; } selectedPaths = new SelectedPaths(); return(selectedPaths); }
private async Task ZipAsync() { var zipPath = Path.Combine( Navigation.FullPath, Path.ChangeExtension(SelectedPaths.First(), ".zip") ).CopyableFileName(); using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create)) { var operations = SelectedPaths.Select(path => ZipOperation(archive, path)).ToArray(); var dialog = new OperationProgressViewModel(operations) { Caption = string.Format(Properties.Resources.File_Zipping, operations.Sum(o => o.Count)) }; await Messenger.SendAsync(dialog); } }
protected override void OnViewChange() { base.OnViewChange(); _inLabelEdit = false; availableFieldsTreeColumns.RootColumn = ViewInfo.ParentColumn; availableFieldsTreeColumns.ShowAdvancedFields = ViewEditor.ShowHiddenFields; availableFieldsTreeColumns.SublistId = ViewInfo.SublistId; availableFieldsTreeColumns.CheckedColumns = ListColumnsInView(); ListViewHelper.ReplaceItems(listViewColumns, VisibleColumns.Select(MakeListViewColumnItem).ToArray()); if (null != SelectedPaths) { var selectedIndexes = VisibleColumns .Select((col, index) => new KeyValuePair<DisplayColumn, int>(col, index)) .Where(kvp => SelectedPaths.Contains(kvp.Key.PropertyPath)) .Select(kvp => kvp.Value); ListViewHelper.SelectIndexes(listViewColumns, selectedIndexes); } UpdateButtons(); }
// Validate // Folder Attribute // File Attribute // File Already Exists //// Folder does not exist /// <summary> /// The execute. /// </summary> /// <param name="folderPath"> /// The folder path. /// </param> /// <param name="iconPath"> /// The icon path. /// </param> /// <param name="driveLabel"> /// The drive label. /// </param> public static void Execute(SelectedPaths paths) { // Checks if the folder and icon are on same drive if (paths.ShareSameRoot) { bool overwriteFile = false; bool fileExists = false; // Check if there is already a .ini/.inf file if (CheckFileExists(paths.FolderPath)) { // TODO User conformation to overwrite file overwriteFile = true; fileExists = true; } // File does not exist AND/OR can be overridden // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (!fileExists || overwriteFile) { // Set the folder attributes for non-root folders if (!IsDisplayFolderRoot(paths.FolderPath)) { DirectoryInfo directoryInfo = new DirectoryInfo(paths.FolderPath); if (!directoryInfo.Attributes.IsSet(FileAttributes.System)) { directoryInfo.Attributes |= FileAttributes.ReadOnly; } } // Text File output // Deletes the file if one exists TextFileOutput.WriteFile(paths); } } }
private async Task DeleteFilesAsync(bool moveToRecycleBin = true) { var operations = SelectedPaths.Select(path => DeleteOperation(path, moveToRecycleBin)).ToArray(); var selectionText = Host.ActiveFileManager.SelectionText; var messageBox = new MessageBoxViewModel { Button = MessageBoxButton.YesNo, Icon = MessageBoxImage.Question, Caption = Properties.Resources.MessageBox_Confirm, Text = string.Format(moveToRecycleBin ? Properties.Resources.File_Recycling : Properties.Resources.File_Deleting, selectionText) }; await Messenger.SendAsync(messageBox); if (messageBox.Result != MessageBoxResult.Yes) { return; } await Messenger.SendAsync(new OperationProgressViewModel(operations) { Caption = string.Format(Properties.Resources.File_DeletingProgress, operations.Sum(o => o.Count)) }); }