[Feature] Stay open when 'Enter' pressed and reactivated within 200ms (#223, #226, #227), version 1.0.24.4

This commit is contained in:
Markus Hofknecht 2021-10-28 16:29:04 +02:00
parent ceb128b702
commit a140f13c23
5 changed files with 32 additions and 15 deletions

View file

@ -37,6 +37,7 @@ namespace SystemTrayMenu.Business
private bool showingMessageBox; private bool showingMessageBox;
private TaskbarPosition taskbarPosition = new WindowsTaskbar().Position; private TaskbarPosition taskbarPosition = new WindowsTaskbar().Position;
private bool searchTextChanging; private bool searchTextChanging;
private bool waitingForReactivate;
public Menus() public Menus()
{ {
@ -245,15 +246,16 @@ namespace SystemTrayMenu.Business
} }
timerShowProcessStartedAsLoadingIcon.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed; timerShowProcessStartedAsLoadingIcon.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed;
timerStillActiveCheck.Interval = 1000; timerStillActiveCheck.Interval = Properties.Settings.Default.TimeUntilClosesAfterEnterPressed + 20;
timerStillActiveCheck.Tick += (sender, e) => StillActiveTick(); timerStillActiveCheck.Tick += (sender, e) => StillActiveTick();
void StillActiveTick() void StillActiveTick()
{ {
if (!IsActive()) if (!IsActive())
{ {
FadeHalfOrOutIfNeeded(); FadeHalfOrOutIfNeeded();
timerStillActiveCheck.Stop();
} }
timerStillActiveCheck.Stop();
} }
waitLeave.LeaveTriggered += FadeHalfOrOutIfNeeded; waitLeave.LeaveTriggered += FadeHalfOrOutIfNeeded;
@ -481,7 +483,9 @@ namespace SystemTrayMenu.Business
internal bool IsOpenCloseStateOpening() internal bool IsOpenCloseStateOpening()
{ {
return openCloseState == OpenCloseState.Opening; Log.Info(openCloseState.ToString());
return openCloseState == OpenCloseState.Opening ||
(openCloseState == OpenCloseState.Default && menus[0] != null && menus[0].Visible);
} }
internal void SwitchOpenClose(bool byClick) internal void SwitchOpenClose(bool byClick)
@ -669,7 +673,7 @@ namespace SystemTrayMenu.Business
void Deactivate(object sender, EventArgs e) void Deactivate(object sender, EventArgs e)
{ {
if (!Properties.Settings.Default.StaysOpenWhenFocusLostAfterEnterPressed || if (!Properties.Settings.Default.StaysOpenWhenFocusLostAfterEnterPressed ||
!timerStillActiveCheck.Enabled) !waitingForReactivate)
{ {
FadeHalfOrOutIfNeeded(); FadeHalfOrOutIfNeeded();
if (!IsActive()) if (!IsActive())
@ -877,20 +881,16 @@ namespace SystemTrayMenu.Business
if (rowData.ProcessStarted) if (rowData.ProcessStarted)
{ {
waitingForReactivate = true;
rowData.ProcessStarted = false; rowData.ProcessStarted = false;
row.Cells[0].Value = Resources.StaticResources.LoadingIcon; row.Cells[0].Value = Resources.StaticResources.LoadingIcon;
timerShowProcessStartedAsLoadingIcon.Tick += Tick; timerShowProcessStartedAsLoadingIcon.Tick += Tick;
void Tick(object sender, EventArgs e) void Tick(object sender, EventArgs e)
{ {
row.Cells[0].Value = rowData.ReadLoadedIcon();
timerShowProcessStartedAsLoadingIcon.Tick -= Tick; timerShowProcessStartedAsLoadingIcon.Tick -= Tick;
timerShowProcessStartedAsLoadingIcon.Stop(); timerShowProcessStartedAsLoadingIcon.Stop();
row.Cells[0].Value = rowData.ReadLoadedIcon();
if (Properties.Settings.Default.StaysOpenWhenFocusLostAfterEnterPressed) waitingForReactivate = false;
{
timerStillActiveCheck.Stop();
FadeHalfOrOutIfNeeded();
}
} }
timerShowProcessStartedAsLoadingIcon.Stop(); timerShowProcessStartedAsLoadingIcon.Stop();

View file

@ -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.0.24.3")] [assembly: AssemblyVersion("1.0.24.4")]
[assembly: AssemblyFileVersion("1.0.24.3")] [assembly: AssemblyFileVersion("1.0.24.4")]

View file

@ -254,7 +254,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("1000")] [global::System.Configuration.DefaultSettingValueAttribute("500")]
public int TimeUntilCloses public int TimeUntilCloses
{ {
get get

View file

@ -137,6 +137,15 @@ namespace SystemTrayMenu.UserInterface
customScrollbar.MouseEnter += ControlsMouseEnter; customScrollbar.MouseEnter += ControlsMouseEnter;
dgv.MouseEnter += ControlsMouseEnter; dgv.MouseEnter += ControlsMouseEnter;
labelTitle.MouseEnter += ControlsMouseEnter; labelTitle.MouseEnter += ControlsMouseEnter;
textBoxSearch.MouseEnter += ControlsMouseEnter;
pictureBoxMenuAlwaysOpen.MouseEnter += ControlsMouseEnter;
pictureBoxOpenFolder.MouseEnter += ControlsMouseEnter;
pictureBoxSearch.MouseEnter += ControlsMouseEnter;
pictureBoxFilesCount.MouseEnter += ControlsMouseEnter;
pictureBoxFoldersCount.MouseEnter += ControlsMouseEnter;
labelFilesCount.MouseEnter += ControlsMouseEnter;
labelFoldersCount.MouseEnter += ControlsMouseEnter;
void ControlsMouseEnter(object sender, EventArgs e) void ControlsMouseEnter(object sender, EventArgs e)
{ {
MouseEnter?.Invoke(); MouseEnter?.Invoke();
@ -145,6 +154,14 @@ namespace SystemTrayMenu.UserInterface
customScrollbar.MouseLeave += ControlsMouseLeave; customScrollbar.MouseLeave += ControlsMouseLeave;
dgv.MouseLeave += ControlsMouseLeave; dgv.MouseLeave += ControlsMouseLeave;
labelTitle.MouseLeave += ControlsMouseLeave; labelTitle.MouseLeave += ControlsMouseLeave;
textBoxSearch.MouseLeave += ControlsMouseLeave;
pictureBoxMenuAlwaysOpen.MouseLeave += ControlsMouseLeave;
pictureBoxOpenFolder.MouseLeave += ControlsMouseLeave;
pictureBoxSearch.MouseLeave += ControlsMouseLeave;
pictureBoxFilesCount.MouseLeave += ControlsMouseLeave;
pictureBoxFoldersCount.MouseLeave += ControlsMouseLeave;
labelFilesCount.MouseLeave += ControlsMouseLeave;
labelFoldersCount.MouseLeave += ControlsMouseLeave;
void ControlsMouseLeave(object sender, EventArgs e) void ControlsMouseLeave(object sender, EventArgs e)
{ {
MouseLeave?.Invoke(); MouseLeave?.Invoke();

View file

@ -801,7 +801,7 @@ namespace SystemTrayMenu.UserInterface
{ {
checkBoxStayOpenWhenItemClicked.Checked = true; checkBoxStayOpenWhenItemClicked.Checked = true;
checkBoxStayOpenWhenFocusLost.Checked = true; checkBoxStayOpenWhenFocusLost.Checked = true;
numericUpDownTimeUntilClose.Value = 1000; numericUpDownTimeUntilClose.Value = 500;
numericUpDownTimeUntilOpens.Value = 100; numericUpDownTimeUntilOpens.Value = 100;
checkBoxStayOpenWhenFocusLostAfterEnterPressed.Checked = true; checkBoxStayOpenWhenFocusLostAfterEnterPressed.Checked = true;
numericUpDownTimeUntilClosesAfterEnterPressed.Value = 200; numericUpDownTimeUntilClosesAfterEnterPressed.Value = 200;