protected static void OnIsBusyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { bool isBusy = (bool)e.NewValue; FloatingWindow me = o as FloatingWindow; if (me != null && me.BusyAnimation != null) { me.BusyAnimation.State = isBusy ? BusySignalState.STATE_BUSY : BusySignalState.STATE_HIDE; } }
protected static void OnIsOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { bool isOpen = (bool)e.NewValue; FloatingWindow me = o as FloatingWindow; if (me != null) { if (isOpen) { me.OpenMe(); } else { me.CloseMe(); } } }
protected static void OnIsExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { bool expanded = (bool)e.NewValue; FloatingWindow me = d as FloatingWindow; if (me != null) { if (expanded) { me.Width = me.currentWidth; me.Height = me.currentHeight; me.WindowToggleButton.State = ToggleButtonState.STATE_ORIGIN; VisualStateManager.GoToState(me, _STATE_EXPAND, true); if (me.RollDownStoryboardName != null) { Storyboard sb = me.Resources[me.RollDownStoryboardName] as Storyboard; if (sb != null) { me.IsToggling = true; sb.Begin(); } } } else { me.WindowToggleButton.State = ToggleButtonState.STATE_ROTATE270; VisualStateManager.GoToState(me, _STATE_COLLAPSE, true); if (me.RollUpStoryboardName != null) { Storyboard sb = me.Resources[me.RollUpStoryboardName] as Storyboard; if (sb != null) { me.IsToggling = true; sb.Begin(); } } } } }
/* ===================================================================== * If current window is activated, deactivate other floating controls * If current window is deactivated, activate the Taskbar or an expanded * window if Taskbar does not exist. Always set IsActive = false for a * window before set IsActive = true for another window * =====================================================================*/ protected void ResetActiveWindow(bool active) { if (ParentCanvas == null) { return; } if (active) { // Deactivate Other Windows if (ParentCanvas.Children.Count > 1) { foreach (FrameworkElement child in ParentCanvas.Children) { if (child is FloatingControl) { FloatingControl win = child as FloatingControl; if (win != this && win.IsActive) { win.IsActive = false; } } } } this.IsActive = true; } else { this.IsActive = false; // Activate Taskbar if Taskbar exists bool found = false; foreach (Control child in ParentCanvas.Children) { if (child is FloatingTaskbar) { FloatingTaskbar taskbar = child as FloatingTaskbar; taskbar.IsActive = true; taskbar.Focus(); found = true; break; } } // Activate an expanded window if (!found) { foreach (Control child in ParentCanvas.Children) { if (child is FloatingWindow) { FloatingWindow win = child as FloatingWindow; if (win != this && win.Visibility == Visibility.Visible && win.IsExpanded) { win.IsActive = true; win.Focus(); break; } } } } } }