diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 10fc3583b..0720501ca 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -331,7 +331,6 @@ HorizontalAlignment="Center" VerticalAlignment="Bottom" StrokeThickness="2" - Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" X1="-100" X2="0" @@ -377,8 +376,8 @@ HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}" /> - + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index b8ae4bc85..f8c4d36cc 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -29,13 +29,14 @@ using System.Windows.Interop; using Windows.Win32; using Window = System.Windows.Window; using System.Linq; +using System.Windows.Shapes; namespace Flow.Launcher { public partial class MainWindow { #region Private Fields - + private readonly Storyboard _progressBarStoryboard = new Storyboard(); private bool isProgressBarStoryboardPaused; private readonly Settings _settings; @@ -65,7 +66,8 @@ namespace Flow.Launcher InitSoundEffects(); DataObject.AddPastingHandler(QueryTextBox, OnPaste); - this.Loaded += (_, _) => + + Loaded += (_, _) => { var handle = new WindowInteropHelper(this).Handle; var win = HwndSource.FromHwnd(handle); @@ -73,13 +75,6 @@ namespace Flow.Launcher }; } - DispatcherTimer timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false }; - - public MainWindow() - { - InitializeComponent(); - } - private int _initialWidth; private int _initialHeight; @@ -229,39 +224,9 @@ namespace Flow.Launcher _viewModel.LastQuerySelected = true; } - if (_viewModel.ProgressBarVisibility == Visibility.Visible && - isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Begin(ProgressBar, true); - isProgressBarStoryboardPaused = false; - } - if (_settings.UseAnimation) WindowAnimator(); } - else if (!isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Stop(ProgressBar); - isProgressBarStoryboardPaused = true; - } - }); - break; - } - case nameof(MainViewModel.ProgressBarVisibility): - { - Dispatcher.Invoke(() => - { - if (_viewModel.ProgressBarVisibility == Visibility.Hidden && !isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Stop(ProgressBar); - isProgressBarStoryboardPaused = true; - } - else if (_viewModel.MainWindowVisibilityStatus && - isProgressBarStoryboardPaused) - { - _progressBarStoryboard.Begin(ProgressBar, true); - isProgressBarStoryboardPaused = false; - } }); break; } @@ -381,7 +346,6 @@ namespace Flow.Launcher Icon = Constant.Version == "1.0.0" ? Properties.Resources.dev : Properties.Resources.app, Visible = !_settings.HideNotifyIcon }; - var openIcon = new FontIcon { Glyph = "\ue71e" }; var open = new MenuItem { @@ -392,7 +356,8 @@ namespace Flow.Launcher var gamemodeIcon = new FontIcon { Glyph = "\ue7fc" }; var gamemode = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("GameMode"), Icon = gamemodeIcon + Header = InternationalizationManager.Instance.GetTranslation("GameMode"), + Icon = gamemodeIcon }; var positionresetIcon = new FontIcon { Glyph = "\ue73f" }; var positionreset = new MenuItem @@ -409,7 +374,8 @@ namespace Flow.Launcher var exitIcon = new FontIcon { Glyph = "\ue7e8" }; var exit = new MenuItem { - Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), Icon = exitIcon + Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit"), + Icon = exitIcon }; open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); @@ -476,17 +442,49 @@ namespace Flow.Launcher private void InitProgressbarAnimation() { + var progressBarStoryBoard = new Storyboard(); + var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 0, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)")); Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)")); - _progressBarStoryboard.Children.Add(da); - _progressBarStoryboard.Children.Add(da1); - _progressBarStoryboard.RepeatBehavior = RepeatBehavior.Forever; + progressBarStoryBoard.Children.Add(da); + progressBarStoryBoard.Children.Add(da1); + progressBarStoryBoard.RepeatBehavior = RepeatBehavior.Forever; + + da.Freeze(); + da1.Freeze(); + + const string progressBarAnimationName = "ProgressBarAnimation"; + var beginStoryboard = new BeginStoryboard + { + Name = progressBarAnimationName, Storyboard = progressBarStoryBoard + }; + + var stopStoryboard = new StopStoryboard() + { + BeginStoryboardName = progressBarAnimationName + }; + + var trigger = new Trigger + { + Property = VisibilityProperty, Value = Visibility.Visible + }; + trigger.EnterActions.Add(beginStoryboard); + trigger.ExitActions.Add(stopStoryboard); + + var progressStyle = new Style(typeof(Line)) + { + BasedOn = FindResource("PendingLineStyle") as Style + }; + progressStyle.RegisterName(progressBarAnimationName, beginStoryboard); + progressStyle.Triggers.Add(trigger); + + ProgressBar.Style = progressStyle; + _viewModel.ProgressBarVisibility = Visibility.Hidden; - isProgressBarStoryboardPaused = true; } public void ResetAnimation() diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Command.cs b/Plugins/Flow.Launcher.Plugin.Sys/Command.cs new file mode 100644 index 000000000..6c3a99f3e --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Sys/Command.cs @@ -0,0 +1,44 @@ +using System.Text.Json.Serialization; + +namespace Flow.Launcher.Plugin.Sys +{ + public class Command : BaseModel + { + public string Key { get; set; } + + private string name; + [JsonIgnore] + public string Name + { + get => name; + set + { + name = value; + OnPropertyChanged(); + } + } + + private string description; + [JsonIgnore] + public string Description + { + get => description; + set + { + description = value; + OnPropertyChanged(); + } + } + + private string keyword; + public string Keyword + { + get => keyword; + set + { + keyword = value; + OnPropertyChanged(); + } + } + } +} diff --git a/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml new file mode 100644 index 000000000..a848f2f1f --- /dev/null +++ b/Plugins/Flow.Launcher.Plugin.Sys/CommandKeywordSetting.xaml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +