C
C#2y ago
Estal

❔ Transitional Timer

I'm Trying to create an animated Menu Expansion and to do so I opted for a winforms timer and have the following code:
WinForms.Timer menuTimer = new WinForms.Timer();

private void settingsDock_MouseDown(object sender, MouseButtonEventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Tick += new EventHandler(MenuTimerOpen);
} else
{
menuTimer.Tick += new EventHandler(MenuTimerClose);
}
menuTimer.Interval = 1;
menuTimer.Start();

}
private void MenuTimerClose(object sender, EventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height - 10;
}
}

private void MenuTimerOpen(object sender, EventArgs e)
{
if(menuBorder.Height == 150)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height + 10;
}
}
WinForms.Timer menuTimer = new WinForms.Timer();

private void settingsDock_MouseDown(object sender, MouseButtonEventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Tick += new EventHandler(MenuTimerOpen);
} else
{
menuTimer.Tick += new EventHandler(MenuTimerClose);
}
menuTimer.Interval = 1;
menuTimer.Start();

}
private void MenuTimerClose(object sender, EventArgs e)
{
if(menuBorder.Height == 0)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height - 10;
}
}

private void MenuTimerOpen(object sender, EventArgs e)
{
if(menuBorder.Height == 150)
{
menuTimer.Stop();
}
else
{
menuBorder.Height = menuBorder.Height + 10;
}
}
If I have the menuBorder set to 150 when I begin debugging it has no problem closing, but has a problem opening. If I set it to 0 when I begin debugging then it has no problem opening, but has issues closing. Any ideas what I'm doing wrong here?
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server