diff --git a/Business/App.cs b/Business/App.cs index b78b76f..885128a 100644 --- a/Business/App.cs +++ b/Business/App.cs @@ -25,8 +25,6 @@ namespace SystemTrayMenu SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; menus.LoadStarted += menuNotifyIcon.LoadingStart; menus.LoadStopped += menuNotifyIcon.LoadingStop; - menuNotifyIcon.Exit += Application.Exit; - menuNotifyIcon.Restart += AppRestart.ByMenuNotifyIcon; menuNotifyIcon.Click += () => menus.SwitchOpenClose(true); menuNotifyIcon.OpenLog += Log.OpenLogFile; menus.MainPreload(); diff --git a/Config/AppColors.cs b/Config/AppColors.cs index 6f6927e..8122cce 100644 --- a/Config/AppColors.cs +++ b/Config/AppColors.cs @@ -88,6 +88,10 @@ namespace SystemTrayMenu public static Bitmap BitmapPin { get; set; } + public static Bitmap BitmapSettings { get; set; } + + public static Bitmap BitmapRestart { get; set; } + public static Bitmap BitmapPinActive { get; set; } public static Bitmap BitmapSearch { get; set; } diff --git a/Config/Config.cs b/Config/Config.cs index d444b3a..d858c78 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -43,6 +43,8 @@ namespace SystemTrayMenu AppColors.BitmapOpenFolder.Dispose(); AppColors.BitmapPin.Dispose(); AppColors.BitmapPinActive.Dispose(); + AppColors.BitmapSettings.Dispose(); + AppColors.BitmapRestart.Dispose(); AppColors.BitmapSearch.Dispose(); AppColors.BitmapFoldersCount.Dispose(); AppColors.BitmapFilesCount.Dispose(); @@ -263,6 +265,8 @@ namespace SystemTrayMenu AppColors.BitmapOpenFolder = ReadSvg(Properties.Resources.ic_fluent_folder_arrow_right_48_regular, htmlColorCodeIcons); AppColors.BitmapPin = ReadSvg(Properties.Resources.ic_fluent_pin_48_regular, htmlColorCodeIcons); + AppColors.BitmapSettings = ReadSvg(Properties.Resources.ic_fluent_settings_28_regular, htmlColorCodeIcons); + AppColors.BitmapRestart = ReadSvg(Properties.Resources.ic_fluent_arrow_sync_24_regular, htmlColorCodeIcons); AppColors.BitmapPinActive = ReadSvg(Properties.Resources.ic_fluent_pin_48_filled, htmlColorCodeIcons); AppColors.BitmapSearch = ReadSvg(Properties.Resources.ic_fluent_search_48_regular, htmlColorCodeIcons); AppColors.BitmapFoldersCount = ReadSvg(Properties.Resources.ic_fluent_folder_48_regular, htmlColorCodeIcons); diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index d7118fa..51f4b54 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.2")] -[assembly: AssemblyFileVersion("1.1.0.2")] +[assembly: AssemblyVersion("1.1.0.3")] +[assembly: AssemblyFileVersion("1.1.0.3")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 03d2414..28bfba8 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -60,6 +60,16 @@ namespace SystemTrayMenu.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + /// + public static byte[] ic_fluent_arrow_sync_24_regular { + get { + object obj = ResourceManager.GetObject("ic_fluent_arrow_sync_24_regular", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. /// @@ -120,6 +130,16 @@ namespace SystemTrayMenu.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. + /// + public static byte[] ic_fluent_settings_28_regular { + get { + object obj = ResourceManager.GetObject("ic_fluent_settings_28_regular", resourceCulture); + return ((byte[])(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). /// diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 556eced..2e6c21c 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + ..\Resources\White50Percentage.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -148,4 +148,10 @@ ..\Resources\Loading.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\ic_fluent_arrow_sync_24_regular.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\ic_fluent_settings_28_regular.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/Resources/ic_fluent_arrow_sync_24_regular.svg b/Resources/ic_fluent_arrow_sync_24_regular.svg new file mode 100644 index 0000000..f735b57 --- /dev/null +++ b/Resources/ic_fluent_arrow_sync_24_regular.svg @@ -0,0 +1,3 @@ + + + diff --git a/Resources/ic_fluent_settings_28_regular.svg b/Resources/ic_fluent_settings_28_regular.svg new file mode 100644 index 0000000..b459d88 --- /dev/null +++ b/Resources/ic_fluent_settings_28_regular.svg @@ -0,0 +1,4 @@ + + + + diff --git a/UserInterface/AppContextMenu.cs b/UserInterface/AppContextMenu.cs index 99dc8ce..71ff59c 100644 --- a/UserInterface/AppContextMenu.cs +++ b/UserInterface/AppContextMenu.cs @@ -16,10 +16,6 @@ namespace SystemTrayMenu.Helper { public event EventHandlerEmpty ClickedOpenLog; - public event EventHandlerEmpty ClickedRestart; - - public event EventHandlerEmpty ClickedExit; - public ContextMenuStrip Create() { ContextMenuStrip menu = new() @@ -124,7 +120,7 @@ namespace SystemTrayMenu.Helper restart.Click += Restart_Click; void Restart_Click(object sender, EventArgs e) { - ClickedRestart?.Invoke(); + AppRestart.ByAppContextMenu(); } menu.Items.Add(restart); @@ -136,7 +132,7 @@ namespace SystemTrayMenu.Helper exit.Click += Exit_Click; void Exit_Click(object sender, EventArgs e) { - ClickedExit?.Invoke(); + Application.Exit(); } menu.Items.Add(exit); diff --git a/UserInterface/AppNotifyIcon.cs b/UserInterface/AppNotifyIcon.cs index f403b75..f876a7f 100644 --- a/UserInterface/AppNotifyIcon.cs +++ b/UserInterface/AppNotifyIcon.cs @@ -35,18 +35,6 @@ namespace SystemTrayMenu.UserInterface OpenLog?.Invoke(); } - contextMenus.ClickedRestart += ClickedRestart; - void ClickedRestart() - { - Restart?.Invoke(); - } - - contextMenus.ClickedExit += ClickedExit; - void ClickedExit() - { - Exit?.Invoke(); - } - notifyIcon.ContextMenuStrip = contextMenus.Create(); notifyIcon.MouseClick += NotifyIcon_MouseClick; void NotifyIcon_MouseClick(object sender, MouseEventArgs e) @@ -65,10 +53,6 @@ namespace SystemTrayMenu.UserInterface public event EventHandlerEmpty OpenLog; - public event EventHandlerEmpty Restart; - - public event EventHandlerEmpty Exit; - public void Dispose() { notifyIcon.Icon = null; diff --git a/UserInterface/Menu.ControlsTheDesignerRemoves.cs b/UserInterface/Menu.ControlsTheDesignerRemoves.cs index 9dd31de..000f245 100644 --- a/UserInterface/Menu.ControlsTheDesignerRemoves.cs +++ b/UserInterface/Menu.ControlsTheDesignerRemoves.cs @@ -98,13 +98,21 @@ namespace SystemTrayMenu.UserInterface customScrollbar.Name = "customScrollbar"; customScrollbar.Size = new Size(Scaling.Scale(15), 40); + pictureBoxOpenFolder.Size = new Size( + Scaling.Scale(pictureBoxOpenFolder.Width), + Scaling.Scale(pictureBoxOpenFolder.Height)); + pictureBoxMenuAlwaysOpen.Size = new Size( Scaling.Scale(pictureBoxMenuAlwaysOpen.Width), Scaling.Scale(pictureBoxMenuAlwaysOpen.Height)); - pictureBoxOpenFolder.Size = new Size( - Scaling.Scale(pictureBoxOpenFolder.Width), - Scaling.Scale(pictureBoxOpenFolder.Height)); + pictureBoxSettings.Size = new Size( + Scaling.Scale(pictureBoxSettings.Width), + Scaling.Scale(pictureBoxSettings.Height)); + + pictureBoxRestart.Size = new Size( + Scaling.Scale(pictureBoxRestart.Width), + Scaling.Scale(pictureBoxRestart.Height)); pictureBoxSearch.Size = new Size( Scaling.Scale(pictureBoxSearch.Width), diff --git a/UserInterface/Menu.Designer.cs b/UserInterface/Menu.Designer.cs index 174f4ad..c67eb34 100644 --- a/UserInterface/Menu.Designer.cs +++ b/UserInterface/Menu.Designer.cs @@ -48,6 +48,8 @@ this.tableLayoutPanelTitle = new System.Windows.Forms.TableLayoutPanel(); this.pictureBoxOpenFolder = new System.Windows.Forms.PictureBox(); this.pictureBoxMenuAlwaysOpen = new System.Windows.Forms.PictureBox(); + this.pictureBoxSettings = new System.Windows.Forms.PictureBox(); + this.pictureBoxRestart = new System.Windows.Forms.PictureBox(); this.timerUpdateIcons = new System.Windows.Forms.Timer(this.components); this.tableLayoutPanelDgvAndScrollbar.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit(); @@ -59,6 +61,8 @@ this.tableLayoutPanelTitle.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpenFolder)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMenuAlwaysOpen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxRestart)).BeginInit(); this.SuspendLayout(); // // tableLayoutPanelDgvAndScrollbar @@ -241,12 +245,16 @@ this.tableLayoutPanelTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanelTitle.AutoSize = true; this.tableLayoutPanelTitle.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.tableLayoutPanelTitle.ColumnCount = 3; + this.tableLayoutPanelTitle.ColumnCount = 5; this.tableLayoutPanelTitle.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanelTitle.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanelTitle.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelTitle.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelTitle.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanelTitle.Controls.Add(this.pictureBoxOpenFolder, 0, 0); this.tableLayoutPanelTitle.Controls.Add(this.pictureBoxMenuAlwaysOpen, 2, 0); + this.tableLayoutPanelTitle.Controls.Add(this.pictureBoxSettings, 3, 0); + this.tableLayoutPanelTitle.Controls.Add(this.pictureBoxRestart, 4, 0); this.tableLayoutPanelTitle.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanelTitle.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanelTitle.Name = "tableLayoutPanelTitle"; @@ -265,7 +273,7 @@ this.pictureBoxOpenFolder.Size = new System.Drawing.Size(20, 20); this.pictureBoxOpenFolder.TabIndex = 1; this.pictureBoxOpenFolder.TabStop = false; - this.pictureBoxOpenFolder.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBoxMenuOpenFolder_Paint); + this.pictureBoxOpenFolder.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBoxOpenFolder_Paint); this.pictureBoxOpenFolder.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PictureBoxOpenFolder_Click); this.pictureBoxOpenFolder.MouseEnter += new System.EventHandler(this.PictureBox_MouseEnter); this.pictureBoxOpenFolder.MouseLeave += new System.EventHandler(this.PictureBox_MouseLeave); @@ -275,7 +283,7 @@ // this.pictureBoxMenuAlwaysOpen.BackColor = System.Drawing.Color.Transparent; this.pictureBoxMenuAlwaysOpen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.pictureBoxMenuAlwaysOpen.Location = new System.Drawing.Point(108, 1); + this.pictureBoxMenuAlwaysOpen.Location = new System.Drawing.Point(64, 1); this.pictureBoxMenuAlwaysOpen.Margin = new System.Windows.Forms.Padding(1); this.pictureBoxMenuAlwaysOpen.Name = "pictureBoxMenuAlwaysOpen"; this.pictureBoxMenuAlwaysOpen.Size = new System.Drawing.Size(20, 20); @@ -287,6 +295,38 @@ this.pictureBoxMenuAlwaysOpen.MouseEnter += new System.EventHandler(this.PictureBox_MouseEnter); this.pictureBoxMenuAlwaysOpen.MouseLeave += new System.EventHandler(this.PictureBox_MouseLeave); this.pictureBoxMenuAlwaysOpen.Resize += new System.EventHandler(this.PictureBox_Resize); + // + // pictureBoxSettings + // + this.pictureBoxSettings.BackColor = System.Drawing.Color.Transparent; + this.pictureBoxSettings.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pictureBoxSettings.Location = new System.Drawing.Point(86, 1); + this.pictureBoxSettings.Margin = new System.Windows.Forms.Padding(1); + this.pictureBoxSettings.Name = "pictureBoxSettings"; + this.pictureBoxSettings.Size = new System.Drawing.Size(20, 20); + this.pictureBoxSettings.TabIndex = 2; + this.pictureBoxSettings.TabStop = false; + this.pictureBoxSettings.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBoxSettings_Paint); + this.pictureBoxSettings.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PictureBoxSettings_MouseClick); + this.pictureBoxSettings.MouseEnter += new System.EventHandler(this.PictureBox_MouseEnter); + this.pictureBoxSettings.MouseLeave += new System.EventHandler(this.PictureBox_MouseLeave); + this.pictureBoxSettings.Resize += new System.EventHandler(this.PictureBox_Resize); + // + // pictureBoxRestart + // + this.pictureBoxRestart.BackColor = System.Drawing.Color.Transparent; + this.pictureBoxRestart.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.pictureBoxRestart.Location = new System.Drawing.Point(108, 1); + this.pictureBoxRestart.Margin = new System.Windows.Forms.Padding(1); + this.pictureBoxRestart.Name = "pictureBoxRestart"; + this.pictureBoxRestart.Size = new System.Drawing.Size(20, 20); + this.pictureBoxRestart.TabIndex = 3; + this.pictureBoxRestart.TabStop = false; + this.pictureBoxRestart.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBoxRestart_Paint); + this.pictureBoxRestart.MouseClick += new System.Windows.Forms.MouseEventHandler(this.PictureBoxRestart_MouseClick); + this.pictureBoxRestart.MouseEnter += new System.EventHandler(this.PictureBox_MouseEnter); + this.pictureBoxRestart.MouseLeave += new System.EventHandler(this.PictureBox_MouseLeave); + this.pictureBoxRestart.Resize += new System.EventHandler(this.PictureBox_Resize); // // Controls like the scrollbar are removed when open the designer // When adding after InitializeComponent(), then e.g. scrollbar on high dpi not more working @@ -295,7 +335,6 @@ // // timerUpdateIcons // - this.timerUpdateIcons.Interval = 100; this.timerUpdateIcons.Tick += new System.EventHandler(this.TimerUpdateIcons_Tick); // // Menu @@ -327,6 +366,8 @@ this.tableLayoutPanelTitle.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxOpenFolder)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxMenuAlwaysOpen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxSettings)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxRestart)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -351,5 +392,7 @@ private System.Windows.Forms.PictureBox pictureBoxFoldersCount; private System.Windows.Forms.Label labelFoldersCount; private System.Windows.Forms.Timer timerUpdateIcons; + private System.Windows.Forms.PictureBox pictureBoxSettings; + private System.Windows.Forms.PictureBox pictureBoxRestart; } } \ No newline at end of file diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 6406cae..72d8ad2 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -137,8 +137,10 @@ namespace SystemTrayMenu.UserInterface dgv.MouseEnter += ControlsMouseEnter; labelTitle.MouseEnter += ControlsMouseEnter; textBoxSearch.MouseEnter += ControlsMouseEnter; - pictureBoxMenuAlwaysOpen.MouseEnter += ControlsMouseEnter; pictureBoxOpenFolder.MouseEnter += ControlsMouseEnter; + pictureBoxMenuAlwaysOpen.MouseEnter += ControlsMouseEnter; + pictureBoxSettings.MouseEnter += ControlsMouseEnter; + pictureBoxRestart.MouseEnter += ControlsMouseEnter; pictureBoxSearch.MouseEnter += ControlsMouseEnter; pictureBoxFilesCount.MouseEnter += ControlsMouseEnter; pictureBoxFoldersCount.MouseEnter += ControlsMouseEnter; @@ -156,6 +158,8 @@ namespace SystemTrayMenu.UserInterface textBoxSearch.MouseLeave += ControlsMouseLeave; pictureBoxMenuAlwaysOpen.MouseLeave += ControlsMouseLeave; pictureBoxOpenFolder.MouseLeave += ControlsMouseLeave; + pictureBoxSettings.MouseLeave += ControlsMouseLeave; + pictureBoxRestart.MouseLeave += ControlsMouseLeave; pictureBoxSearch.MouseLeave += ControlsMouseLeave; pictureBoxFilesCount.MouseLeave += ControlsMouseLeave; pictureBoxFoldersCount.MouseLeave += ControlsMouseLeave; @@ -179,6 +183,8 @@ namespace SystemTrayMenu.UserInterface internal event EventHandlerEmpty UserClickedOpenFolder; + internal event EventHandlerEmpty UserClickedRestart; + internal event EventHandler CmdKeyProcessed; internal event EventHandlerEmpty SearchTextChanging; @@ -254,6 +260,8 @@ namespace SystemTrayMenu.UserInterface if (type != MenuType.Main) { pictureBoxMenuAlwaysOpen.Visible = false; + pictureBoxSettings.Visible = false; + pictureBoxRestart.Visible = false; } switch (type) @@ -285,9 +293,8 @@ namespace SystemTrayMenu.UserInterface pictureBoxMenuAlwaysOpen.Paint -= PictureBoxMenuAlwaysOpen_Paint; pictureBoxMenuAlwaysOpen.Paint += LoadingMenu_Paint; timerUpdateIcons.Tick -= TimerUpdateIcons_Tick; - timerUpdateIcons.Tick += TimerUpdateLoadingMenu_Tick; + timerUpdateIcons.Tick += (sender, e) => pictureBoxMenuAlwaysOpen.Invalidate(); timerUpdateIcons.Interval = 15; - pictureBoxMenuAlwaysOpen.Visible = true; break; default: break; @@ -787,22 +794,25 @@ namespace SystemTrayMenu.UserInterface pictureBox.Invalidate(); } - private void PictureBoxSearch_Paint(object sender, PaintEventArgs e) + private void PictureBoxOpenFolder_Paint(object sender, PaintEventArgs e) { PictureBox pictureBox = (PictureBox)sender; - e.Graphics.DrawImage(AppColors.BitmapSearch, new Rectangle(Point.Empty, pictureBox.ClientSize)); + + e.Graphics.DrawImage(AppColors.BitmapOpenFolder, new Rectangle(Point.Empty, pictureBox.ClientSize)); + + if (pictureBox.Tag != null && (bool)pictureBox.Tag) + { + Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height); + ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid); + } } - private void PictureBoxFoldersCount_Paint(object sender, PaintEventArgs e) + private void PictureBoxOpenFolder_Click(object sender, MouseEventArgs e) { - PictureBox pictureBox = (PictureBox)sender; - e.Graphics.DrawImage(AppColors.BitmapFoldersCount, new Rectangle(Point.Empty, pictureBox.ClientSize)); - } - - private void PictureBoxFilesCount_Paint(object sender, PaintEventArgs e) - { - PictureBox pictureBox = (PictureBox)sender; - e.Graphics.DrawImage(AppColors.BitmapFilesCount, new Rectangle(Point.Empty, pictureBox.ClientSize)); + if (e.Button == MouseButtons.Left) + { + UserClickedOpenFolder?.Invoke(); + } } private void PictureBoxMenuAlwaysOpen_Paint(object sender, PaintEventArgs e) @@ -825,9 +835,85 @@ namespace SystemTrayMenu.UserInterface } } - private void TimerUpdateLoadingMenu_Tick(object sender, EventArgs e) + private void PictureBoxMenuAlwaysOpen_Click(object sender, EventArgs e) { - pictureBoxMenuAlwaysOpen.Invalidate(); + PictureBox pictureBox = (PictureBox)sender; + Config.AlwaysOpenByPin = !Config.AlwaysOpenByPin; + pictureBox.Invalidate(); + } + + private void PictureBoxSettings_Paint(object sender, PaintEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + + e.Graphics.DrawImage(AppColors.BitmapSettings, new Rectangle(Point.Empty, pictureBox.ClientSize)); + + if (pictureBox.Tag != null && (bool)pictureBox.Tag) + { + Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height); + ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid); + } + } + + private void PictureBoxSettings_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + SettingsForm settingsForm = new(); + if (settingsForm.ShowDialog() == DialogResult.OK) + { + AppRestart.ByConfigChange(); + } + } + } + + private void PictureBoxRestart_Paint(object sender, PaintEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + + e.Graphics.DrawImage(AppColors.BitmapRestart, new Rectangle(Point.Empty, pictureBox.ClientSize)); + + if (pictureBox.Tag != null && (bool)pictureBox.Tag) + { + Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height); + ControlPaint.DrawBorder(e.Graphics, rowBounds, MenuDefines.ColorSelectedItemBorder, ButtonBorderStyle.Solid); + } + } + + private void PictureBoxRestart_MouseClick(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + AppRestart.ByMenuButton(); + } + } + + private void PictureBoxRestart_Click(object sender, EventArgs e) + { + + } + + private void PictureBoxSettings_Click(object sender, EventArgs e) + { + + } + + private void PictureBoxSearch_Paint(object sender, PaintEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + e.Graphics.DrawImage(AppColors.BitmapSearch, new Rectangle(Point.Empty, pictureBox.ClientSize)); + } + + private void PictureBoxFoldersCount_Paint(object sender, PaintEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + e.Graphics.DrawImage(AppColors.BitmapFoldersCount, new Rectangle(Point.Empty, pictureBox.ClientSize)); + } + + private void PictureBoxFilesCount_Paint(object sender, PaintEventArgs e) + { + PictureBox pictureBox = (PictureBox)sender; + e.Graphics.DrawImage(AppColors.BitmapFilesCount, new Rectangle(Point.Empty, pictureBox.ClientSize)); } private void LoadingMenu_Paint(object sender, PaintEventArgs e) @@ -839,34 +925,6 @@ namespace SystemTrayMenu.UserInterface new Rectangle(Point.Empty, new Size(pictureBox.ClientSize.Width - 2, pictureBox.ClientSize.Height - 2))); } - private void PictureBoxMenuOpenFolder_Paint(object sender, PaintEventArgs e) - { - PictureBox pictureBox = (PictureBox)sender; - - e.Graphics.DrawImage(AppColors.BitmapOpenFolder, new Rectangle(Point.Empty, pictureBox.ClientSize)); - - if (pictureBox.Tag != null && (bool)pictureBox.Tag) - { - Rectangle rowBounds = new(0, 0, pictureBox.Width, pictureBox.Height); - 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(); - } - } - private void TimerUpdateIcons_Tick(object sender, EventArgs e) { int iconsToUpdate = 0; diff --git a/Utilities/AppRestart.cs b/Utilities/AppRestart.cs index f20bd53..cdf7ec8 100644 --- a/Utilities/AppRestart.cs +++ b/Utilities/AppRestart.cs @@ -19,7 +19,7 @@ namespace SystemTrayMenu.Utilities Restart(GetCurrentMethod()); } - internal static void ByMenuNotifyIcon() + internal static void ByAppContextMenu() { Restart(GetCurrentMethod()); } @@ -34,6 +34,11 @@ namespace SystemTrayMenu.Utilities Restart(GetCurrentMethod()); } + internal static void ByMenuButton() + { + Restart(GetCurrentMethod()); + } + private static void Restart(string reason) { BeforeRestarting?.Invoke();