public WindowAnimation(Boolean enbaled = true, Int32 animationTime = 200, WindowAnimationStyle showEffect = WindowAnimationStyle.Center, WindowAnimationStyle hideEffect = WindowAnimationStyle.Fade ) { this.Enabled = enbaled; this.AnimationTime = animationTime; this.ShowEffect = showEffect; this.HideEffect = hideEffect; }
public override object ConvertFrom( ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { String str = value as String; if (str != null) { Regex regex = new Regex(SplitSymbol); String[] propertyValues = regex.Split(str); if (propertyValues.Length < 4) { throw new ArgumentException("Invalid parameter format"); } Boolean enabled = Boolean.Parse(propertyValues[0]); Int32 animationTime = Int32.Parse(propertyValues[1]); Type enumType = typeof(WindowAnimationStyle); WindowAnimationStyle showEffect = (WindowAnimationStyle)Enum.Parse(enumType, propertyValues[2]); WindowAnimationStyle hideEffect = (WindowAnimationStyle)Enum.Parse(enumType, propertyValues[3]); return(new WindowAnimation(enabled, animationTime, showEffect, hideEffect)); } return(base.ConvertFrom(context, culture, value)); }
public static void ShowForm(Form formToShow, WindowAnimationStyle style) { var t = new Timer(); switch (style) { case WindowAnimationStyle.Fade: var bw = new BackgroundWorker(); bw.DoWork += (object se, DoWorkEventArgs ea) => { //The form's handle has not been created so we just invoke //the action on the desktop thread. API.CurrentSession.Invoke(new Action(() => { try { formToShow.Opacity = 0; formToShow.Show(); formToShow.Left = (Screen.PrimaryScreen.Bounds.Width - formToShow.Width) / 2; formToShow.Top = (Screen.PrimaryScreen.Bounds.Height - formToShow.Height) / 2; } catch { } })); t.Interval = API.CurrentSkin.WindowFadeTime; t.Tick += (object s, EventArgs a) => { if (API.Upgrades["fancyeffects"] == true) { API.CurrentSession.Invoke(new Action(() => { if (formToShow.Opacity < 1) { formToShow.Opacity += Convert.ToDouble(API.CurrentSkin.WindowFadeSpeed); formToShow.Refresh(); } else { t.Stop(); } })); } else { API.CurrentSession.Invoke(new Action(() => { formToShow.Opacity = 1; })); } }; API.CurrentSession.Invoke(new Action(() => { t.Start(); })); }; bw.RunWorkerAsync(); break; default: var bwork = new BackgroundWorker(); bwork.DoWork += (object s, DoWorkEventArgs a) => { API.CurrentSession.Invoke(new Action(() => { formToShow.Show(); formToShow.Left = (Screen.PrimaryScreen.Bounds.Width - formToShow.Width) / 2; formToShow.Top = (Screen.PrimaryScreen.Bounds.Height - formToShow.Height) / 2; formToShow.Show(); })); }; bwork.RunWorkerAsync(); break; } }
public static void CloseForm(Form formToClose, PanelButton pbtn, WindowAnimationStyle style) { var t = new Timer(); switch (style) { case WindowAnimationStyle.Fade: _CanClose = false; t.Interval = API.CurrentSkin.WindowFadeTime; t.Tick += (object s, EventArgs a) => { if (API.Upgrades["fancyeffects"] == true) { try { if (formToClose.Opacity > 0) { formToClose.Invoke(new Action(() => { formToClose.Opacity -= Convert.ToDouble(API.CurrentSkin.WindowFadeSpeed); formToClose.Refresh(); })); } else { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } } catch (Exception ex) { formToClose = null; } } else { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } }; t.Start(); break; case WindowAnimationStyle.Zoom: _CanClose = false; t.Interval = 1; int w = formToClose.Width; int h = formToClose.Height; int maxw = w / 2; int maxh = h / 2; t.Tick += (object s, EventArgs a) => { if (API.Upgrades["fancyeffects"] == true) { formToClose.MinimumSize = new Size(maxw, maxh); formToClose.Opacity -= 0.1; formToClose.Left += 50; formToClose.Top += 50; formToClose.Width -= 50; formToClose.Height -= 50; if (formToClose.Size == formToClose.MinimumSize) { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } } else { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } }; t.Start(); break; break; case WindowAnimationStyle.ToAppLauncher: _CanClose = false; t.Interval = 1; int w2 = formToClose.Width; int h2 = formToClose.Height; int maxw2 = w2 / 2; int maxh2 = h2 / 2; t.Tick += (object s, EventArgs a) => { formToClose.MinimumSize = new Size(maxw2, maxh2); formToClose.Opacity -= 0.1; if (API.Upgrades["fancyeffects"] == true) { switch (API.CurrentSkin.desktoppanelposition) { case "Bottom": formToClose.Left += 50; formToClose.Top += 50; break; case "Top": formToClose.Left -= 50; formToClose.Top -= 50; break; } formToClose.Width -= 50; formToClose.Height -= 50; if (formToClose.Size == formToClose.MinimumSize) { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } } else { API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); t.Stop(); } }; t.Start(); break; default: API.PanelButtons.Remove(pbtn); API.CurrentSession.SetupPanelButtons(); API.UpdateWindows(); formToClose.Dispose(); //Room for more animations, but just close the form if none is selected. break; } }