mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-28 19:10:26 +12:00
parent
03acc34e04
commit
464ff68252
|
@ -111,23 +111,14 @@ namespace SystemTrayMenu
|
||||||
MenuData menuData = (MenuData)e.Result;
|
MenuData menuData = (MenuData)e.Result;
|
||||||
if (menuData.Validity == MenuDataValidity.Valid)
|
if (menuData.Validity == MenuDataValidity.Valid)
|
||||||
{
|
{
|
||||||
DisposeMenu(menus[0]); //maybe not necessary
|
DisposeMenu(menus[0]);
|
||||||
|
menus[0].Visible = false; // resets activated
|
||||||
menus[0] = CreateMenu(menuData, Path.GetFileName(Config.Path));
|
menus[0] = CreateMenu(menuData, Path.GetFileName(Config.Path));
|
||||||
menus[0].AdjustLocationAndSize(screen);
|
menus[0].AdjustLocationAndSize(screen);
|
||||||
Menus().ToList().ForEach(m => { m.ShowWithFade(); });
|
Menus().ToList().ForEach(m => { m.ShowWithFade(); });
|
||||||
menus[0].VisibleChanged += WhenVisibleActivate;
|
menus[0].Activate();
|
||||||
menus[0].Visible = false; // resets activated
|
menus[0].SetTitleColorActive();
|
||||||
menus[0].Visible = true; // resets activated
|
NativeMethods.ForceForegroundWindow(menus[0].Handle);
|
||||||
void WhenVisibleActivate(object senderM, EventArgs eM)
|
|
||||||
{
|
|
||||||
if (menus[0].Visible)
|
|
||||||
{
|
|
||||||
menus[0].VisibleChanged -= WhenVisibleActivate;
|
|
||||||
menus[0].Activate();
|
|
||||||
menus[0].SetTitleColorActive();
|
|
||||||
NativeMethods.ForceForegroundWindow(menus[0].Handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openCloseState = OpenCloseState.Default;
|
openCloseState = OpenCloseState.Default;
|
||||||
|
@ -143,9 +134,9 @@ namespace SystemTrayMenu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning #72, #73 First start slower than others
|
|
||||||
menus[0] = CreateMenu(ReadMenu(worker, Config.Path, 0),
|
menus[0] = CreateMenu(ReadMenu(worker, Config.Path, 0),
|
||||||
Path.GetFileName(Config.Path));
|
Path.GetFileName(Config.Path));
|
||||||
|
menus[0].AdjustLocationAndSize(screen);
|
||||||
DisposeMenu(menus[0]);
|
DisposeMenu(menus[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,75 +31,10 @@ namespace SystemTrayMenu.UserInterface
|
||||||
internal Fading()
|
internal Fading()
|
||||||
{
|
{
|
||||||
timer.Interval = Interval60FPS;
|
timer.Interval = Interval60FPS;
|
||||||
timer.Tick += FadeStep;
|
timer.Tick += Tick;
|
||||||
void FadeStep(object sender, EventArgs e)
|
void Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
switch (state)
|
FadeStep();
|
||||||
{
|
|
||||||
case FadingState.Show:
|
|
||||||
if (!visible)
|
|
||||||
{
|
|
||||||
visible = true;
|
|
||||||
Show?.Invoke();
|
|
||||||
opacity = 0;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (opacity < ShownMinus)
|
|
||||||
{
|
|
||||||
opacity += StepIn;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (opacity != Shown)
|
|
||||||
{
|
|
||||||
opacity = Shown;
|
|
||||||
ChangeOpacity?.Invoke(this, Shown);
|
|
||||||
StartStopTimer(FadingState.Idle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FadingState.ShowTransparent:
|
|
||||||
if (!visible)
|
|
||||||
{
|
|
||||||
visible = true;
|
|
||||||
Show?.Invoke();
|
|
||||||
opacity = 0;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (opacity < TransparentMinus)
|
|
||||||
{
|
|
||||||
opacity += StepIn;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (opacity > TransparentPlus)
|
|
||||||
{
|
|
||||||
opacity -= StepOut;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (opacity != Transparent)
|
|
||||||
{
|
|
||||||
ChangeOpacity?.Invoke(this, Transparent);
|
|
||||||
StartStopTimer(FadingState.Idle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FadingState.Hide:
|
|
||||||
if (opacity > StepOut)
|
|
||||||
{
|
|
||||||
opacity -= StepOut;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
}
|
|
||||||
else if (visible)
|
|
||||||
{
|
|
||||||
opacity = 0;
|
|
||||||
ChangeOpacity?.Invoke(this, opacity);
|
|
||||||
visible = false;
|
|
||||||
Hide?.Invoke();
|
|
||||||
StartStopTimer(FadingState.Idle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FadingState.Idle:
|
|
||||||
default:
|
|
||||||
StartStopTimer(FadingState.Idle);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,29 +46,97 @@ namespace SystemTrayMenu.UserInterface
|
||||||
private void StartStopTimer(FadingState state)
|
private void StartStopTimer(FadingState state)
|
||||||
{
|
{
|
||||||
#warning if too many threads throw some away? win32 exception if too fast here
|
#warning if too many threads throw some away? win32 exception if too fast here
|
||||||
lock (lockTimerEnable)
|
if (state == FadingState.Idle)
|
||||||
{
|
{
|
||||||
if (state == FadingState.Idle)
|
this.state = state;
|
||||||
|
timer.Stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShowAtLeastTransparentBeforeHideItAgain();
|
||||||
|
void ShowAtLeastTransparentBeforeHideItAgain()
|
||||||
{
|
{
|
||||||
this.state = state;
|
if (state == FadingState.Hide)
|
||||||
timer.Stop();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ShowAtLeastTransparentBeforeHideItAgain();
|
|
||||||
void ShowAtLeastTransparentBeforeHideItAgain()
|
|
||||||
{
|
{
|
||||||
if (state == FadingState.Hide)
|
while (opacity < TransparentMinus)
|
||||||
{
|
{
|
||||||
while (opacity < TransparentMinus)
|
Application.DoEvents();
|
||||||
{
|
|
||||||
Application.DoEvents();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.state = state;
|
|
||||||
timer.Start();
|
|
||||||
}
|
}
|
||||||
|
this.state = state;
|
||||||
|
timer.Start();
|
||||||
|
FadeStep();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FadeStep()
|
||||||
|
{
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case FadingState.Show:
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
visible = true;
|
||||||
|
Show?.Invoke();
|
||||||
|
opacity = 0;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (opacity < ShownMinus)
|
||||||
|
{
|
||||||
|
opacity += StepIn;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (opacity != Shown)
|
||||||
|
{
|
||||||
|
opacity = Shown;
|
||||||
|
ChangeOpacity?.Invoke(this, Shown);
|
||||||
|
StartStopTimer(FadingState.Idle);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FadingState.ShowTransparent:
|
||||||
|
if (!visible)
|
||||||
|
{
|
||||||
|
visible = true;
|
||||||
|
Show?.Invoke();
|
||||||
|
opacity = 0;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (opacity < TransparentMinus)
|
||||||
|
{
|
||||||
|
opacity += StepIn;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (opacity > TransparentPlus)
|
||||||
|
{
|
||||||
|
opacity -= StepOut;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (opacity != Transparent)
|
||||||
|
{
|
||||||
|
ChangeOpacity?.Invoke(this, Transparent);
|
||||||
|
StartStopTimer(FadingState.Idle);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FadingState.Hide:
|
||||||
|
if (opacity > StepOut)
|
||||||
|
{
|
||||||
|
opacity -= StepOut;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
}
|
||||||
|
else if (visible)
|
||||||
|
{
|
||||||
|
opacity = 0;
|
||||||
|
ChangeOpacity?.Invoke(this, opacity);
|
||||||
|
visible = false;
|
||||||
|
Hide?.Invoke();
|
||||||
|
StartStopTimer(FadingState.Idle);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FadingState.Idle:
|
||||||
|
default:
|
||||||
|
StartStopTimer(FadingState.Idle);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.9.2.17")]
|
[assembly: AssemblyVersion("0.9.2.18")]
|
||||||
[assembly: AssemblyFileVersion("0.9.2.17")]
|
[assembly: AssemblyFileVersion("0.9.2.18")]
|
||||||
|
|
Loading…
Reference in a new issue