This commit is contained in:
Markus Hofknecht 2020-05-06 13:59:31 +02:00
parent 7bbe8d6c2a
commit 0b3e096ec6
7 changed files with 51 additions and 38 deletions

View file

@ -16,15 +16,11 @@ namespace SystemTrayMenu
public App()
{
Scaling.Initialize();
FolderOptions.Initialize();
Screen screen = Screen.PrimaryScreen;
Statics.ScreenHeight = screen.Bounds.Height;
Statics.ScreenWidth = screen.Bounds.Width;
Statics.ScreenRight = screen.Bounds.Right;
Statics.TaskbarHeight = new WindowsTaskbar().Size.Height;
AppRestart.BeforeRestarting += Dispose;
SystemEvents.DisplaySettingsChanged += AppRestart.ByDisplaySettings;
menus.LoadStarted += menuNotifyIcon.LoadingStart;

View file

@ -28,6 +28,9 @@ namespace SystemTrayMenu
AskUserSendError(t.Exception);
}
Scaling.Initialize();
FolderOptions.Initialize();
using (new App())
{
Log.WriteApplicationRuns();

View file

@ -35,5 +35,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("0.9.2.26")]
[assembly: AssemblyFileVersion("0.9.2.26")]
[assembly: AssemblyVersion("0.9.2.27")]
[assembly: AssemblyFileVersion("0.9.2.27")]

View file

