mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-06-29 03:20:46 +12:00
parent
03acc34e04
commit
464ff68252
|
@ -111,24 +111,15 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,8 +31,46 @@ 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)
|
||||
{
|
||||
FadeStep();
|
||||
}
|
||||
}
|
||||
|
||||
internal void Fade(FadingState state)
|
||||
{
|
||||
StartStopTimer(state);
|
||||
}
|
||||
|
||||
private void StartStopTimer(FadingState state)
|
||||
{
|
||||
#warning if too many threads throw some away? win32 exception if too fast here
|
||||
if (state == FadingState.Idle)
|
||||
{
|
||||
this.state = state;
|
||||
timer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowAtLeastTransparentBeforeHideItAgain();
|
||||
void ShowAtLeastTransparentBeforeHideItAgain()
|
||||
{
|
||||
if (state == FadingState.Hide)
|
||||
{
|
||||
while (opacity < TransparentMinus)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.state = state;
|
||||
timer.Start();
|
||||
FadeStep();
|
||||
}
|
||||
}
|
||||
|
||||
private void FadeStep()
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
|
@ -101,41 +139,6 @@ namespace SystemTrayMenu.UserInterface
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void Fade(FadingState state)
|
||||
{
|
||||
StartStopTimer(state);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.state = state;
|
||||
timer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowAtLeastTransparentBeforeHideItAgain();
|
||||
void ShowAtLeastTransparentBeforeHideItAgain()
|
||||
{
|
||||
if (state == FadingState.Hide)
|
||||
{
|
||||
while (opacity < TransparentMinus)
|
||||
{
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.state = state;
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
|
|
@ -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