/// <summary> /// Hide current overlay panel /// </summary> /// <param name="length"></param> /// <param name="left_right"></param> void HideOverlayPanel(double length, bool left_right) { _leftRightAnimation = left_right; _tempPaneAnimation = _tempPane; _lengthAnimation = length; _animation = new DoubleAnimation(); _animation.From = length; _animation.To = 0.0; _animation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); _animation.Completed += new EventHandler(HideOverlayPanel_Completed); if (left_right) { _tempPaneAnimation.BeginAnimation(FrameworkElement.WidthProperty, _animation); } else { _tempPaneAnimation.BeginAnimation(FrameworkElement.HeightProperty, _animation); } DoubleAnimation anOpacity = new DoubleAnimation(); anOpacity.From = 1.0; anOpacity.To = 0.0; anOpacity.Duration = new Duration(TimeSpan.FromMilliseconds(200)); panelFront.BeginAnimation(DockPanel.OpacityProperty, anOpacity); }
/// <summary> /// Hide temporay pane and reset current docking button /// </summary> /// <param name="smooth">True if resize animation is enabled</param> private void HideTempPane(bool smooth) { if (_tempPane != null) { DockablePane pane = gridDocking.GetPaneFromContent(_tempPane.Contents[0]) as DockablePane; bool right_left = false; double length = 0.0; switch (_currentButton.DockingButtonGroup.Dock) { case Dock.Left: case Dock.Right: if (_tempPaneAnimation != null) { pane.PaneWidth = _lengthAnimation; } else { pane.PaneWidth = _tempPane.Width; } length = _tempPane.Width; right_left = true; break; case Dock.Top: case Dock.Bottom: if (_tempPaneAnimation != null) { pane.PaneHeight = _lengthAnimation; } else { pane.PaneHeight = _tempPane.Height; } length = _tempPane.Height; right_left = false; break; } _tempPane.OnStateChanged -= new EventHandler(_tempPane_OnStateChanged); if (smooth) { HideOverlayPanel(length, right_left); } else { ForceHideOverlayPanel(); panelFront.BeginAnimation(DockPanel.OpacityProperty, null); panelFront.Children.Clear(); panelFront.Opacity = 0.0; _tempPane.Close(); } _currentButton = null; _tempPane = null; } }
/// <summary> /// Show tampoary pane attached to current docking buttno /// </summary> /// <param name="smooth">True if resize animation is enabled</param> private void ShowTempPane(bool smooth) { _tempPane = new OverlayDockablePane(this, _currentButton.DockableContent, _currentButton.DockingButtonGroup.Dock); _tempPane.OnStateChanged += new EventHandler(_tempPane_OnStateChanged); DockablePane pane = gridDocking.GetPaneFromContent(_currentButton.DockableContent) as DockablePane; panelFront.Children.Clear(); _tempPane.SetValue(DockPanel.DockProperty, _currentButton.DockingButtonGroup.Dock); panelFront.Children.Add(_tempPane); DockPanelSplitter splitter = null; bool right_left = false; double length = 0.0; switch (_currentButton.DockingButtonGroup.Dock) { case Dock.Left: splitter = new DockPanelSplitter(_tempPane, null, SplitOrientation.Vertical); length = pane.PaneWidth; right_left = true; break; case Dock.Right: splitter = new DockPanelSplitter(null, _tempPane, SplitOrientation.Vertical); length = pane.PaneWidth; right_left = true; break; case Dock.Top: splitter = new DockPanelSplitter(_tempPane, null, SplitOrientation.Horizontal); length = pane.PaneHeight; right_left = false; break; case Dock.Bottom: splitter = new DockPanelSplitter(null, _tempPane, SplitOrientation.Horizontal); length = pane.PaneHeight; right_left = false; break; } splitter.SetValue(DockPanel.DockProperty, _currentButton.DockingButtonGroup.Dock); panelFront.Children.Add(splitter); if (smooth) ShowOverlayPanel(length, right_left); else { if (right_left) _tempPane.Width = length; else _tempPane.Height = length; panelFront.Opacity = 1.0; } }
/// <summary> /// Showing animation completed event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks>Set final lenght and reset animation object on temp overlay panel</remarks> void ShowOverlayPanel_Completed(object sender, EventArgs e) { _animation.Completed -= new EventHandler(ShowOverlayPanel_Completed); if (_tempPaneAnimation != null) { if (_leftRightAnimation) { _tempPaneAnimation.BeginAnimation(FrameworkElement.WidthProperty, null); _tempPaneAnimation.Width = _lengthAnimation; } else { _tempPaneAnimation.BeginAnimation(FrameworkElement.HeightProperty, null); _tempPaneAnimation.Height = _lengthAnimation; } } _tempPaneAnimation = null; }
/// <summary> /// Forces to hide current overlay panel /// </summary> /// <remarks>Usually used when a second animation is about to start from a different button</remarks> void ForceHideOverlayPanel() { if (_tempPaneAnimation != null) { _animation.Completed -= new EventHandler(HideOverlayPanel_Completed); _animation.Completed -= new EventHandler(ShowOverlayPanel_Completed); if (_leftRightAnimation) { _tempPaneAnimation.BeginAnimation(FrameworkElement.WidthProperty, null); //_tempPaneAnimation.Width = 0; } else { _tempPaneAnimation.BeginAnimation(FrameworkElement.HeightProperty, null); //_tempPaneAnimation.Height = 0; } _tempPaneAnimation.Close(); _tempPaneAnimation = null; } }
/// <summary> /// Show current overlay pane which hosts current auto-hiding content /// </summary> /// <param name="length">Target length</param> /// <param name="left_right">Resize orientaion</param> void ShowOverlayPanel(double length, bool left_right) { ForceHideOverlayPanel(); _leftRightAnimation = left_right; _tempPaneAnimation = _tempPane; _lengthAnimation = length; _animation = new DoubleAnimation(); _animation.From = 0.0; _animation.To = length; _animation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); _animation.Completed += new EventHandler(ShowOverlayPanel_Completed); if (_leftRightAnimation) _tempPaneAnimation.BeginAnimation(FrameworkElement.WidthProperty, _animation); else _tempPaneAnimation.BeginAnimation(FrameworkElement.HeightProperty, _animation); DoubleAnimation anOpacity = new DoubleAnimation(); anOpacity.From = 0.0; anOpacity.To = 1.0; anOpacity.Duration = new Duration(TimeSpan.FromMilliseconds(200)); panelFront.BeginAnimation(DockPanel.OpacityProperty, anOpacity); }
/// <summary> /// Hide temporay pane and reset current docking button /// </summary> /// <param name="smooth">True if resize animation is enabled</param> private void HideTempPane(bool smooth) { if (_tempPane != null) { DockablePane pane = gridDocking.GetPaneFromContent(_tempPane.Contents[0]) as DockablePane; bool right_left = false; double length = 0.0; switch (_currentButton.DockingButtonGroup.Dock) { case Dock.Left: case Dock.Right: if (_tempPaneAnimation != null) pane.PaneWidth = _lengthAnimation; else pane.PaneWidth = _tempPane.Width; length = _tempPane.Width; right_left = true; break; case Dock.Top: case Dock.Bottom: if (_tempPaneAnimation != null) pane.PaneHeight = _lengthAnimation; else pane.PaneHeight = _tempPane.Height; length = _tempPane.Height; right_left = false; break; } _tempPane.OnStateChanged-=new EventHandler(_tempPane_OnStateChanged); if (smooth) { HideOverlayPanel(length, right_left); } else { ForceHideOverlayPanel(); panelFront.BeginAnimation(DockPanel.OpacityProperty, null); panelFront.Children.Clear(); panelFront.Opacity = 0.0; _tempPane.Close(); } _currentButton = null; _tempPane = null; } }