From b70f966371a38f3fd0c45fafca57d2e218d873af Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Sat, 13 Nov 2021 19:44:32 +0100 Subject: [PATCH] [Feature] Round corners (#236), version 1.0.26.0 --- Helpers/ImagingHelper.cs | 2 +- NativeDllImport/CreateRoundRectRgn.cs | 29 ++++++++++++++++++++++++++ Properties/AssemblyInfo.cs | 4 ++-- Properties/Settings.Designer.cs | 16 ++++++++++++++ Resources/lang.Designer.cs | 9 ++++++++ Resources/lang.cs-CZ.resx | 6 ++++++ Resources/lang.de-DE.resx | 6 ++++++ Resources/lang.es-ES.resx | 6 ++++++ Resources/lang.fr-FR.resx | 6 ++++++ Resources/lang.it-IT.resx | 6 ++++++ Resources/lang.ja-JP.resx | 6 ++++++ Resources/lang.ko-KR.resx | 6 ++++++ Resources/lang.nl-NL.resx | 6 ++++++ Resources/lang.pt-BR.resx | 6 ++++++ Resources/lang.resx | 3 +++ Resources/lang.ru-RU.resx | 6 ++++++ Resources/lang.tr-TR.resx | 6 ++++++ Resources/lang.vi-VN.resx | 6 ++++++ Resources/lang.zh-CN.resx | 6 ++++++ UserInterface/Menu.cs | 5 +++++ UserInterface/SettingsForm.Designer.cs | 23 ++++++++++++++++---- UserInterface/SettingsForm.cs | 4 ++++ Utilities/File/IconReader.cs | 1 - 23 files changed, 166 insertions(+), 8 deletions(-) create mode 100644 NativeDllImport/CreateRoundRectRgn.cs diff --git a/Helpers/ImagingHelper.cs b/Helpers/ImagingHelper.cs index 0167123..3d8f674 100644 --- a/Helpers/ImagingHelper.cs +++ b/Helpers/ImagingHelper.cs @@ -24,7 +24,7 @@ namespace SystemTrayMenu.Helper /// Wether or not the icon was succesfully generated. public static bool ConvertToIcon(Stream input, Stream output, int size = 16, bool preserveAspectRatio = false) { - Bitmap inputBitmap = (Bitmap)Bitmap.FromStream(input); + Bitmap inputBitmap = (Bitmap)Image.FromStream(input); if (inputBitmap != null) { int width, height; diff --git a/NativeDllImport/CreateRoundRectRgn.cs b/NativeDllImport/CreateRoundRectRgn.cs new file mode 100644 index 0000000..5d0e63c --- /dev/null +++ b/NativeDllImport/CreateRoundRectRgn.cs @@ -0,0 +1,29 @@ +// +// Copyright (c) PlaceholderCompany. All rights reserved. +// + +namespace SystemTrayMenu.DllImports +{ + using System; + using System.Runtime.InteropServices; + + /// + /// wraps the methodcalls to native windows dll's. + /// + public static partial class NativeMethods + { + public static IntPtr CreateRoundCorners(int width, int height, int widthEllipse, int heightEllipse) + { + return CreateRoundRectRgn(0, 0, width, height, widthEllipse, heightEllipse); + } + + [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn", SetLastError = true, CharSet = CharSet.Unicode)] + private static extern IntPtr CreateRoundRectRgn( + int nLeftRect, // x-coordinate of upper-left corner + int nTopRect, // y-coordinate of upper-left corner + int nRightRect, // x-coordinate of lower-right corner + int nBottomRect, // y-coordinate of lower-right corner + int nWidthEllipse, // width of ellipse + int nHeightEllipse); // height of ellipse + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index c46b45b..38a21ad 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.0.25.9")] -[assembly: AssemblyFileVersion("1.0.25.9")] +[assembly: AssemblyVersion("1.0.26.0")] +[assembly: AssemblyFileVersion("1.0.26.0")] diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index b74c8c7..34651c3 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -283,6 +283,22 @@ namespace SystemTrayMenu.Properties } } + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("true")] + public bool RoundCorners + { + get + { + return ((bool)(this["RoundCorners"])); + } + set + { + this["RoundCorners"] = value; + } + } + [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] diff --git a/Resources/lang.Designer.cs b/Resources/lang.Designer.cs index 26497af..40a2259 100644 --- a/Resources/lang.Designer.cs +++ b/Resources/lang.Designer.cs @@ -673,6 +673,15 @@ namespace SystemTrayMenu.Resources { } } + /// + /// Looks up a localized string similar to Round corners. + /// + internal static string Round_corners { + get { + return ResourceManager.GetString("Round corners", resourceCulture); + } + } + /// /// Looks up a localized string similar to Row height in percentage. /// diff --git a/Resources/lang.cs-CZ.resx b/Resources/lang.cs-CZ.resx index a2ccfbd..dd107ea 100644 --- a/Resources/lang.cs-CZ.resx +++ b/Resources/lang.cs-CZ.resx @@ -399,4 +399,10 @@ Přidejte ukázkovou složku 'Start Menu' + + Kulaté rohy + + + Výška řádku v procentech + \ No newline at end of file diff --git a/Resources/lang.de-DE.resx b/Resources/lang.de-DE.resx index f482761..ef54628 100644 --- a/Resources/lang.de-DE.resx +++ b/Resources/lang.de-DE.resx @@ -399,4 +399,10 @@ Beispielordner 'Startmenü' hinzufügen + + Runde Ecken + + + Zeilenhöhe in Prozent + \ No newline at end of file diff --git a/Resources/lang.es-ES.resx b/Resources/lang.es-ES.resx index 74cf2e4..b4e719a 100644 --- a/Resources/lang.es-ES.resx +++ b/Resources/lang.es-ES.resx @@ -399,4 +399,10 @@ Agregar carpeta de muestra 'Menú Inicio' + + Esquinas redondas + + + Altura de fila en porcentaje + \ No newline at end of file diff --git a/Resources/lang.fr-FR.resx b/Resources/lang.fr-FR.resx index 4ad4715..05adf2c 100644 --- a/Resources/lang.fr-FR.resx +++ b/Resources/lang.fr-FR.resx @@ -399,4 +399,10 @@ Ajouter un exemple de dossier 'Start Menu' + + Coins arrondis + + + Hauteur de ligne en pourcentage + \ No newline at end of file diff --git a/Resources/lang.it-IT.resx b/Resources/lang.it-IT.resx index 26921e6..e7c6403 100644 --- a/Resources/lang.it-IT.resx +++ b/Resources/lang.it-IT.resx @@ -399,4 +399,10 @@ Aggiungi la cartella "Start Menu" di esempio + + Angoli arrotondati + + + Altezza riga in percentuale + \ No newline at end of file diff --git a/Resources/lang.ja-JP.resx b/Resources/lang.ja-JP.resx index 8c87690..0c719ba 100644 --- a/Resources/lang.ja-JP.resx +++ b/Resources/lang.ja-JP.resx @@ -399,4 +399,10 @@ サンプルの「スタートメニュー」フォルダを追加します + + 丸い角 + + + 行の高さ(パーセンテージ) + \ No newline at end of file diff --git a/Resources/lang.ko-KR.resx b/Resources/lang.ko-KR.resx index 258b261..1a5544b 100644 --- a/Resources/lang.ko-KR.resx +++ b/Resources/lang.ko-KR.resx @@ -399,4 +399,10 @@ 샘플 '시작 메뉴' 폴더 추가 + + 둥근 모서리 + + + 행 높이(%) + \ No newline at end of file diff --git a/Resources/lang.nl-NL.resx b/Resources/lang.nl-NL.resx index 68e10b7..0c99fff 100644 --- a/Resources/lang.nl-NL.resx +++ b/Resources/lang.nl-NL.resx @@ -399,4 +399,10 @@ Voorbeeldmap 'Start Menu' toevoegen + + Ronde hoeken + + + Rijhoogte in procenten + \ No newline at end of file diff --git a/Resources/lang.pt-BR.resx b/Resources/lang.pt-BR.resx index 622cfc3..f44974a 100644 --- a/Resources/lang.pt-BR.resx +++ b/Resources/lang.pt-BR.resx @@ -399,4 +399,10 @@ Adicionar amostra da pasta 'Menu Iniciar' + + Cantos arredondados + + + Altura da linha em porcentagem + \ No newline at end of file diff --git a/Resources/lang.resx b/Resources/lang.resx index 4901fc0..2e02ec0 100644 --- a/Resources/lang.resx +++ b/Resources/lang.resx @@ -402,4 +402,7 @@ Row height in percentage + + Round corners + \ No newline at end of file diff --git a/Resources/lang.ru-RU.resx b/Resources/lang.ru-RU.resx index 2ed584f..94a55ed 100644 --- a/Resources/lang.ru-RU.resx +++ b/Resources/lang.ru-RU.resx @@ -399,4 +399,10 @@ Добавить образец папки "Меню Пуск" + + Закругленные углы + + + Высота строки в процентах + \ No newline at end of file diff --git a/Resources/lang.tr-TR.resx b/Resources/lang.tr-TR.resx index 01962d7..eaea4f4 100644 --- a/Resources/lang.tr-TR.resx +++ b/Resources/lang.tr-TR.resx @@ -399,4 +399,10 @@ Örnek 'Başlat Menüsü' klasörü ekleyin + + Yuvarlak köşeler + + + Yüzde olarak satır yüksekliği + \ No newline at end of file diff --git a/Resources/lang.vi-VN.resx b/Resources/lang.vi-VN.resx index 39451d6..acb9eb3 100644 --- a/Resources/lang.vi-VN.resx +++ b/Resources/lang.vi-VN.resx @@ -399,4 +399,10 @@ Thêm thư mục 'Start Menu' mẫu + + Góc tròn + + + Chiều cao hàng tính bằng phần trăm + \ No newline at end of file diff --git a/Resources/lang.zh-CN.resx b/Resources/lang.zh-CN.resx index b7fec2a..835a3cf 100644 --- a/Resources/lang.zh-CN.resx +++ b/Resources/lang.zh-CN.resx @@ -399,4 +399,10 @@ 添加示例“开始菜单”文件夹 + + 圆角 + + + 行高百分比 + \ No newline at end of file diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index b886f65..36c5797 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -479,6 +479,11 @@ namespace SystemTrayMenu.UserInterface // Update position Location = new Point(x, y); + + if (Properties.Settings.Default.RoundCorners) + { + Region = Region.FromHrgn(NativeMethods.CreateRoundCorners(Width, Height + 1, 15, 15)); + } } internal void KeyPressedSearch(string letter) diff --git a/UserInterface/SettingsForm.Designer.cs b/UserInterface/SettingsForm.Designer.cs index 8f5217c..e73ce8d 100644 --- a/UserInterface/SettingsForm.Designer.cs +++ b/UserInterface/SettingsForm.Designer.cs @@ -85,6 +85,7 @@ namespace SystemTrayMenu.UserInterface this.checkBoxOpenItemWithOneClick = new System.Windows.Forms.CheckBox(); this.groupBoxSizeAndLocation = new System.Windows.Forms.GroupBox(); this.tableLayoutPanelSizeAndLocation = new System.Windows.Forms.TableLayoutPanel(); + this.checkBoxRoundCorners = new System.Windows.Forms.CheckBox(); this.tableLayoutPanel11 = new System.Windows.Forms.TableLayoutPanel(); this.numericUpDownRowHeighteInPercentage = new System.Windows.Forms.NumericUpDown(); this.labelRowHeightInPercentage = new System.Windows.Forms.Label(); @@ -1225,7 +1226,7 @@ namespace SystemTrayMenu.UserInterface this.groupBoxSizeAndLocation.MinimumSize = new System.Drawing.Size(400, 0); this.groupBoxSizeAndLocation.Name = "groupBoxSizeAndLocation"; this.groupBoxSizeAndLocation.Padding = new System.Windows.Forms.Padding(3, 3, 3, 6); - this.groupBoxSizeAndLocation.Size = new System.Drawing.Size(400, 216); + this.groupBoxSizeAndLocation.Size = new System.Drawing.Size(400, 241); this.groupBoxSizeAndLocation.TabIndex = 0; this.groupBoxSizeAndLocation.TabStop = false; this.groupBoxSizeAndLocation.Text = "groupBoxSizeAndLocation"; @@ -1236,6 +1237,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelSizeAndLocation.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tableLayoutPanelSizeAndLocation.ColumnCount = 1; this.tableLayoutPanelSizeAndLocation.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanelSizeAndLocation.Controls.Add(this.checkBoxRoundCorners, 0, 7); this.tableLayoutPanelSizeAndLocation.Controls.Add(this.tableLayoutPanel11, 0, 1); this.tableLayoutPanelSizeAndLocation.Controls.Add(this.tableLayoutPanel2, 0, 0); this.tableLayoutPanelSizeAndLocation.Controls.Add(this.checkBoxAppearAtTheBottomLeft, 0, 6); @@ -1246,7 +1248,7 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelSizeAndLocation.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanelSizeAndLocation.Location = new System.Drawing.Point(3, 19); this.tableLayoutPanelSizeAndLocation.Name = "tableLayoutPanelSizeAndLocation"; - this.tableLayoutPanelSizeAndLocation.RowCount = 7; + this.tableLayoutPanelSizeAndLocation.RowCount = 8; this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); @@ -1254,9 +1256,21 @@ namespace SystemTrayMenu.UserInterface this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanelSizeAndLocation.Size = new System.Drawing.Size(394, 191); + this.tableLayoutPanelSizeAndLocation.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanelSizeAndLocation.Size = new System.Drawing.Size(394, 216); this.tableLayoutPanelSizeAndLocation.TabIndex = 0; // + // checkBoxRoundCorners + // + this.checkBoxRoundCorners.AutoSize = true; + this.checkBoxRoundCorners.Dock = System.Windows.Forms.DockStyle.Fill; + this.checkBoxRoundCorners.Location = new System.Drawing.Point(3, 194); + this.checkBoxRoundCorners.Name = "checkBoxRoundCorners"; + this.checkBoxRoundCorners.Size = new System.Drawing.Size(388, 19); + this.checkBoxRoundCorners.TabIndex = 4; + this.checkBoxRoundCorners.Text = "checkBoxRoundCorners"; + this.checkBoxRoundCorners.UseVisualStyleBackColor = true; + // // tableLayoutPanel11 // this.tableLayoutPanel11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); @@ -1444,7 +1458,7 @@ namespace SystemTrayMenu.UserInterface // this.buttonAdvancedDefault.AutoSize = true; this.buttonAdvancedDefault.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.buttonAdvancedDefault.Location = new System.Drawing.Point(9, 284); + this.buttonAdvancedDefault.Location = new System.Drawing.Point(9, 309); this.buttonAdvancedDefault.Margin = new System.Windows.Forms.Padding(9, 9, 3, 9); this.buttonAdvancedDefault.MinimumSize = new System.Drawing.Size(75, 25); this.buttonAdvancedDefault.Name = "buttonAdvancedDefault"; @@ -4714,5 +4728,6 @@ namespace SystemTrayMenu.UserInterface private System.Windows.Forms.TableLayoutPanel tableLayoutPanel10; private System.Windows.Forms.NumericUpDown numericUpDown1; private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox checkBoxRoundCorners; } } \ No newline at end of file diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index 6f1a4e5..4cabfb7 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -151,6 +151,7 @@ namespace SystemTrayMenu.UserInterface checkBoxAppearAtMouseLocation.Text = Translator.GetText("Appear at mouse location"); checkBoxShowInTaskbar.Text = Translator.GetText("Show in Taskbar"); checkBoxAppearAtTheBottomLeft.Text = Translator.GetText("Appear at the bottom left"); + checkBoxRoundCorners.Text = Translator.GetText("Round corners"); buttonAdvancedDefault.Text = Translator.GetText("Default"); groupBoxStaysOpen.Text = Translator.GetText("Stays open"); checkBoxStayOpenWhenItemClicked.Text = Translator.GetText("If an item was clicked"); @@ -362,6 +363,7 @@ namespace SystemTrayMenu.UserInterface checkBoxAppearAtMouseLocation.Checked = Settings.Default.AppearAtMouseLocation; checkBoxShowInTaskbar.Checked = Settings.Default.ShowInTaskbar; checkBoxAppearAtTheBottomLeft.Checked = Settings.Default.AppearAtTheBottomLeft; + checkBoxRoundCorners.Checked = Settings.Default.RoundCorners; checkBoxStayOpenWhenItemClicked.Checked = Settings.Default.StaysOpenWhenItemClicked; checkBoxStayOpenWhenFocusLost.Checked = Settings.Default.StaysOpenWhenFocusLost; @@ -722,6 +724,7 @@ namespace SystemTrayMenu.UserInterface Settings.Default.MaximumMenuHeight = (int)numericUpDownMenuHeight.Value; Settings.Default.ShowInTaskbar = checkBoxShowInTaskbar.Checked; Settings.Default.AppearAtTheBottomLeft = checkBoxAppearAtTheBottomLeft.Checked; + Settings.Default.RoundCorners = checkBoxRoundCorners.Checked; Settings.Default.StaysOpenWhenItemClicked = checkBoxStayOpenWhenItemClicked.Checked; Settings.Default.StaysOpenWhenFocusLost = checkBoxStayOpenWhenFocusLost.Checked; Settings.Default.TimeUntilCloses = (int)numericUpDownTimeUntilClose.Value; @@ -970,6 +973,7 @@ namespace SystemTrayMenu.UserInterface numericUpDownMenuHeight.Value = 600; checkBoxShowInTaskbar.Checked = false; checkBoxAppearAtTheBottomLeft.Checked = false; + checkBoxRoundCorners.Checked = true; } private void CheckBoxStayOpenWhenFocusLost_CheckedChanged(object sender, EventArgs e) diff --git a/Utilities/File/IconReader.cs b/Utilities/File/IconReader.cs index 59c719f..36fbc97 100644 --- a/Utilities/File/IconReader.cs +++ b/Utilities/File/IconReader.cs @@ -42,7 +42,6 @@ namespace SystemTrayMenu.Utilities public static void Dispose(bool includingMainMenu = true) { - if (includingMainMenu) { foreach (Icon icon in DictIconCacheMainMenu.Values)