mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
commit
99fcdc166b
1 changed files with 39 additions and 25 deletions
|
|
@ -11,6 +11,7 @@ using Flow.Launcher.Core.Resource;
|
||||||
using Flow.Launcher.Helper;
|
using Flow.Launcher.Helper;
|
||||||
using Flow.Launcher.Infrastructure.UserSettings;
|
using Flow.Launcher.Infrastructure.UserSettings;
|
||||||
using Flow.Launcher.ViewModel;
|
using Flow.Launcher.ViewModel;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
using Screen = System.Windows.Forms.Screen;
|
using Screen = System.Windows.Forms.Screen;
|
||||||
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
||||||
|
|
@ -30,6 +31,7 @@ namespace Flow.Launcher
|
||||||
private bool isProgressBarStoryboardPaused;
|
private bool isProgressBarStoryboardPaused;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
private NotifyIcon _notifyIcon;
|
private NotifyIcon _notifyIcon;
|
||||||
|
private ContextMenu contextMenu;
|
||||||
private MainViewModel _viewModel;
|
private MainViewModel _viewModel;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -159,14 +161,10 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void UpdateNotifyIconText()
|
private void UpdateNotifyIconText()
|
||||||
{
|
{
|
||||||
var menu = _notifyIcon.ContextMenuStrip;
|
var menu = contextMenu;
|
||||||
var open = menu.Items[0];
|
((MenuItem)menu.Items[1]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen");
|
||||||
var setting = menu.Items[1];
|
((MenuItem)menu.Items[2]).Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
|
||||||
var exit = menu.Items[2];
|
((MenuItem)menu.Items[3]).Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
|
||||||
|
|
||||||
open.Text = InternationalizationManager.Instance.GetTranslation("iconTrayOpen");
|
|
||||||
setting.Text = InternationalizationManager.Instance.GetTranslation("iconTraySettings");
|
|
||||||
exit.Text = InternationalizationManager.Instance.GetTranslation("iconTrayExit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeNotifyIcon()
|
private void InitializeNotifyIcon()
|
||||||
|
|
@ -177,30 +175,46 @@ namespace Flow.Launcher
|
||||||
Icon = Properties.Resources.app,
|
Icon = Properties.Resources.app,
|
||||||
Visible = !_settings.HideNotifyIcon
|
Visible = !_settings.HideNotifyIcon
|
||||||
};
|
};
|
||||||
var menu = new ContextMenuStrip();
|
contextMenu = new ContextMenu();
|
||||||
var items = menu.Items;
|
|
||||||
|
var header = new MenuItem
|
||||||
|
{
|
||||||
|
Header = "Flow Launcher",
|
||||||
|
IsEnabled = false
|
||||||
|
};
|
||||||
|
var open = new MenuItem
|
||||||
|
{
|
||||||
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayOpen")
|
||||||
|
};
|
||||||
|
var settings = new MenuItem
|
||||||
|
{
|
||||||
|
Header = InternationalizationManager.Instance.GetTranslation("iconTraySettings")
|
||||||
|
};
|
||||||
|
var exit = new MenuItem
|
||||||
|
{
|
||||||
|
Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit")
|
||||||
|
};
|
||||||
|
|
||||||
var open = items.Add(InternationalizationManager.Instance.GetTranslation("iconTrayOpen"));
|
|
||||||
open.Click += (o, e) => Visibility = Visibility.Visible;
|
open.Click += (o, e) => Visibility = Visibility.Visible;
|
||||||
var setting = items.Add(InternationalizationManager.Instance.GetTranslation("iconTraySettings"));
|
settings.Click += (o, e) => App.API.OpenSettingDialog();
|
||||||
setting.Click += (o, e) => App.API.OpenSettingDialog();
|
|
||||||
var exit = items.Add(InternationalizationManager.Instance.GetTranslation("iconTrayExit"));
|
|
||||||
exit.Click += (o, e) => Close();
|
exit.Click += (o, e) => Close();
|
||||||
|
contextMenu.Items.Add(header);
|
||||||
|
contextMenu.Items.Add(open);
|
||||||
|
contextMenu.Items.Add(settings);
|
||||||
|
contextMenu.Items.Add(exit);
|
||||||
|
|
||||||
_notifyIcon.ContextMenuStrip = menu;
|
_notifyIcon.ContextMenuStrip = new ContextMenuStrip(); // it need for close the context menu. if not, context menu can't close.
|
||||||
_notifyIcon.MouseClick += (o, e) =>
|
_notifyIcon.MouseClick += (o, e) =>
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left)
|
switch (e.Button)
|
||||||
{
|
{
|
||||||
if (menu.Visible)
|
case MouseButtons.Left:
|
||||||
{
|
_viewModel.ToggleFlowLauncher();
|
||||||
menu.Close();
|
break;
|
||||||
}
|
|
||||||
else
|
case MouseButtons.Right:
|
||||||
{
|
contextMenu.IsOpen = true;
|
||||||
var p = System.Windows.Forms.Cursor.Position;
|
break;
|
||||||
menu.Show(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue