From d77400d39bbe1dbc7ae476326dfce66e3748f93f Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 1 Apr 2025 05:36:24 +0900 Subject: [PATCH] Add customcontrol for searchdelay --- .../Controls/InstalledPluginDisplay.xaml | 5 +- .../InstalledPluginSearchDelayCombobox.xaml | 39 +++++++++ ...InstalledPluginSearchDelayCombobox.xaml.cs | 84 +++++++++++++++++++ 3 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml create mode 100644 Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml.cs diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml b/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml index 009644fd6..cb1d8dbc4 100644 --- a/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml +++ b/Flow.Launcher/Resources/Controls/InstalledPluginDisplay.xaml @@ -92,7 +92,7 @@ - - diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml new file mode 100644 index 000000000..b379b875f --- /dev/null +++ b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml @@ -0,0 +1,39 @@ + + + + + + + + \ No newline at end of file diff --git a/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml.cs b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml.cs new file mode 100644 index 000000000..649913872 --- /dev/null +++ b/Flow.Launcher/Resources/Controls/InstalledPluginSearchDelayCombobox.xaml.cs @@ -0,0 +1,84 @@ +using System.Collections.Generic; +using System.Windows.Controls; +using Flow.Launcher.Plugin; + +namespace Flow.Launcher.Resources.Controls +{ + public partial class InstalledPluginSearchDelayCombobox + { + public InstalledPluginSearchDelayCombobox() + { + InitializeComponent(); + LoadDelayOptions(); + Loaded += InstalledPluginSearchDelayCombobox_Loaded; + } + + private void InstalledPluginSearchDelayCombobox_Loaded(object sender, System.Windows.RoutedEventArgs e) + { + if (DataContext is ViewModel.PluginViewModel viewModel) + { + // 초기 값 설정 + int currentDelayMs = GetCurrentDelayMs(viewModel); + foreach (DelayOption option in cbDelay.Items) + { + if (option.Value == currentDelayMs) + { + cbDelay.SelectedItem = option; + break; + } + } + } + } + + private int GetCurrentDelayMs(ViewModel.PluginViewModel viewModel) + { + // SearchDelayTime enum 값을 int로 변환 + SearchDelayTime? delayTime = viewModel.PluginPair.Metadata.SearchDelayTime; + if (delayTime.HasValue) + { + return (int)delayTime.Value; + } + return 0; // 기본값 + } + + private void LoadDelayOptions() + { + // 검색 지연 시간 옵션들 (SearchDelayTime enum 값에 맞춰야 함) + var delayOptions = new List + { + new DelayOption { Display = "0 ms", Value = 0 }, + new DelayOption { Display = "50 ms", Value = 50 }, + new DelayOption { Display = "100 ms", Value = 100 }, + new DelayOption { Display = "150 ms", Value = 150 }, + new DelayOption { Display = "200 ms", Value = 200 }, + new DelayOption { Display = "250 ms", Value = 250 }, + new DelayOption { Display = "300 ms", Value = 300 }, + new DelayOption { Display = "350 ms", Value = 350 }, + new DelayOption { Display = "400 ms", Value = 400 }, + new DelayOption { Display = "450 ms", Value = 450 }, + new DelayOption { Display = "500 ms", Value = 500 }, + }; + + cbDelay.ItemsSource = delayOptions; + } + + private void CbDelay_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (DataContext is ViewModel.PluginViewModel viewModel && cbDelay.SelectedItem is DelayOption selectedOption) + { + // int 값을 SearchDelayTime enum으로 변환 + int delayValue = selectedOption.Value; + viewModel.PluginPair.Metadata.SearchDelayTime = (SearchDelayTime)delayValue; + + // 설정 저장 + //How to save? + } + } + } + + public class DelayOption + { + public string Display { get; set; } + public int Value { get; set; } + } +}