コード例 #1
0
            public PopupWindow(PopupTaskBar popup)
            {
                this.stayOpenMilliseconds = popup.OpenTime;
                this.openingMilliseconds = popup.OpeningTime;
                this.hidingMilliseconds = popup.HiddingTime;
                this.isAnimation = popup.IsAnimation;
                this.position = popup.Position;
                this.AllowDrop = true;
                this.MouseLeftButtonUp += PopupWindow_MouseLeftButtonUp;

                this.MouseMove += PopupWindow_MouseMove;
                this.MouseDown += PopupWindow_MouseDown;
                this.MouseUp += PopupWindow_MouseUp;
                this.MouseMove += PopupWindow_MouseMove;
                taskbarNotifier = popup;
            }
コード例 #2
0
            /// <summary>
            /// 当显示状态发生改变时
            /// </summary>
            private void OnDisplayStateChanged()
            {
                this.stayOpenMilliseconds = taskbarNotifier.OpenTime;
                this.openingMilliseconds = taskbarNotifier.OpeningTime;
                this.hidingMilliseconds = taskbarNotifier.HiddingTime;
                this.isAnimation = taskbarNotifier.IsAnimation;
                this.position = taskbarNotifier.Position;
                if (this.storyboard == null)
                    return;

                this.storyboard.Stop(this); // 停止动画效果

                //由于用于打开和关闭,都可能被重用故事板,已完成的事件处理程序需要被删除
                this.storyboard.Completed -= arrivedHidden;
                this.storyboard.Completed -= arrivedOpened;

                // 处于已经打开状态时
                if (this.displayState == DisplayStates.Opened)
                {
                    this.SetInitialLocations(true);
                    if (!this.IsMouseOver)
                    {
                        // 鼠标不在窗口的范围里面时,窗口显示设定的时间后,隐藏。当鼠标在窗口的范围里面,窗口将一直显示到屏幕上面
                        this.stayOpenTimer.Stop();
                        this.stayOpenTimer.Start();
                    }
                }
                else if (this.displayState == DisplayStates.Opening) // 窗口正在打开
                {
                    this.Visibility = Visibility.Visible;
                    // 当有部分窗口已经打开,且该速度只是一小部分的正常速度,那得重新计算未打开窗口的速度
                    int milliseconds = this.CalculateMillseconds(this.openingMilliseconds, this.openedTop);
                    if (milliseconds < 1)
                    {
                        // 窗口必须处于已经打开的状态
                        this.DisplayState = DisplayStates.Opened;
                        return;
                    }

                    if (isAnimation)
                    {
                        // 重新设置动画效果
                        this.animation.To = this.openedTop;
                        this.animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milliseconds));
                    }
                    this.storyboard.Completed += arrivedOpened; // 完成后事件处理
                    this.storyboard.Begin(this, true); // 开始显示动画效果
                }
                else if (this.displayState == DisplayStates.Hiding) // 正在慢慢的隐藏窗口
                {
                    if (this.stayOpenMilliseconds <= 0)
                    {
                        this.displayState = DisplayStates.Opened;
                        return;
                    }
                    // 当有部分窗口已经隐藏,且该速度只是一小部分的正常速度,那得重新计算未隐藏窗口的速度
                    int milliseconds = this.CalculateMillseconds(this.hidingMilliseconds, this.hiddenTop);

                    if (milliseconds < 1)
                    {
                        this.DisplayState = DisplayStates.Hidden;// 已经隐藏
                        return;
                    }
                    if (isAnimation)
                    {
                        this.animation.To = this.hiddenTop;
                        this.animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milliseconds));
                    }
                    this.storyboard.Completed += arrivedHidden;
                    this.storyboard.Begin(this, true);
                }
                else if (this.displayState == DisplayStates.Hidden)
                {
                    Close();
                }
            }
コード例 #3
0
 public TaskbarNotifierWindow(TaskbarNotifier task)
 {
     this.stayOpenMilliseconds = task.OpenTime;
     this.openingMilliseconds = task.OpeningTime;
     this.hiddenTop = task.HiddingTime;
     this.isAnimation = task.IsAnimation;
     this.position = task.Position;
     this.MouseLeftButtonDown += TaskbarNotifierWindow_MouseLeftButtonDown;
     this.Background = null;
     taskbarNotifier = task;
 }