Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        /// <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();
            }
        }
Esempio n. 3
0
        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();
            }
        }