From 7c118a43c658cd1c487e00d56eab66a8888855b4 Mon Sep 17 00:00:00 2001 From: MountainFlash Date: Wed, 6 Oct 2021 21:24:43 +0530 Subject: [PATCH] go to last cursor location --- FModel/Framework/NavigationList.cs | 34 ++++++++++++++ FModel/ViewModels/CUE4ParseViewModel.cs | 1 + .../Resources/Controls/AvalonEditor.xaml | 6 +-- .../Resources/Controls/AvalonEditor.xaml.cs | 47 +++++++++++++++++-- 4 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 FModel/Framework/NavigationList.cs diff --git a/FModel/Framework/NavigationList.cs b/FModel/Framework/NavigationList.cs new file mode 100644 index 00000000..7e32beea --- /dev/null +++ b/FModel/Framework/NavigationList.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; + +namespace FModel.Framework +{ + public class NavigationList : List + { + private int _currentIndex = 0; + public int CurrentIndex + { + get + { + if (_currentIndex > Count - 1) { _currentIndex = Count - 1; } + if (_currentIndex < 0) { _currentIndex = 0; } + return _currentIndex; + } + set { _currentIndex = value; } + } + + public T MoveNext + { + get { _currentIndex++; return this[CurrentIndex]; } + } + + public T MovePrevious + { + get { _currentIndex--; return this[CurrentIndex]; } + } + + public T Current + { + get { return this[CurrentIndex]; } + } + } +} diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 877cabcc..3c95a135 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -357,6 +357,7 @@ namespace FModel.ViewModels await _threadWorkerView.Begin(cancellationToken => { var hotfixes = ApplicationService.ApiEndpointView.BenbotApi.GetHotfixes(cancellationToken, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage)); + if (hotfixes == null) return; foreach (var entries in hotfixes) { diff --git a/FModel/Views/Resources/Controls/AvalonEditor.xaml b/FModel/Views/Resources/Controls/AvalonEditor.xaml index f45de016..e1b45d20 100644 --- a/FModel/Views/Resources/Controls/AvalonEditor.xaml +++ b/FModel/Views/Resources/Controls/AvalonEditor.xaml @@ -17,7 +17,7 @@ - +