2020-07-07 09:37:55 +12:00
|
|
|
|
// <copyright file="Menu.cs" company="PlaceholderCompany">
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
|
|
namespace SystemTrayMenu.UserInterface
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2020-07-07 07:15:45 +12:00
|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using SystemTrayMenu.DataClasses;
|
|
|
|
|
using SystemTrayMenu.DllImports;
|
2021-10-26 08:45:49 +13:00
|
|
|
|
using SystemTrayMenu.Helper;
|
2020-07-07 07:15:45 +12:00
|
|
|
|
using SystemTrayMenu.Utilities;
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
internal partial class Menu : Form
|
|
|
|
|
{
|
2021-11-17 12:13:46 +13:00
|
|
|
|
private readonly Fading fading = new();
|
2021-04-17 12:39:48 +12:00
|
|
|
|
private bool isShowing;
|
|
|
|
|
private bool directionToRight;
|
2021-10-04 07:24:22 +13:00
|
|
|
|
private int rotationAngle;
|
2020-06-06 21:47:19 +12:00
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
internal Menu()
|
|
|
|
|
{
|
|
|
|
|
fading.ChangeOpacity += Fading_ChangeOpacity;
|
|
|
|
|
void Fading_ChangeOpacity(object sender, double newOpacity)
|
|
|
|
|
{
|
2020-07-04 08:02:16 +12:00
|
|
|
|
if (!IsDisposed && !Disposing)
|
2020-06-21 06:11:25 +12:00
|
|
|
|
{
|
|
|
|
|
Opacity = newOpacity;
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
fading.Show += Fading_Show;
|
|
|
|
|
void Fading_Show()
|
|
|
|
|
{
|
2021-05-29 06:48:17 +12:00
|
|
|
|
try
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-05-29 06:48:17 +12:00
|
|
|
|
isShowing = true;
|
|
|
|
|
Visible = true;
|
|
|
|
|
isShowing = false;
|
2021-09-24 08:53:46 +12:00
|
|
|
|
timerUpdateIcons.Start();
|
2021-05-29 06:48:17 +12:00
|
|
|
|
}
|
|
|
|
|
catch (ObjectDisposedException)
|
|
|
|
|
{
|
|
|
|
|
Visible = false;
|
|
|
|
|
isShowing = false;
|
|
|
|
|
Log.Info($"Could not open menu, old menu was disposing," +
|
|
|
|
|
$" IsDisposed={IsDisposed}");
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
|
2021-05-29 06:48:17 +12:00
|
|
|
|
if (Visible)
|
|
|
|
|
{
|
|
|
|
|
if (Level == 0)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
|
|
|
|
Activate();
|
2021-11-02 01:32:06 +13:00
|
|
|
|
textBoxSearch.SelectAll();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
textBoxSearch.Focus();
|
|
|
|
|
NativeMethods.User32ShowInactiveTopmost(this);
|
|
|
|
|
NativeMethods.ForceForegroundWindow(Handle);
|
|
|
|
|
}
|
2021-05-29 06:48:17 +12:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NativeMethods.User32ShowInactiveTopmost(this);
|
2021-11-02 01:32:06 +13:00
|
|
|
|
textBoxSearch.SelectAll();
|
2021-05-29 06:48:17 +12:00
|
|
|
|
textBoxSearch.Focus();
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
fading.Hide += Hide;
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
SetDoubleBuffer(dgv, true);
|
|
|
|
|
|
2020-08-08 01:24:25 +12:00
|
|
|
|
Color foreColor = Color.Black;
|
2021-05-05 02:58:12 +12:00
|
|
|
|
Color titleBackColor = AppColors.Title;
|
2021-05-05 07:59:55 +12:00
|
|
|
|
Color backColor = AppColors.Background;
|
|
|
|
|
Color backColorSearch = AppColors.SearchField;
|
2021-07-04 07:50:59 +12:00
|
|
|
|
Color backgroundBorder = AppColors.BackgroundBorder;
|
2021-06-26 23:24:56 +12:00
|
|
|
|
|
2020-08-08 01:24:25 +12:00
|
|
|
|
if (Config.IsDarkMode())
|
|
|
|
|
{
|
|
|
|
|
foreColor = Color.White;
|
|
|
|
|
labelTitle.ForeColor = foreColor;
|
|
|
|
|
textBoxSearch.ForeColor = foreColor;
|
2021-05-05 02:58:12 +12:00
|
|
|
|
titleBackColor = AppColors.DarkModeTitle;
|
2021-05-05 07:59:55 +12:00
|
|
|
|
backColor = AppColors.DarkModeBackground;
|
|
|
|
|
backColorSearch = AppColors.DarkModeSearchField;
|
2021-07-04 07:50:59 +12:00
|
|
|
|
backgroundBorder = AppColors.DarkModeBackgroundBorder;
|
2020-08-08 01:24:25 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 12:13:46 +13:00
|
|
|
|
ColorConverter colorConverter = new();
|
2021-08-16 21:48:35 +12:00
|
|
|
|
labelFoldersCount.ForeColor = MenuDefines.ColorIcons;
|
|
|
|
|
labelFilesCount.ForeColor = MenuDefines.ColorIcons;
|
2021-06-28 01:42:34 +12:00
|
|
|
|
|
2021-06-06 23:15:01 +12:00
|
|
|
|
if (backColor.R == 0)
|
|
|
|
|
{
|
|
|
|
|
backColor = Color.White;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-04 07:50:59 +12:00
|
|
|
|
BackColor = backgroundBorder;
|
2021-06-26 23:24:56 +12:00
|
|
|
|
tableLayoutPanelTitle.BackColor = titleBackColor;
|
2021-06-03 22:52:47 +12:00
|
|
|
|
tableLayoutPanelDgvAndScrollbar.BackColor = backColor;
|
2021-05-05 02:18:19 +12:00
|
|
|
|
dgv.BackgroundColor = backColor;
|
|
|
|
|
textBoxSearch.BackColor = backColorSearch;
|
|
|
|
|
pictureBoxSearch.BackColor = backColorSearch;
|
2021-06-28 00:44:12 +12:00
|
|
|
|
pictureBoxFoldersCount.BackColor = backColorSearch;
|
|
|
|
|
pictureBoxFilesCount.BackColor = backColorSearch;
|
2021-05-05 02:18:19 +12:00
|
|
|
|
tableLayoutPanelSearch.BackColor = backColorSearch;
|
2021-06-03 22:52:47 +12:00
|
|
|
|
dgv.DefaultCellStyle = new DataGridViewCellStyle
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2020-08-08 01:24:25 +12:00
|
|
|
|
SelectionForeColor = foreColor,
|
|
|
|
|
ForeColor = foreColor,
|
|
|
|
|
BackColor = backColor,
|
2020-06-08 00:28:59 +12:00
|
|
|
|
};
|
|
|
|
|
|
2021-11-02 01:32:06 +13:00
|
|
|
|
dgv.GotFocus += (sender, e) => FocusTextBox();
|
|
|
|
|
customScrollbar.GotFocus += (sender, e) => FocusTextBox();
|
2021-06-03 22:52:47 +12:00
|
|
|
|
|
|
|
|
|
customScrollbar.Margin = new Padding(0);
|
|
|
|
|
customScrollbar.Scroll += CustomScrollbar_Scroll;
|
|
|
|
|
void CustomScrollbar_Scroll(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
decimal firstIndex = customScrollbar.Value * dgv.Rows.Count / (decimal)customScrollbar.Maximum;
|
2021-06-26 23:24:56 +12:00
|
|
|
|
int firstIndexRounded = (int)Math.Ceiling(firstIndex);
|
2021-06-03 22:52:47 +12:00
|
|
|
|
if (firstIndexRounded > -1 && firstIndexRounded < dgv.RowCount)
|
|
|
|
|
{
|
|
|
|
|
dgv.FirstDisplayedScrollingRowIndex = firstIndexRounded;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
customScrollbar.MouseEnter += ControlsMouseEnter;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
dgv.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
labelTitle.MouseEnter += ControlsMouseEnter;
|
2021-10-29 03:29:04 +13:00
|
|
|
|
textBoxSearch.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
pictureBoxMenuAlwaysOpen.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
pictureBoxOpenFolder.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
pictureBoxSearch.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
pictureBoxFilesCount.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
pictureBoxFoldersCount.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
labelFilesCount.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
labelFoldersCount.MouseEnter += ControlsMouseEnter;
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
void ControlsMouseEnter(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-29 06:57:03 +12:00
|
|
|
|
MouseEnter?.Invoke();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
customScrollbar.MouseLeave += ControlsMouseLeave;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
dgv.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
labelTitle.MouseLeave += ControlsMouseLeave;
|
2021-10-29 03:29:04 +13:00
|
|
|
|
textBoxSearch.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
pictureBoxMenuAlwaysOpen.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
pictureBoxOpenFolder.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
pictureBoxSearch.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
pictureBoxFilesCount.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
pictureBoxFoldersCount.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
labelFilesCount.MouseLeave += ControlsMouseLeave;
|
|
|
|
|
labelFoldersCount.MouseLeave += ControlsMouseLeave;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
void ControlsMouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
2020-06-29 06:57:03 +12:00
|
|
|
|
MouseLeave?.Invoke();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
2021-06-26 23:24:56 +12:00
|
|
|
|
|
|
|
|
|
AllowDrop = true;
|
|
|
|
|
DragEnter += DragDropHelper.DragEnter;
|
|
|
|
|
DragDrop += DragDropHelper.DragDrop;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 09:37:55 +12:00
|
|
|
|
internal new event EventHandlerEmpty MouseWheel;
|
|
|
|
|
|
|
|
|
|
internal new event EventHandlerEmpty MouseEnter;
|
|
|
|
|
|
|
|
|
|
internal new event EventHandlerEmpty MouseLeave;
|
|
|
|
|
|
|
|
|
|
internal event EventHandlerEmpty UserClickedOpenFolder;
|
|
|
|
|
|
|
|
|
|
internal event EventHandler<Keys> CmdKeyProcessed;
|
|
|
|
|
|
|
|
|
|
internal event EventHandlerEmpty SearchTextChanging;
|
|
|
|
|
|
|
|
|
|
internal event EventHandler SearchTextChanged;
|
|
|
|
|
|
|
|
|
|
internal enum MenuType
|
|
|
|
|
{
|
|
|
|
|
Main,
|
|
|
|
|
Sub,
|
|
|
|
|
Empty,
|
|
|
|
|
NoAccess,
|
|
|
|
|
MaxReached,
|
2021-10-04 07:24:22 +13:00
|
|
|
|
Loading,
|
2020-07-07 09:37:55 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 05:19:21 +12:00
|
|
|
|
internal enum StartLocation
|
|
|
|
|
{
|
|
|
|
|
Predecessor,
|
|
|
|
|
BottomLeft,
|
|
|
|
|
BottomRight,
|
|
|
|
|
TopRight,
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-17 12:39:48 +12:00
|
|
|
|
internal int Level { get; set; }
|
2020-07-08 03:05:19 +12:00
|
|
|
|
|
2020-07-07 09:37:55 +12:00
|
|
|
|
internal bool IsUsable => Visible && !fading.IsHiding &&
|
|
|
|
|
!IsDisposed && !Disposing;
|
|
|
|
|
|
2020-07-08 03:05:19 +12:00
|
|
|
|
protected override CreateParams CreateParams
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2020-07-08 03:05:19 +12:00
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
CreateParams createparams = base.CreateParams;
|
|
|
|
|
createparams.ExStyle |= 0x80;
|
|
|
|
|
return createparams;
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 11:39:52 +13:00
|
|
|
|
internal void ResetSearchText()
|
|
|
|
|
{
|
|
|
|
|
textBoxSearch.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 03:05:19 +12:00
|
|
|
|
internal void FocusTextBox()
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-11-02 01:32:06 +13:00
|
|
|
|
textBoxSearch.SelectAll();
|
2020-07-08 03:05:19 +12:00
|
|
|
|
textBoxSearch.Focus();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetTypeSub()
|
|
|
|
|
{
|
|
|
|
|
SetType(MenuType.Sub);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetTypeEmpty()
|
|
|
|
|
{
|
|
|
|
|
SetType(MenuType.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetTypeNoAccess()
|
|
|
|
|
{
|
|
|
|
|
SetType(MenuType.NoAccess);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-04 07:24:22 +13:00
|
|
|
|
internal void SetTypeLoading()
|
|
|
|
|
{
|
|
|
|
|
SetType(MenuType.Loading);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
internal void SetType(MenuType type)
|
|
|
|
|
{
|
2021-06-26 23:24:56 +12:00
|
|
|
|
if (type != MenuType.Main)
|
|
|
|
|
{
|
|
|
|
|
pictureBoxMenuAlwaysOpen.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
switch (type)
|
|
|
|
|
{
|
2021-10-04 07:24:22 +13:00
|
|
|
|
case MenuType.Main:
|
|
|
|
|
break;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
case MenuType.Sub:
|
|
|
|
|
break;
|
|
|
|
|
case MenuType.Empty:
|
|
|
|
|
SetTitle(Translator.GetText("Folder empty"));
|
|
|
|
|
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
2020-06-21 03:38:21 +12:00
|
|
|
|
pictureBoxSearch.Visible = false;
|
|
|
|
|
textBoxSearch.Visible = false;
|
|
|
|
|
tableLayoutPanelSearch.Visible = false;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
break;
|
|
|
|
|
case MenuType.NoAccess:
|
|
|
|
|
SetTitle(Translator.GetText("Folder inaccessible"));
|
|
|
|
|
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
2020-06-21 03:38:21 +12:00
|
|
|
|
pictureBoxSearch.Visible = false;
|
|
|
|
|
textBoxSearch.Visible = false;
|
|
|
|
|
tableLayoutPanelSearch.Visible = false;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
break;
|
2021-10-04 07:24:22 +13:00
|
|
|
|
case MenuType.Loading:
|
|
|
|
|
SetTitle(Translator.GetText("loading"));
|
|
|
|
|
pictureBoxSearch.Visible = false;
|
|
|
|
|
textBoxSearch.Visible = false;
|
|
|
|
|
tableLayoutPanelSearch.Visible = false;
|
|
|
|
|
pictureBoxOpenFolder.Visible = false;
|
|
|
|
|
pictureBoxMenuAlwaysOpen.Paint -= PictureBoxMenuAlwaysOpen_Paint;
|
|
|
|
|
pictureBoxMenuAlwaysOpen.Paint += LoadingMenu_Paint;
|
|
|
|
|
timerUpdateIcons.Tick -= TimerUpdateIcons_Tick;
|
|
|
|
|
timerUpdateIcons.Tick += TimerUpdateLoadingMenu_Tick;
|
|
|
|
|
timerUpdateIcons.Interval = 15;
|
|
|
|
|
pictureBoxMenuAlwaysOpen.Visible = true;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal bool IsMouseOn(Point mousePosition)
|
|
|
|
|
{
|
|
|
|
|
bool isMouseOn = Visible && ClientRectangle.Contains(
|
|
|
|
|
PointToClient(mousePosition));
|
|
|
|
|
return isMouseOn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal DataGridView GetDataGridView()
|
|
|
|
|
{
|
|
|
|
|
return dgv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void SetTitle(string title)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(title))
|
|
|
|
|
{
|
|
|
|
|
if (title.Length > MenuDefines.LengthMax)
|
|
|
|
|
{
|
|
|
|
|
title = $"{title.Substring(0, MenuDefines.LengthMax)}...";
|
|
|
|
|
}
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
labelTitle.Text = title;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ShowWithFadeOrTransparent(bool formActiveFormIsMenu)
|
|
|
|
|
{
|
|
|
|
|
if (formActiveFormIsMenu)
|
|
|
|
|
{
|
|
|
|
|
ShowWithFade();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowTransparent();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ShowWithFade()
|
|
|
|
|
{
|
|
|
|
|
fading.Fade(Fading.FadingState.Show);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void ShowTransparent()
|
|
|
|
|
{
|
|
|
|
|
fading.Fade(Fading.FadingState.ShowTransparent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal void HideWithFade()
|
|
|
|
|
{
|
|
|
|
|
if (!isShowing)
|
|
|
|
|
{
|
|
|
|
|
fading.Fade(Fading.FadingState.Hide);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 07:47:46 +12:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Update the position and size of the menu.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="bounds">Screen coordinates where the menu is allowed to be drawn in.</param>
|
|
|
|
|
/// <param name="menuPredecessor">Predecessor menu (when available).</param>
|
|
|
|
|
/// <param name="startLocation">Defines where the first menu is drawn (when no predecessor is set).</param>
|
2020-07-07 07:15:45 +12:00
|
|
|
|
internal void AdjustSizeAndLocation(
|
2020-09-21 03:26:45 +12:00
|
|
|
|
Rectangle bounds,
|
|
|
|
|
Menu menuPredecessor,
|
2020-09-21 05:19:21 +12:00
|
|
|
|
StartLocation startLocation)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-05-29 09:23:05 +12:00
|
|
|
|
// Update the height and width
|
|
|
|
|
AdjustDataGridViewHeight(menuPredecessor, bounds.Height);
|
|
|
|
|
AdjustDataGridViewWidth();
|
|
|
|
|
|
2020-09-21 05:19:21 +12:00
|
|
|
|
if (menuPredecessor != null)
|
|
|
|
|
{
|
2020-09-21 06:45:12 +12:00
|
|
|
|
// Ignore start as we use predecessor
|
2020-09-21 05:19:21 +12:00
|
|
|
|
startLocation = StartLocation.Predecessor;
|
|
|
|
|
}
|
2021-04-29 08:58:33 +12:00
|
|
|
|
else if (Properties.Settings.Default.AppearAtMouseLocation)
|
|
|
|
|
{
|
2021-06-27 22:24:05 +12:00
|
|
|
|
// Do not adjust location again because Cursor.Postion changed
|
|
|
|
|
if (Tag != null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use this menu as predecessor and overwrite location with Cursor.Postion
|
2021-04-29 08:58:33 +12:00
|
|
|
|
menuPredecessor = this;
|
|
|
|
|
Tag = new RowData();
|
|
|
|
|
Location = new Point(Cursor.Position.X, Cursor.Position.Y - labelTitle.Height);
|
|
|
|
|
directionToRight = true;
|
|
|
|
|
startLocation = StartLocation.Predecessor;
|
|
|
|
|
}
|
2020-09-21 05:19:21 +12:00
|
|
|
|
|
|
|
|
|
// Calculate X position
|
2020-06-08 00:28:59 +12:00
|
|
|
|
int x;
|
2020-09-21 05:19:21 +12:00
|
|
|
|
switch (startLocation)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2020-09-21 05:19:21 +12:00
|
|
|
|
case StartLocation.Predecessor:
|
2020-09-21 06:45:12 +12:00
|
|
|
|
int scaling = (int)Math.Round(Scaling.Factor, 0, MidpointRounding.AwayFromZero);
|
|
|
|
|
directionToRight = menuPredecessor.directionToRight; // try keeping same direction
|
2020-09-21 05:19:21 +12:00
|
|
|
|
if (directionToRight)
|
|
|
|
|
{
|
2020-09-21 06:45:12 +12:00
|
|
|
|
x = menuPredecessor.Location.X + menuPredecessor.Width - scaling;
|
|
|
|
|
|
|
|
|
|
// Change direction when out of bounds
|
|
|
|
|
if (bounds.X + bounds.Width <= x + Width - scaling)
|
|
|
|
|
{
|
|
|
|
|
x = menuPredecessor.Location.X - Width + scaling;
|
|
|
|
|
directionToRight = !directionToRight;
|
|
|
|
|
}
|
2020-09-21 05:19:21 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-09-21 06:45:12 +12:00
|
|
|
|
x = menuPredecessor.Location.X - Width + scaling;
|
|
|
|
|
|
|
|
|
|
// Change direction when out of bounds
|
|
|
|
|
if (x < bounds.X)
|
|
|
|
|
{
|
|
|
|
|
x = menuPredecessor.Location.X + menuPredecessor.Width - scaling;
|
|
|
|
|
directionToRight = !directionToRight;
|
|
|
|
|
}
|
2020-09-21 05:19:21 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case StartLocation.BottomLeft:
|
|
|
|
|
x = bounds.X;
|
2020-09-21 06:45:12 +12:00
|
|
|
|
directionToRight = true;
|
2020-09-21 05:19:21 +12:00
|
|
|
|
break;
|
|
|
|
|
case StartLocation.TopRight:
|
|
|
|
|
case StartLocation.BottomRight:
|
|
|
|
|
default:
|
|
|
|
|
x = bounds.Width - Width;
|
2020-09-21 06:45:12 +12:00
|
|
|
|
directionToRight = false;
|
2020-09-21 05:19:21 +12:00
|
|
|
|
break;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-29 08:58:33 +12:00
|
|
|
|
// X position for click, remove width of this menu as it is used as predecessor
|
|
|
|
|
if (menuPredecessor == this && directionToRight)
|
|
|
|
|
{
|
|
|
|
|
x -= Width;
|
|
|
|
|
directionToRight = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 05:19:21 +12:00
|
|
|
|
// Calculate Y position
|
2020-06-08 00:28:59 +12:00
|
|
|
|
int y;
|
2020-09-21 05:19:21 +12:00
|
|
|
|
switch (startLocation)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2020-09-21 05:19:21 +12:00
|
|
|
|
case StartLocation.Predecessor:
|
|
|
|
|
RowData trigger = (RowData)Tag;
|
|
|
|
|
DataGridView dgv = menuPredecessor.GetDataGridView();
|
|
|
|
|
int distanceFromItemToDgvTop = 0;
|
2020-09-21 06:45:12 +12:00
|
|
|
|
|
|
|
|
|
// Get offset of selected row from predecessor
|
2020-09-21 05:19:21 +12:00
|
|
|
|
if (dgv.Rows.Count > trigger.RowIndex)
|
|
|
|
|
{
|
|
|
|
|
Rectangle cellRectangle = dgv.GetCellDisplayRectangle(0, trigger.RowIndex, false);
|
|
|
|
|
distanceFromItemToDgvTop = cellRectangle.Top;
|
|
|
|
|
}
|
2020-07-07 07:15:45 +12:00
|
|
|
|
|
2020-09-21 06:45:12 +12:00
|
|
|
|
// Set position on same height as the selected row from predecessor
|
|
|
|
|
y = menuPredecessor.Location.Y + menuPredecessor.dgv.Location.Y + distanceFromItemToDgvTop;
|
|
|
|
|
|
2021-06-28 01:42:34 +12:00
|
|
|
|
// when warning the title should appear in same height as selected row
|
|
|
|
|
if (!tableLayoutPanelSearch.Visible)
|
2021-06-26 23:24:56 +12:00
|
|
|
|
{
|
|
|
|
|
y += tableLayoutPanelTitle.Height;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 06:45:12 +12:00
|
|
|
|
// Move vertically when out of bounds
|
2020-09-27 22:24:58 +13:00
|
|
|
|
if (bounds.Y + bounds.Height < y + Height)
|
2020-09-21 05:19:21 +12:00
|
|
|
|
{
|
2020-09-21 06:45:12 +12:00
|
|
|
|
y = bounds.Y + bounds.Height - Height;
|
2020-09-21 05:19:21 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case StartLocation.TopRight:
|
|
|
|
|
y = bounds.Y;
|
|
|
|
|
break;
|
|
|
|
|
case StartLocation.BottomLeft:
|
|
|
|
|
case StartLocation.BottomRight:
|
|
|
|
|
default:
|
|
|
|
|
y = bounds.Height - Height;
|
|
|
|
|
break;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 05:19:21 +12:00
|
|
|
|
// Update position
|
2020-06-08 00:28:59 +12:00
|
|
|
|
Location = new Point(x, y);
|
2021-11-14 07:44:32 +13:00
|
|
|
|
|
|
|
|
|
if (Properties.Settings.Default.RoundCorners)
|
|
|
|
|
{
|
2021-11-19 09:12:03 +13:00
|
|
|
|
if (NativeMethods.GetRegionRoundCorners(Width + 1, Height + 1, 15, 15, out Region regionOutline))
|
|
|
|
|
{
|
|
|
|
|
Region = regionOutline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NativeMethods.GetRegionRoundCorners(Width - 1, Height - 1, 15, 15, out Region region))
|
|
|
|
|
{
|
|
|
|
|
tableLayoutPanelMenu.Region = region;
|
|
|
|
|
}
|
2021-11-14 07:44:32 +13:00
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 03:05:19 +12:00
|
|
|
|
internal void KeyPressedSearch(string letter)
|
|
|
|
|
{
|
|
|
|
|
textBoxSearch.Text += letter;
|
|
|
|
|
textBoxSearch.SelectionStart = textBoxSearch.Text.Length;
|
|
|
|
|
textBoxSearch.SelectionLength = 0;
|
|
|
|
|
textBoxSearch.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
internal void AdjustScrollbar()
|
|
|
|
|
{
|
|
|
|
|
customScrollbar.Value = (int)Math.Round(
|
|
|
|
|
dgv.FirstDisplayedScrollingRowIndex * (decimal)customScrollbar.Maximum / dgv.Rows.Count,
|
|
|
|
|
0,
|
|
|
|
|
MidpointRounding.AwayFromZero);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 01:42:34 +12:00
|
|
|
|
internal void SetCounts(int foldersCount, int filesCount)
|
|
|
|
|
{
|
|
|
|
|
labelFoldersCount.Text = foldersCount.ToString();
|
|
|
|
|
labelFilesCount.Text = filesCount.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 03:05:19 +12:00
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keys)
|
|
|
|
|
{
|
|
|
|
|
switch (keys)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Enter:
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
case Keys.Left:
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
case Keys.Escape:
|
|
|
|
|
case Keys.Control | Keys.F:
|
|
|
|
|
case Keys.Tab:
|
|
|
|
|
case Keys.Tab | Keys.Shift:
|
|
|
|
|
case Keys.Apps:
|
|
|
|
|
CmdKeyProcessed.Invoke(this, keys);
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.ProcessCmdKey(ref msg, keys);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void SetDoubleBuffer(Control ctl, bool doubleBuffered)
|
|
|
|
|
{
|
|
|
|
|
typeof(Control).InvokeMember(
|
|
|
|
|
"DoubleBuffered",
|
|
|
|
|
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,
|
|
|
|
|
null,
|
|
|
|
|
ctl,
|
|
|
|
|
new object[] { doubleBuffered },
|
|
|
|
|
CultureInfo.InvariantCulture);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 07:47:46 +12:00
|
|
|
|
private void AdjustDataGridViewHeight(Menu menuPredecessor, int screenHeightMax)
|
|
|
|
|
{
|
2021-11-14 04:52:55 +13:00
|
|
|
|
double factor = Properties.Settings.Default.RowHeighteInPercentage / 100f;
|
2020-09-21 07:47:46 +12:00
|
|
|
|
if (NativeMethods.IsTouchEnabled())
|
|
|
|
|
{
|
2021-11-14 04:52:55 +13:00
|
|
|
|
factor = Properties.Settings.Default.RowHeighteInPercentageTouch / 100f;
|
2020-09-21 07:47:46 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (menuPredecessor == null)
|
|
|
|
|
{
|
|
|
|
|
if (dgv.Tag == null && dgv.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
// Find row size based on content and apply factor
|
|
|
|
|
dgv.AutoResizeRows();
|
|
|
|
|
dgv.RowTemplate.Height = (int)(dgv.Rows[0].Height * factor);
|
|
|
|
|
dgv.Tag = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Take over the height from predecessor menu
|
|
|
|
|
dgv.RowTemplate.Height = menuPredecessor.GetDataGridView().RowTemplate.Height;
|
|
|
|
|
dgv.Tag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Patch size of each row
|
|
|
|
|
foreach (DataGridViewRow row in dgv.Rows)
|
|
|
|
|
{
|
|
|
|
|
row.Height = dgv.RowTemplate.Height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DataTable data = (DataTable)dgv.DataSource;
|
2021-06-03 22:52:47 +12:00
|
|
|
|
int dgvHeightNew = dgv.Rows.GetRowsHeight(DataGridViewElementStates.None); // Height of all rows
|
|
|
|
|
int dgvHeightMax = screenHeightMax - (Height - dgv.Height); // except dgv
|
|
|
|
|
|
|
|
|
|
if (dgvHeightMax > Properties.Settings.Default.MaximumMenuHeight)
|
2020-09-21 07:47:46 +12:00
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
dgvHeightMax = Properties.Settings.Default.MaximumMenuHeight;
|
|
|
|
|
}
|
2021-05-29 19:46:54 +12:00
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
if (dgvHeightNew > dgvHeightMax)
|
|
|
|
|
{
|
|
|
|
|
// Make all rows fit into the screen
|
|
|
|
|
customScrollbar.PaintEnable();
|
|
|
|
|
if (customScrollbar.Maximum != dgvHeightNew)
|
2021-05-29 19:46:54 +12:00
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
customScrollbar.Reset();
|
|
|
|
|
customScrollbar.Height = dgvHeightMax;
|
|
|
|
|
customScrollbar.Minimum = 0;
|
|
|
|
|
customScrollbar.Maximum = dgvHeightNew;
|
2021-06-05 21:52:33 +12:00
|
|
|
|
customScrollbar.LargeChange = dgvHeightMax;
|
2021-06-03 22:52:47 +12:00
|
|
|
|
customScrollbar.SmallChange = dgv.RowTemplate.Height;
|
2021-05-29 19:46:54 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
dgvHeightNew = dgvHeightMax;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
customScrollbar.PaintDisable();
|
|
|
|
|
}
|
2020-09-21 07:47:46 +12:00
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
if (string.IsNullOrEmpty(data.DefaultView.RowFilter))
|
|
|
|
|
{
|
|
|
|
|
dgv.Height = dgvHeightNew;
|
2020-09-21 07:47:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
private void AdjustDataGridViewWidth()
|
|
|
|
|
{
|
|
|
|
|
DataGridViewExtensions.FastAutoSizeColumns(dgv);
|
2021-06-03 22:52:47 +12:00
|
|
|
|
|
|
|
|
|
if (dgv.Columns[1].Width < 60)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
dgv.Columns[1].Width = 60;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-03 22:52:47 +12:00
|
|
|
|
int widthIcon = dgv.Columns[0].Width;
|
|
|
|
|
int widthText = dgv.Columns[1].Width;
|
|
|
|
|
int widthScrollbar = 0;
|
|
|
|
|
if (customScrollbar.Enabled)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
widthScrollbar = customScrollbar.Width;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 23:24:56 +12:00
|
|
|
|
if (tableLayoutPanelTitle.Width > (widthIcon + widthText + widthScrollbar))
|
2021-06-03 22:52:47 +12:00
|
|
|
|
{
|
2021-06-26 23:24:56 +12:00
|
|
|
|
dgv.Width = tableLayoutPanelTitle.Width - widthScrollbar;
|
|
|
|
|
dgv.Columns[1].Width = tableLayoutPanelTitle.Width - widthIcon - widthScrollbar;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
dgv.Width = widthIcon + widthText;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 07:15:45 +12:00
|
|
|
|
// Only scaling correct with Sans Serif for textBoxSearch. Workaround:
|
|
|
|
|
textBoxSearch.Font = new Font(
|
|
|
|
|
"Segoe UI",
|
|
|
|
|
8.25F * Scaling.Factor,
|
|
|
|
|
FontStyle.Regular,
|
|
|
|
|
GraphicsUnit.Point,
|
|
|
|
|
0);
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 02:46:47 +12:00
|
|
|
|
private void DgvMouseWheel(object sender, MouseEventArgs e)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
|
|
|
|
((HandledMouseEventArgs)e).Handled = true;
|
2021-06-03 22:52:47 +12:00
|
|
|
|
customScrollbar.CustomScrollbar_MouseWheel(sender, e);
|
2020-06-29 06:57:03 +12:00
|
|
|
|
MouseWheel?.Invoke();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 02:46:47 +12:00
|
|
|
|
private void TextBoxSearch_TextChanged(object sender, EventArgs e)
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-06-03 22:52:47 +12:00
|
|
|
|
customScrollbar.Value = 0;
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
DataTable data = (DataTable)dgv.DataSource;
|
|
|
|
|
string filterField = dgv.Columns[1].Name;
|
2020-06-29 06:56:03 +12:00
|
|
|
|
SearchTextChanging?.Invoke();
|
2020-06-08 00:28:59 +12:00
|
|
|
|
|
2021-06-28 00:44:12 +12:00
|
|
|
|
string searchString = textBoxSearch.Text.Trim()
|
|
|
|
|
.Replace("%", " ")
|
|
|
|
|
.Replace("*", " ");
|
2021-04-15 09:12:14 +12:00
|
|
|
|
string like = string.Empty;
|
|
|
|
|
string[] splittedParts = searchString.Split(" ");
|
|
|
|
|
if (splittedParts.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
foreach (string splittedPart in splittedParts)
|
|
|
|
|
{
|
|
|
|
|
string and = string.Empty;
|
|
|
|
|
if (!string.IsNullOrEmpty(like))
|
|
|
|
|
{
|
|
|
|
|
and = $" AND [{filterField}]";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
like += $"{and} LIKE '%{splittedPart}%'";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
like = $"LIKE '%{searchString}%'";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
data.DefaultView.RowFilter = $"[{filterField}] {like}";
|
|
|
|
|
}
|
2021-04-17 04:39:21 +12:00
|
|
|
|
catch (Exception ex)
|
2021-04-15 09:12:14 +12:00
|
|
|
|
{
|
2021-04-17 04:39:21 +12:00
|
|
|
|
if (ex is EvaluateException ||
|
|
|
|
|
ex is SyntaxErrorException)
|
|
|
|
|
{
|
|
|
|
|
Log.Warn($"searchString \"{searchString}\" is a invalid", ex);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw;
|
|
|
|
|
}
|
2021-04-15 09:12:14 +12:00
|
|
|
|
}
|
2021-04-15 07:06:54 +12:00
|
|
|
|
|
2021-04-15 09:12:14 +12:00
|
|
|
|
if (string.IsNullOrEmpty(searchString))
|
2020-06-08 00:28:59 +12:00
|
|
|
|
{
|
2021-04-15 07:06:54 +12:00
|
|
|
|
data.DefaultView.Sort = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string columnSortIndex = "SortIndex";
|
|
|
|
|
|
|
|
|
|
foreach (DataRow row in data.Rows)
|
|
|
|
|
{
|
|
|
|
|
if (row[1].ToString().StartsWith(
|
2021-04-15 09:12:14 +12:00
|
|
|
|
searchString,
|
2021-04-15 07:06:54 +12:00
|
|
|
|
StringComparison.InvariantCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
row[columnSortIndex] = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
row[columnSortIndex] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.DefaultView.Sort = columnSortIndex;
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 00:44:12 +12:00
|
|
|
|
int foldersCount = 0;
|
|
|
|
|
int filesCount = 0;
|
2021-10-22 08:28:58 +13:00
|
|
|
|
bool anyIconNotUpdated = false;
|
2021-06-28 00:44:12 +12:00
|
|
|
|
|
2021-04-17 09:14:39 +12:00
|
|
|
|
foreach (DataGridViewRow row in dgv.Rows)
|
|
|
|
|
{
|
|
|
|
|
RowData rowData = (RowData)row.Cells[2].Value;
|
|
|
|
|
rowData.RowIndex = row.Index;
|
2021-06-28 00:44:12 +12:00
|
|
|
|
|
|
|
|
|
if (rowData.ContainsMenu)
|
|
|
|
|
{
|
|
|
|
|
foldersCount++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
filesCount++;
|
|
|
|
|
}
|
2021-10-22 08:28:58 +13:00
|
|
|
|
|
|
|
|
|
if (rowData.IconLoading)
|
|
|
|
|
{
|
|
|
|
|
anyIconNotUpdated = true;
|
|
|
|
|
}
|
2021-04-17 09:14:39 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 00:44:12 +12:00
|
|
|
|
SetCounts(foldersCount, filesCount);
|
|
|
|
|
|
2020-06-08 00:28:59 +12:00
|
|
|
|
SearchTextChanged.Invoke(this, null);
|
2021-10-22 08:28:58 +13:00
|
|
|
|
|
|
|
|
|
if (anyIconNotUpdated)
|
|
|
|
|
{
|
|
|
|
|
timerUpdateIcons.Start();
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
2021-06-26 23:24:56 +12:00
|
|
|
|
|
|
|
|
|
private void PictureBox_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
pictureBox.BackColor = MenuDefines.ColorSelectedItem;
|
|
|
|
|
pictureBox.Tag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBox_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
pictureBox.BackColor = Color.Transparent;
|
|
|
|
|
pictureBox.Tag = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBox_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
pictureBox.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBoxSearch_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
2021-06-27 21:35:07 +12:00
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapSearch, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-26 23:24:56 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 00:44:12 +12:00
|
|
|
|
private void PictureBoxFoldersCount_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapFoldersCount, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-28 00:44:12 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBoxFilesCount_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapFilesCount, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-28 00:44:12 +12:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 23:24:56 +12:00
|
|
|
|
private void PictureBoxMenuAlwaysOpen_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
|
|
|
|
|
if (Config.AlwaysOpenByPin)
|
|
|
|
|
{
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapPinActive, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-26 23:24:56 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapPin, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-26 23:24:56 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pictureBox.Tag != null && (bool)pictureBox.Tag)
|
|
|
|
|
{
|
2021-11-17 12:13:46 +13:00
|
|
|
|
Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height);
|
2021-06-26 23:24:56 +12:00
|
|
|
|
ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-04 07:24:22 +13:00
|
|
|
|
private void TimerUpdateLoadingMenu_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
pictureBoxMenuAlwaysOpen.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadingMenu_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
2021-10-11 04:33:54 +13:00
|
|
|
|
rotationAngle += 5;
|
2021-10-04 07:24:22 +13:00
|
|
|
|
e.Graphics.DrawImage(
|
2021-10-26 08:45:49 +13:00
|
|
|
|
ImagingHelper.RotateImage(Resources.StaticResources.LoadingIcon.ToBitmap(), rotationAngle),
|
2021-10-04 07:24:22 +13:00
|
|
|
|
new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-26 23:24:56 +12:00
|
|
|
|
private void PictureBoxMenuOpenFolder_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
|
2021-08-16 21:48:35 +12:00
|
|
|
|
e.Graphics.DrawImage(AppColors.BitmapOpenFolder, new Rectangle(Point.Empty, pictureBox.ClientSize));
|
2021-06-26 23:24:56 +12:00
|
|
|
|
|
|
|
|
|
if (pictureBox.Tag != null && (bool)pictureBox.Tag)
|
|
|
|
|
{
|
2021-11-17 12:13:46 +13:00
|
|
|
|
Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height);
|
2021-06-26 23:24:56 +12:00
|
|
|
|
ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBoxMenuAlwaysOpen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PictureBox pictureBox = (PictureBox)sender;
|
|
|
|
|
Config.AlwaysOpenByPin = !Config.AlwaysOpenByPin;
|
|
|
|
|
pictureBox.Invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PictureBoxOpenFolder_Click(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
UserClickedOpenFolder?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-24 08:53:46 +12:00
|
|
|
|
|
|
|
|
|
private void TimerUpdateIcons_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int iconsToUpdate = 0;
|
|
|
|
|
|
|
|
|
|
foreach (DataGridViewRow row in dgv.Rows)
|
|
|
|
|
{
|
|
|
|
|
RowData rowData = (RowData)row.Cells[2].Value;
|
|
|
|
|
rowData.RowIndex = row.Index;
|
|
|
|
|
|
|
|
|
|
if (rowData.IconLoading)
|
|
|
|
|
{
|
|
|
|
|
iconsToUpdate++;
|
2021-09-25 01:37:58 +12:00
|
|
|
|
row.Cells[0].Value = rowData.ReadLoadedIcon();
|
2021-09-24 08:53:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (iconsToUpdate < 1)
|
|
|
|
|
{
|
|
|
|
|
timerUpdateIcons.Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-08 00:28:59 +12:00
|
|
|
|
}
|
2019-07-05 05:04:14 +12:00
|
|
|
|
}
|