From fccc6cedd0d608e0e0369c7c1aa13859f8d48ee3 Mon Sep 17 00:00:00 2001 From: Henry Timms <36480544+Hen676@users.noreply.github.com> Date: Sat, 17 Sep 2022 22:30:45 +0100 Subject: [PATCH 1/4] Init switch to DataGrid --- FadedVanguardLogUploader/App.axaml | 5 ++ FadedVanguardLogUploader/Enums/SortingType.cs | 2 +- .../FadedVanguardLogUploader.csproj | 9 +- .../ViewModels/ListViewModel.cs | 75 ++-------------- .../ViewModels/MainWindowViewModel.cs | 1 - FadedVanguardLogUploader/Views/ListView.axaml | 88 ++++++++++--------- 6 files changed, 64 insertions(+), 116 deletions(-) diff --git a/FadedVanguardLogUploader/App.axaml b/FadedVanguardLogUploader/App.axaml index e3e3054..a8c61ce 100644 --- a/FadedVanguardLogUploader/App.axaml +++ b/FadedVanguardLogUploader/App.axaml @@ -6,4 +6,9 @@ + + + + + diff --git a/FadedVanguardLogUploader/Enums/SortingType.cs b/FadedVanguardLogUploader/Enums/SortingType.cs index 70955f2..0865c2a 100644 --- a/FadedVanguardLogUploader/Enums/SortingType.cs +++ b/FadedVanguardLogUploader/Enums/SortingType.cs @@ -5,6 +5,6 @@ public enum SortingType Date, Length, User, - Charcter, + Charcter } } diff --git a/FadedVanguardLogUploader/FadedVanguardLogUploader.csproj b/FadedVanguardLogUploader/FadedVanguardLogUploader.csproj index c927e34..77c73bc 100644 --- a/FadedVanguardLogUploader/FadedVanguardLogUploader.csproj +++ b/FadedVanguardLogUploader/FadedVanguardLogUploader.csproj @@ -20,11 +20,12 @@ - - + + + - - + + diff --git a/FadedVanguardLogUploader/ViewModels/ListViewModel.cs b/FadedVanguardLogUploader/ViewModels/ListViewModel.cs index de1f68c..3c49539 100644 --- a/FadedVanguardLogUploader/ViewModels/ListViewModel.cs +++ b/FadedVanguardLogUploader/ViewModels/ListViewModel.cs @@ -20,27 +20,7 @@ namespace FadedVanguardLogUploader.ViewModels { public class ListViewModel : ViewModelBase { - public ObservableCollection Items { get; } = new(); - public int Page - { - get => page; - set => this.RaiseAndSetIfChanged(ref page, value); - } - public int PageMax - { - get => pageMax; - set => this.RaiseAndSetIfChanged(ref pageMax, value); - } - public bool EnabledDown - { - get => enabledDown; - set => this.RaiseAndSetIfChanged(ref enabledDown, value); - } - public bool EnabledUp - { - get => enabledUp; - set => this.RaiseAndSetIfChanged(ref enabledUp, value); - } + public List Items { get; set; } = new(); public int FileCount { get => fileCount; @@ -56,17 +36,11 @@ public int ProgressBarMax get => progressBarMax; set => this.RaiseAndSetIfChanged(ref progressBarMax, value); } - public ReactiveCommand PageUpCommand { get; } - public ReactiveCommand PageDownCommand { get; } public ReactiveCommand UploadCommand { get; } public Interaction ShowDialog { get; } = new Interaction(); private ConcurrentBag StoredItems = new(); private List FilteredItems = new(); private readonly Filter FilterSettings = new(); - private int pageMax = 1; - private int page = 0; - private bool enabledDown = false; - private bool enabledUp = false; private int fileCount = 0; private int progressBarValue = 0; private int progressBarMax = 100; @@ -74,15 +48,13 @@ public int ProgressBarMax public ListViewModel() { - PageUpCommand = ReactiveCommand.Create(PageUp); - PageDownCommand = ReactiveCommand.Create(PageDown); UploadCommand = ReactiveCommand.Create(UploadAsync); } public void Load() { StoredItems = storageIO.GetRecords(); - if (StoredItems.Count == 0) + if (StoredItems.IsEmpty) SearchFolder(); else UpdateFolder(); @@ -149,42 +121,6 @@ private async void UploadAsync() ProgressBarValue = 0; } - private void PageZero() - { - Items.Clear(); - Page = 0; - EnabledDown = false; - EnabledUp = FilteredItems.Count >= App.Settings.PageAmount; - if (FilteredItems.Count == 0) - return; - Items.AddRange(FilteredItems.GetRange(0, Math.Min(FilteredItems.Count, App.Settings.PageAmount))); - } - - private void PageUp() - { - Page++; - int total = Page * App.Settings.PageAmount; - EnabledDown = true; - Items.Clear(); - if (FilteredItems.Count <= total + App.Settings.PageAmount) - { - EnabledUp = false; - Items.AddRange(FilteredItems.GetRange(total, FilteredItems.Count - total)); - } - else - Items.AddRange(FilteredItems.GetRange(total, App.Settings.PageAmount)); - } - - private void PageDown() - { - if (Page == 1) - EnabledDown = false; - EnabledUp = true; - Page--; - Items.Clear(); - Items.AddRange(FilteredItems.GetRange(Page * App.Settings.PageAmount, App.Settings.PageAmount)); - } - public void UpdateFolder() { if (App.Settings.Path == "") @@ -195,7 +131,7 @@ public void UpdateFolder() s.ToLower().EndsWith(".evtc.zip") || s.ToLower().EndsWith(".zevtc")) && !StoredItems.Any(val => s.Equals(val.FullPath))); - if (files.Count() == 0) + if (!files.Any()) return; ConcurrentBag temp = new(); List bagTasks = new(); @@ -226,7 +162,7 @@ public void UpdateFolder() public void SearchFolder() { StoredItems.Clear(); - //storageIO.Delete(); + storageIO.WipeDB(); if (App.Settings.Path == "") return; IEnumerable files = Directory.EnumerateFiles(App.Settings.Path, "*.*", SearchOption.AllDirectories) @@ -284,7 +220,7 @@ public void Sort() }); break; } - PageZero(); + Items.AddRange(FilteredItems); } public void Filter(DateTimeOffset? date = null, TimeSpan? time = null) @@ -301,7 +237,6 @@ public void Filter(DateTimeOffset? date = null, TimeSpan? time = null) return FilterSettings.Predicate(x); }).ToList(); FileCount = FilteredItems.Count; - PageMax = (FilteredItems.Count - 1) / App.Settings.PageAmount + 1; Sort(); } } diff --git a/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs b/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs index cd8c611..3023fbb 100644 --- a/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs +++ b/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs @@ -119,7 +119,6 @@ private void AscDesToggle() } // Set sorting types - // TODO:: Refine to simple sort types, remove asc/des from enum private void DateSort() { App.Settings.SortingType = SortingType.Date; diff --git a/FadedVanguardLogUploader/Views/ListView.axaml b/FadedVanguardLogUploader/Views/ListView.axaml index bc4897d..aa5a0dc 100644 --- a/FadedVanguardLogUploader/Views/ListView.axaml +++ b/FadedVanguardLogUploader/Views/ListView.axaml @@ -60,46 +60,54 @@ ToolTip.Tip="{x:Static p:Resources.LNG_List_Upload_Tooltip}" Content="{x:Static p:Resources.LNG_List_Upload}"/> - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + From d746b508f68e656021d2d7f861f7ee9a75dd35fe Mon Sep 17 00:00:00 2001 From: Henry Timms <36480544+Hen676@users.noreply.github.com> Date: Sun, 18 Sep 2022 00:02:42 +0100 Subject: [PATCH 2/4] Removed paging elements + DataGrid update fixes --- .../ViewModels/ListViewModel.cs | 9 ++--- .../ViewModels/MainWindowViewModel.cs | 2 ++ FadedVanguardLogUploader/Views/ListView.axaml | 34 +++---------------- .../Views/ListView.axaml.cs | 12 ++++--- 4 files changed, 19 insertions(+), 38 deletions(-) diff --git a/FadedVanguardLogUploader/ViewModels/ListViewModel.cs b/FadedVanguardLogUploader/ViewModels/ListViewModel.cs index 3c49539..9a3cf2d 100644 --- a/FadedVanguardLogUploader/ViewModels/ListViewModel.cs +++ b/FadedVanguardLogUploader/ViewModels/ListViewModel.cs @@ -20,7 +20,7 @@ namespace FadedVanguardLogUploader.ViewModels { public class ListViewModel : ViewModelBase { - public List Items { get; set; } = new(); + public ObservableCollection Items { get; } = new(); public int FileCount { get => fileCount; @@ -102,7 +102,7 @@ private async void UploadAsync() if (file.UploadUrl == string.Empty) continue; - if (lastboss == Encounter.Empty || lastboss != file.Encounter) + if (lastboss == Encounter.Empty || lastboss != file.Encounter) { clipborad.Add($"{file.Encounter}"); lastboss = file.Encounter; @@ -126,9 +126,9 @@ public void UpdateFolder() if (App.Settings.Path == "") return; IEnumerable files = Directory.EnumerateFiles(App.Settings.Path, "*evtc*", SearchOption.AllDirectories) - .Where(s => + .Where(s => (s.ToLower().EndsWith(".evtc") || - s.ToLower().EndsWith(".evtc.zip") || + s.ToLower().EndsWith(".evtc.zip") || s.ToLower().EndsWith(".zevtc")) && !StoredItems.Any(val => s.Equals(val.FullPath))); if (!files.Any()) @@ -220,6 +220,7 @@ public void Sort() }); break; } + Items.Clear(); Items.AddRange(FilteredItems); } diff --git a/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs b/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs index 3023fbb..adbbe81 100644 --- a/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs +++ b/FadedVanguardLogUploader/ViewModels/MainWindowViewModel.cs @@ -140,6 +140,7 @@ private void NameSort() List.Filter(); } + // TODO: Force restart for change private void ChangeLanguage(string code) { Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(code); @@ -174,6 +175,7 @@ private void ErrorHidden() List.Filter(); } + // TODO: Force restart for change private void Mode() { ModeToggle = !ModeToggle; diff --git a/FadedVanguardLogUploader/Views/ListView.axaml b/FadedVanguardLogUploader/Views/ListView.axaml index aa5a0dc..d32b523 100644 --- a/FadedVanguardLogUploader/Views/ListView.axaml +++ b/FadedVanguardLogUploader/Views/ListView.axaml @@ -19,41 +19,14 @@ - - - - - - - - / - - - -