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;
|
||||
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].AdjustLocationAndSize(screen);
|
||||
Menus().ToList().ForEach(m => { m.ShowWithFade(); });
|
||||
menus[0].VisibleChanged += WhenVisibleActivate;
|
||||
menus[0].Visible = false; // resets activated
|
||||
menus[0].Visible = true; // resets activated
|
||||
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);
|
||||
}
|
||||
}
|
||||
menus[0].Activate();
|
||||
menus[0].SetTitleColorActive();
|
||||
NativeMethods.ForceForegroundWindow(menus[0].Handle);
|
||||
}
|
||||
|
||||
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),
|
||||
Path.GetFileName(Config.Path));
|
||||
menus[0].AdjustLocationAndSize(screen);
|
||||
DisposeMenu(menus[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,75 +31,10 @@ namespace SystemTrayMenu.UserInterface
|
|||
internal Fading()
|
||||
{
|
||||
timer.Interval = Interval60FPS;
|
||||
timer.Tick += FadeStep;
|
||||
void FadeStep(object sender, EventArgs e)
|
||||
timer.Tick += Tick;
|
||||
void Tick(object sender, EventArgs e)
|
||||
{
|
||||
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;
|
||||
}
|
||||
FadeStep();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,29 +46,97 @@ namespace SystemTrayMenu.UserInterface
|
|||
private void StartStopTimer(FadingState state)
|
||||
{
|
||||
#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;
|
||||
timer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowAtLeastTransparentBeforeHideItAgain();
|
||||
void ShowAtLeastTransparentBeforeHideItAgain()
|
||||
if (state == FadingState.Hide)
|
||||
{
|
||||
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
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.9.2.17")]
|
||||
[assembly: AssemblyFileVersion("0.9.2.17")]
|
||||
[assembly: AssemblyVersion("0.9.2.18")]
|
||||
[assembly: AssemblyFileVersion("0.9.2.18")]
|
||||
|
|
Loading…
Reference in a new issue