From 6414fe8cf8a7d6b869b996db8ba3490309b91f28 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Mon, 23 Mar 2020 12:13:13 -0700 Subject: [PATCH 1/3] Removed notify icon component --- src/modules/launcher/Wox/MainWindow.xaml.cs | 47 --------------------- 1 file changed, 47 deletions(-) diff --git a/src/modules/launcher/Wox/MainWindow.xaml.cs b/src/modules/launcher/Wox/MainWindow.xaml.cs index 427f641a4e..f7934bab86 100644 --- a/src/modules/launcher/Wox/MainWindow.xaml.cs +++ b/src/modules/launcher/Wox/MainWindow.xaml.cs @@ -27,7 +27,6 @@ namespace Wox private readonly Storyboard _progressBarStoryboard = new Storyboard(); private Settings _settings; - private NotifyIcon _notifyIcon; private MainViewModel _viewModel; #endregion @@ -46,14 +45,11 @@ namespace Wox private void OnClosing(object sender, CancelEventArgs e) { - _notifyIcon.Visible = false; _viewModel.Save(); } private void OnInitialized(object sender, EventArgs e) { - // show notify icon when wox is hided - InitializeNotifyIcon(); } private void OnLoaded(object sender, RoutedEventArgs _) @@ -85,13 +81,6 @@ namespace Wox } } }; - _settings.PropertyChanged += (o, e) => - { - if (e.PropertyName == nameof(Settings.HideNotifyIcon)) - { - _notifyIcon.Visible = !_settings.HideNotifyIcon; - } - }; InitializePosition(); } @@ -103,42 +92,6 @@ namespace Wox _settings.WindowLeft = Left; } - private void InitializeNotifyIcon() - { - _notifyIcon = new NotifyIcon - { - Text = Infrastructure.Constant.Wox, - Icon = Properties.Resources.app, - Visible = !_settings.HideNotifyIcon - }; - var menu = new ContextMenuStrip(); - var items = menu.Items; - - var open = items.Add(InternationalizationManager.Instance.GetTranslation("iconTrayOpen")); - open.Click += (o, e) => Visibility = Visibility.Visible; - var setting = items.Add(InternationalizationManager.Instance.GetTranslation("iconTraySettings")); - setting.Click += (o, e) => App.API.OpenSettingDialog(); - var exit = items.Add(InternationalizationManager.Instance.GetTranslation("iconTrayExit")); - exit.Click += (o, e) => Close(); - - _notifyIcon.ContextMenuStrip = menu; - _notifyIcon.MouseClick += (o, e) => - { - if (e.Button == MouseButtons.Left) - { - if (menu.Visible) - { - menu.Close(); - } - else - { - var p = System.Windows.Forms.Cursor.Position; - menu.Show(p); - } - } - }; - } - private void InitProgressbarAnimation() { var da = new DoubleAnimation(ProgressBar.X2, ActualWidth + 100, new Duration(new TimeSpan(0, 0, 0, 0, 1600))); From 7c174b9c05671afc1a5638d17385acc8b87c19d0 Mon Sep 17 00:00:00 2001 From: Divyansh Date: Mon, 23 Mar 2020 14:37:43 -0700 Subject: [PATCH 2/3] Removed setting UI XAML file and references --- src/modules/launcher/Wox.Plugin/IPublicAPI.cs | 5 - src/modules/launcher/Wox/App.xaml.cs | 7 - .../Wox/CustomQueryHotkeySetting.xaml | 39 -- .../Wox/CustomQueryHotkeySetting.xaml.cs | 129 ------ src/modules/launcher/Wox/MainWindow.xaml.cs | 10 - src/modules/launcher/Wox/PublicAPIInstance.cs | 8 - src/modules/launcher/Wox/SettingWindow.xaml | 402 ------------------ .../launcher/Wox/SettingWindow.xaml.cs | 293 ------------- src/modules/launcher/Wox/Wox.csproj | 14 - 9 files changed, 907 deletions(-) delete mode 100644 src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml delete mode 100644 src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml.cs delete mode 100644 src/modules/launcher/Wox/SettingWindow.xaml delete mode 100644 src/modules/launcher/Wox/SettingWindow.xaml.cs diff --git a/src/modules/launcher/Wox.Plugin/IPublicAPI.cs b/src/modules/launcher/Wox.Plugin/IPublicAPI.cs index 754b76d36b..72e400e26e 100644 --- a/src/modules/launcher/Wox.Plugin/IPublicAPI.cs +++ b/src/modules/launcher/Wox.Plugin/IPublicAPI.cs @@ -83,11 +83,6 @@ namespace Wox.Plugin /// Message icon path (relative path to your plugin folder) void ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true); - /// - /// Open setting dialog - /// - void OpenSettingDialog(); - /// /// Show loading animation /// diff --git a/src/modules/launcher/Wox/App.xaml.cs b/src/modules/launcher/Wox/App.xaml.cs index 0fc1e8c95e..f6dcc8ee2f 100644 --- a/src/modules/launcher/Wox/App.xaml.cs +++ b/src/modules/launcher/Wox/App.xaml.cs @@ -94,13 +94,6 @@ namespace Wox private void AutoStartup() { - if (_settings.StartWoxOnSystemStartup) - { - if (!SettingWindow.StartupSet()) - { - SettingWindow.SetStartup(); - } - } } //[Conditional("RELEASE")] diff --git a/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml b/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml deleted file mode 100644 index a4e3d77f69..0000000000 --- a/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml.cs b/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml.cs deleted file mode 100644 index f5ce9cabf3..0000000000 --- a/src/modules/launcher/Wox/CustomQueryHotkeySetting.xaml.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Windows; -using NHotkey; -using NHotkey.Wpf; -using Wox.Core.Resource; -using Wox.Infrastructure.Hotkey; -using Wox.Infrastructure.UserSettings; - -namespace Wox -{ - public partial class CustomQueryHotkeySetting : Window - { - private SettingWindow _settingWidow; - private bool update; - private CustomPluginHotkey updateCustomHotkey; - private Settings _settings; - - public CustomQueryHotkeySetting(SettingWindow settingWidow, Settings settings) - { - _settingWidow = settingWidow; - InitializeComponent(); - _settings = settings; - } - - private void BtnCancel_OnClick(object sender, RoutedEventArgs e) - { - Close(); - } - - private void btnAdd_OnClick(object sender, RoutedEventArgs e) - { - if (!update) - { - if (!ctlHotkey.CurrentHotkeyAvailable) - { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable")); - return; - } - - if (_settings.CustomPluginHotkeys == null) - { - _settings.CustomPluginHotkeys = new ObservableCollection(); - } - - var pluginHotkey = new CustomPluginHotkey - { - Hotkey = ctlHotkey.CurrentHotkey.ToString(), - ActionKeyword = tbAction.Text - }; - _settings.CustomPluginHotkeys.Add(pluginHotkey); - - SetHotkey(ctlHotkey.CurrentHotkey, delegate - { - App.API.ChangeQuery(pluginHotkey.ActionKeyword); - Application.Current.MainWindow.Visibility = Visibility.Visible; - }); - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success")); - } - else - { - if (updateCustomHotkey.Hotkey != ctlHotkey.CurrentHotkey.ToString() && !ctlHotkey.CurrentHotkeyAvailable) - { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("hotkeyIsNotUnavailable")); - return; - } - var oldHotkey = updateCustomHotkey.Hotkey; - updateCustomHotkey.ActionKeyword = tbAction.Text; - updateCustomHotkey.Hotkey = ctlHotkey.CurrentHotkey.ToString(); - //remove origin hotkey - RemoveHotkey(oldHotkey); - SetHotkey(new HotkeyModel(updateCustomHotkey.Hotkey), delegate - { - App.API.ChangeQuery(updateCustomHotkey.ActionKeyword); - Application.Current.MainWindow.Visibility = Visibility.Visible; - }); - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("success")); - } - - Close(); - } - - public void UpdateItem(CustomPluginHotkey item) - { - updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); - if (updateCustomHotkey == null) - { - MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey")); - Close(); - return; - } - - tbAction.Text = updateCustomHotkey.ActionKeyword; - ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false); - update = true; - lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update"); - } - - private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e) - { - App.API.ChangeQuery(tbAction.Text); - Application.Current.MainWindow.Visibility = Visibility.Visible; - } - - private void RemoveHotkey(string hotkeyStr) - { - if (!string.IsNullOrEmpty(hotkeyStr)) - { - HotkeyManager.Current.Remove(hotkeyStr); - } - } - - private void SetHotkey(HotkeyModel hotkey, EventHandler action) - { - string hotkeyStr = hotkey.ToString(); - try - { - HotkeyManager.Current.AddOrReplace(hotkeyStr, hotkey.CharKey, hotkey.ModifierKeys, action); - } - catch (Exception) - { - string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); - MessageBox.Show(errorMsg); - } - } - } -} diff --git a/src/modules/launcher/Wox/MainWindow.xaml.cs b/src/modules/launcher/Wox/MainWindow.xaml.cs index f7934bab86..d9be3c161f 100644 --- a/src/modules/launcher/Wox/MainWindow.xaml.cs +++ b/src/modules/launcher/Wox/MainWindow.xaml.cs @@ -16,7 +16,6 @@ using DataFormats = System.Windows.DataFormats; using DragEventArgs = System.Windows.DragEventArgs; using KeyEventArgs = System.Windows.Input.KeyEventArgs; using MessageBox = System.Windows.MessageBox; -using NotifyIcon = System.Windows.Forms.NotifyIcon; namespace Wox { @@ -48,10 +47,6 @@ namespace Wox _viewModel.Save(); } - private void OnInitialized(object sender, EventArgs e) - { - } - private void OnLoaded(object sender, RoutedEventArgs _) { // todo is there a way to set blur only once? @@ -156,11 +151,6 @@ namespace Wox e.Handled = true; } - private void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e) - { - App.API.OpenSettingDialog(); - } - private void OnDeactivated(object sender, EventArgs e) { diff --git a/src/modules/launcher/Wox/PublicAPIInstance.cs b/src/modules/launcher/Wox/PublicAPIInstance.cs index 58915f87b2..21057a78e9 100644 --- a/src/modules/launcher/Wox/PublicAPIInstance.cs +++ b/src/modules/launcher/Wox/PublicAPIInstance.cs @@ -106,14 +106,6 @@ namespace Wox }); } - public void OpenSettingDialog() - { - Application.Current.Dispatcher.Invoke(() => - { - SettingWindow sw = SingletonWindowOpener.Open(this, _settingsVM); - }); - } - public void StartLoadingBar() { _mainVM.ProgressBarVisibility = Visibility.Visible; diff --git a/src/modules/launcher/Wox/SettingWindow.xaml b/src/modules/launcher/Wox/SettingWindow.xaml deleted file mode 100644 index 1eddd8ab6a..0000000000 --- a/src/modules/launcher/Wox/SettingWindow.xaml +++ /dev/null @@ -1,402 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -