mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-17 10:53:27 +12:00
[Feature] Default sizes to match Windows File Explorer (#418), version 1.3.0.8
This commit is contained in:
parent
663baa3f69
commit
a14ea6fb32
|
@ -59,10 +59,17 @@ namespace SystemTrayMenu
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
taskbarForm?.Dispose();
|
if (taskbarForm?.InvokeRequired == true)
|
||||||
SystemEvents.DisplaySettingsChanged -= (s, e) => SystemEvents_DisplaySettingsChanged();
|
{
|
||||||
menus.Dispose();
|
Dispose();
|
||||||
menuNotifyIcon.Dispose();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
taskbarForm?.Dispose();
|
||||||
|
SystemEvents.DisplaySettingsChanged -= (s, e) => SystemEvents_DisplaySettingsChanged();
|
||||||
|
menus.Dispose();
|
||||||
|
menuNotifyIcon.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEvents_DisplaySettingsChanged()
|
private void SystemEvents_DisplaySettingsChanged()
|
||||||
|
|
|
@ -90,6 +90,7 @@ namespace SystemTrayMenu.Business
|
||||||
workerMainMenu.DoWork -= LoadMenu;
|
workerMainMenu.DoWork -= LoadMenu;
|
||||||
menus[0] = Create(menuData, Path.GetFileName(Config.Path));
|
menus[0] = Create(menuData, Path.GetFileName(Config.Path));
|
||||||
menus[0].HandleCreated += (s, e) => ExecuteWatcherHistory();
|
menus[0].HandleCreated += (s, e) => ExecuteWatcherHistory();
|
||||||
|
Scaling.CalculateFactorByDpi(menus[0].GetDataGridView().CreateGraphics());
|
||||||
IconReader.MainPreload = false;
|
IconReader.MainPreload = false;
|
||||||
if (showMenuAfterMainPreload)
|
if (showMenuAfterMainPreload)
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.3.0.7")]
|
[assembly: AssemblyVersion("1.3.0.8")]
|
||||||
[assembly: AssemblyFileVersion("1.3.0.7")]
|
[assembly: AssemblyFileVersion("1.3.0.8")]
|
||||||
|
|
2
Properties/Settings.Designer.cs
generated
2
Properties/Settings.Designer.cs
generated
|
@ -159,7 +159,7 @@ namespace SystemTrayMenu.Properties
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
[global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))]
|
[global::System.Configuration.SettingsProviderAttribute(typeof(CustomSettingsProvider))]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("125")]
|
[global::System.Configuration.DefaultSettingValueAttribute("100")]
|
||||||
public int SizeInPercent
|
public int SizeInPercent
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
|
@ -275,7 +275,7 @@ Thanks for ideas, reporting issues and contributing!
|
||||||
#285 #286 [dao-net](https://github.com/dao-net),
|
#285 #286 [dao-net](https://github.com/dao-net),
|
||||||
#288 William P.,
|
#288 William P.,
|
||||||
#294 #295 #296 Stefan Mahrer,
|
#294 #295 #296 Stefan Mahrer,
|
||||||
#225 #297 #299 #317 #321 #324 #330 #386 #390 #401 #402 #407 #409 #414 #416 [chip33](https://github.com/chip33),
|
#225 #297 #299 #317 #321 #324 #330 #386 #390 #401 #402 #407 #409 #414 #416 #418 [chip33](https://github.com/chip33),
|
||||||
#298 [phanirithvij](https://github.com/phanirithvij),
|
#298 [phanirithvij](https://github.com/phanirithvij),
|
||||||
#306 [wini2](https://github.com/wini2),
|
#306 [wini2](https://github.com/wini2),
|
||||||
#370 [dna5589](https://github.com/dna5589),
|
#370 [dna5589](https://github.com/dna5589),
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace SystemTrayMenu.Helper
|
||||||
aboutBox.AppMoreInfo += "#235 #242 243 #247, #271 Tom, #237 Torsten S., #240 video Patrick, #244 Gunter D., #246 #329 MACE4GITHUB, #259 #310 vanjac, ";
|
aboutBox.AppMoreInfo += "#235 #242 243 #247, #271 Tom, #237 Torsten S., #240 video Patrick, #244 Gunter D., #246 #329 MACE4GITHUB, #259 #310 vanjac, ";
|
||||||
aboutBox.AppMoreInfo += "#262 terencemcdonnell, #269 petersnows25, #272 Peter M., #273 #274 ParasiteDelta, #275 #276 #278 donaldaken, ";
|
aboutBox.AppMoreInfo += "#262 terencemcdonnell, #269 petersnows25, #272 Peter M., #273 #274 ParasiteDelta, #275 #276 #278 donaldaken, ";
|
||||||
aboutBox.AppMoreInfo += "#277 Jan S., #282 akuznets, #283 #284 #289 RuSieg, #285 #286 dao-net, #288 William P., #294 #295 #296 Stefan Mahrer, ";
|
aboutBox.AppMoreInfo += "#277 Jan S., #282 akuznets, #283 #284 #289 RuSieg, #285 #286 dao-net, #288 William P., #294 #295 #296 Stefan Mahrer, ";
|
||||||
aboutBox.AppMoreInfo += "#225 #297 #299 #317 #321 #324 #330 #386 #390 #401 #402 #407 #409 #414 #416 chip33, #298 phanirithvij, #306 wini2, #370 dna5589, #372 not-nef, #376 Michelle H. ";
|
aboutBox.AppMoreInfo += "#225 #297 #299 #317 #321 #324 #330 #386 #390 #401 #402 #407 #409 #414 #416 #418 chip33, #298 phanirithvij, #306 wini2, #370 dna5589, #372 not-nef, #376 Michelle H. ";
|
||||||
aboutBox.AppMoreInfo += "#377 SoenkeHob, #380 #394 TransLucida, #384 boydfields, #386 visusys, #387 #411 yrctw" + Environment.NewLine;
|
aboutBox.AppMoreInfo += "#377 SoenkeHob, #380 #394 TransLucida, #384 boydfields, #386 visusys, #387 #411 yrctw" + Environment.NewLine;
|
||||||
aboutBox.AppMoreInfo += @"
|
aboutBox.AppMoreInfo += @"
|
||||||
Sponsors - Thank you!
|
Sponsors - Thank you!
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
ColumnIcon.DataPropertyName = "ColumnIcon";
|
ColumnIcon.DataPropertyName = "ColumnIcon";
|
||||||
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||||
dataGridViewCellStyle1.NullValue = "System.Drawing.Icon";
|
dataGridViewCellStyle1.NullValue = "System.Drawing.Icon";
|
||||||
dataGridViewCellStyle1.Padding = new Padding(3, 2, 6, 2);
|
dataGridViewCellStyle1.Padding = new Padding(3, 1, 2, 1);
|
||||||
ColumnIcon.DefaultCellStyle = dataGridViewCellStyle1;
|
ColumnIcon.DefaultCellStyle = dataGridViewCellStyle1;
|
||||||
ColumnIcon.Frozen = true;
|
ColumnIcon.Frozen = true;
|
||||||
ColumnIcon.HeaderText = "ColumnIcon";
|
ColumnIcon.HeaderText = "ColumnIcon";
|
||||||
|
|
|
@ -730,20 +730,17 @@ namespace SystemTrayMenu.UserInterface
|
||||||
factor = Properties.Settings.Default.RowHeighteInPercentageTouch / 100f;
|
factor = Properties.Settings.Default.RowHeighteInPercentageTouch / 100f;
|
||||||
}
|
}
|
||||||
|
|
||||||
double factorIconSizeInPercent = Properties.Settings.Default.IconSizeInPercent / 100f;
|
|
||||||
|
|
||||||
if (factor < factorIconSizeInPercent)
|
|
||||||
{
|
|
||||||
factor = factorIconSizeInPercent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menuPredecessor == null)
|
if (menuPredecessor == null)
|
||||||
{
|
{
|
||||||
if (dgv.Tag == null && dgv.Rows.Count > 0)
|
if (dgv.Tag == null && dgv.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
// Find row size based on content and apply factor
|
// dgv.AutoResizeRows(); slightly incorrect depending on dpi
|
||||||
dgv.AutoResizeRows();
|
// 100% = 20 instead 21
|
||||||
dgv.RowTemplate.Height = (int)(dgv.Rows[0].Height * factor);
|
// 125% = 23 instead 27, 150% = 28 instead 32
|
||||||
|
// 175% = 33 instead 37, 200% = 35 instead 42
|
||||||
|
// #418 use 21 as default and scale it manually
|
||||||
|
float rowHeightDefault = 21.24f * Scaling.FactorByDpi;
|
||||||
|
dgv.RowTemplate.Height = (int)((rowHeightDefault * factor * Scaling.Factor) + 0.5);
|
||||||
dgv.Tag = true;
|
dgv.Tag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
|
|
||||||
private void ButtonSizeAndLocationDefault_Click(object sender, EventArgs e)
|
private void ButtonSizeAndLocationDefault_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
numericUpDownSizeInPercent.Value = 125;
|
numericUpDownSizeInPercent.Value = 100;
|
||||||
numericUpDownIconSizeInPercent.Value = 100;
|
numericUpDownIconSizeInPercent.Value = 100;
|
||||||
numericUpDownRowHeighteInPercentage.Value = 100;
|
numericUpDownRowHeighteInPercentage.Value = 100;
|
||||||
numericUpDownMenuWidth.Value = 400;
|
numericUpDownMenuWidth.Value = 400;
|
||||||
|
|
|
@ -20,13 +20,13 @@ namespace SystemTrayMenu.Utilities
|
||||||
/// <param name="dgv">datagridview.</param>
|
/// <param name="dgv">datagridview.</param>
|
||||||
internal static void FastAutoSizeColumns(this DataGridView dgv)
|
internal static void FastAutoSizeColumns(this DataGridView dgv)
|
||||||
{
|
{
|
||||||
using Graphics gfx = dgv.CreateGraphics();
|
using Graphics graphics = dgv.CreateGraphics();
|
||||||
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
||||||
float widthMax = WidthMin;
|
float widthMax = WidthMin;
|
||||||
DataTable data = (DataTable)dgv.DataSource;
|
DataTable data = (DataTable)dgv.DataSource;
|
||||||
foreach (DataRow row in data.Rows)
|
foreach (DataRow row in data.Rows)
|
||||||
{
|
{
|
||||||
float checkWidth = gfx.MeasureString(
|
float checkWidth = graphics.MeasureString(
|
||||||
((RowData)row[2]).Text + "___",
|
((RowData)row[2]).Text + "___",
|
||||||
dgv.RowTemplate.DefaultCellStyle.Font).Width;
|
dgv.RowTemplate.DefaultCellStyle.Font).Width;
|
||||||
if (checkWidth > widthMax)
|
if (checkWidth > widthMax)
|
||||||
|
@ -41,13 +41,11 @@ namespace SystemTrayMenu.Utilities
|
||||||
}
|
}
|
||||||
|
|
||||||
dgv.Columns[1].Width = (int)(widthMax + 0.5);
|
dgv.Columns[1].Width = (int)(widthMax + 0.5);
|
||||||
string stringWithWidthLikeIcon = "____";
|
|
||||||
float width0 = gfx.MeasureString(
|
|
||||||
stringWithWidthLikeIcon,
|
|
||||||
dgv.RowTemplate.DefaultCellStyle.Font).Width;
|
|
||||||
|
|
||||||
double factorIconSizeInPercent = Properties.Settings.Default.IconSizeInPercent / 100f;
|
double factorIconSizeInPercent = Properties.Settings.Default.IconSizeInPercent / 100f;
|
||||||
dgv.Columns[0].Width = (int)(width0 * factorIconSizeInPercent);
|
|
||||||
|
// IcoWidth 100% = 21px, 175% is 33, +3+2 is padding from ColumnIcon
|
||||||
|
float icoWidth = (16 * Scaling.FactorByDpi) + 5;
|
||||||
|
dgv.Columns[0].Width = (int)((icoWidth * factorIconSizeInPercent * Scaling.Factor) + 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,13 @@ namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
loading = false;
|
loading = false;
|
||||||
string extension = Path.GetExtension(path);
|
string extension = Path.GetExtension(path);
|
||||||
IconSize size = IconSize.Large;
|
IconSize size = IconSize.Small;
|
||||||
|
if (Scaling.Factor >= 1.25f ||
|
||||||
|
Scaling.FactorByDpi >= 1.25f ||
|
||||||
|
Properties.Settings.Default.IconSizeInPercent / 100f >= 1.25f)
|
||||||
|
{
|
||||||
|
size = IconSize.Large;
|
||||||
|
}
|
||||||
|
|
||||||
string key = path;
|
string key = path;
|
||||||
if (!string.IsNullOrEmpty(keyPath))
|
if (!string.IsNullOrEmpty(keyPath))
|
||||||
|
@ -129,8 +135,9 @@ namespace SystemTrayMenu.Utilities
|
||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
IconSize size = IconSize.Small;
|
IconSize size = IconSize.Small;
|
||||||
if (Scaling.Factor >= 1.50f ||
|
if (Scaling.Factor >= 1.25f ||
|
||||||
Properties.Settings.Default.IconSizeInPercent / 100f >= 1.50f)
|
Scaling.FactorByDpi >= 1.25f ||
|
||||||
|
Properties.Settings.Default.IconSizeInPercent / 100f >= 1.25f)
|
||||||
{
|
{
|
||||||
// IconSize.Large returns another folder icon than windows explorer
|
// IconSize.Large returns another folder icon than windows explorer
|
||||||
size = IconSize.Large;
|
size = IconSize.Large;
|
||||||
|
|
|
@ -5,25 +5,27 @@
|
||||||
namespace SystemTrayMenu.Utilities
|
namespace SystemTrayMenu.Utilities
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
internal static class Scaling
|
internal static class Scaling
|
||||||
{
|
{
|
||||||
private enum DeviceCap
|
|
||||||
{
|
|
||||||
VERTRES = 10,
|
|
||||||
DESKTOPVERTRES = 117,
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float Factor { get; private set; } = 1;
|
public static float Factor { get; private set; } = 1;
|
||||||
|
|
||||||
internal static void Initialize()
|
public static float FactorByDpi { get; private set; } = 1;
|
||||||
|
|
||||||
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
Factor = Properties.Settings.Default.SizeInPercent / 100f;
|
Factor = Properties.Settings.Default.SizeInPercent / 100f;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static int Scale(int width)
|
public static int Scale(int width)
|
||||||
{
|
{
|
||||||
return (int)Math.Round(width * Factor, 0, MidpointRounding.AwayFromZero);
|
return (int)Math.Round(width * Factor, 0, MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CalculateFactorByDpi(Graphics graphics)
|
||||||
|
{
|
||||||
|
FactorByDpi = graphics.DpiX / 96;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue