mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-16 10:22:34 +12:00
[Feature] Adjust height when items deleted or added (#430), version 1.3.0.14
This commit is contained in:
parent
14a83d7672
commit
8f1d04a66c
|
@ -745,6 +745,7 @@ namespace SystemTrayMenu.Business
|
|||
if (menu.Level == 0)
|
||||
{
|
||||
menu.ResetSearchText();
|
||||
menu.ResetHeight();
|
||||
AdjustMenusSizeAndLocation();
|
||||
}
|
||||
}
|
||||
|
@ -1391,6 +1392,7 @@ namespace SystemTrayMenu.Business
|
|||
dgv.DataSource = dataTable;
|
||||
|
||||
hideSubmenuDuringRefreshSearch = false;
|
||||
menus[0].ResetHeight();
|
||||
menus[0].RefreshSearchText();
|
||||
hideSubmenuDuringRefreshSearch = true;
|
||||
}
|
||||
|
@ -1429,6 +1431,7 @@ namespace SystemTrayMenu.Business
|
|||
AddItemsToMenu(rowDatas, menus[0], out _, out _);
|
||||
|
||||
hideSubmenuDuringRefreshSearch = false;
|
||||
menus[0].ResetHeight();
|
||||
menus[0].RefreshSearchText();
|
||||
hideSubmenuDuringRefreshSearch = true;
|
||||
|
||||
|
|
|
@ -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.3.0.13")]
|
||||
[assembly: AssemblyFileVersion("1.3.0.13")]
|
||||
[assembly: AssemblyVersion("1.3.0.14")]
|
||||
[assembly: AssemblyFileVersion("1.3.0.14")]
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace SystemTrayMenu.UserInterface
|
|||
private bool mouseDown;
|
||||
private Point lastLocation;
|
||||
private bool isSetSearchText;
|
||||
private bool dgvHeightSet;
|
||||
|
||||
internal Menu()
|
||||
{
|
||||
|
@ -678,6 +679,11 @@ namespace SystemTrayMenu.UserInterface
|
|||
}
|
||||
}
|
||||
|
||||
internal void ResetHeight()
|
||||
{
|
||||
dgvHeightSet = false;
|
||||
}
|
||||
|
||||
internal void SetCounts(int foldersCount, int filesCount)
|
||||
{
|
||||
int filesAndFoldersCount = foldersCount + filesCount;
|
||||
|
@ -757,47 +763,35 @@ namespace SystemTrayMenu.UserInterface
|
|||
row.Height = dgv.RowTemplate.Height;
|
||||
}
|
||||
|
||||
int dgvHeightNew = dgv.Rows.GetRowsHeight(DataGridViewElementStates.None);
|
||||
int dgvHeightMax = screenHeightMax - (Height - dgv.Height);
|
||||
|
||||
int heightMaxInPixel = (int)(Scaling.Factor * Scaling.FactorByDpi *
|
||||
int dgvHeightByItems = dgv.Rows.GetRowsHeight(DataGridViewElementStates.None);
|
||||
int dgvHeightMaxByScreen = screenHeightMax - (Height - dgv.Height);
|
||||
int dgvHeightMaxByOptions = (int)(Scaling.Factor * Scaling.FactorByDpi *
|
||||
450f * (Properties.Settings.Default.HeightMaxInPercent / 100f));
|
||||
if (dgvHeightMax > heightMaxInPixel)
|
||||
int dgvHeightMax = Math.Min(dgvHeightMaxByScreen, dgvHeightMaxByOptions);
|
||||
if (!dgvHeightSet)
|
||||
{
|
||||
dgvHeightMax = heightMaxInPixel;
|
||||
dgv.Height = Math.Min(dgvHeightByItems, dgvHeightMax);
|
||||
dgvHeightSet = true;
|
||||
}
|
||||
|
||||
tableLayoutPanelDgvAndScrollbar.SuspendLayout();
|
||||
tableLayoutPanelMenu.SuspendLayout();
|
||||
dgv.ScrollBars = ScrollBars.None;
|
||||
if (dgvHeightNew > dgvHeightMax)
|
||||
if (dgvHeightByItems > dgvHeightMax)
|
||||
{
|
||||
// Make all rows fit into the screen
|
||||
customScrollbar.PaintEnable(dgvHeightMax);
|
||||
if (customScrollbar.Maximum != dgvHeightNew)
|
||||
ScrollbarVisible = true;
|
||||
customScrollbar.PaintEnable(dgv.Height);
|
||||
if (customScrollbar.Maximum != dgvHeightByItems)
|
||||
{
|
||||
customScrollbar.Reset();
|
||||
customScrollbar.Minimum = 0;
|
||||
customScrollbar.Maximum = dgvHeightNew;
|
||||
customScrollbar.Maximum = dgvHeightByItems;
|
||||
customScrollbar.LargeChange = dgvHeightMax;
|
||||
customScrollbar.SmallChange = dgv.RowTemplate.Height;
|
||||
}
|
||||
|
||||
dgvHeightNew = dgvHeightMax;
|
||||
ScrollbarVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
customScrollbar.PaintDisable();
|
||||
ScrollbarVisible = false;
|
||||
customScrollbar.PaintDisable();
|
||||
}
|
||||
|
||||
dgv.Height = dgvHeightNew;
|
||||
tableLayoutPanelMenu.ResumeLayout();
|
||||
tableLayoutPanelDgvAndScrollbar.AutoScroll = false;
|
||||
tableLayoutPanelDgvAndScrollbar.ResumeLayout();
|
||||
tableLayoutPanelMenu.PerformLayout();
|
||||
tableLayoutPanelDgvAndScrollbar.PerformLayout();
|
||||
}
|
||||
|
||||
private void AdjustDataGridViewWidth()
|
||||
|
|
Loading…
Reference in a new issue