diff --git a/Files/DataModels/FilesystemItemsOperationDataModel.cs b/Files/DataModels/FilesystemItemsOperationDataModel.cs index 429db5456dc4..57eebb3a00aa 100644 --- a/Files/DataModels/FilesystemItemsOperationDataModel.cs +++ b/Files/DataModels/FilesystemItemsOperationDataModel.cs @@ -1,5 +1,6 @@ using Files.Enums; using Files.ViewModels.Dialogs; +using System; using System.Collections.Generic; using System.Linq; using Windows.UI.Xaml; @@ -52,7 +53,7 @@ public FilesystemItemsOperationDataModel(FilesystemOperationType operationType, this.ConflictingItems = conflictingItems; } - public List ToItems() + public List ToItems(Action updatePrimaryButtonEnabled, Action optionGenerateNewName, Action optionReplaceExisting, Action optionSkip) { List items = new List(); @@ -61,31 +62,32 @@ public List ToItems() // Add conflicting items first foreach (var item in ConflictingItems) { - items.Add(new FilesystemOperationItemViewModel() + items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip) { + IsConflict = true, OperationIconGlyph = GetOperationIconGlyph(item.OperationType), SourcePath = item.SourcePath, - PlusIconVisibility = Visibility.Collapsed, DestinationPath = item.DestinationPath, - IsConflicting = true, + ConflictResolveOption = FileNameConflictResolveOptionType.GenerateNewName, ExclamationMarkVisibility = Visibility.Visible, - ItemOperation = item.OperationType + ItemOperation = item.OperationType, + ActionTaken = false }); } // Then add non-conflicting items foreach (var item in nonConflictingItems) { - items.Add(new FilesystemOperationItemViewModel() + items.Add(new FilesystemOperationItemViewModel(updatePrimaryButtonEnabled, optionGenerateNewName, optionReplaceExisting, optionSkip) { + IsConflict = false, OperationIconGlyph = GetOperationIconGlyph(item.OperationType), SourcePath = item.SourcePath, - ArrowIconVisibility = item.OperationType == FilesystemOperationType.Delete ? Visibility.Collapsed : Visibility.Visible, - PlusIconVisibility = item.OperationType == FilesystemOperationType.Delete ? Visibility.Collapsed : Visibility.Visible, DestinationPath = item.DestinationPath, - IsConflicting = false, + ConflictResolveOption = FileNameConflictResolveOptionType.NotAConflict, ExclamationMarkVisibility = Visibility.Collapsed, - ItemOperation = item.OperationType + ItemOperation = item.OperationType, + ActionTaken = true }); } diff --git a/Files/Dialogs/FilesystemOperationDialog.xaml b/Files/Dialogs/FilesystemOperationDialog.xaml index 6d6343c0af2d..c85c3366e504 100644 --- a/Files/Dialogs/FilesystemOperationDialog.xaml +++ b/Files/Dialogs/FilesystemOperationDialog.xaml @@ -4,14 +4,15 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:helpers="using:Files.Helpers" + xmlns:i="using:Microsoft.Xaml.Interactivity" + xmlns:icore="using:Microsoft.Xaml.Interactions.Core" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:vc="using:Files.Converters" Title="{x:Bind ViewModel.Title, Mode=OneWay}" - CloseButtonCommand="{x:Bind ViewModel.CloseButtonCommand, Mode=OneWay}" - CloseButtonStyle="{StaticResource DefaultButtonStyle}" - CloseButtonText="{x:Bind ViewModel.CloseButtonText, Mode=OneWay}" CornerRadius="4" DefaultButton="Primary" + IsPrimaryButtonEnabled="{x:Bind ViewModel.PrimaryButtonEnabled, Mode=OneWay}" PrimaryButtonCommand="{x:Bind ViewModel.PrimaryButtonCommand, Mode=OneWay}" PrimaryButtonStyle="{StaticResource DefaultButtonStyle}" PrimaryButtonText="{x:Bind ViewModel.PrimaryButtonText, Mode=OneWay}" @@ -20,6 +21,12 @@ SecondaryButtonStyle="{StaticResource DefaultButtonStyle}" SecondaryButtonText="{x:Bind ViewModel.SecondaryButtonText, Mode=OneWay}" mc:Ignorable="d"> + + + + + + @@ -38,174 +45,263 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + FontSize="12" + Foreground="Gray" + Text="{Binding TakenActionText}" + Visibility="{Binding ShowResolveOption}" /> + + + + + + + - + Foreground="Gray" + Glyph="" + Visibility="{Binding DestinationLocationVisibility}" /> - - + + + - - - - + + + + - - + + - - + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Files/Dialogs/FilesystemOperationDialog.xaml.cs b/Files/Dialogs/FilesystemOperationDialog.xaml.cs index 685fa260de2a..953dfad34f8a 100644 --- a/Files/Dialogs/FilesystemOperationDialog.xaml.cs +++ b/Files/Dialogs/FilesystemOperationDialog.xaml.cs @@ -1,11 +1,12 @@ using Files.ViewModels.Dialogs; +using System.Collections.Generic; using Windows.UI.Xaml.Controls; // The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 namespace Files.Dialogs { - public sealed partial class FilesystemOperationDialog : ContentDialog + public sealed partial class FilesystemOperationDialog : ContentDialog, IFilesystemOperationDialogView { public FilesystemOperationDialogViewModel ViewModel { @@ -13,11 +14,19 @@ public FilesystemOperationDialogViewModel ViewModel set => DataContext = value; } + public IList SelectedItems => DetailsGrid.SelectedItems; + public FilesystemOperationDialog(FilesystemOperationDialogViewModel viewModel) { this.InitializeComponent(); ViewModel = viewModel; + ViewModel.View = this; } } + + public interface IFilesystemOperationDialogView + { + IList SelectedItems { get; } + } } \ No newline at end of file diff --git a/Files/Enums/FileNameConflictResolveOptionType.cs b/Files/Enums/FileNameConflictResolveOptionType.cs index 994fd60e0be2..19807a6ee474 100644 --- a/Files/Enums/FileNameConflictResolveOptionType.cs +++ b/Files/Enums/FileNameConflictResolveOptionType.cs @@ -1,10 +1,10 @@ namespace Files.Enums { - public enum FileNameConflictResolveOptionType + public enum FileNameConflictResolveOptionType : uint { - None = 0, - GenerateNewName = 1, - ReplaceExisting = 2, - Skip = 4 + GenerateNewName = 0, + ReplaceExisting = 1, + Skip = 2, + NotAConflict = 4 } } \ No newline at end of file diff --git a/Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs b/Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs index a5df5e369481..3da6acba684a 100644 --- a/Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs +++ b/Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs @@ -891,7 +891,7 @@ not when file name has changed for (int i = 0; i < source.Count(); i++) { incomingItems.Add(new FilesystemItemsOperationItemModel(operationType, source.ElementAt(i).Path ?? source.ElementAt(i).Item.Path, destination.ElementAt(i))); - collisions.Add(incomingItems.ElementAt(i).SourcePath, FileNameConflictResolveOptionType.None); + collisions.Add(incomingItems.ElementAt(i).SourcePath, FileNameConflictResolveOptionType.GenerateNewName); if (destination.Count() > 0 && StorageItemHelpers.Exists(destination.ElementAt(i))) // Same item names in both directories { @@ -915,7 +915,7 @@ not when file name has changed if (mustResolveConflicts) // If there were conflicts, result buttons are different { - if (result != ContentDialogResult.Primary && result != ContentDialogResult.Secondary) // Operation was cancelled + if (result != ContentDialogResult.Primary) // Operation was cancelled { return (new List(), true); } diff --git a/Files/Helpers/EnumConversionHelpers.cs b/Files/Helpers/EnumConversionHelpers.cs index 427e6e0e1a23..ad88fdf614fd 100644 --- a/Files/Helpers/EnumConversionHelpers.cs +++ b/Files/Helpers/EnumConversionHelpers.cs @@ -27,9 +27,6 @@ public static NameCollisionOption Convert(this FileNameConflictResolveOptionType { switch (option) { - case FileNameConflictResolveOptionType.None: - return NameCollisionOption.GenerateUniqueName; - case FileNameConflictResolveOptionType.GenerateNewName: return NameCollisionOption.GenerateUniqueName; diff --git a/Files/Strings/en-US/Resources.resw b/Files/Strings/en-US/Resources.resw index d3ccb7d160ab..9c2a6a3d873a 100644 --- a/Files/Strings/en-US/Resources.resw +++ b/Files/Strings/en-US/Resources.resw @@ -2034,23 +2034,20 @@ {0} items will be deleted - - Cancel - - Generate new name + Continue - Replace existing + Cancel - - There are {0} conflicting file names, and {1} outgoing item(s) + + There are {0} conflicting file names, and {1} outgoing item(s). Conflicting file name(s) - - There is one conflicting file name, and {0} outgoing item(s) + + There is one conflicting file name, and {0} outgoing item(s). One item will be copied @@ -2094,9 +2091,27 @@ Manage Widgets - + Open themes folder + + Generate new name + + + Replace existing + + + Skip + + + Generate new name + + + Replace existing + + + Skip + Use new details view @@ -2109,4 +2124,28 @@ Type + + Details + + + Generate new name + + + Replace existing + + + Skip + + + Generate new name + + + Undo + + + There are {0} conflicting file names. + + + There is one conflicting file name. + \ No newline at end of file diff --git a/Files/ViewModels/Dialogs/FilesystemOperationDialogViewModel.cs b/Files/ViewModels/Dialogs/FilesystemOperationDialogViewModel.cs index edde2c78f1da..56f2e4ae9b5a 100644 --- a/Files/ViewModels/Dialogs/FilesystemOperationDialogViewModel.cs +++ b/Files/ViewModels/Dialogs/FilesystemOperationDialogViewModel.cs @@ -4,19 +4,25 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using Microsoft.Toolkit.Uwp; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows.Input; +using Windows.UI.Xaml.Controls; namespace Files.ViewModels.Dialogs { public class FilesystemOperationDialogViewModel : ObservableObject { - #region Public Properties public ObservableCollection Items { get; private set; } + public ListViewSelectionMode ItemsSelectionMode + { + get => MustResolveConflicts ? ListViewSelectionMode.Extended : ListViewSelectionMode.None; + } + private string title; public string Title @@ -33,6 +39,14 @@ public string Subtitle set => SetProperty(ref subtitle, value); } + private bool primaryButtonEnabled = false; + + public bool PrimaryButtonEnabled + { + get => primaryButtonEnabled; + set => SetProperty(ref primaryButtonEnabled, value); + } + private string primaryButtonText; public string PrimaryButtonText @@ -49,38 +63,6 @@ public string SecondaryButtonText set => SetProperty(ref secondaryButtonText, value); } - private string closeButtonText; - - public string CloseButtonText - { - get => closeButtonText; - set => SetProperty(ref closeButtonText, value); - } - - private bool chevronUpLoad = false; - - public bool ChevronUpLoad - { - get => chevronUpLoad; - set => SetProperty(ref chevronUpLoad, value); - } - - private bool chevronDownLoad = true; - - public bool ChevronDownLoad - { - get => chevronDownLoad; - set => SetProperty(ref chevronDownLoad, value); - } - - private bool expandableDetailsLoad = false; - - public bool ExpandableDetailsLoad - { - get => expandableDetailsLoad; - set => SetProperty(ref expandableDetailsLoad, value); - } - private bool permanentlyDeleteLoad = false; public bool PermanentlyDeleteLoad @@ -113,70 +95,85 @@ public bool MustResolveConflicts set => SetProperty(ref mustResolveConflicts, value); } - #endregion Public Properties - - #region Commands - - public ICommand ExpandDetailsCommand { get; private set; } + public IFilesystemOperationDialogView View { get; set; } public ICommand PrimaryButtonCommand { get; private set; } public ICommand SecondaryButtonCommand { get; private set; } - public ICommand CloseButtonCommand { get; private set; } - - #endregion Commands + public ICommand LoadedCommand { get; private set; } public FilesystemOperationDialogViewModel() { // Create commands PrimaryButtonCommand = new RelayCommand(PrimaryButton); SecondaryButtonCommand = new RelayCommand(SecondaryButton); - CloseButtonCommand = new RelayCommand(CloseButton); + LoadedCommand = new RelayCommand(() => + { + UpdatePrimaryButtonEnabled(); + }); } - #region Command Implementation - private void PrimaryButton() + { + // Something there? + } + + private void SecondaryButton() { if (MustResolveConflicts) { - // Generate new name + // Replace existing foreach (var item in Items) { - item.ConflictResolveOption = FileNameConflictResolveOptionType.GenerateNewName; + // Don't do anything + item.ConflictResolveOption = FileNameConflictResolveOptionType.Skip; } } } - private void SecondaryButton() + public void OptionSkip() { - if (MustResolveConflicts) + foreach (var item in View.SelectedItems) { - // Replace existing + var detailItem = (FilesystemOperationItemViewModel)item; - foreach (var item in Items) - { - item.ConflictResolveOption = FileNameConflictResolveOptionType.ReplaceExisting; - } + detailItem.TakeAction(FileNameConflictResolveOptionType.Skip); } } - private void CloseButton() + public void OptionReplaceExisting() { - if (MustResolveConflicts) + foreach (var item in View.SelectedItems) { - // Skip + var detailItem = (FilesystemOperationItemViewModel)item; - foreach (var item in Items) - { - item.ConflictResolveOption = FileNameConflictResolveOptionType.Skip; - } + detailItem.TakeAction(FileNameConflictResolveOptionType.ReplaceExisting); + } + } + + public void OptionGenerateNewName() + { + foreach (var item in View.SelectedItems) + { + var detailItem = (FilesystemOperationItemViewModel)item; + + detailItem.TakeAction(FileNameConflictResolveOptionType.GenerateNewName); } } - #endregion Command Implementation + public void UpdatePrimaryButtonEnabled() + { + if (MustResolveConflicts) + { + PrimaryButtonEnabled = !Items.Any((item) => !item.ActionTaken); + } + else if (PermanentlyDeleteLoad) // PermanentlyDeleteLoad - is only loaded (`true`) when deleting items + { + PrimaryButtonEnabled = true; + } + } public List GetResult() { @@ -189,18 +186,43 @@ public static FilesystemOperationDialog GetDialog(FilesystemItemsOperationDataMo string subtitleText = null; string primaryButtonText = null; string secondaryButtonText = null; - string closeButtonText = null; bool permanentlyDeleteLoad = false; if (itemsData.MustResolveConflicts) { List nonConflictingItems = itemsData.IncomingItems.Except(itemsData.ConflictingItems).ToList(); + // Subtitle text + if (itemsData.ConflictingItems.Count > 1) + { + if (nonConflictingItems.Count > 0) + { + // There are {0} conflicting file names, and {1} outgoing item(s) + subtitleText = string.Format("ConflictingItemsDialogSubtitleMultipleConflictsMultipleNonConflicts".GetLocalized(), itemsData.ConflictingItems.Count, nonConflictingItems.Count); + } + else + { + // There are {0} conflicting file names + subtitleText = string.Format("ConflictingItemsDialogSubtitleMultipleConflictsNoNonConflicts".GetLocalized(), itemsData.ConflictingItems.Count); + } + } + else + { + if (nonConflictingItems.Count > 0) + { + // There is one conflicting file name, and {0} outgoing item(s) + subtitleText = string.Format("ConflictingItemsDialogSubtitleSingleConflictMultipleNonConflicts".GetLocalized(), nonConflictingItems.Count); + } + else + { + // There is one conflicting file name + subtitleText = string.Format("ConflictingItemsDialogSubtitleSingleConflictNoNonConflicts".GetLocalized(), itemsData.ConflictingItems.Count); + } + } + titleText = "ConflictingItemsDialogTitle".GetLocalized(); - subtitleText = itemsData.ConflictingItems.Count == 1 ? string.Format("ConflictingItemsDialogSubtitleSingle".GetLocalized(), nonConflictingItems.Count) : string.Format("ConflictingItemsDialogSubtitleMultiple".GetLocalized(), itemsData.ConflictingItems.Count, nonConflictingItems.Count); primaryButtonText = "ConflictingItemsDialogPrimaryButtonText".GetLocalized(); secondaryButtonText = "ConflictingItemsDialogSecondaryButtonText".GetLocalized(); - closeButtonText = "ConflictingItemsDialogCloseButtonText".GetLocalized(); } else { @@ -242,21 +264,13 @@ public static FilesystemOperationDialog GetDialog(FilesystemItemsOperationDataMo Subtitle = subtitleText, PrimaryButtonText = primaryButtonText, SecondaryButtonText = secondaryButtonText, - CloseButtonText = closeButtonText, PermanentlyDeleteLoad = permanentlyDeleteLoad, PermanentlyDelete = itemsData.PermanentlyDelete, PermanentlyDeleteEnabled = itemsData.PermanentlyDeleteEnabled, - MustResolveConflicts = itemsData.MustResolveConflicts, - ExpandDetailsCommand = new RelayCommand((vm) => - { - bool detailsShown = !vm.ExpandableDetailsLoad; // Inverted - - vm.ExpandableDetailsLoad = detailsShown; - vm.ChevronDownLoad = !detailsShown; - vm.ChevronUpLoad = detailsShown; - }), - Items = new ObservableCollection(itemsData.ToItems()) + MustResolveConflicts = itemsData.MustResolveConflicts }; + viewModel.Items = new ObservableCollection(itemsData.ToItems( + viewModel.UpdatePrimaryButtonEnabled, viewModel.OptionGenerateNewName, viewModel.OptionReplaceExisting, viewModel.OptionSkip)); FilesystemOperationDialog dialog = new FilesystemOperationDialog(viewModel); diff --git a/Files/ViewModels/Dialogs/FilesystemOperationItemViewModel.cs b/Files/ViewModels/Dialogs/FilesystemOperationItemViewModel.cs index 8ddf68269793..f18652d5705f 100644 --- a/Files/ViewModels/Dialogs/FilesystemOperationItemViewModel.cs +++ b/Files/ViewModels/Dialogs/FilesystemOperationItemViewModel.cs @@ -1,48 +1,79 @@ using Files.Enums; using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using Microsoft.Toolkit.Uwp; +using System; +using System.Windows.Input; using Windows.UI.Xaml; namespace Files.ViewModels.Dialogs { public class FilesystemOperationItemViewModel : ObservableObject, IFilesystemOperationItemModel { + private readonly Action updatePrimaryButtonEnabled; + public string OperationIconGlyph { get; set; } public string SourcePath { get; set; } - public Visibility PlusIconVisibility { get; set; } // Item will be created - show plus icon - public string DestinationPath { get; set; } - private bool isConflicting = false; + private bool isConflict; + public bool IsConflict + { + get => isConflict; + set => SetProperty(ref isConflict, value); + } + + public string SourceDirectoryDisplayName + { + // If the destination path is empty, then show full source path instead + get => !string.IsNullOrEmpty(DestinationPath) ? System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(SourcePath)) : System.IO.Path.GetDirectoryName(SourcePath); + } + + public string DestinationDirectoryDisplayName + { + get => System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(DestinationPath)); + } + + public string DisplayFileName + { + get => string.IsNullOrEmpty(DestinationPath) ? System.IO.Path.GetFileName(SourcePath) : System.IO.Path.GetFileName(DestinationPath); + } - /// - /// Determines whether an item is or was a conflicting one - ///
- ///
- /// If the item is no longer a conflicting file name, this property value should NOT be changed. - ///
- public bool IsConflicting + public string TakenActionText { - get => isConflicting; - set + get { - if (isConflicting != value) + switch (ConflictResolveOption) { - isConflicting = value; + case FileNameConflictResolveOptionType.GenerateNewName: + { + return "ConflictingItemsDialogTakenActionGenerateNewName".GetLocalized(); + } - ExclamationMarkVisibility = isConflicting ? Visibility.Visible : Visibility.Collapsed; - ArrowIconVisibility = isConflicting ? Visibility.Collapsed : Visibility.Visible; + case FileNameConflictResolveOptionType.ReplaceExisting: + { + return "ConflictingItemsDialogTakenActionReplaceExisting".GetLocalized(); + } + + case FileNameConflictResolveOptionType.Skip: + { + return "ConflictingItemsDialogTakenActionSkip".GetLocalized(); + } + + case FileNameConflictResolveOptionType.NotAConflict: + default: + { + return "Not a conflict"; + } } } } - private Visibility arrowIconVisibility = Visibility.Visible; - - public Visibility ArrowIconVisibility + public Visibility DestinationLocationVisibility { - get => arrowIconVisibility; - set => SetProperty(ref arrowIconVisibility, value); + get => string.IsNullOrEmpty(DestinationPath) ? Visibility.Collapsed : Visibility.Visible; } private Visibility exclamationMarkVisibility = Visibility.Collapsed; @@ -53,20 +84,82 @@ public Visibility ExclamationMarkVisibility set => SetProperty(ref exclamationMarkVisibility, value); } - private FileNameConflictResolveOptionType conflictResolveOption = FileNameConflictResolveOptionType.None; + public FileNameConflictResolveOptionType ConflictResolveOption { get; set; } - public FileNameConflictResolveOptionType ConflictResolveOption + private bool actionTaken = false; + public bool ActionTaken { - get => conflictResolveOption; - set - { - if (conflictResolveOption != value && IsConflicting) - { - conflictResolveOption = value; - } - } + get => actionTaken; + set => SetProperty(ref actionTaken, value); + } + + public Visibility ShowSubFolders + { + get => string.IsNullOrEmpty(DestinationPath) || !IsConflict || (!ActionTaken && ConflictResolveOption != FileNameConflictResolveOptionType.NotAConflict) ? Visibility.Visible : Visibility.Collapsed; + } + + public Visibility ShowResolveOption + { + get => ActionTaken && ConflictResolveOption != FileNameConflictResolveOptionType.NotAConflict ? Visibility.Visible : Visibility.Collapsed; + } + + public Visibility ShowUndoButton + { + get => ActionTaken && ConflictResolveOption != FileNameConflictResolveOptionType.NotAConflict ? Visibility.Visible : Visibility.Collapsed; + } + + public Visibility ShowSplitButton + { + get => !ActionTaken && ConflictResolveOption != FileNameConflictResolveOptionType.NotAConflict ? Visibility.Visible : Visibility.Collapsed; } public FilesystemOperationType ItemOperation { get; set; } + + public ICommand GenerateNewNameCommand { get; private set; } + + public ICommand ReplaceExistingCommand { get; private set; } + + public ICommand SkipCommand { get; private set; } + + public ICommand SplitButtonDefaultActionCommand { get; private set; } + + public ICommand UndoTakenActionCommand { get; private set; } + + public ICommand OptionGenerateNewNameCommand { get; private set; } + + public ICommand OptionReplaceExistingCommand { get; private set; } + + public ICommand OptionSkipCommand { get; private set; } + + public FilesystemOperationItemViewModel(Action updatePrimaryButtonEnabled, Action optionGenerateNewName, Action optionReplaceExisting, Action optionSkip) + { + this.updatePrimaryButtonEnabled = updatePrimaryButtonEnabled; + + GenerateNewNameCommand = new RelayCommand(() => TakeAction(FileNameConflictResolveOptionType.GenerateNewName)); + ReplaceExistingCommand = new RelayCommand(() => TakeAction(FileNameConflictResolveOptionType.ReplaceExisting)); + SkipCommand = new RelayCommand(() => TakeAction(FileNameConflictResolveOptionType.Skip)); + SplitButtonDefaultActionCommand = new RelayCommand(() => TakeAction(FileNameConflictResolveOptionType.GenerateNewName)); // GenerateNewName is the default action + UndoTakenActionCommand = new RelayCommand((e) => TakeAction(FileNameConflictResolveOptionType.GenerateNewName, false)); + + OptionGenerateNewNameCommand = new RelayCommand(optionGenerateNewName); + OptionReplaceExistingCommand = new RelayCommand(optionReplaceExisting); + OptionSkipCommand = new RelayCommand(optionSkip); + } + + public void TakeAction(FileNameConflictResolveOptionType action, bool actionTaken = true) + { + if (IsConflict) + { + ConflictResolveOption = action; + ActionTaken = actionTaken; + ExclamationMarkVisibility = actionTaken ? Visibility.Collapsed : Visibility.Visible; + OnPropertyChanged(nameof(ShowSubFolders)); + OnPropertyChanged(nameof(ShowResolveOption)); + OnPropertyChanged(nameof(ShowUndoButton)); + OnPropertyChanged(nameof(ShowSplitButton)); + OnPropertyChanged(nameof(TakenActionText)); + this.updatePrimaryButtonEnabled?.Invoke(); + } + } } } \ No newline at end of file diff --git a/Files/ViewModels/Dialogs/IFilesystemOperationItemModel.cs b/Files/ViewModels/Dialogs/IFilesystemOperationItemModel.cs index 62dfc9a8b431..2d430c3bb00b 100644 --- a/Files/ViewModels/Dialogs/IFilesystemOperationItemModel.cs +++ b/Files/ViewModels/Dialogs/IFilesystemOperationItemModel.cs @@ -8,8 +8,6 @@ public interface IFilesystemOperationItemModel string DestinationPath { get; } - bool IsConflicting { get; } - FileNameConflictResolveOptionType ConflictResolveOption { get; } FilesystemOperationType ItemOperation { get; }