diff --git a/src/Captura.Core/Settings.cs b/src/Captura.Core/Settings.cs index 6c3a33322..9cce869e3 100644 --- a/src/Captura.Core/Settings.cs +++ b/src/Captura.Core/Settings.cs @@ -23,6 +23,14 @@ public List RecentItems set => Set(value); } + [UserScopedSetting] + [DefaultSettingValue("30")] + public int RecentMax + { + get => Get(); + set => Set(value); + } + #region Remember [UserScopedSetting] [DefaultSettingValue("Png")] diff --git a/src/Captura.Core/ViewModels/RecentViewModel.cs b/src/Captura.Core/ViewModels/RecentViewModel.cs index dc0b5aac4..64814f56b 100644 --- a/src/Captura.Core/ViewModels/RecentViewModel.cs +++ b/src/Captura.Core/ViewModels/RecentViewModel.cs @@ -2,14 +2,15 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Windows.Input; namespace Captura.ViewModels { public class RecentViewModel : ViewModelBase, IDisposable { public ObservableCollection RecentList { get; } = new ObservableCollection(); - - int maxItemsToPersist = 30; + + public ICommand ClearCommand { get; } public RecentViewModel() { @@ -21,6 +22,8 @@ public RecentViewModel() foreach (var recent in Settings.Instance.RecentItems) Add(recent.FilePath, recent.ItemType, false); + + ClearCommand = new DelegateCommand(() => RecentList.Clear()); } public RecentItemViewModel Add(string FilePath, RecentItemType ItemType, bool IsSaving) @@ -39,7 +42,9 @@ public void Dispose() { Settings.Instance.RecentItems.Clear(); - for (int i = 0; i < RecentList.Count && i < maxItemsToPersist; ++i) + var max = Settings.Instance.RecentMax; + + for (int i = 0; i < RecentList.Count && i < max; ++i) Settings.Instance.RecentItems.Add(new RecentItemModel(RecentList[i].FilePath, RecentList[i].ItemType)); } } diff --git a/src/Captura/Views/RecentView.xaml b/src/Captura/Views/RecentView.xaml index 57ee7db57..afb981424 100644 --- a/src/Captura/Views/RecentView.xaml +++ b/src/Captura/Views/RecentView.xaml @@ -3,23 +3,30 @@ xmlns:local="clr-namespace:Captura" DataContext="{StaticResource MainViewModel}"> - - - - - - - - - - - - + + +