mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-10-03 10:36:30 +13:00
Reduce event dependencies during startup (preloading)
Remove obsolete code
This commit is contained in:
parent
74d5be3890
commit
3464e3e4b9
8 changed files with 36 additions and 216 deletions
|
@ -28,14 +28,17 @@ namespace SystemTrayMenu
|
||||||
menus.LoadStarted += menuNotifyIcon.LoadingStart;
|
menus.LoadStarted += menuNotifyIcon.LoadingStart;
|
||||||
menus.LoadStopped += menuNotifyIcon.LoadingStop;
|
menus.LoadStopped += menuNotifyIcon.LoadingStop;
|
||||||
menuNotifyIcon.Click += () => menus.SwitchOpenClose(true);
|
menuNotifyIcon.Click += () => menus.SwitchOpenClose(true);
|
||||||
menus.MainPreload();
|
|
||||||
|
|
||||||
if (Settings.Default.ShowInTaskbar)
|
if (Settings.Default.ShowInTaskbar)
|
||||||
{
|
{
|
||||||
TaskbarLogo = new TaskbarLogo();
|
TaskbarLogo = new ();
|
||||||
TaskbarLogo.Activated += (_, _) => menus.SwitchOpenCloseByTaskbarItem();
|
TaskbarLogo.Activated += (_, _) => menus.SwitchOpenCloseByTaskbarItem();
|
||||||
TaskbarLogo.Show();
|
TaskbarLogo.Show();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menus.FirstStartInBackground();
|
||||||
|
}
|
||||||
|
|
||||||
if (Settings.Default.CheckForUpdates)
|
if (Settings.Default.CheckForUpdates)
|
||||||
{
|
{
|
||||||
|
|
|
@ -331,13 +331,6 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
ClosePressed?.Invoke();
|
ClosePressed?.Invoke();
|
||||||
}
|
}
|
||||||
#if TODO // WPF: Can be removed as we do not paint ourselfs?
|
|
||||||
if (iRowKey > -1 && dgv.Rows.Count > iRowKey)
|
|
||||||
{
|
|
||||||
// Raise Dgv_RowPostPaint to show ProcessStarted
|
|
||||||
dgv.InvalidateRow(iRowKey);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,11 +45,6 @@ namespace SystemTrayMenu.Business
|
||||||
private bool searchTextChanging;
|
private bool searchTextChanging;
|
||||||
private int lastMouseDownRowIndex = -1;
|
private int lastMouseDownRowIndex = -1;
|
||||||
private bool showMenuAfterMainPreload;
|
private bool showMenuAfterMainPreload;
|
||||||
#if TODO // TOUCH
|
|
||||||
private int dragSwipeScrollingStartRowIndex = -1;
|
|
||||||
private bool isDraggingSwipeScrolling;
|
|
||||||
#endif
|
|
||||||
private bool isDragSwipeScrolled;
|
|
||||||
private bool hideSubmenuDuringRefreshSearch;
|
private bool hideSubmenuDuringRefreshSearch;
|
||||||
|
|
||||||
public Menus()
|
public Menus()
|
||||||
|
@ -107,12 +102,13 @@ namespace SystemTrayMenu.Business
|
||||||
switch (menuData.DirectoryState)
|
switch (menuData.DirectoryState)
|
||||||
{
|
{
|
||||||
case MenuDataDirectoryState.Valid:
|
case MenuDataDirectoryState.Valid:
|
||||||
if (IconReader.MainPreload)
|
if (IconReader.IsPreloading)
|
||||||
{
|
{
|
||||||
workerMainMenu.DoWork -= LoadMenu;
|
workerMainMenu.DoWork -= LoadMenu;
|
||||||
|
workerMainMenu.CancelAsync();
|
||||||
Create(menuData, Config.Path); // Level 0 Main Menu
|
Create(menuData, Config.Path); // Level 0 Main Menu
|
||||||
|
|
||||||
IconReader.MainPreload = false;
|
IconReader.IsPreloading = false;
|
||||||
if (showMenuAfterMainPreload)
|
if (showMenuAfterMainPreload)
|
||||||
{
|
{
|
||||||
AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); });
|
AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); });
|
||||||
|
@ -258,7 +254,6 @@ namespace SystemTrayMenu.Business
|
||||||
joystickHelper = new();
|
joystickHelper = new();
|
||||||
joystickHelper.KeyPressed += (key, modifiers) => menus[0]?.Dispatcher.Invoke(keyboardInput.CmdKeyProcessed, new object[] { null!, key, modifiers });
|
joystickHelper.KeyPressed += (key, modifiers) => menus[0]?.Dispatcher.Invoke(keyboardInput.CmdKeyProcessed, new object[] { null!, key, modifiers });
|
||||||
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(Settings.Default.TimeUntilClosesAfterEnterPressed);
|
|
||||||
timerStillActiveCheck.Interval = TimeSpan.FromMilliseconds(Settings.Default.TimeUntilClosesAfterEnterPressed + 20);
|
timerStillActiveCheck.Interval = TimeSpan.FromMilliseconds(Settings.Default.TimeUntilClosesAfterEnterPressed + 20);
|
||||||
timerStillActiveCheck.Tick += (sender, e) => StillActiveTick();
|
timerStillActiveCheck.Tick += (sender, e) => StillActiveTick();
|
||||||
void StillActiveTick()
|
void StillActiveTick()
|
||||||
|
@ -327,7 +322,7 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
private bool IsMainUsable => menus[0]?.IsUsable ?? false;
|
private bool IsMainUsable => menus[0]?.IsUsable ?? false;
|
||||||
|
|
||||||
private IEnumerable<Menu> AsEnumerable => menus.Where(m => m != null && !m.IsDisposed)!;
|
private IEnumerable<Menu> AsEnumerable => menus.Where(m => m != null && !m.IsClosed)!;
|
||||||
|
|
||||||
private List<Menu> AsList => AsEnumerable.ToList();
|
private List<Menu> AsList => AsEnumerable.ToList();
|
||||||
|
|
||||||
|
@ -372,20 +367,23 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
internal void SwitchOpenCloseByTaskbarItem()
|
internal void SwitchOpenCloseByTaskbarItem()
|
||||||
{
|
{
|
||||||
SwitchOpenClose(true);
|
// User started with taskbar or clicked on taskbar: remember to open menu after preload has finished
|
||||||
|
showMenuAfterMainPreload = true;
|
||||||
|
SwitchOpenClose(true, true);
|
||||||
timerStillActiveCheck.Start();
|
timerStillActiveCheck.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsOpenCloseStateOpening()
|
internal void FirstStartInBackground()
|
||||||
{
|
{
|
||||||
return openCloseState == OpenCloseState.Opening;
|
dispatchter.Invoke(() => SwitchOpenClose(false, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SwitchOpenClose(bool byClick, bool isMainPreload = false)
|
internal void SwitchOpenClose(bool byClick, bool allowPreloading = false)
|
||||||
{
|
{
|
||||||
// Ignore open close events during main preload #248
|
// Ignore open close events during main preload #248
|
||||||
if (IconReader.MainPreload && !isMainPreload)
|
if (IconReader.IsPreloading && !allowPreloading)
|
||||||
{
|
{
|
||||||
|
// User pressed hotkey or clicked on notifyicon: remember to open menu after preload has finished
|
||||||
showMenuAfterMainPreload = true;
|
showMenuAfterMainPreload = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -426,21 +424,6 @@ namespace SystemTrayMenu.Business
|
||||||
deactivatedTime = DateTime.MinValue;
|
deactivatedTime = DateTime.MinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MainPreload()
|
|
||||||
{
|
|
||||||
IconReader.MainPreload = true;
|
|
||||||
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Tick += Tick;
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(5);
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Start();
|
|
||||||
void Tick(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Tick -= Tick;
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(Settings.Default.TimeUntilClosesAfterEnterPressed);
|
|
||||||
SwitchOpenClose(false, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void StartWorker()
|
internal void StartWorker()
|
||||||
{
|
{
|
||||||
if (Settings.Default.GenerateShortcutsToDrives)
|
if (Settings.Default.GenerateShortcutsToDrives)
|
||||||
|
@ -451,8 +434,7 @@ namespace SystemTrayMenu.Business
|
||||||
if (!workerMainMenu.IsBusy)
|
if (!workerMainMenu.IsBusy)
|
||||||
{
|
{
|
||||||
LoadStarted?.Invoke();
|
LoadStarted?.Invoke();
|
||||||
workerMainMenu.RunWorkerAsync(
|
workerMainMenu.RunWorkerAsync(null);
|
||||||
new object[] { Config.Path, 0 });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,16 +471,6 @@ namespace SystemTrayMenu.Business
|
||||||
eDoWork.Result = menuData;
|
eDoWork.Result = menuData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetRowUnderCursor(ListView dgv, Point location)
|
|
||||||
{
|
|
||||||
#if TODO // TOUCH
|
|
||||||
ListView.HitTestInfo myHitTest = dgv.HitTest(location.X, location.Y);
|
|
||||||
return myHitTest.RowIndex;
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsActive()
|
private bool IsActive()
|
||||||
{
|
{
|
||||||
bool IsShellContextMenuOpen()
|
bool IsShellContextMenuOpen()
|
||||||
|
@ -543,9 +515,7 @@ namespace SystemTrayMenu.Business
|
||||||
};
|
};
|
||||||
menu.MouseEnter += (_, _) => waitLeave.Stop();
|
menu.MouseEnter += (_, _) => waitLeave.Stop();
|
||||||
menu.CmdKeyProcessed += keyboardInput.CmdKeyProcessed;
|
menu.CmdKeyProcessed += keyboardInput.CmdKeyProcessed;
|
||||||
#if TODO // Misc MouseEvents and TOUCH
|
|
||||||
menu.KeyPressCheck += Menu_KeyPressCheck;
|
|
||||||
#endif
|
|
||||||
menu.SearchTextChanging += Menu_SearchTextChanging;
|
menu.SearchTextChanging += Menu_SearchTextChanging;
|
||||||
void Menu_SearchTextChanging()
|
void Menu_SearchTextChanging()
|
||||||
{
|
{
|
||||||
|
@ -585,7 +555,7 @@ namespace SystemTrayMenu.Business
|
||||||
menu.Deactivated += Deactivate;
|
menu.Deactivated += Deactivate;
|
||||||
void Deactivate(object? sender, EventArgs e)
|
void Deactivate(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (IsOpenCloseStateOpening())
|
if (openCloseState == OpenCloseState.Opening)
|
||||||
{
|
{
|
||||||
Log.Info("Ignored Deactivate, because openCloseState == OpenCloseState.Opening");
|
Log.Info("Ignored Deactivate, because openCloseState == OpenCloseState.Opening");
|
||||||
}
|
}
|
||||||
|
@ -625,11 +595,7 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
#if TODO // Misc MouseEvents
|
#if TODO // Misc MouseEvents
|
||||||
dgv.MouseLeave += dgvMouseRow.MouseLeave;
|
dgv.MouseLeave += dgvMouseRow.MouseLeave;
|
||||||
dgv.MouseLeave += Dgv_MouseLeave;
|
|
||||||
dgv.MouseMove += waitToOpenMenu.MouseMove;
|
dgv.MouseMove += waitToOpenMenu.MouseMove;
|
||||||
#endif
|
|
||||||
#if TODO // TOUCH
|
|
||||||
dgv.MouseMove += Dgv_MouseMove;
|
|
||||||
#endif
|
#endif
|
||||||
dgv.SelectionChanged += Dgv_SelectionChanged;
|
dgv.SelectionChanged += Dgv_SelectionChanged;
|
||||||
#if TODO // BorderColors and PaintEvent
|
#if TODO // BorderColors and PaintEvent
|
||||||
|
@ -685,53 +651,6 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TODO // TOUCH
|
|
||||||
private void Dgv_MouseMove(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (isDraggingSwipeScrolling)
|
|
||||||
{
|
|
||||||
ListView dgv = (ListView)sender;
|
|
||||||
int newRow = GetRowUnderCursor(dgv, e.Location);
|
|
||||||
if (newRow > -1)
|
|
||||||
{
|
|
||||||
int delta = dragSwipeScrollingStartRowIndex - newRow;
|
|
||||||
if (DoScroll(dgv, ref delta))
|
|
||||||
{
|
|
||||||
dragSwipeScrollingStartRowIndex += delta;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool DoScroll(ListView dgv, ref int delta)
|
|
||||||
{
|
|
||||||
bool scrolled = false;
|
|
||||||
if (delta != 0)
|
|
||||||
{
|
|
||||||
if (delta < 0 && dgv.FirstDisplayedScrollingRowIndex == 0)
|
|
||||||
{
|
|
||||||
delta = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newFirstDisplayedScrollingRowIndex = dgv.FirstDisplayedScrollingRowIndex + (delta * 2);
|
|
||||||
|
|
||||||
if (newFirstDisplayedScrollingRowIndex < 0 || newFirstDisplayedScrollingRowIndex >= dgv.RowCount)
|
|
||||||
{
|
|
||||||
newFirstDisplayedScrollingRowIndex = dgv.FirstDisplayedScrollingRowIndex + delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newFirstDisplayedScrollingRowIndex > -1 && newFirstDisplayedScrollingRowIndex < dgv.RowCount)
|
|
||||||
{
|
|
||||||
isDragSwipeScrolled = true;
|
|
||||||
dgv.FirstDisplayedScrollingRowIndex = newFirstDisplayedScrollingRowIndex;
|
|
||||||
scrolled = dgv.FirstDisplayedScrollingRowIndex == newFirstDisplayedScrollingRowIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return scrolled;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private void Dgv_MouseDown(object sender, int index, MouseButtonEventArgs e)
|
private void Dgv_MouseDown(object sender, int index, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
ListView dgv = (ListView)sender;
|
ListView dgv = (ListView)sender;
|
||||||
|
@ -745,37 +664,11 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
lastMouseDownRowIndex = index;
|
lastMouseDownRowIndex = index;
|
||||||
}
|
}
|
||||||
#if TODO // TOUCH
|
|
||||||
Menu menu = (Menu)((ListView)sender).GetParentWindow();
|
|
||||||
if (menu != null && menu.ScrollbarVisible)
|
|
||||||
{
|
|
||||||
bool isTouchEnabled = DllImports.NativeMethods.IsTouchEnabled();
|
|
||||||
if ((isTouchEnabled && Settings.Default.SwipeScrollingEnabledTouch) ||
|
|
||||||
(!isTouchEnabled && Settings.Default.SwipeScrollingEnabled))
|
|
||||||
{
|
|
||||||
isDraggingSwipeScrolling = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
dragSwipeScrollingStartRowIndex = GetRowUnderCursor(dgv, e.Location);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dgv_MouseUp(object sender, int index, MouseButtonEventArgs e)
|
private void Dgv_MouseUp(object sender, int index, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
lastMouseDownRowIndex = -1;
|
lastMouseDownRowIndex = -1;
|
||||||
#if TODO // TOUCH
|
|
||||||
isDraggingSwipeScrolling = false;
|
|
||||||
#endif
|
|
||||||
isDragSwipeScrolled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dgv_MouseLeave(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
#if TODO // TOUCH
|
|
||||||
isDraggingSwipeScrolling = false;
|
|
||||||
#endif
|
|
||||||
isDragSwipeScrolled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MouseEnterOk(ListView dgv, int rowIndex)
|
private void MouseEnterOk(ListView dgv, int rowIndex)
|
||||||
|
@ -801,8 +694,7 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
ListView dgv = (ListView)sender;
|
ListView dgv = (ListView)sender;
|
||||||
|
|
||||||
if (!isDragSwipeScrolled &&
|
if (e.RowIndex == lastMouseDownRowIndex &&
|
||||||
e.RowIndex == lastMouseDownRowIndex &&
|
|
||||||
e.RowIndex > -1 &&
|
e.RowIndex > -1 &&
|
||||||
e.RowIndex < dgv.Items.Count)
|
e.RowIndex < dgv.Items.Count)
|
||||||
{
|
{
|
||||||
|
@ -825,14 +717,11 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
if (e.ClickCount == 1)
|
if (e.ClickCount == 1)
|
||||||
{
|
{
|
||||||
if (!isDragSwipeScrolled)
|
lastMouseDownRowIndex = -1;
|
||||||
{
|
|
||||||
lastMouseDownRowIndex = -1;
|
|
||||||
|
|
||||||
((Menu.ListViewItemData)sender.Items[index]).data.MouseClick(e, out doClose);
|
((Menu.ListViewItemData)sender.Items[index]).data.MouseClick(e, out doClose);
|
||||||
|
|
||||||
waitToOpenMenu.ClickOpensInstantly(sender, index);
|
waitToOpenMenu.ClickOpensInstantly(sender, index);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (e.ClickCount == 2)
|
else if (e.ClickCount == 2)
|
||||||
{
|
{
|
||||||
|
@ -945,6 +834,8 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
rowData.ProcessStarted = false;
|
rowData.ProcessStarted = false;
|
||||||
row.Cells[0].Value = Resources.StaticResources.LoadingIcon;
|
row.Cells[0].Value = Resources.StaticResources.LoadingIcon;
|
||||||
|
timerShowProcessStartedAsLoadingIcon.Stop();
|
||||||
|
timerShowProcessStartedAsLoadingIcon.Interval = TimeSpan.FromMilliseconds(Settings.Default.TimeUntilClosesAfterEnterPressed);
|
||||||
timerShowProcessStartedAsLoadingIcon.Tick += Tick;
|
timerShowProcessStartedAsLoadingIcon.Tick += Tick;
|
||||||
void Tick(object sender, EventArgs e)
|
void Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -952,8 +843,6 @@ namespace SystemTrayMenu.Business
|
||||||
timerShowProcessStartedAsLoadingIcon.Stop();
|
timerShowProcessStartedAsLoadingIcon.Stop();
|
||||||
row.Cells[0].Value = rowData.ReadIcon(false);
|
row.Cells[0].Value = rowData.ReadIcon(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Stop();
|
|
||||||
timerShowProcessStartedAsLoadingIcon.Start();
|
timerShowProcessStartedAsLoadingIcon.Start();
|
||||||
timerStillActiveCheck.Stop();
|
timerStillActiveCheck.Stop();
|
||||||
timerStillActiveCheck.Start();
|
timerStillActiveCheck.Start();
|
||||||
|
@ -1157,16 +1046,6 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TODO // Misc MouseEvents and TOUCH
|
|
||||||
private void Menu_KeyPressCheck(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
if (isDraggingSwipeScrolling)
|
|
||||||
{
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private void ExecuteWatcherHistory()
|
private void ExecuteWatcherHistory()
|
||||||
{
|
{
|
||||||
foreach (var fileSystemEventArgs in watcherHistory)
|
foreach (var fileSystemEventArgs in watcherHistory)
|
||||||
|
|
|
@ -45,10 +45,6 @@ namespace SystemTrayMenu.Handler
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
timerStartLoad.Stop();
|
timerStartLoad.Stop();
|
||||||
#if TODO // WPF: Can be optimized away?
|
|
||||||
dgv?.Dispose();
|
|
||||||
dgvTmp?.Dispose();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MouseEnter(object sender, int rowIndex)
|
internal void MouseEnter(object sender, int rowIndex)
|
||||||
|
@ -136,11 +132,7 @@ namespace SystemTrayMenu.Handler
|
||||||
if (mouseMoveEvents > 6)
|
if (mouseMoveEvents > 6)
|
||||||
{
|
{
|
||||||
MouseActive = true;
|
MouseActive = true;
|
||||||
#if TODO // WPF: Can be optimized away?
|
|
||||||
if (dgvTmp != null && !dgvTmp.IsDisposed)
|
|
||||||
#else
|
|
||||||
if (dgvTmp != null)
|
if (dgvTmp != null)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
MouseEnter(dgvTmp, rowIndexTmp);
|
MouseEnter(dgvTmp, rowIndexTmp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,6 @@ namespace SystemTrayMenu.Helpers
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
timerRaiseRowMouseLeave.Stop();
|
timerRaiseRowMouseLeave.Stop();
|
||||||
#if TODO // WPF: Can be optimized away?
|
|
||||||
senderObject?.Dispose();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,18 +43,17 @@ namespace SystemTrayMenu.UserInterface
|
||||||
private bool directionToRight;
|
private bool directionToRight;
|
||||||
private bool mouseDown;
|
private bool mouseDown;
|
||||||
private Point lastLocation;
|
private Point lastLocation;
|
||||||
|
|
||||||
#if TODO // SEARCH
|
#if TODO // SEARCH
|
||||||
private bool isSetSearchText;
|
private bool isSetSearchText;
|
||||||
#endif
|
#endif
|
||||||
private bool isClosed = false; // TODO WPF Replace Forms wrapper
|
|
||||||
|
|
||||||
internal Menu(MenuData menuData, string path)
|
internal Menu(MenuData menuData, string path)
|
||||||
{
|
{
|
||||||
timerUpdateIcons.Tick += TimerUpdateIcons_Tick;
|
timerUpdateIcons.Tick += TimerUpdateIcons_Tick;
|
||||||
Closed += (_, _) =>
|
Closed += (_, _) =>
|
||||||
{
|
{
|
||||||
timerUpdateIcons.Stop();
|
timerUpdateIcons.Stop();
|
||||||
isClosed = true; // TODO WPF Replace Forms wrapper
|
IsClosed = true; // TODO WPF Replace Forms wrapper
|
||||||
};
|
};
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -228,7 +227,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
pictureBoxRestart.MouseEnter += ControlsMouseEnter;
|
pictureBoxRestart.MouseEnter += ControlsMouseEnter;
|
||||||
pictureBoxSearch.MouseEnter += ControlsMouseEnter;
|
pictureBoxSearch.MouseEnter += ControlsMouseEnter;
|
||||||
tableLayoutPanelMenu.MouseEnter += ControlsMouseEnter;
|
tableLayoutPanelMenu.MouseEnter += ControlsMouseEnter;
|
||||||
tableLayoutPanelDgvAndScrollbar.MouseEnter += ControlsMouseEnter;
|
dgv.MouseEnter += ControlsMouseEnter;
|
||||||
tableLayoutPanelBottom.MouseEnter += ControlsMouseEnter;
|
tableLayoutPanelBottom.MouseEnter += ControlsMouseEnter;
|
||||||
labelStatus.MouseEnter += ControlsMouseEnter;
|
labelStatus.MouseEnter += ControlsMouseEnter;
|
||||||
void ControlsMouseEnter(object sender, EventArgs e)
|
void ControlsMouseEnter(object sender, EventArgs e)
|
||||||
|
@ -245,7 +244,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
pictureBoxRestart.MouseLeave += ControlsMouseLeave;
|
pictureBoxRestart.MouseLeave += ControlsMouseLeave;
|
||||||
pictureBoxSearch.MouseLeave += ControlsMouseLeave;
|
pictureBoxSearch.MouseLeave += ControlsMouseLeave;
|
||||||
tableLayoutPanelMenu.MouseLeave += ControlsMouseLeave;
|
tableLayoutPanelMenu.MouseLeave += ControlsMouseLeave;
|
||||||
tableLayoutPanelDgvAndScrollbar.MouseLeave += ControlsMouseLeave;
|
dgv.MouseLeave += ControlsMouseLeave;
|
||||||
tableLayoutPanelBottom.MouseLeave += ControlsMouseLeave;
|
tableLayoutPanelBottom.MouseLeave += ControlsMouseLeave;
|
||||||
labelStatus.MouseLeave += ControlsMouseLeave;
|
labelStatus.MouseLeave += ControlsMouseLeave;
|
||||||
void ControlsMouseLeave(object sender, EventArgs e)
|
void ControlsMouseLeave(object sender, EventArgs e)
|
||||||
|
@ -253,7 +252,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
MouseLeave?.Invoke();
|
MouseLeave?.Invoke();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if TODO // TOUCH
|
#if TODO // Misc MouseEvents
|
||||||
bool isTouchEnabled = NativeMethods.IsTouchEnabled();
|
bool isTouchEnabled = NativeMethods.IsTouchEnabled();
|
||||||
if ((isTouchEnabled && Settings.Default.DragDropItemsEnabledTouch) ||
|
if ((isTouchEnabled && Settings.Default.DragDropItemsEnabledTouch) ||
|
||||||
(!isTouchEnabled && Settings.Default.DragDropItemsEnabled))
|
(!isTouchEnabled && Settings.Default.DragDropItemsEnabled))
|
||||||
|
@ -290,10 +289,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
internal event Action<Menu, Key, ModifierKeys>? CmdKeyProcessed;
|
internal event Action<Menu, Key, ModifierKeys>? CmdKeyProcessed;
|
||||||
|
|
||||||
#if TODO // Misc MouseEvents and TOUCH
|
|
||||||
internal event EventHandler<KeyPressEventArgs> KeyPressCheck;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal event Action? SearchTextChanging;
|
internal event Action? SearchTextChanging;
|
||||||
|
|
||||||
internal event Action<Menu, bool>? SearchTextChanged;
|
internal event Action<Menu, bool>? SearchTextChanged;
|
||||||
|
@ -330,23 +325,15 @@ namespace SystemTrayMenu.UserInterface
|
||||||
TopRight,
|
TopRight,
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDisposed => isClosed; // TODO WPF Replace Forms wrapper
|
public System.Drawing.Point Location => new ((int)Left, (int)Top); // TODO WPF Replace Forms wrapper
|
||||||
|
|
||||||
public bool Disposing => isClosed; // TODO WPF Replace Forms wrapper
|
|
||||||
|
|
||||||
public System.Drawing.Point Location => new ((int)Left, (int)Top); // TODO WPF Replace Forms wrapper)
|
|
||||||
|
|
||||||
internal int Level { get; set; }
|
internal int Level { get; set; }
|
||||||
|
|
||||||
internal RowData? RowDataParent { get; set; }
|
internal RowData? RowDataParent { get; set; }
|
||||||
|
|
||||||
internal bool IsUsable => Visibility == Visibility.Visible && !isFading && !IsDisposed && !Disposing;
|
internal bool IsClosed { get; private set; } = false;
|
||||||
|
|
||||||
#if TODO // TOUCH
|
internal bool IsUsable => Visibility == Visibility.Visible && !isFading && !IsClosed;
|
||||||
internal bool ScrollbarVisible { get; private set; }
|
|
||||||
|
|
||||||
private ListView tableLayoutPanelDgvAndScrollbar => dgv; // TODO WPF Remove and replace with dgv
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal void ResetSearchText()
|
internal void ResetSearchText()
|
||||||
{
|
{
|
||||||
|
@ -609,7 +596,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Layout cannot be calculated during loading, postpone this event
|
// Layout cannot be calculated during loading, postpone this event
|
||||||
// TODO: Make sure lampa capture is registered only once
|
|
||||||
Loaded += (_, _) => AdjustWindowPositionInternal();
|
Loaded += (_, _) => AdjustWindowPositionInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -964,12 +950,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TODO // Misc MouseEvents and TOUCH
|
|
||||||
private void TextBoxSearch_KeyPress(object sender, KeyPressEventArgs e)
|
|
||||||
{
|
|
||||||
KeyPressCheck?.Invoke(sender, e);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
private void TextBoxSearch_TextChanged()
|
private void TextBoxSearch_TextChanged()
|
||||||
{
|
{
|
||||||
SearchTextChanging?.Invoke();
|
SearchTextChanging?.Invoke();
|
||||||
|
@ -1077,11 +1057,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
timerUpdateIcons.Start();
|
timerUpdateIcons.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dgv.Rows.Count > 0)
|
|
||||||
{
|
|
||||||
dgv.FirstDisplayedScrollingRowIndex = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,14 +46,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
Title = myname;
|
Title = myname;
|
||||||
|
|
||||||
Closed += (_, _) => Application.Current.Shutdown();
|
Closed += (_, _) => Application.Current.Shutdown();
|
||||||
Deactivated += SetStateNormal;
|
|
||||||
Activated += (object? sender, EventArgs e) =>
|
|
||||||
{
|
|
||||||
SetStateNormal(sender, e);
|
|
||||||
Activate();
|
|
||||||
UpdateLayout();
|
|
||||||
Focus();
|
|
||||||
};
|
|
||||||
ContentRendered += MoveOutOfScreen;
|
ContentRendered += MoveOutOfScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,16 +55,5 @@ namespace SystemTrayMenu.UserInterface
|
||||||
ContentRendered -= MoveOutOfScreen;
|
ContentRendered -= MoveOutOfScreen;
|
||||||
Top += SystemParameters.VirtualScreenHeight;
|
Top += SystemParameters.VirtualScreenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This ensures that next click on taskbaritem works as activate event/click event.
|
|
||||||
/// </summary>
|
|
||||||
private void SetStateNormal(object? sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (IsActive)
|
|
||||||
{
|
|
||||||
WindowState = WindowState.Normal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
}
|
}
|
||||||
|
|
||||||
// see https://github.com/Hofknecht/SystemTrayMenu/issues/209.
|
// see https://github.com/Hofknecht/SystemTrayMenu/issues/209.
|
||||||
public static bool MainPreload { get; set; }
|
public static bool IsPreloading { get; set; } = true;
|
||||||
|
|
||||||
public static void Dispose(bool includingMainMenu = true)
|
public static void Dispose(bool includingMainMenu = true)
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ namespace SystemTrayMenu.Utilities
|
||||||
|
|
||||||
if (updateIconInBackground)
|
if (updateIconInBackground)
|
||||||
{
|
{
|
||||||
if (MainPreload)
|
if (IsPreloading)
|
||||||
{
|
{
|
||||||
DictIconCache(isMainMenu).GetOrAdd(key, GetFolder);
|
DictIconCache(isMainMenu).GetOrAdd(key, GetFolder);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue