private void mouseClickManager_DoubleClick(object sender, MouseButtonEventArgs e) { if (this.showMaxButton) { if (!this.isMaximized) { DraggingEnabled = false; this.initialWindowSize.Width = !double.IsNaN(base.Width) ? base.Width : base.ActualWidth; this.initialWindowSize.Height = !double.IsNaN(base.Height) ? base.Height : base.ActualHeight; this.initialBarLocation.X = Canvas.GetLeft(this); this.initialBarLocation.Y = Canvas.GetTop(this); if (this.Maximized != null) { this.Maximized(this, EventArgs.Empty); } } else { Storyboard PrepareWindow = CommonAnimation.PrepareWindow (this, TimeOffset, new Point(0, 0), initialBarLocation, new Size(this.Width, this.Height), initialWindowSize, 0, 1, false); PrepareWindow.Begin(); if (this.Normalized != null) { this.Normalized(this, EventArgs.Empty); } DraggingEnabled = true; } this.isMaximized = !this.isMaximized; } }
public static void MaxWindow(object sender) { Window element = (Window)sender; Point from = new Point(Canvas.GetLeft(element), Canvas.GetTop(element)); Size fromSize = new Size(element.Width, element.Height); Size toSize = new Size(desktop.ActualWidth, desktop.ActualHeight); Storyboard PrepareWindow = CommonAnimation.PrepareWindow (element, element.TimeOffset, from, new Point(0, 0), fromSize, toSize, 0, 1, false); PrepareWindow.Begin(); }
private static void taskBarItem_Clicked(object sender, EventArgs e) { TaskBarItem taskBarItem = (TaskBarItem)sender; Window window = (Window)desktop.Children.Where <UIElement>(delegate(UIElement i) { return((i is Window) && (((Window)i).Name == taskBarItem.Name.Substring(2))); }).FirstOrDefault <UIElement>(); if (window != null) { if (window.Visibility == Visibility.Collapsed) { if (!window.IsHideWindow) { window.Visibility = Visibility.Visible; GeneralTransform gentransform = taskBarItem.TransformToVisual(desktop); Point point = gentransform.Transform(new Point(0, 0)); Point to = new Point(Canvas.GetLeft(window), Canvas.GetTop(window)); Storyboard PrepareWindow = CommonAnimation.PrepareWindow (window, window.TimeOffset, point, window.TaskBarPoint, new Size(2, 2), window.HideWindowSize, 0, 1, true); PrepareWindow.Begin(); PrepareWindow.Completed += (ob, arg) => { window.IsHideWindow = true; }; } } else { if (window.IsHideWindow) { GeneralTransform gentransform = taskBarItem.TransformToVisual(desktop); Point point = gentransform.Transform(new Point(0, 0)); window.TaskBarPoint = new Point(Canvas.GetLeft(window), Canvas.GetTop(window)); window.HideWindowSize = new Size(window.Width, window.Height); Storyboard PrepareWindow = CommonAnimation.PrepareWindow (window, window.TimeOffset, window.TaskBarPoint, point, window.HideWindowSize, new Size(2, 2), 1, 0, true); PrepareWindow.Begin(); PrepareWindow.Completed += (o, arg) => { window.Visibility = Visibility.Collapsed; window.IsHideWindow = false; }; ArrangeActiveWindow(); } } window.Focus(); } }
/// <summary> /// 激活窗口 /// </summary> /// <param name="WindowName"></param> public static void ActiveWindow(string WindowName) { ///根据窗口名称获取窗口在任务栏按钮的对象以及窗口对象 TaskBarItem taskBarItem = (TaskBarItem)taskBar.Children.Where <UIElement>(delegate(UIElement i) { return((i is TaskBarItem) && (((TaskBarItem)i).Name == "tb" + WindowName)); }).FirstOrDefault <UIElement>(); Window window = (Window)desktop.Children.Where <UIElement>(delegate(UIElement i) { return((i is Window) && (((Window)i).Name == WindowName)); }).FirstOrDefault <UIElement>(); ///判断窗口是否为NULL if (window != null) { //如果窗口视图为不显示则将其从任务栏位置显示出来 if (window.Visibility == Visibility.Collapsed) { if (!window.IsHideWindow) { ///设置窗口显示,并使用动画将其呈现 window.Visibility = Visibility.Visible; GeneralTransform gentransform = taskBarItem.TransformToVisual(desktop); Point point = gentransform.Transform(new Point(0, 0)); Point to = new Point(Canvas.GetLeft(window), Canvas.GetTop(window)); Storyboard PrepareWindow = CommonAnimation.PrepareWindow (window, window.TimeOffset, point, window.TaskBarPoint, new Size(2, 2), window.HideWindowSize, 0, 1, true); PrepareWindow.Begin(); PrepareWindow.Completed += (ob, arg) => { window.IsHideWindow = true; }; } } else { Canvas.SetZIndex(window, Window.currentZIndex++); } window.Focus(); } }
private static void window_Minimized(object sender, EventArgs e) { Window window = (Window)sender; TaskBarItem item = (TaskBarItem)taskBar.Children.Where <UIElement>(delegate(UIElement i) { return((i is TaskBarItem) && (((TaskBarItem)i).Name == "tb" + window.Name)); }).FirstOrDefault <UIElement>(); if (window.IsHideWindow) { GeneralTransform gentransform = item.TransformToVisual(desktop); Point point = gentransform.Transform(new Point(0, 0)); window.TaskBarPoint = new Point(Canvas.GetLeft(window), Canvas.GetTop(window)); window.HideWindowSize = new Size(window.Width, window.Height); Storyboard PrepareWindow = CommonAnimation.PrepareWindow (window, window.TimeOffset, window.TaskBarPoint, point, window.HideWindowSize, new Size(2, 2), 1, 0, true); PrepareWindow.Begin(); PrepareWindow.Completed += (o, arg) => { window.Visibility = Visibility.Collapsed; window.IsHideWindow = false; }; ArrangeActiveWindow(); } }