mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-29 16:51:18 +13:00
[Feature] Code Analyze and Refactor 0.11 (#88) [Feature] Mouse disturbing while using keys (#69) [Feature] Reload menu when reenter or click (#103) [BUG] Crash when fast mouse movings (#104) [BUG] Loading was shown too often (#105) [BUG] submenu wrong location in edgecase (#97) [BUG] Folder shown as open (green) but is not open (#106)
This commit is contained in:
parent
1b683ff48a
commit
d1b8c0b279
15 changed files with 901 additions and 988 deletions
|
@ -14,10 +14,9 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
public event EventHandlerEmpty HotKeyPressed;
|
public event EventHandlerEmpty HotKeyPressed;
|
||||||
public event EventHandlerEmpty ClosePressed;
|
public event EventHandlerEmpty ClosePressed;
|
||||||
#warning use event not action
|
|
||||||
public event Action<Keys> KeyPressedSearching;
|
|
||||||
public event Action<DataGridView, int> RowSelected;
|
public event Action<DataGridView, int> RowSelected;
|
||||||
public event Action<int, int, DataGridView> RowDeselected;
|
public event Action<int, int, DataGridView> RowDeselected;
|
||||||
|
internal Action<DataGridView, int> EnterPressed;
|
||||||
public event EventHandlerEmpty Cleared;
|
public event EventHandlerEmpty Cleared;
|
||||||
|
|
||||||
private readonly Menu[] menus;
|
private readonly Menu[] menus;
|
||||||
|
@ -237,7 +236,7 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
RowData rowData = (RowData)dgv.
|
RowData rowData = (RowData)dgv.
|
||||||
Rows[iRowKey].Cells[2].Value;
|
Rows[iRowKey].Cells[2].Value;
|
||||||
if (rowData.IsSelectedByKeyboard)
|
if (rowData.IsSelected)
|
||||||
{
|
{
|
||||||
isStillSelected = true;
|
isStillSelected = true;
|
||||||
menuFromSelected = rowData.SubMenu;
|
menuFromSelected = rowData.SubMenu;
|
||||||
|
@ -289,7 +288,7 @@ namespace SystemTrayMenu.Handler
|
||||||
dgv.Rows.Count > iRowKey)
|
dgv.Rows.Count > iRowKey)
|
||||||
{
|
{
|
||||||
RowData trigger = (RowData)dgv.Rows[iRowKey].Cells[2].Value;
|
RowData trigger = (RowData)dgv.Rows[iRowKey].Cells[2].Value;
|
||||||
if (trigger.IsSelected || !trigger.ContainsMenu)
|
if (trigger.IsMenuOpen || !trigger.ContainsMenu)
|
||||||
{
|
{
|
||||||
trigger.MouseDown(dgv, null);
|
trigger.MouseDown(dgv, null);
|
||||||
trigger.DoubleClick(
|
trigger.DoubleClick(
|
||||||
|
@ -299,6 +298,7 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
RowDeselected(iMenuBefore, iRowBefore, dgvBefore);
|
RowDeselected(iMenuBefore, iRowBefore, dgvBefore);
|
||||||
SelectRow(dgv, iRowKey);
|
SelectRow(dgv, iRowKey);
|
||||||
|
EnterPressed.Invoke(dgv, iRowKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -474,7 +474,7 @@ namespace SystemTrayMenu.Handler
|
||||||
iMenuKey = newiMenuKey;
|
iMenuKey = newiMenuKey;
|
||||||
DataGridViewRow row = dgv.Rows[i];
|
DataGridViewRow row = dgv.Rows[i];
|
||||||
RowData rowData = (RowData)row.Cells[2].Value;
|
RowData rowData = (RowData)row.Cells[2].Value;
|
||||||
rowData.IsSelectedByKeyboard = true;
|
rowData.IsSelected = true;
|
||||||
row.Selected = false; //event trigger
|
row.Selected = false; //event trigger
|
||||||
row.Selected = true; //event trigger
|
row.Selected = true; //event trigger
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ namespace SystemTrayMenu.Handler
|
||||||
if (text.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
|
if (text.StartsWith(keyInput, true, CultureInfo.InvariantCulture))
|
||||||
{
|
{
|
||||||
iRowKey = rowData.RowIndex;
|
iRowKey = rowData.RowIndex;
|
||||||
rowData.IsSelectedByKeyboard = true;
|
rowData.IsSelected = true;
|
||||||
row.Selected = false; //event trigger
|
row.Selected = false; //event trigger
|
||||||
row.Selected = true; //event trigger
|
row.Selected = true; //event trigger
|
||||||
if (row.Index < dgv.FirstDisplayedScrollingRowIndex)
|
if (row.Index < dgv.FirstDisplayedScrollingRowIndex)
|
||||||
|
@ -529,8 +529,8 @@ namespace SystemTrayMenu.Handler
|
||||||
{
|
{
|
||||||
DataGridViewRow row = dgv.Rows[rowIndex];
|
DataGridViewRow row = dgv.Rows[rowIndex];
|
||||||
RowData rowData = (RowData)row.Cells[2].Value;
|
RowData rowData = (RowData)row.Cells[2].Value;
|
||||||
rowData.IsSelectedByKeyboard = false;
|
rowData.IsSelected = false;
|
||||||
row.Selected = false; //event trigger
|
row.Selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,15 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
internal class Menus : IDisposable
|
internal class Menus : IDisposable
|
||||||
{
|
{
|
||||||
internal event EventHandler<bool> LoadStarted;
|
internal event EventHandlerEmpty LoadStarted;
|
||||||
internal event EventHandlerEmpty LoadStopped;
|
internal event EventHandlerEmpty LoadStopped;
|
||||||
private enum OpenCloseState { Default, Opening, Closing };
|
private enum OpenCloseState { Default, Opening, Closing };
|
||||||
private OpenCloseState openCloseState = OpenCloseState.Default;
|
private OpenCloseState openCloseState = OpenCloseState.Default;
|
||||||
private readonly Menu[] menus = new Menu[MenuDefines.MenusMax];
|
private readonly Menu[] menus = new Menu[MenuDefines.MenusMax];
|
||||||
private readonly BackgroundWorker worker = new BackgroundWorker();
|
private readonly BackgroundWorker workerMainMenu = new BackgroundWorker();
|
||||||
|
private readonly List<BackgroundWorker> workersSubMenu = new List<BackgroundWorker>();
|
||||||
|
|
||||||
|
private readonly WaitToLoadMenu waitToOpenMenu = new WaitToLoadMenu();
|
||||||
private readonly KeyboardInput keyboardInput;
|
private readonly KeyboardInput keyboardInput;
|
||||||
private readonly Timer timerStillActiveCheck = new Timer();
|
private readonly Timer timerStillActiveCheck = new Timer();
|
||||||
private readonly WaitLeave waitLeave = new WaitLeave(MenuDefines.TimeUntilClose);
|
private readonly WaitLeave waitLeave = new WaitLeave(MenuDefines.TimeUntilClose);
|
||||||
|
@ -35,27 +37,101 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
public Menus()
|
public Menus()
|
||||||
{
|
{
|
||||||
worker.WorkerSupportsCancellation = true;
|
workerMainMenu.WorkerSupportsCancellation = true;
|
||||||
worker.DoWork += Load;
|
workerMainMenu.DoWork += LoadMenu;
|
||||||
void Load(object sender, DoWorkEventArgs e)
|
void LoadMenu(object senderDoWork, DoWorkEventArgs eDoWork)
|
||||||
{
|
{
|
||||||
e.Result = GetData((BackgroundWorker)sender, Config.Path, 0);
|
string path = Config.Path;
|
||||||
|
int level = 0;
|
||||||
|
RowData rowData = eDoWork.Argument as RowData;
|
||||||
|
if (rowData != null)
|
||||||
|
{
|
||||||
|
path = rowData.TargetFilePath;
|
||||||
|
level = rowData.MenuLevel + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
worker.RunWorkerCompleted += LoadCompleted;
|
MenuData menuData = GetData((BackgroundWorker)senderDoWork, path, level);
|
||||||
void LoadCompleted(object sender, RunWorkerCompletedEventArgs e)
|
menuData.RowDataParent = rowData;
|
||||||
|
eDoWork.Result = menuData;
|
||||||
|
}
|
||||||
|
|
||||||
|
workerMainMenu.RunWorkerCompleted += LoadMainMenuCompleted;
|
||||||
|
void LoadMainMenuCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
keyboardInput.ResetSelectedByKey();
|
keyboardInput.ResetSelectedByKey();
|
||||||
LoadStopped();
|
LoadStopped();
|
||||||
MenuData menuData = (MenuData)e.Result;
|
MenuData menuData = (MenuData)e.Result;
|
||||||
if (menuData.Validity == MenuDataValidity.Valid)
|
if (menuData.Validity == MenuDataValidity.Valid)
|
||||||
{
|
{
|
||||||
DisposeMenu(menus[0]);
|
DisposeMenu(menus[menuData.Level]);
|
||||||
menus[0] = Create(menuData, Path.GetFileName(Config.Path));
|
menus[0] = Create(menuData, Path.GetFileName(Config.Path));
|
||||||
AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); });
|
AsEnumerable.ToList().ForEach(m => { m.ShowWithFade(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
waitToOpenMenu.StopLoadMenu += WaitToOpenMenu_StopLoadMenu;
|
||||||
|
void WaitToOpenMenu_StopLoadMenu()
|
||||||
|
{
|
||||||
|
foreach (BackgroundWorker workerSubMenu in workersSubMenu.
|
||||||
|
Where(w => w.IsBusy))
|
||||||
|
{
|
||||||
|
workerSubMenu.CancelAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
waitToOpenMenu.StartLoadMenu += StartLoadMenu;
|
||||||
|
void StartLoadMenu(RowData rowData)
|
||||||
|
{
|
||||||
|
if (menus[0].IsUsable &&
|
||||||
|
menus[rowData.MenuLevel] == null ||
|
||||||
|
menus[rowData.MenuLevel].Tag as RowData != rowData)
|
||||||
|
{
|
||||||
|
LoadStarted();
|
||||||
|
BackgroundWorker workerSubMenu = workersSubMenu.
|
||||||
|
Where(w => !w.IsBusy).FirstOrDefault();
|
||||||
|
if (workerSubMenu == null)
|
||||||
|
{
|
||||||
|
workerSubMenu = new BackgroundWorker
|
||||||
|
{
|
||||||
|
WorkerSupportsCancellation = true
|
||||||
|
};
|
||||||
|
workerSubMenu.DoWork += LoadMenu;
|
||||||
|
workerSubMenu.RunWorkerCompleted += LoadSubMenuCompleted;
|
||||||
|
workersSubMenu.Add(workerSubMenu);
|
||||||
|
}
|
||||||
|
workerSubMenu.RunWorkerAsync(rowData); ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadSubMenuCompleted(object senderCompleted,
|
||||||
|
RunWorkerCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
LoadStopped();
|
||||||
|
MenuData menuData = (MenuData)e.Result;
|
||||||
|
if (menus[0].IsUsable &&
|
||||||
|
menuData.Validity != MenuDataValidity.AbortedOrUnknown)
|
||||||
|
{
|
||||||
|
Menu menu = Create(menuData);
|
||||||
|
switch (menuData.Validity)
|
||||||
|
{
|
||||||
|
case MenuDataValidity.Valid:
|
||||||
|
menu.SetTypeSub();
|
||||||
|
break;
|
||||||
|
case MenuDataValidity.Empty:
|
||||||
|
menu.SetTypeEmpty();
|
||||||
|
break;
|
||||||
|
case MenuDataValidity.NoAccess:
|
||||||
|
menu.SetTypeNoAccess();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
menu.Tag = menuData.RowDataParent;
|
||||||
|
menuData.RowDataParent.SubMenu = menu;
|
||||||
|
if (menus[0].IsUsable)
|
||||||
|
{
|
||||||
|
ShowSubMenu(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
keyboardInput = new KeyboardInput(menus);
|
keyboardInput = new KeyboardInput(menus);
|
||||||
keyboardInput.RegisterHotKey();
|
keyboardInput.RegisterHotKey();
|
||||||
keyboardInput.HotKeyPressed += KeyboardInput_HotKeyPressed;
|
keyboardInput.HotKeyPressed += KeyboardInput_HotKeyPressed;
|
||||||
|
@ -65,12 +141,18 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboardInput.ClosePressed += MenusFadeOut;
|
keyboardInput.ClosePressed += MenusFadeOut;
|
||||||
keyboardInput.RowDeselected += CheckMenuOpenerStop;
|
keyboardInput.RowDeselected += waitToOpenMenu.RowDeselected;
|
||||||
keyboardInput.RowSelected += KeyboardInputRowSelected;
|
keyboardInput.RowSelected += waitToOpenMenu.RowSelected;
|
||||||
void KeyboardInputRowSelected(DataGridView dgv, int rowIndex)
|
|
||||||
|
timerStillActiveCheck.Interval = 1000;
|
||||||
|
timerStillActiveCheck.Tick += StillActiveTick;
|
||||||
|
void StillActiveTick(object senderTimer, EventArgs eTimer)
|
||||||
{
|
{
|
||||||
FadeInIfNeeded();
|
if (!IsActive())
|
||||||
CheckMenuOpenerStart(dgv, rowIndex);
|
{
|
||||||
|
FadeHalfOrOutIfNeeded();
|
||||||
|
timerStillActiveCheck.Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waitLeave.LeaveTriggered += LeaveTriggered;
|
waitLeave.LeaveTriggered += LeaveTriggered;
|
||||||
|
@ -104,7 +186,6 @@ namespace SystemTrayMenu.Business
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
openCloseState = OpenCloseState.Opening;
|
openCloseState = OpenCloseState.Opening;
|
||||||
LoadStarted(this, true);
|
|
||||||
StartWorker();
|
StartWorker();
|
||||||
}
|
}
|
||||||
deactivatedTime = DateTime.MinValue;
|
deactivatedTime = DateTime.MinValue;
|
||||||
|
@ -112,10 +193,9 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
worker.Dispose();
|
workerMainMenu.Dispose();
|
||||||
keyboardInput.Dispose();
|
keyboardInput.Dispose();
|
||||||
timerStillActiveCheck.Dispose();
|
timerStillActiveCheck.Dispose();
|
||||||
waitLeave.Dispose();
|
|
||||||
IconReader.Dispose();
|
IconReader.Dispose();
|
||||||
DisposeMenu(menus[0]);
|
DisposeMenu(menus[0]);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +221,7 @@ namespace SystemTrayMenu.Business
|
||||||
MenuData menuData = new MenuData
|
MenuData menuData = new MenuData
|
||||||
{
|
{
|
||||||
RowDatas = new List<RowData>(),
|
RowDatas = new List<RowData>(),
|
||||||
Validity = MenuDataValidity.Invalid,
|
Validity = MenuDataValidity.AbortedOrUnknown,
|
||||||
Level = level
|
Level = level
|
||||||
};
|
};
|
||||||
if (!worker.CancellationPending)
|
if (!worker.CancellationPending)
|
||||||
|
@ -181,6 +261,7 @@ namespace SystemTrayMenu.Business
|
||||||
rowData.HiddenEntry = hiddenEntry;
|
rowData.HiddenEntry = hiddenEntry;
|
||||||
string resolvedLnkPath = string.Empty;
|
string resolvedLnkPath = string.Empty;
|
||||||
rowData.ReadIcon(true, ref resolvedLnkPath);
|
rowData.ReadIcon(true, ref resolvedLnkPath);
|
||||||
|
rowData.MenuLevel = level;
|
||||||
menuData.RowDatas.Add(rowData);
|
menuData.RowDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,18 +313,25 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
if (!worker.CancellationPending)
|
if (!worker.CancellationPending)
|
||||||
{
|
{
|
||||||
if (menuData.Validity == MenuDataValidity.Invalid)
|
if (menuData.Validity == MenuDataValidity.AbortedOrUnknown)
|
||||||
|
{
|
||||||
|
if (menuData.RowDatas.Count == 0)
|
||||||
|
{
|
||||||
|
menuData.Validity = MenuDataValidity.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
menuData.Validity = MenuDataValidity.Valid;
|
menuData.Validity = MenuDataValidity.Valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return menuData;
|
return menuData;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MainPreload()
|
internal void MainPreload()
|
||||||
{
|
{
|
||||||
menus[0] = Create(GetData(worker, Config.Path, 0),
|
menus[0] = Create(GetData(workerMainMenu, Config.Path, 0),
|
||||||
Path.GetFileName(Config.Path));
|
Path.GetFileName(Config.Path));
|
||||||
menus[0].AdjustSizeAndLocation();
|
menus[0].AdjustSizeAndLocation();
|
||||||
DisposeMenu(menus[0]);
|
DisposeMenu(menus[0]);
|
||||||
|
@ -251,21 +339,19 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
internal void StartWorker()
|
internal void StartWorker()
|
||||||
{
|
{
|
||||||
if (worker.IsBusy)
|
if (!workerMainMenu.IsBusy)
|
||||||
{
|
{
|
||||||
LoadStopped();
|
LoadStarted();
|
||||||
}
|
workerMainMenu.RunWorkerAsync(
|
||||||
else
|
new object[] { Config.Path, 0 });
|
||||||
{
|
|
||||||
worker.RunWorkerAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void StopWorker()
|
internal void StopWorker()
|
||||||
{
|
{
|
||||||
if (worker.IsBusy)
|
if (workerMainMenu.IsBusy)
|
||||||
{
|
{
|
||||||
worker.CancelAsync();
|
workerMainMenu.CancelAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +419,7 @@ namespace SystemTrayMenu.Business
|
||||||
menu.MouseEnter += waitLeave.Stop;
|
menu.MouseEnter += waitLeave.Stop;
|
||||||
menu.KeyPress += keyboardInput.KeyPress;
|
menu.KeyPress += keyboardInput.KeyPress;
|
||||||
menu.CmdKeyProcessed += keyboardInput.CmdKeyProcessed;
|
menu.CmdKeyProcessed += keyboardInput.CmdKeyProcessed;
|
||||||
|
keyboardInput.EnterPressed += waitToOpenMenu.EnterOpensInstantly;
|
||||||
menu.SearchTextChanging += keyboardInput.SearchTextChanging;
|
menu.SearchTextChanging += keyboardInput.SearchTextChanging;
|
||||||
menu.SearchTextChanged += Menu_SearchTextChanged;
|
menu.SearchTextChanged += Menu_SearchTextChanged;
|
||||||
void Menu_SearchTextChanged(object sender, EventArgs e)
|
void Menu_SearchTextChanged(object sender, EventArgs e)
|
||||||
|
@ -358,33 +445,43 @@ namespace SystemTrayMenu.Business
|
||||||
{
|
{
|
||||||
menus[0].SetTitleColorActive();
|
menus[0].SetTitleColorActive();
|
||||||
AsList.ForEach(m => m.ShowWithFade());
|
AsList.ForEach(m => m.ShowWithFade());
|
||||||
}
|
|
||||||
|
|
||||||
CheckIfWindowsStartStoleFocusNoDeactivateInRareCase();
|
|
||||||
void CheckIfWindowsStartStoleFocusNoDeactivateInRareCase()
|
|
||||||
{
|
|
||||||
timerStillActiveCheck.Interval = 1000;
|
|
||||||
timerStillActiveCheck.Tick += StillActiveTick;
|
|
||||||
void StillActiveTick(object senderTimer, EventArgs eTimer)
|
|
||||||
{
|
|
||||||
if (!waitLeave.IsRunning)
|
|
||||||
{
|
|
||||||
FadeHalfOrOutIfNeeded();
|
|
||||||
if (!IsActive())
|
|
||||||
{
|
|
||||||
timerStillActiveCheck.Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timerStillActiveCheck.Start();
|
timerStillActiveCheck.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.VisibleChanged += MenuVisibleChanged;
|
menu.VisibleChanged += MenuVisibleChanged;
|
||||||
AddItemsToMenu(menuData.RowDatas, menu);
|
AddItemsToMenu(menuData.RowDatas, menu);
|
||||||
|
void AddItemsToMenu(List<RowData> data, Menu menu)
|
||||||
|
{
|
||||||
DataGridView dgv = menu.GetDataGridView();
|
DataGridView dgv = menu.GetDataGridView();
|
||||||
|
DataTable dataTable = new DataTable();
|
||||||
|
dataTable.Columns.Add(dgv.Columns[0].Name, typeof(Icon));
|
||||||
|
dataTable.Columns.Add(dgv.Columns[1].Name, typeof(string));
|
||||||
|
dataTable.Columns.Add("data", typeof(RowData));
|
||||||
|
foreach (RowData rowData in data)
|
||||||
|
{
|
||||||
|
rowData.SetData(rowData, dataTable);
|
||||||
|
}
|
||||||
|
dgv.DataSource = dataTable;
|
||||||
|
}
|
||||||
|
DataGridView dgv = menu.GetDataGridView();
|
||||||
|
dgv.CellMouseEnter += waitToOpenMenu.MouseEnter;
|
||||||
dgv.CellMouseEnter += Dgv_CellMouseEnter;
|
dgv.CellMouseEnter += Dgv_CellMouseEnter;
|
||||||
dgv.CellMouseLeave += Dgv_CellMouseLeave;
|
void Dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
if (menus[0].IsUsable)
|
||||||
|
{
|
||||||
|
if (keyboardInput.InUse)
|
||||||
|
{
|
||||||
|
keyboardInput.ClearIsSelectedByKey();
|
||||||
|
keyboardInput.InUse = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
keyboardInput.Select(dgv, e.RowIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dgv.CellMouseLeave += waitToOpenMenu.MouseLeave;
|
||||||
|
dgv.MouseMove += waitToOpenMenu.MouseMove;
|
||||||
dgv.MouseDown += Dgv_MouseDown;
|
dgv.MouseDown += Dgv_MouseDown;
|
||||||
dgv.MouseDoubleClick += Dgv_MouseDoubleClick;
|
dgv.MouseDoubleClick += Dgv_MouseDoubleClick;
|
||||||
dgv.SelectionChanged += Dgv_SelectionChanged;
|
dgv.SelectionChanged += Dgv_SelectionChanged;
|
||||||
|
@ -398,10 +495,6 @@ namespace SystemTrayMenu.Business
|
||||||
if (menu.IsUsable)
|
if (menu.IsUsable)
|
||||||
{
|
{
|
||||||
AdjustMenusSizeAndLocation();
|
AdjustMenusSizeAndLocation();
|
||||||
if (menu.Level == 0)
|
|
||||||
{
|
|
||||||
menus[0].AdjustSizeAndLocation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!menu.Visible)
|
if (!menu.Visible)
|
||||||
{
|
{
|
||||||
|
@ -413,126 +506,6 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddItemsToMenu(List<RowData> data, Menu menu)
|
|
||||||
{
|
|
||||||
DataGridView dgv = menu.GetDataGridView();
|
|
||||||
DataTable dataTable = new DataTable();
|
|
||||||
dataTable.Columns.Add(dgv.Columns[0].Name, typeof(Icon));
|
|
||||||
dataTable.Columns.Add(dgv.Columns[1].Name, typeof(string));
|
|
||||||
dataTable.Columns.Add("data", typeof(RowData));
|
|
||||||
foreach (RowData rowData in data)
|
|
||||||
{
|
|
||||||
CreateMenuRow(rowData, menu, dataTable);
|
|
||||||
}
|
|
||||||
dgv.DataSource = dataTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
|
|
||||||
{
|
|
||||||
if (menus[0].IsUsable)
|
|
||||||
{
|
|
||||||
if (keyboardInput.InUse)
|
|
||||||
{
|
|
||||||
CheckMenuOpenerStop(keyboardInput.iMenuKey,
|
|
||||||
keyboardInput.iRowKey);
|
|
||||||
keyboardInput.ClearIsSelectedByKey();
|
|
||||||
keyboardInput.InUse = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DataGridView dgv = (DataGridView)sender;
|
|
||||||
keyboardInput.Select(dgv, e.RowIndex);
|
|
||||||
CheckMenuOpenerStart(dgv, e.RowIndex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckMenuOpenerStart(DataGridView dgv, int rowIndex)
|
|
||||||
{
|
|
||||||
if (rowIndex > -1 &&
|
|
||||||
dgv.Rows.Count > rowIndex)
|
|
||||||
{
|
|
||||||
RowData trigger = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
|
||||||
trigger.IsSelected = true;
|
|
||||||
dgv.Rows[rowIndex].Selected = true;
|
|
||||||
Menu menuFromTrigger = (Menu)dgv.FindForm();
|
|
||||||
Menu menuTriggered = trigger.SubMenu;
|
|
||||||
int level = menuFromTrigger.Level + 1;
|
|
||||||
|
|
||||||
if (trigger.ContainsMenu &&
|
|
||||||
level < MenuDefines.MenusMax &&
|
|
||||||
menus[0].IsUsable &&
|
|
||||||
(menus[level] == null ||
|
|
||||||
menus[level] != menuTriggered))
|
|
||||||
{
|
|
||||||
trigger.StopLoadMenuAndStartWaitToOpenIt();
|
|
||||||
trigger.StartMenuOpener();
|
|
||||||
|
|
||||||
if (trigger.Reading.IsBusy)
|
|
||||||
{
|
|
||||||
trigger.RestartLoading = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LoadStarted(this, false);
|
|
||||||
trigger.Reading.RunWorkerAsync(level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckMenuOpenerStop(int menuIndex, int rowIndex, DataGridView dgv = null)
|
|
||||||
{
|
|
||||||
Menu menu = menus[menuIndex];
|
|
||||||
if (menu != null &&
|
|
||||||
rowIndex > -1)
|
|
||||||
{
|
|
||||||
if (dgv == null)
|
|
||||||
{
|
|
||||||
dgv = menu.GetDataGridView();
|
|
||||||
}
|
|
||||||
if (dgv.Rows.Count > rowIndex)
|
|
||||||
{
|
|
||||||
RowData trigger = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
|
||||||
if (trigger.Reading.IsBusy)
|
|
||||||
{
|
|
||||||
if (!trigger.IsContextMenuOpen)
|
|
||||||
{
|
|
||||||
trigger.IsSelected = false;
|
|
||||||
dgv.Rows[rowIndex].Selected = false;
|
|
||||||
}
|
|
||||||
trigger.Reading.CancelAsync();
|
|
||||||
}
|
|
||||||
else if (trigger.ContainsMenu && !trigger.IsLoading)
|
|
||||||
{
|
|
||||||
trigger.IsSelected = true;
|
|
||||||
dgv.Rows[rowIndex].Selected = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!trigger.IsContextMenuOpen)
|
|
||||||
{
|
|
||||||
trigger.IsSelected = false;
|
|
||||||
dgv.Rows[rowIndex].Selected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (trigger.IsLoading)
|
|
||||||
{
|
|
||||||
trigger.StopLoadMenuAndStartWaitToOpenIt();
|
|
||||||
trigger.IsLoading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dgv_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
|
|
||||||
{
|
|
||||||
if (!keyboardInput.InUse)
|
|
||||||
{
|
|
||||||
DataGridView dgv = (DataGridView)sender;
|
|
||||||
Menu menu = (Menu)dgv.FindForm();
|
|
||||||
CheckMenuOpenerStop(menu.Level, e.RowIndex, dgv);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dgv_MouseDown(object sender, MouseEventArgs e)
|
private void Dgv_MouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
DataGridView dgv = (DataGridView)sender;
|
DataGridView dgv = (DataGridView)sender;
|
||||||
|
@ -541,8 +514,9 @@ namespace SystemTrayMenu.Business
|
||||||
if (hitTestInfo.RowIndex > -1 &&
|
if (hitTestInfo.RowIndex > -1 &&
|
||||||
dgv.Rows.Count > hitTestInfo.RowIndex)
|
dgv.Rows.Count > hitTestInfo.RowIndex)
|
||||||
{
|
{
|
||||||
RowData trigger = (RowData)dgv.Rows[hitTestInfo.RowIndex].Cells[2].Value;
|
RowData rowData = (RowData)dgv.Rows[hitTestInfo.RowIndex].Cells[2].Value;
|
||||||
trigger.MouseDown(dgv, e);
|
rowData.MouseDown(dgv, e);
|
||||||
|
waitToOpenMenu.ClickOpensInstantly(dgv, hitTestInfo.RowIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +535,11 @@ namespace SystemTrayMenu.Business
|
||||||
|
|
||||||
private void Dgv_SelectionChanged(object sender, EventArgs e)
|
private void Dgv_SelectionChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DataGridView dgv = (DataGridView)sender;
|
RefreshSelection((DataGridView)sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshSelection(DataGridView dgv)
|
||||||
|
{
|
||||||
foreach (DataGridViewRow row in dgv.Rows)
|
foreach (DataGridViewRow row in dgv.Rows)
|
||||||
{
|
{
|
||||||
RowData rowData = (RowData)row.Cells[2].Value;
|
RowData rowData = (RowData)row.Cells[2].Value;
|
||||||
|
@ -573,14 +551,15 @@ namespace SystemTrayMenu.Business
|
||||||
else if (!menus[0].IsUsable)
|
else if (!menus[0].IsUsable)
|
||||||
{
|
{
|
||||||
row.DefaultCellStyle.SelectionBackColor = Color.White;
|
row.DefaultCellStyle.SelectionBackColor = Color.White;
|
||||||
|
row.Selected = false;
|
||||||
}
|
}
|
||||||
else if (rowData.IsSelectedByKeyboard)
|
else if (rowData.IsSelected)
|
||||||
{
|
{
|
||||||
row.DefaultCellStyle.SelectionBackColor =
|
row.DefaultCellStyle.SelectionBackColor =
|
||||||
MenuDefines.ColorSelectedItem;
|
MenuDefines.ColorSelectedItem;
|
||||||
row.Selected = true;
|
row.Selected = true;
|
||||||
}
|
}
|
||||||
else if (rowData.IsSelected)
|
else if (rowData.IsMenuOpen)
|
||||||
{
|
{
|
||||||
row.DefaultCellStyle.SelectionBackColor =
|
row.DefaultCellStyle.SelectionBackColor =
|
||||||
MenuDefines.ColorOpenFolder;
|
MenuDefines.ColorOpenFolder;
|
||||||
|
@ -588,93 +567,42 @@ namespace SystemTrayMenu.Business
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rowData.IsSelected = false;
|
row.DefaultCellStyle.SelectionBackColor = Color.White;
|
||||||
row.Selected = false;
|
row.Selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateMenuRow(RowData rowData, Menu menu, DataTable dataTable)
|
private void ShowSubMenu(Menu menuToShow)
|
||||||
{
|
{
|
||||||
rowData.SetData(rowData, dataTable);
|
//Clean up menu status IsMenuOpen for previous one
|
||||||
rowData.OpenMenu += OpenSubMenu;
|
Menu menuPrevious = menus[menuToShow.Level - 1];
|
||||||
rowData.Reading.WorkerSupportsCancellation = true;
|
DataGridView dgvPrevious = menuPrevious.GetDataGridView();
|
||||||
rowData.Reading.DoWork += ReadMenu_DoWork;
|
foreach (DataRow row in ((DataTable)dgvPrevious.DataSource).Rows)
|
||||||
void ReadMenu_DoWork(object senderDoWork,
|
|
||||||
DoWorkEventArgs eDoWork)
|
|
||||||
{
|
{
|
||||||
int level = (int)eDoWork.Argument;
|
RowData rowDataToClear = (RowData)row[2];
|
||||||
BackgroundWorker worker = (BackgroundWorker)senderDoWork;
|
if (rowDataToClear == (RowData)menuToShow.Tag)
|
||||||
eDoWork.Result = Business.Menus.GetData(worker, rowData.TargetFilePath, level);
|
|
||||||
}
|
|
||||||
|
|
||||||
rowData.Reading.RunWorkerCompleted += ReadMenu_RunWorkerCompleted;
|
|
||||||
void ReadMenu_RunWorkerCompleted(object senderCompleted,
|
|
||||||
RunWorkerCompletedEventArgs e)
|
|
||||||
{
|
{
|
||||||
MenuData menuData = (MenuData)e.Result;
|
rowDataToClear.IsMenuOpen = true;
|
||||||
if (rowData.RestartLoading)
|
|
||||||
{
|
|
||||||
rowData.RestartLoading = false;
|
|
||||||
rowData.Reading.RunWorkerAsync(menuData.Level);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadStopped();
|
rowDataToClear.IsMenuOpen = false;
|
||||||
if (menuData.Validity != MenuDataValidity.Invalid)
|
|
||||||
{
|
|
||||||
menu = Create(menuData);
|
|
||||||
if (menuData.RowDatas.Count > 0)
|
|
||||||
{
|
|
||||||
menu.SetTypeSub();
|
|
||||||
}
|
|
||||||
else if (menuData.Validity == MenuDataValidity.NoAccess)
|
|
||||||
{
|
|
||||||
menu.SetTypeNoAccess();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
menu.SetTypeEmpty();
|
|
||||||
}
|
|
||||||
menu.Tag = rowData;
|
|
||||||
rowData.SubMenu = menu;
|
|
||||||
rowData.MenuLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RefreshSelection(dgvPrevious);
|
||||||
|
|
||||||
private void OpenSubMenu(object sender, RowData trigger)
|
foreach (Menu menuToClose in menus.Where(
|
||||||
|
m => m != null && m.Level > menuPrevious.Level))
|
||||||
{
|
{
|
||||||
Menu menuTriggered = trigger.SubMenu;
|
|
||||||
Menu menuFromTrigger = menus[menuTriggered.Level - 1];
|
|
||||||
|
|
||||||
for (int level = menuTriggered.Level;
|
|
||||||
level < MenuDefines.MenusMax; level++)
|
|
||||||
{
|
|
||||||
if (menus[level] != null)
|
|
||||||
{
|
|
||||||
Menu menuToClose = menus[level];
|
|
||||||
RowData oldTrigger = (RowData)menuToClose.Tag;
|
|
||||||
DataGridView dgv = menuFromTrigger.GetDataGridView();
|
|
||||||
foreach (DataGridViewRow row in dgv.Rows)
|
|
||||||
{
|
|
||||||
RowData rowData = (RowData)row.Cells[2].Value;
|
|
||||||
rowData.IsSelected = false;
|
|
||||||
}
|
|
||||||
trigger.IsSelected = true;
|
|
||||||
dgv.ClearSelection();
|
|
||||||
dgv.Rows[trigger.RowIndex].Selected = true;
|
|
||||||
menuToClose.HideWithFade();
|
|
||||||
menuToClose.VisibleChanged += MenuVisibleChanged;
|
menuToClose.VisibleChanged += MenuVisibleChanged;
|
||||||
menus[level] = null;
|
menuToClose.HideWithFade();
|
||||||
}
|
menus[menuToClose.Level] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeMenu(menus[menuTriggered.Level]);
|
menus[menuToShow.Level] = menuToShow;
|
||||||
menus[menuTriggered.Level] = menuTriggered;
|
|
||||||
AdjustMenusSizeAndLocation();
|
AdjustMenusSizeAndLocation();
|
||||||
menus[menuTriggered.Level].ShowWithFadeOrTransparent(IsActive());
|
menus[menuToShow.Level].ShowWithFadeOrTransparent(IsActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FadeInIfNeeded()
|
private void FadeInIfNeeded()
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
using System;
|
|
||||||
using SystemTrayMenu.Utilities;
|
|
||||||
using Timer = System.Windows.Forms.Timer;
|
|
||||||
|
|
||||||
namespace SystemTrayMenu.Handler
|
|
||||||
{
|
|
||||||
internal class WaitMenuOpen : IDisposable
|
|
||||||
{
|
|
||||||
public event EventHandlerEmpty DoOpen;
|
|
||||||
|
|
||||||
private readonly Timer waitOpen = new Timer();
|
|
||||||
private bool waitedDone = false;
|
|
||||||
private bool clicked = false;
|
|
||||||
private bool menuLoaded = false;
|
|
||||||
|
|
||||||
public WaitMenuOpen()
|
|
||||||
{
|
|
||||||
waitOpen.Interval = MenuDefines.WaitMenuOpen;
|
|
||||||
waitOpen.Tick += WaitOpen_Tick;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WaitOpen_Tick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
waitOpen.Stop();
|
|
||||||
waitedDone = true;
|
|
||||||
CheckConditionsToOpenMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckConditionsToOpenMenu()
|
|
||||||
{
|
|
||||||
if ((waitedDone || clicked) &&
|
|
||||||
menuLoaded)
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
DoOpen?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// When mouse on menu, wait x ms until open it
|
|
||||||
// meanwhile load content, click opens when loaded
|
|
||||||
// (to not interrupt user when he moves into a submenu)
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
if (!waitedDone)
|
|
||||||
{
|
|
||||||
waitOpen.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
clicked = false;
|
|
||||||
waitedDone = false;
|
|
||||||
menuLoaded = false;
|
|
||||||
waitOpen.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Click()
|
|
||||||
{
|
|
||||||
clicked = true;
|
|
||||||
CheckConditionsToOpenMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void MenuLoaded()
|
|
||||||
{
|
|
||||||
menuLoaded = true;
|
|
||||||
CheckConditionsToOpenMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
waitOpen.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
139
Business/WaitToLoadMenu.cs
Normal file
139
Business/WaitToLoadMenu.cs
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using SystemTrayMenu.DataClasses;
|
||||||
|
using SystemTrayMenu.UserInterface;
|
||||||
|
using SystemTrayMenu.Utilities;
|
||||||
|
using Timer = System.Windows.Forms.Timer;
|
||||||
|
|
||||||
|
namespace SystemTrayMenu.Handler
|
||||||
|
{
|
||||||
|
internal class WaitToLoadMenu : IDisposable
|
||||||
|
{
|
||||||
|
internal event Action<RowData> StartLoadMenu;
|
||||||
|
internal event EventHandlerEmpty StopLoadMenu;
|
||||||
|
|
||||||
|
private readonly Timer timer = new Timer();
|
||||||
|
private DataGridView dgv = null;
|
||||||
|
private int rowIndex = 0;
|
||||||
|
|
||||||
|
private bool mouseActive = false;
|
||||||
|
private bool checkForMouseActive = false;
|
||||||
|
|
||||||
|
internal WaitToLoadMenu()
|
||||||
|
{
|
||||||
|
timer.Interval = 200;
|
||||||
|
timer.Tick += WaitOpen_Tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void MouseEnter(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
SetData((DataGridView)sender, e.RowIndex);
|
||||||
|
checkForMouseActive = true;
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RowSelected(DataGridView dgv, int rowIndex)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
SetData(dgv, rowIndex);
|
||||||
|
mouseActive = false;
|
||||||
|
checkForMouseActive = false;
|
||||||
|
timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void MouseLeave(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
ResetData((DataGridView)sender, e.RowIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void RowDeselected(int iMenuBefore, int rowIndex, DataGridView dgv) //iMenuBefore not needed
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
ResetData(dgv, rowIndex);
|
||||||
|
mouseActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClickOpensInstantly(DataGridView dgv, int rowIndex)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
SetData(dgv, rowIndex);
|
||||||
|
mouseActive = true;
|
||||||
|
checkForMouseActive = false;
|
||||||
|
CallOpenMenuNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void EnterOpensInstantly(DataGridView dgv, int rowIndex)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
StopLoadMenu.Invoke();
|
||||||
|
SetData(dgv, rowIndex);
|
||||||
|
mouseActive = false;
|
||||||
|
checkForMouseActive = false;
|
||||||
|
CallOpenMenuNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void MouseMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
mouseActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WaitOpen_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
if (!checkForMouseActive || mouseActive)
|
||||||
|
{
|
||||||
|
CallOpenMenuNow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CallOpenMenuNow()
|
||||||
|
{
|
||||||
|
if (dgv.Rows.Count > rowIndex)
|
||||||
|
{
|
||||||
|
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
||||||
|
Menu menu = (Menu)dgv.FindForm();
|
||||||
|
rowData.MenuLevel = menu.Level;
|
||||||
|
if (!rowData.IsContextMenuOpen &&
|
||||||
|
rowData.ContainsMenu &&
|
||||||
|
rowData.MenuLevel < MenuDefines.MenusMax)
|
||||||
|
{
|
||||||
|
StartLoadMenu.Invoke(rowData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetData(DataGridView dgv, int rowIndex)
|
||||||
|
{
|
||||||
|
this.dgv = dgv;
|
||||||
|
this.rowIndex = rowIndex;
|
||||||
|
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
||||||
|
rowData.IsSelected = true;
|
||||||
|
dgv.Rows[rowIndex].Selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetData(DataGridView dgv, int rowIndex)
|
||||||
|
{
|
||||||
|
if (dgv != null)
|
||||||
|
{
|
||||||
|
RowData rowData = (RowData)dgv.Rows[rowIndex].Cells[2].Value;
|
||||||
|
rowData.IsSelected = false;
|
||||||
|
dgv.Rows[rowIndex].Selected = false;
|
||||||
|
this.dgv = null;
|
||||||
|
this.rowIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
timer.Stop();
|
||||||
|
timer.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
//using Microsoft.WindowsAPICodePack.Dialogs;
|
using System.Diagnostics;
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
|
@ -14,11 +14,11 @@ namespace SystemTrayMenu
|
||||||
internal static readonly Color ColorTitleSelected = AppColors.Yellow;
|
internal static readonly Color ColorTitleSelected = AppColors.Yellow;
|
||||||
internal static readonly Color ColorTitleBackground = AppColors.Azure;
|
internal static readonly Color ColorTitleBackground = AppColors.Azure;
|
||||||
internal const int KeySearchInterval = 1000;
|
internal const int KeySearchInterval = 1000;
|
||||||
internal const int LengthMax = 37;
|
|
||||||
internal const int Scrollspeed = 4;
|
internal const int Scrollspeed = 4;
|
||||||
internal const int WaitMenuOpen = 200;
|
|
||||||
internal const int MenusMax = 50;
|
|
||||||
internal const int TimeUntilClose = 1000;
|
internal const int TimeUntilClose = 1000;
|
||||||
|
internal const int MenusMax = 50;
|
||||||
|
internal const int LengthMax = 37;
|
||||||
|
internal static float MaxMenuWidth = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class AppColors
|
internal static class AppColors
|
||||||
|
|
|
@ -4,15 +4,17 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
internal enum MenuDataValidity
|
internal enum MenuDataValidity
|
||||||
{
|
{
|
||||||
|
AbortedOrUnknown,
|
||||||
Valid,
|
Valid,
|
||||||
Invalid,
|
Empty,
|
||||||
NoAccess
|
NoAccess
|
||||||
}
|
}
|
||||||
|
|
||||||
internal struct MenuData
|
internal struct MenuData
|
||||||
{
|
{
|
||||||
public List<RowData> RowDatas;
|
internal List<RowData> RowDatas;
|
||||||
public MenuDataValidity Validity;
|
internal MenuDataValidity Validity;
|
||||||
public int Level;
|
internal int Level;
|
||||||
|
internal RowData RowDataParent;
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -10,7 +10,6 @@ using System.Linq;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using SystemTrayMenu.Handler;
|
|
||||||
using SystemTrayMenu.Utilities;
|
using SystemTrayMenu.Utilities;
|
||||||
using TAFactory.IconPack;
|
using TAFactory.IconPack;
|
||||||
using Menu = SystemTrayMenu.UserInterface.Menu;
|
using Menu = SystemTrayMenu.UserInterface.Menu;
|
||||||
|
@ -19,18 +18,14 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
internal class RowData : IDisposable
|
internal class RowData : IDisposable
|
||||||
{
|
{
|
||||||
internal event EventHandler<RowData> OpenMenu;
|
|
||||||
internal BackgroundWorker Reading = new BackgroundWorker();
|
|
||||||
internal FileInfo FileInfo;
|
internal FileInfo FileInfo;
|
||||||
internal Menu SubMenu;
|
internal Menu SubMenu;
|
||||||
|
internal bool IsMenuOpen;
|
||||||
internal bool IsSelected;
|
internal bool IsSelected;
|
||||||
internal bool IsSelectedByKeyboard;
|
|
||||||
internal bool ContainsMenu;
|
internal bool ContainsMenu;
|
||||||
internal bool IsContextMenuOpen;
|
internal bool IsContextMenuOpen;
|
||||||
private static DateTime ContextMenuClosed;
|
private static DateTime ContextMenuClosed;
|
||||||
internal bool IsResolvedLnk;
|
internal bool IsResolvedLnk;
|
||||||
internal bool IsLoading = false;
|
|
||||||
internal bool RestartLoading = false;
|
|
||||||
internal bool HiddenEntry;
|
internal bool HiddenEntry;
|
||||||
internal string TargetFilePath;
|
internal string TargetFilePath;
|
||||||
internal string TargetFilePathOrig;
|
internal string TargetFilePathOrig;
|
||||||
|
@ -38,23 +33,17 @@ namespace SystemTrayMenu.DataClasses
|
||||||
private string WorkingDirectory;
|
private string WorkingDirectory;
|
||||||
private string Arguments;
|
private string Arguments;
|
||||||
private string Text;
|
private string Text;
|
||||||
private readonly WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
|
|
||||||
private Icon Icon = null;
|
private Icon Icon = null;
|
||||||
private bool diposeIcon = true;
|
private bool diposeIcon = true;
|
||||||
private bool isDisposed = false;
|
private bool isDisposed = false;
|
||||||
|
internal int MenuLevel;
|
||||||
|
|
||||||
internal RowData()
|
internal RowData()
|
||||||
{
|
{
|
||||||
Reading.WorkerSupportsCancellation = true;
|
|
||||||
waitMenuOpen.DoOpen += WaitMenuOpen_DoOpen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void SetText(string text)
|
internal void SetText(string text)
|
||||||
{
|
{
|
||||||
if (text.Length > MenuDefines.LengthMax)
|
|
||||||
{
|
|
||||||
text = $"{text.Substring(0, MenuDefines.LengthMax)}...";
|
|
||||||
}
|
|
||||||
Text = text;
|
Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,16 +284,6 @@ namespace SystemTrayMenu.DataClasses
|
||||||
|
|
||||||
internal void MouseDown(DataGridView dgv, MouseEventArgs e)
|
internal void MouseDown(DataGridView dgv, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (ContainsMenu)
|
|
||||||
{
|
|
||||||
TriggerMenuOpener(); // Touchscreen
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IsLoading)
|
|
||||||
{
|
|
||||||
waitMenuOpen.Click();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e != null &&
|
if (e != null &&
|
||||||
e.Button == MouseButtons.Right &&
|
e.Button == MouseButtons.Right &&
|
||||||
FileInfo != null &&
|
FileInfo != null &&
|
||||||
|
@ -381,43 +360,6 @@ namespace SystemTrayMenu.DataClasses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void MenuLoaded()
|
|
||||||
{
|
|
||||||
waitMenuOpen.MenuLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void StartMenuOpener()
|
|
||||||
{
|
|
||||||
if (ContainsMenu)
|
|
||||||
{
|
|
||||||
IsLoading = true;
|
|
||||||
waitMenuOpen.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TriggerMenuOpener()
|
|
||||||
{
|
|
||||||
if (ContainsMenu && IsLoading)
|
|
||||||
{
|
|
||||||
waitMenuOpen.Start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void StopLoadMenuAndStartWaitToOpenIt()
|
|
||||||
{
|
|
||||||
if (ContainsMenu)
|
|
||||||
{
|
|
||||||
waitMenuOpen.Stop();
|
|
||||||
//IsLoading = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WaitMenuOpen_DoOpen()
|
|
||||||
{
|
|
||||||
IsLoading = false;
|
|
||||||
OpenMenu?.Invoke(this, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -428,8 +370,6 @@ namespace SystemTrayMenu.DataClasses
|
||||||
{
|
{
|
||||||
if (!isDisposed)
|
if (!isDisposed)
|
||||||
{
|
{
|
||||||
waitMenuOpen.Dispose();
|
|
||||||
Reading.Dispose();
|
|
||||||
if (diposeIcon)
|
if (diposeIcon)
|
||||||
{
|
{
|
||||||
Icon?.Dispose();
|
Icon?.Dispose();
|
||||||
|
|
|
@ -35,5 +35,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("0.10.2.7")]
|
[assembly: AssemblyVersion("0.10.2.8")]
|
||||||
[assembly: AssemblyFileVersion("0.10.2.7")]
|
[assembly: AssemblyFileVersion("0.10.2.8")]
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace SystemTrayMenu.UserInterface
|
||||||
private const int Interval60FPS = 16; //60fps=>1s/60fps=~16.6ms
|
private const int Interval60FPS = 16; //60fps=>1s/60fps=~16.6ms
|
||||||
private readonly NotifyIcon notifyIcon = new NotifyIcon();
|
private readonly NotifyIcon notifyIcon = new NotifyIcon();
|
||||||
private DateTime timeLoadingStart;
|
private DateTime timeLoadingStart;
|
||||||
private int threadsLoading = 0;
|
private bool threadsLoading = false;
|
||||||
private readonly Timer load = new Timer();
|
private readonly Timer load = new Timer();
|
||||||
private int loadCount = 0;
|
private int loadCount = 0;
|
||||||
private readonly int indexLoad = 0;
|
private readonly int indexLoad = 0;
|
||||||
|
@ -85,36 +85,21 @@ namespace SystemTrayMenu.UserInterface
|
||||||
load.Dispose();
|
load.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadingStart(object sender = null, bool reset = false)
|
public void LoadingStart()
|
||||||
{
|
{
|
||||||
if (reset)
|
|
||||||
{
|
|
||||||
threadsLoading = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeLoadingStart = DateTime.Now;
|
timeLoadingStart = DateTime.Now;
|
||||||
threadsLoading++;
|
threadsLoading = true;
|
||||||
load.Start();
|
load.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadingStop()
|
public void LoadingStop()
|
||||||
{
|
{
|
||||||
threadsLoading--;
|
threadsLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show a static icon when mainthread blocked
|
|
||||||
//public void LoadingStaticWait()
|
|
||||||
//{
|
|
||||||
// notifyIcon.Icon = bitmapsLoading[loadCount++ % indexLoad];
|
|
||||||
//}
|
|
||||||
//public void LoadingStaticStop()
|
|
||||||
//{
|
|
||||||
// notifyIcon.Icon = R.SystemTrayMenu;
|
|
||||||
//}
|
|
||||||
|
|
||||||
private void Load_Tick(object sender, EventArgs e)
|
private void Load_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (threadsLoading > 0)
|
if (threadsLoading)
|
||||||
{
|
{
|
||||||
if (DateTime.Now - timeLoadingStart > new TimeSpan(0, 0, 0, 0, 500))
|
if (DateTime.Now - timeLoadingStart > new TimeSpan(0, 0, 0, 0, 500))
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,33 +42,30 @@ namespace SystemTrayMenu.UserInterface.FolderDialog
|
||||||
}
|
}
|
||||||
public DialogResult ShowVistaDialog(IWin32Window owner)
|
public DialogResult ShowVistaDialog(IWin32Window owner)
|
||||||
{
|
{
|
||||||
var frm = (NativeMethods.IFileDialog)(new NativeMethods.FileOpenDialogRCW());
|
NativeMethods.IFileDialog frm = (NativeMethods.IFileDialog)(new NativeMethods.FileOpenDialogRCW());
|
||||||
uint options;
|
frm.GetOptions(out uint options);
|
||||||
frm.GetOptions(out options);
|
|
||||||
options |= NativeMethods.FOS_PICKFOLDERS |
|
options |= NativeMethods.FOS_PICKFOLDERS |
|
||||||
NativeMethods.FOS_FORCEFILESYSTEM |
|
NativeMethods.FOS_FORCEFILESYSTEM |
|
||||||
NativeMethods.FOS_NOVALIDATE |
|
NativeMethods.FOS_NOVALIDATE |
|
||||||
NativeMethods.FOS_NOTESTFILECREATE |
|
NativeMethods.FOS_NOTESTFILECREATE |
|
||||||
NativeMethods.FOS_DONTADDTORECENT;
|
NativeMethods.FOS_DONTADDTORECENT;
|
||||||
frm.SetOptions(options);
|
frm.SetOptions(options);
|
||||||
if (this.InitialFolder != null)
|
if (InitialFolder != null)
|
||||||
{
|
{
|
||||||
NativeMethods.IShellItem directoryShellItem;
|
Guid riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
|
||||||
var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
|
|
||||||
if (NativeMethods.SHCreateItemFromParsingName
|
if (NativeMethods.SHCreateItemFromParsingName
|
||||||
(this.InitialFolder, IntPtr.Zero, ref riid,
|
(InitialFolder, IntPtr.Zero, ref riid,
|
||||||
out directoryShellItem) == NativeMethods.S_OK)
|
out NativeMethods.IShellItem directoryShellItem) == NativeMethods.S_OK)
|
||||||
{
|
{
|
||||||
frm.SetFolder(directoryShellItem);
|
frm.SetFolder(directoryShellItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.DefaultFolder != null)
|
if (DefaultFolder != null)
|
||||||
{
|
{
|
||||||
NativeMethods.IShellItem directoryShellItem;
|
Guid riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
|
||||||
var riid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IShellItem
|
|
||||||
if (NativeMethods.SHCreateItemFromParsingName
|
if (NativeMethods.SHCreateItemFromParsingName
|
||||||
(this.DefaultFolder, IntPtr.Zero, ref riid,
|
(DefaultFolder, IntPtr.Zero, ref riid,
|
||||||
out directoryShellItem) == NativeMethods.S_OK)
|
out NativeMethods.IShellItem directoryShellItem) == NativeMethods.S_OK)
|
||||||
{
|
{
|
||||||
frm.SetDefaultFolder(directoryShellItem);
|
frm.SetDefaultFolder(directoryShellItem);
|
||||||
}
|
}
|
||||||
|
@ -76,18 +73,16 @@ namespace SystemTrayMenu.UserInterface.FolderDialog
|
||||||
|
|
||||||
if (frm.Show(owner.Handle) == NativeMethods.S_OK)
|
if (frm.Show(owner.Handle) == NativeMethods.S_OK)
|
||||||
{
|
{
|
||||||
NativeMethods.IShellItem shellItem;
|
if (frm.GetResult(out NativeMethods.IShellItem shellItem) == NativeMethods.S_OK)
|
||||||
if (frm.GetResult(out shellItem) == NativeMethods.S_OK)
|
|
||||||
{
|
{
|
||||||
IntPtr pszString;
|
|
||||||
if (shellItem.GetDisplayName(NativeMethods.SIGDN_FILESYSPATH,
|
if (shellItem.GetDisplayName(NativeMethods.SIGDN_FILESYSPATH,
|
||||||
out pszString) == NativeMethods.S_OK)
|
out IntPtr pszString) == NativeMethods.S_OK)
|
||||||
{
|
{
|
||||||
if (pszString != IntPtr.Zero)
|
if (pszString != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.Folder = Marshal.PtrToStringAuto(pszString);
|
Folder = Marshal.PtrToStringAuto(pszString);
|
||||||
return DialogResult.OK;
|
return DialogResult.OK;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -102,20 +97,20 @@ namespace SystemTrayMenu.UserInterface.FolderDialog
|
||||||
}
|
}
|
||||||
public DialogResult ShowLegacyDialog(IWin32Window owner)
|
public DialogResult ShowLegacyDialog(IWin32Window owner)
|
||||||
{
|
{
|
||||||
using (var frm = new SaveFileDialog())
|
using (SaveFileDialog frm = new SaveFileDialog())
|
||||||
{
|
{
|
||||||
frm.CheckFileExists = false;
|
frm.CheckFileExists = false;
|
||||||
frm.CheckPathExists = true;
|
frm.CheckPathExists = true;
|
||||||
frm.CreatePrompt = false;
|
frm.CreatePrompt = false;
|
||||||
frm.Filter = "|" + Guid.Empty.ToString();
|
frm.Filter = "|" + Guid.Empty.ToString();
|
||||||
frm.FileName = "any";
|
frm.FileName = "any";
|
||||||
if (this.InitialFolder != null) { frm.InitialDirectory = this.InitialFolder; }
|
if (InitialFolder != null) { frm.InitialDirectory = InitialFolder; }
|
||||||
frm.OverwritePrompt = false;
|
frm.OverwritePrompt = false;
|
||||||
frm.Title = "Select Folder";
|
frm.Title = "Select Folder";
|
||||||
frm.ValidateNames = false;
|
frm.ValidateNames = false;
|
||||||
if (frm.ShowDialog(owner) == DialogResult.OK)
|
if (frm.ShowDialog(owner) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
this.Folder = Path.GetDirectoryName(frm.FileName);
|
Folder = Path.GetDirectoryName(frm.FileName);
|
||||||
return DialogResult.OK;
|
return DialogResult.OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -154,12 +149,9 @@ namespace SystemTrayMenu.UserInterface.FolderDialog
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Original ptr
|
/// Original ptr
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IntPtr Handle
|
public IntPtr Handle => _hwnd;
|
||||||
{
|
|
||||||
get { return _hwnd; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntPtr _hwnd;
|
private readonly IntPtr _hwnd;
|
||||||
}
|
}
|
||||||
internal static class NativeMethods
|
internal static class NativeMethods
|
||||||
{
|
{
|
||||||
|
|
1
UserInterface/Menu.Designer.cs
generated
1
UserInterface/Menu.Designer.cs
generated
|
@ -174,6 +174,7 @@
|
||||||
this.textBoxSearch.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold);
|
this.textBoxSearch.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold);
|
||||||
this.textBoxSearch.Location = new System.Drawing.Point(25, 4);
|
this.textBoxSearch.Location = new System.Drawing.Point(25, 4);
|
||||||
this.textBoxSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 2);
|
this.textBoxSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 2);
|
||||||
|
this.textBoxSearch.MaxLength = 37;
|
||||||
this.textBoxSearch.Name = "textBoxSearch";
|
this.textBoxSearch.Name = "textBoxSearch";
|
||||||
this.textBoxSearch.ShortcutsEnabled = false;
|
this.textBoxSearch.ShortcutsEnabled = false;
|
||||||
this.textBoxSearch.Size = new System.Drawing.Size(55, 15);
|
this.textBoxSearch.Size = new System.Drawing.Size(55, 15);
|
||||||
|
|
|
@ -20,7 +20,6 @@ namespace SystemTrayMenu.UserInterface
|
||||||
internal event EventHandler<Keys> CmdKeyProcessed;
|
internal event EventHandler<Keys> CmdKeyProcessed;
|
||||||
internal event EventHandlerEmpty SearchTextChanging;
|
internal event EventHandlerEmpty SearchTextChanging;
|
||||||
internal event EventHandler SearchTextChanged;
|
internal event EventHandler SearchTextChanged;
|
||||||
#warning #68 => use event and not a action here?
|
|
||||||
|
|
||||||
internal bool IsUsable => Visible && !fading.IsHiding &&
|
internal bool IsUsable => Visible && !fading.IsHiding &&
|
||||||
!IsDisposed && !Disposing;
|
!IsDisposed && !Disposing;
|
||||||
|
@ -158,23 +157,23 @@ namespace SystemTrayMenu.UserInterface
|
||||||
case MenuType.Empty:
|
case MenuType.Empty:
|
||||||
SetTitle(Translator.GetText("Folder empty"));
|
SetTitle(Translator.GetText("Folder empty"));
|
||||||
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
||||||
this.pictureBoxSearch.Visible = false;
|
pictureBoxSearch.Visible = false;
|
||||||
this.textBoxSearch.Visible = false;
|
textBoxSearch.Visible = false;
|
||||||
this.tableLayoutPanelSearch.Visible = false;
|
tableLayoutPanelSearch.Visible = false;
|
||||||
break;
|
break;
|
||||||
case MenuType.NoAccess:
|
case MenuType.NoAccess:
|
||||||
SetTitle(Translator.GetText("Folder inaccessible"));
|
SetTitle(Translator.GetText("Folder inaccessible"));
|
||||||
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
||||||
this.pictureBoxSearch.Visible = false;
|
pictureBoxSearch.Visible = false;
|
||||||
this.textBoxSearch.Visible = false;
|
textBoxSearch.Visible = false;
|
||||||
this.tableLayoutPanelSearch.Visible = false;
|
tableLayoutPanelSearch.Visible = false;
|
||||||
break;
|
break;
|
||||||
case MenuType.MaxReached:
|
case MenuType.MaxReached:
|
||||||
SetTitle($"Max {MenuDefines.MenusMax - 1} Menus");
|
SetTitle($"Max {MenuDefines.MenusMax - 1} Menus");
|
||||||
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
labelTitle.BackColor = MenuDefines.ColorTitleWarning;
|
||||||
this.pictureBoxSearch.Visible = false;
|
pictureBoxSearch.Visible = false;
|
||||||
this.textBoxSearch.Visible = false;
|
textBoxSearch.Visible = false;
|
||||||
this.tableLayoutPanelSearch.Visible = false;
|
tableLayoutPanelSearch.Visible = false;
|
||||||
break;
|
break;
|
||||||
case MenuType.Main:
|
case MenuType.Main:
|
||||||
break;
|
break;
|
||||||
|
@ -275,13 +274,15 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
if (directionToRight)
|
if (directionToRight)
|
||||||
{
|
{
|
||||||
x = menuPredecessor.Location.X + Width -
|
x = menuPredecessor.Location.X +
|
||||||
|
menuPredecessor.Width -
|
||||||
(int)Math.Round(Scaling.Factor, 0,
|
(int)Math.Round(Scaling.Factor, 0,
|
||||||
MidpointRounding.AwayFromZero);
|
MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = menuPredecessor.Location.X - Width +
|
x = menuPredecessor.Location.X -
|
||||||
|
Width +
|
||||||
(int)Math.Round(Scaling.Factor, 0,
|
(int)Math.Round(Scaling.Factor, 0,
|
||||||
MidpointRounding.AwayFromZero);
|
MidpointRounding.AwayFromZero);
|
||||||
}
|
}
|
||||||
|
@ -302,17 +303,17 @@ namespace SystemTrayMenu.UserInterface
|
||||||
{
|
{
|
||||||
RowData trigger = (RowData)Tag;
|
RowData trigger = (RowData)Tag;
|
||||||
DataGridView dgv = menuPredecessor.GetDataGridView();
|
DataGridView dgv = menuPredecessor.GetDataGridView();
|
||||||
int distanceToDgvTop = 0;
|
int distanceFromItemToDgvTop = 0;
|
||||||
if (dgv.Rows.Count > trigger.RowIndex)
|
if (dgv.Rows.Count > trigger.RowIndex)
|
||||||
{
|
{
|
||||||
Rectangle cellRectangle = dgv.GetCellDisplayRectangle(
|
Rectangle cellRectangle = dgv.GetCellDisplayRectangle(
|
||||||
0, trigger.RowIndex, false);
|
0, trigger.RowIndex, false);
|
||||||
distanceToDgvTop = cellRectangle.Top;
|
distanceFromItemToDgvTop = cellRectangle.Top;
|
||||||
}
|
}
|
||||||
y = menuPredecessor.Location.Y +
|
y = menuPredecessor.Location.Y +
|
||||||
menuPredecessor.dgv.Location.Y +
|
menuPredecessor.dgv.Location.Y +
|
||||||
distanceToDgvTop;
|
distanceFromItemToDgvTop;
|
||||||
if ((y + Height) > dgvHeightMax)
|
if ((y + Height - tableLayoutPanelSearch.Height) > dgvHeightMax)
|
||||||
{
|
{
|
||||||
y = dgvHeightMax - Height + menuRestNeeded;
|
y = dgvHeightMax - Height + menuRestNeeded;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,10 @@ namespace SystemTrayMenu.Utilities
|
||||||
widthMax = checkWidth;
|
widthMax = checkWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (widthMax > MenuDefines.MaxMenuWidth)
|
||||||
|
{
|
||||||
|
widthMax = MenuDefines.MaxMenuWidth;
|
||||||
|
}
|
||||||
dgv.Columns[i].Width = (int)(widthMax + 0.5);
|
dgv.Columns[i].Width = (int)(widthMax + 0.5);
|
||||||
|
|
||||||
string stringWithWidthLikeIcon = "____";
|
string stringWithWidthLikeIcon = "____";
|
||||||
|
|
Loading…
Reference in a new issue