private Rectangle GetShowStartBounds(ShowTransition transition) { FluidHost host = FluidHost.Instance; Rectangle client = host.ClientBounds; int h = client.Height; int w = client.Width; switch (transition) { case ShowTransition.FromBottom: return(new Rectangle(0, h, w, Height)); case ShowTransition.FromTop: return(new Rectangle(0, -Height, w, Height)); case ShowTransition.FromLeft: return(new Rectangle(-Width, 0, Width, h)); case ShowTransition.FromRight: return(new Rectangle(w, 0, Width, h)); case ShowTransition.Zoom: throw new NotImplementedException(); default: return(Bounds); } }
public virtual void ShowMaximized(ShowTransition transition) { Visible = false; FluidHost host = FluidHost.Instance; host.Add(this); Bounds = host.ClientBounds; Show(transition); }
/// <summary> /// Creates a new instance. /// </summary> public FluidHost() : base() { // Font = new Font(FontFamily.GenericSansSerif, 8f, FontStyle.Regular); if (Instance != null) { throw new ArgumentException("There can be only one host."); } region.MakeInfinite(); CreateKeyInputHelper(); BackColor = Color.Empty; panel = new FluidPanel(); panel.BackColor = Color.Transparent; panel.EnableDoubleBuffer = true; panel.Anchor = AnchorStyles.None; this.Control = panel; panel.Name = "__root"; Instance = this; }
/// <summary> /// Closes the panel with the specified transition. /// </summary> /// <param name="transition">The transition to perform.</param> public virtual void Close(ShowTransition transition) { if (!Visible) { return; } RestorePreviousFocusedControl(); EnsureTopAnimation(); FluidHost host = FluidHost.Instance; Rectangle client = host.ClientBounds; int h = client.Height; int w = client.Width; bool modal = true; switch (transition) { case ShowTransition.None: Hide(); HideModalBackground(); break; case ShowTransition.FromBottom: topAnimation.Completed += new EventHandler(OnTopAnimationCompleted); AnimateTop(h, Animation.DefaultDuration, modal); break; case ShowTransition.FromTop: topAnimation.Completed += new EventHandler(OnTopAnimationCompleted); AnimateTop(0 - Bounds.Height, Animation.DefaultDuration, modal); break; default: throw new NotImplementedException(); } OnClosing(); }
/// <summary> /// Opens the panel with the specified transition. /// </summary> /// <param name="transition">The transition to perform while the panel is shown.</param> public virtual void Show(ShowTransition transition) { previousFocusedControl = Host != null ? Host.FocusedControl : null; showTransition = transition; FluidTextBox.InputPanel.Enabled = false; Visible = false; FluidHost host = FluidHost.Instance; Rectangle client = host.ClientBounds; int h = client.Height; int w = client.Width; host.Add(this); bool modal = false; Bounds = GetShowStartBounds(transition); Visible = true; switch (transition) { case ShowTransition.None: Show(); break; case ShowTransition.FromBottom: AnimateTop(h - Bounds.Height, Animation.DefaultDuration, modal); break; case ShowTransition.FromTop: AnimateTop(Bounds.Height, Animation.DefaultDuration, modal); break; default: throw new NotImplementedException(); } Focus(); OnShowing(); }