private void Panel_Timer_Tick(object sender, EventArgs e) { if (temp_open) { if (temp_panel.Size.Height > temp_closeSize) { temp_panel.Size = new Size(temp_panel.Size.Width, temp_panel.Size.Height - subPanel_velocity); subPanel_velocity++; } else { temp_panel.Size = new Size(temp_panel.Size.Width, temp_closeSize); Panel_Timer.Stop(); subPanel_velocity = 0; menu_flowlayout.Enabled = true; } } else { if (temp_panel.Size.Height < temp_openSize) { temp_panel.Size = new Size(temp_panel.Size.Width, temp_panel.Size.Height + subPanel_velocity); subPanel_velocity++; } else { temp_panel.Size = new Size(temp_panel.Size.Width, temp_openSize); Panel_Timer.Stop(); subPanel_velocity = 0; menu_flowlayout.Enabled = true; } } }
private void SubmenuOpen_Click(object sender, EventArgs e) { menu_flowlayout.Enabled = false; Button c = new Button(); if (sender is Button) { temp_panel = SubMenu[sender as Button].panel; c = sender as Button; } else if (sender is Label) { temp_panel = ((Panel)((Label)sender).Parent); foreach (KeyValuePair <Button, Panel_Size_Pair> pair in SubMenu) { if (pair.Value.panel == temp_panel) { c = pair.Key; } } } else { temp_panel = sender as Panel; foreach (KeyValuePair <Button, Panel_Size_Pair> pair in SubMenu) { if (pair.Value.panel == sender as Panel) { c = pair.Key; } } } temp_openSize = SubMenu[c].OpenSize; temp_closeSize = SubMenu[c].CloseSize; temp_open = SubMenu[c].open; SubMenu[c].open = !temp_open; Panel_Timer.Start(); }