@ -35,7 +35,6 @@ namespace SystemTrayMenu.UserInterface
internal int Level = 0;
private readonly Fading fading = new Fading();
private bool autoResizeRowsDone = false;
private bool isShowing = false;
internal Menu()
@ -219,23 +218,11 @@ namespace SystemTrayMenu.UserInterface
internal void AdjustSizeAndLocation(Menu menuPredecessor = null)
{
if (!autoResizeRowsDone)
{
autoResizeRowsDone = true;
dgv.AutoResizeRows();
}
dgv.AutoResizeRows();
int dgvHeightNeeded = dgv.Rows.GetRowsHeight(
DataGridViewElementStates.None);
int labelTitleHeight = labelTitle.Height;
if (labelTitle.IsDisposed)
{
labelTitleHeight = 0;
}
int menuRestNeeded = Height - dgv.Height;
//labelTitleHeight + tableLayoutPanelSearch.Height +
//(int)Math.Round(5 * Scaling.Factor);
//(tableLayoutPanelSearch.Margin.Vertical + 5) * Scaling.Factor);
int dgvHeightMax = Statics.ScreenHeight - Statics.TaskbarHeight -
menuRestNeeded;

View file

@ -37,7 +37,6 @@ namespace SystemTrayMenu.UserInterface
this.tableLayoutPanelGeneral = new System.Windows.Forms.TableLayoutPanel();
this.comboBoxLanguage = new System.Windows.Forms.ComboBox();
this.labelLanguage = new System.Windows.Forms.Label();
this.textBoxHotkey = new SystemTrayMenu.UserInterface.Controls.HotkeyControl();
this.checkBoxAutostart = new System.Windows.Forms.CheckBox();
this.labelHotkey = new System.Windows.Forms.Label();
this.labelAutostart = new System.Windows.Forms.Label();
@ -52,6 +51,7 @@ namespace SystemTrayMenu.UserInterface
this.tableLayoutPanelBottom = new System.Windows.Forms.TableLayoutPanel();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.textBoxHotkey = new SystemTrayMenu.UserInterface.Controls.HotkeyControl();
this.tableLayoutPanelMain.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPageGeneral.SuspendLayout();
@ -146,20 +146,6 @@ namespace SystemTrayMenu.UserInterface
this.labelLanguage.TabIndex = 2;
this.labelLanguage.Text = "labelLanguage";
//
// textBoxHotkey
//
this.textBoxHotkey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.textBoxHotkey.Hotkey = System.Windows.Forms.Keys.None;
this.textBoxHotkey.HotkeyModifiers = System.Windows.Forms.Keys.None;
this.textBoxHotkey.Location = new System.Drawing.Point(92, 57);
this.textBoxHotkey.Margin = new System.Windows.Forms.Padding(9, 7, 9, 0);
this.textBoxHotkey.Name = "textBoxHotkey";
this.textBoxHotkey.Size = new System.Drawing.Size(200, 20);
this.textBoxHotkey.TabIndex = 0;
this.textBoxHotkey.Text = "None";
this.textBoxHotkey.Enter += new System.EventHandler(this.textBoxHotkey_Enter);
this.textBoxHotkey.Leave += new System.EventHandler(this.textBoxHotkey_Leave);
//
// checkBoxAutostart
//
this.checkBoxAutostart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
@ -335,9 +321,12 @@ namespace SystemTrayMenu.UserInterface
//
// buttonOk
//
this.buttonOk.AutoSize = true;
this.buttonOk.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonOk.DialogResult = System.Windows.Forms.DialogResult.OK;
this.buttonOk.Location = new System.Drawing.Point(236, 0);
this.buttonOk.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.buttonOk.MinimumSize = new System.Drawing.Size(75, 23);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 2;
@ -347,9 +336,12 @@ namespace SystemTrayMenu.UserInterface
//
// buttonCancel
//
this.buttonCancel.AutoSize = true;
this.buttonCancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(317, 0);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.buttonCancel.MinimumSize = new System.Drawing.Size(75, 23);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3;
@ -357,6 +349,20 @@ namespace SystemTrayMenu.UserInterface
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// textBoxHotkey
//
this.textBoxHotkey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.textBoxHotkey.Hotkey = System.Windows.Forms.Keys.None;
this.textBoxHotkey.HotkeyModifiers = System.Windows.Forms.Keys.None;
this.textBoxHotkey.Location = new System.Drawing.Point(92, 57);
this.textBoxHotkey.Margin = new System.Windows.Forms.Padding(9, 7, 9, 0);
this.textBoxHotkey.Name = "textBoxHotkey";
this.textBoxHotkey.Size = new System.Drawing.Size(200, 20);
this.textBoxHotkey.TabIndex = 0;
this.textBoxHotkey.Text = "None";
this.textBoxHotkey.Enter += new System.EventHandler(this.textBoxHotkey_Enter);
this.textBoxHotkey.Leave += new System.EventHandler(this.textBoxHotkey_Leave);
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -385,6 +391,7 @@ namespace SystemTrayMenu.UserInterface
this.tableLayoutPanel5.ResumeLayout(false);
this.tableLayoutPanel5.PerformLayout();
this.tableLayoutPanelBottom.ResumeLayout(false);
this.tableLayoutPanelBottom.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -32,6 +32,14 @@ namespace SystemTrayMenu.Utilities
}
}
dgv.Columns[i].Width = (int)(widthMax + 0.5);
string stringWithWidthLikeIcon = "___";
#pragma warning disable CA1303 // Do not pass literals as localized parameters
float Width0 = gfx.MeasureString(stringWithWidthLikeIcon,
#pragma warning restore CA1303 // Do not pass literals as localized parameters
dgv.RowTemplate.DefaultCellStyle.Font
).Width * Scaling.Factor;
dgv.Columns[0].Width = (int)Width0;
}
}
}

View file

@ -118,7 +118,17 @@ namespace SystemTrayMenu.Utilities
hIcon = DllImports.NativeMethods.ImageList_GetIcon(hImageList, shfi.iIcon, DllImports.NativeMethods.IldTransparent);
}
icon = (Icon)Icon.FromHandle(hIcon).Clone();
try
{
// Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly
icon = (Icon)Icon.FromHandle(hIcon).Clone();
}
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
Log.Error($"filePath:'{filePath}'", ex);
}
// Cleanup
if (!linkOverlay)
@ -178,9 +188,11 @@ namespace SystemTrayMenu.Utilities
icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
DllImports.NativeMethods.User32DestroyIcon(shfi.hIcon);
}
catch
#pragma warning disable CA1031 // Do not catch general exception types
catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
{
#warning todo
Log.Error($"directoryPath:'{directoryPath}'", ex);
}
}