From ab20dcca7c0f90381e7c35a9ceb47fd6438f4e15 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Sat, 22 Apr 2023 14:12:12 +0800 Subject: [PATCH] Reorganize preview code --- Flow.Launcher/ViewModel/MainViewModel.cs | 100 ++++++++++++----------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 27809f67b..3ac7a1902 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -293,6 +293,8 @@ namespace Flow.Launcher.ViewModel } } + #region BasicCommands + [RelayCommand] private void OpenSetting() { @@ -356,6 +358,8 @@ namespace Flow.Launcher.ViewModel #endregion + #endregion + #region ViewModel Properties public Settings Settings { get; } @@ -444,52 +448,6 @@ namespace Flow.Launcher.ViewModel Settings.MaxResultsToShow -= 1; } - [RelayCommand] - public void TogglePreview() - { - if (!PreviewVisible) - { - ShowPreview(); - } - else - { - HidePreview(); - } - } - - private void ShowPreview() - { - ResultAreaColumn = 1; - PreviewVisible = true; - Results.SelectedItem?.LoadPreviewImage(); - } - - private void HidePreview() - { - ResultAreaColumn = 3; - PreviewVisible = false; - } - - public void ResetPreview() - { - if (Settings.AlwaysPreview == true) - { - ShowPreview(); - } - else - { - HidePreview(); - } - } - - private void UpdatePreview() - { - if (PreviewVisible) - { - Results.SelectedItem?.LoadPreviewImage(); - } - } - /// /// we need move cursor to end when we manually changed query /// but we don't want to move cursor to end when query is updated from TextBox @@ -610,6 +568,56 @@ namespace Flow.Launcher.ViewModel #endregion + #region Preview + + [RelayCommand] + public void TogglePreview() + { + if (!PreviewVisible) + { + ShowPreview(); + } + else + { + HidePreview(); + } + } + + private void ShowPreview() + { + ResultAreaColumn = 1; + PreviewVisible = true; + Results.SelectedItem?.LoadPreviewImage(); + } + + private void HidePreview() + { + ResultAreaColumn = 3; + PreviewVisible = false; + } + + public void ResetPreview() + { + if (Settings.AlwaysPreview == true) + { + ShowPreview(); + } + else + { + HidePreview(); + } + } + + private void UpdatePreview() + { + if (PreviewVisible) + { + Results.SelectedItem?.LoadPreviewImage(); + } + } + + #endregion + #region Query public void Query()