public void Notify(bool isAlert, string refId, int attempt)
        {
            try
            {
                this.IsPopupAlert = isAlert;
                this.SetInitialLocations(true);
                IsThresholdNotifierClosed = false;

                //if (!dictPopupAlertAttempts.ContainsKey(refId))
                //{
                //    dictPopupAlertAttempts.Add(refId, attempt);
                //}
                //else
                //{
                //    dictPopupAlertAttempts[refId] = Convert.ToInt32(dictPopupAlertAttempts[refId] + 1);
                //}


                //if (this.DisplayState == DisplayStates.Opened)
                //{
                //    this.stayOpenTimer.Stop();
                //    this.stayOpenTimer.Start();
                //}
                //else
                //{
                this.DisplayState = DisplayStates.Opening;
                //System.Windows.MessageBox.Show("Inside Notify : this.stayOpenTimer Stopped");
                //this.stayOpenTimer.Stop();
                //}
            }
            catch {}
        }
        private void stayOpenTimer_Elapsed(Object sender, EventArgs args)
        {
            // Stop the timer because this should not be an ongoing event.

            //System.Windows.MessageBox.Show("stayOpenTimer_Elapsed");
            //System.Windows.MessageBox.Show("Inside stayOpenTimer_Elapsed : this.stayOpenTimer Stopped");

            this.stayOpenTimer.Stop();

            //System.Windows.MessageBox.Show("stayOpenTimer_Elapsed");

            if (!this.IsMouseOver)
            {
                // Only start closing the window if the mouse is not over it.

                //System.Windows.MessageBox.Show(this.IsPopupAlert.ToString());
                if (!this.IsPopupAlert)
                {
                    this.DisplayState = DisplayStates.Hiding;
                }
                else
                {
                    this.Visibility = Visibility.Hidden;
                    this.Topmost    = false;
                    //System.Windows.MessageBox.Show("stayOpenTimer_Elapsed : isThresholdNotifierClosed : " + isThresholdNotifierClosed.ToString());
                    isThresholdNotifierClosed = true;
                }
            }
        }
Пример #3
0
    public void ShowInfo(DisplayStates state)
    {
        activeState = state;

        if (state == DisplayStates.ActIntro)
        {
            UpdateFields_Act();
        }
        else if (state == DisplayStates.ActOutro)
        {
            UpdateFields_Act();
        }
        else if (state == DisplayStates.BossIntro)
        {
            // hack to make sure that we do not stomp on already existing info slides
            if (cg.alpha == 0)
            {
                UpdateFields_Boss();

                StartCoroutine(Spin());
                PF_GamePlay.IntroPane(gameObject, .75f);
            }
        }
        else if (state == DisplayStates.PlayerDied)
        {
            UpdateFields_Fail();
            PF_GamePlay.IntroPane(gameObject, .75f);
        }
    }
Пример #4
0
        private void TaskbarNotifier_Loaded(object sender, RoutedEventArgs e)
        {
            // Set initial settings based on the current screen working area.
            SetInitialLocations(false);

            // Start the window in the Hidden state.
            DisplayState = DisplayStates.Hidden;

            // Prepare the timer for how long the window should stay open.
            stayOpenTimer          = new DispatcherTimer();
            stayOpenTimer.Interval = TimeSpan.FromMilliseconds(stayOpenMilliseconds);
            if (stayOpenMilliseconds > 0)
            {
                stayOpenTimer.Tick += stayOpenTimer_Elapsed;
            }

            // Prepare the animation to change the Top property.
            animation = new DoubleAnimation();
            Storyboard.SetTargetProperty(animation, new PropertyPath(TopProperty));
            storyboard = new Storyboard();
            storyboard.Children.Add(animation);
            storyboard.FillBehavior = FillBehavior.Stop;

            // Create the event handlers for when the animation finishes.
            arrivedHidden = Storyboard_ArrivedHidden;
            arrivedOpened = Storyboard_ArrivedOpened;
        }
 private void stayOpenTimer_Elapsed(Object sender, EventArgs args)
 {
     // Stop the timer because this should not be an ongoing event.
     this.stayOpenTimer.Stop();
     if (!this.IsMouseOver && !pinState)
     {
         // Only start closing the window if the mouse is not over it.
         this.DisplayState = DisplayStates.Hiding;
     }
 }
Пример #6
0
 public void Notify()
 {
     if (this.DisplayState == DisplayStates.Opened)
     {
         // The window is already open, and should now remain open for another count.
         this.stayOpenTimer.Stop();
         this.stayOpenTimer.Start();
     }
     else
     {
         this.DisplayState = DisplayStates.Opening;
     }
 }
Пример #7
0
        public LogicManager()
        {
            manualMode = false;
            outputColors = new byte[Config.numberOfLeds * 3];

            _scheduler = new Timer { Enabled = false };
            _scheduler.Elapsed += TimerElapsed;

            _state = DisplayStates.Null;
            assignShooter();

            _relay = new DeviceRelay();
            _relay.NotifyLogicAboutError += relayErrorEvent;
            _relay.NotifyLogicAboutMessage += relayMessageEvent;
        }
Пример #8
0
 public void Notify( )
 {
     if (Visibility != Visibility.Visible)
     {
         Visibility = Visibility.Visible;
     }
     if (DisplayState == DisplayStates.Opened)
     {
         // The window is already open, and should now remain open for another count.
         _stayOpenTimer.Stop();
         _stayOpenTimer.Start();
     }
     else
     {
         DisplayState = DisplayStates.Opening;
     }
 }
Пример #9
0
        protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
        {
            if (this.DisplayState == DisplayStates.Opened)
            {
                // When the user mouses over and the window is already open, it should stay open.
                // Stop the timer that would have otherwise hidden it.
                this.stayOpenTimer.Stop();
            }
            else if ((this.DisplayState == DisplayStates.Hidden) ||
                     (this.DisplayState == DisplayStates.Hiding))
            {
                // When the user mouses over and the window is hidden or hiding, it should open.
                this.DisplayState = DisplayStates.Opening;
            }

            base.OnMouseEnter(e);
        }
Пример #10
0
        private void Publisher_StatusChanged(BluetoothLEAdvertisementPublisher sender,
                                             BluetoothLEAdvertisementPublisherStatusChangedEventArgs args)
        {
            Debug.WriteLine(args.Status);
            Debug.WriteLine(args.Error);
            lock (lockObject)
            {
                CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    switch (args.Status)
                    {
                    case BluetoothLEAdvertisementPublisherStatus.Waiting:
                        TransitionToStarting.Begin();
                        state = DisplayStates.Wait;
                        break;

                    case BluetoothLEAdvertisementPublisherStatus.Started:
                        TransitionToBroad.Begin();
                        state = DisplayStates.Good;
                        break;

                    case BluetoothLEAdvertisementPublisherStatus.Stopping:
                        TransitionToStarting.Begin();
                        state = DisplayStates.Wait;
                        break;

                    case BluetoothLEAdvertisementPublisherStatus.Stopped:
                        Stop.Begin();
                        state = DisplayStates.Done;
                        break;

                    case BluetoothLEAdvertisementPublisherStatus.Created:
                        break;

                    case BluetoothLEAdvertisementPublisherStatus.Aborted:
                        TransitionToError.Begin();
                        state = DisplayStates.Error;
                        break;
                    }
                    Status.Text = args.Status.ToString();
                }).AsTask().Wait();
            }
        }
Пример #11
0
        /// <summary>
        /// Updates the state.
        /// </summary>
        /// <param name="maxWidth">MaxWidth of the label.</param>
        /// <returns>Returns the desired display state.</returns>
        private DisplayStates UpdateState(double maxWidth)
        {
            if (this.Mode == LabelMode.Full)
            {
                DisplayStates stateName              = DisplayStates.FullDetails;
                double        medicationNameWidth    = GetPanelDesiredWidth(this.medicationName);
                double        medicationDetailsWidth = GetPanelDesiredWidth(this.medicationDetails);
                double        ellipsisWidth          = GetPanelDesiredWidth(this.ellipsis);

                if (medicationNameWidth + medicationDetailsWidth > maxWidth)
                {
                    if (medicationNameWidth + ellipsisWidth > maxWidth)
                    {
                        if (medicationNameWidth > maxWidth)
                        {
                            stateName = DisplayStates.EllipsisOnly;
                        }
                        else
                        {
                            stateName = DisplayStates.MedicationNameWithEllipsis;
                        }
                    }
                    else
                    {
                        stateName = DisplayStates.MedicationNameWithEllipsis;
                    }
                }

                return(stateName);
            }
            else
            {
                DisplayStates stateName = DisplayStates.PartialMode;
                double        nameWidth = GetPanelDesiredWidth(this.partialModeMedicationName);
                if (nameWidth > maxWidth)
                {
                    stateName = DisplayStates.PartialModeEllipsis;
                }

                return(stateName);
            }
        }
Пример #12
0
 protected virtual void Storyboard_ArrivedOpened(object sender, EventArgs e)
 {
     // Setting the display state will result in any needed actions.
     this.DisplayState = DisplayStates.Opened;
 }
Пример #13
0
        private void OnDisplayStateChanged()
        {
            // The display state has changed.

            // Unless the stortboard as already been created, nothing can be done yet.
            if (this.storyboard == null)
            {
                return;
            }

            // Stop the current animation.
            this.storyboard.Stop(this);

            // Since the storyboard is reused for opening and closing, both possible
            // completed event handlers need to be removed.  It is not a problem if
            // either of them was not previously set.
            this.storyboard.Completed -= arrivedHidden;
            this.storyboard.Completed -= arrivedOpened;

            if (this.displayState != DisplayStates.Hidden)
            {
                // Unless the window has just arrived at the hidden state, it must be
                // moving, and should be shown.
                this.BringToTop();
            }

            if (this.displayState == DisplayStates.Opened)
            {
                // The window has just arrived at the opened state.

                // Because the inital settings of this TaskNotifier depend on the screen's working area,
                // it is best to reset these occasionally in case the screen size has been adjusted.
                this.SetInitialLocations(true);

                if (!this.IsMouseOver)
                {
                    // The mouse is not within the window, so start the countdown to hide it.
                    this.stayOpenTimer.Stop();
                    this.stayOpenTimer.Start();
                }
            }
            else if (this.displayState == DisplayStates.Opening)
            {
                // The window should start opening.

                // Make the window visible.
                this.Visibility = Visibility.Visible;
                this.BringToTop();

                // Because the window may already be partially open, the rate at which
                // it opens may be a fraction of the normal rate.
                // This must be calculated.
                int milliseconds = this.CalculateMillseconds(this.openingMilliseconds, this.openedTop);

                if (milliseconds < 1)
                {
                    // This window must already be open.
                    this.DisplayState = DisplayStates.Opened;
                    return;
                }

                // Reconfigure the animation.
                this.animation.To       = this.openedTop;
                this.animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milliseconds));

                // Set the specific completed event handler.
                this.storyboard.Completed += arrivedOpened;

                // Start the animation.
                this.storyboard.Begin(this, true);
            }
            else if (this.displayState == DisplayStates.Hiding)
            {
                //// The window should start hiding.

                //// Because the window may already be partially hidden, the rate at which
                //// it hides may be a fraction of the normal rate.
                //// This must be calculated.
                //int milliseconds = this.CalculateMillseconds(this.hidingMilliseconds, this.hiddenTop);

                //if (milliseconds < 1)
                //{
                //    // This window must already be hidden.
                //    this.DisplayState = DisplayStates.Hidden;
                //    return;
                //}

                //// Reconfigure the animation.
                //this.animation.To = this.hiddenTop;
                //this.animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, milliseconds));

                //// Set the specific completed event handler.
                //this.storyboard.Completed += arrivedHidden;

                //// Start the animation.
                //this.storyboard.Begin(this, true);
            }
            else if (this.displayState == DisplayStates.Hidden)
            {
                // Ensure the window is in the hidden position.
                SetInitialLocations(false);

                // Hide the window.
                this.Visibility = Visibility.Hidden;
            }
        }
Пример #14
0
 public static void SetInitialDisplayState(DisplayStates displayState, DateTime selectedDate)
 {
     _lastDisplayState    = displayState;
     _initialSelectedDate = selectedDate;
 }
Пример #15
0
 internal void TryUpdateShooter(bool useGDIShooter)
 {
     DisplayStates newState = useGDIShooter ? DisplayStates.Win : DisplayStates.Const;
     if (newState != _state)
     {
         _state = newState;
         assignShooter();
     }
 }
Пример #16
0
        /// <summary>
        /// Gets the desired width of the label.
        /// </summary>
        /// <param name="maxWidth">Max width for the label.</param>
        /// <returns>Desired width.</returns>
        public double GetDesiredWidth(double maxWidth)
        {
            Size desiredSize = new Size();

            maxWidth -= this.Padding.Left + this.Padding.Right + this.BorderThickness.Left + this.BorderThickness.Right;

            if (this.medicationName == null)
            {
                this.ApplyTemplate();
            }

            if (this.full != null)
            {
                this.simple.Visibility  = Visibility.Collapsed;
                this.partial.Visibility = Visibility.Collapsed;
                this.full.Visibility    = Visibility.Collapsed;

                switch (this.Mode)
                {
                case LabelMode.Simple:
                    this.simple.Visibility = Visibility.Visible;
                    break;

                case LabelMode.Partial:
                    this.partial.Visibility = Visibility.Visible;
                    break;

                case LabelMode.Full:
                    this.full.Visibility = Visibility.Visible;
                    break;
                }
            }

            if (this.Mode == LabelMode.Full)
            {
                if (this.medicationName != null)
                {
                    this.medicationName.Visibility    = Visibility.Visible;
                    this.medicationDetails.Visibility = Visibility.Visible;
                    this.ellipsis.Visibility          = Visibility.Visible;

                    DisplayStates state = this.UpdateState(maxWidth);

                    switch (state)
                    {
                    case DisplayStates.FullDetails:
                        this.medicationName.Visibility    = Visibility.Visible;
                        this.medicationDetails.Visibility = Visibility.Visible;
                        this.ellipsis.Visibility          = Visibility.Collapsed;
                        break;

                    case DisplayStates.MedicationNameOnly:
                        this.medicationName.Visibility    = Visibility.Visible;
                        this.medicationDetails.Visibility = Visibility.Collapsed;
                        this.ellipsis.Visibility          = Visibility.Collapsed;
                        break;

                    case DisplayStates.MedicationNameWithEllipsis:
                        this.medicationName.Visibility    = Visibility.Visible;
                        this.medicationDetails.Visibility = Visibility.Collapsed;
                        this.ellipsis.Visibility          = Visibility.Visible;
                        break;

                    case DisplayStates.EllipsisOnly:
                        this.medicationName.Visibility    = Visibility.Collapsed;
                        this.medicationDetails.Visibility = Visibility.Collapsed;
                        this.ellipsis.Visibility          = Visibility.Visible;
                        break;
                    }
                }
            }
            else if (this.Mode == LabelMode.Partial)
            {
                if (this.partialModeMedicationName != null)
                {
                    this.partialModeMedicationName.Visibility = Visibility.Visible;
                    this.partialModeEllipsis.Visibility       = Visibility.Visible;

                    DisplayStates state = this.UpdateState(maxWidth);
                    switch (state)
                    {
                    case DisplayStates.PartialMode:
                        this.partialModeMedicationName.Visibility = Visibility.Visible;
                        this.partialModeEllipsis.Visibility       = Visibility.Collapsed;
                        break;

                    case DisplayStates.PartialModeEllipsis:
                        this.partialModeMedicationName.Visibility = Visibility.Collapsed;
                        this.partialModeEllipsis.Visibility       = Visibility.Visible;
                        break;
                    }
                }
            }
            else
            {
                if (this.simpleLabel != null)
                {
                    this.simpleLabel.ResetDisplayValue();
                    this.simpleLabel.AutoEllipse(maxWidth);
                }
            }

            desiredSize = this.MeasureOverride(new Size(double.PositiveInfinity, double.PositiveInfinity));
            return(desiredSize.Width);
        }
Пример #17
0
 protected virtual void Storyboard_ArrivedOpened(object sender, EventArgs e)
 {
     // Setting the display state will result in any needed actions.
     this.DisplayState = DisplayStates.Opened;
 }
Пример #18
0
 public void Notify()
 {
     if (this.DisplayState == DisplayStates.Opened)
     {
         // The window is already open, and should now remain open for another count.
         this.stayOpenTimer.Stop ();
         this.stayOpenTimer.Start ();
     }
     else
     {
         this.DisplayState = DisplayStates.Opening;
     }
 }
Пример #19
0
 /// <summary>
 /// Force the window to immediately move to the hidden state.
 /// </summary>
 public void ForceHidden()
 {
     this.DisplayState = DisplayStates.Hidden;
 }
Пример #20
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();
                }
            }
Пример #21
0
            /// <summary>
            /// 窗体加载事件(动画效果弹出窗口)
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="args"></param>
            public void PopupTaskBar_Loaded()
            {
                SetInitialLocations(false);
                this.DisplayState = DisplayStates.Hidden;

                // 准备时间器,默认显示多长时间
                this.stayOpenTimer = new DispatcherTimer();
                this.stayOpenTimer.Interval = TimeSpan.FromMilliseconds(this.stayOpenMilliseconds);
                this.stayOpenTimer.Tick += new EventHandler(this.stayOpenTimer_Elapsed);

                // 动画来改变顶部的属性
                this.animation = new DoubleAnimation();
                Storyboard.SetTargetProperty(this.animation, new PropertyPath(Popup.VerticalOffsetProperty));
                this.storyboard = new Storyboard();
                this.storyboard.Children.Add(this.animation);
                this.storyboard.FillBehavior = FillBehavior.Stop;
                // 当动画完成时,激活事件,显示或者隐藏
                this.arrivedHidden = new EventHandler(this.Storyboard_ArrivedHidden);
                this.arrivedOpened = new EventHandler(this.Storyboard_ArrivedOpened);
                Notify();
            }
Пример #22
0
 /// <summary>
 /// 当时间线已经到达隐藏,窗口的状态为隐藏
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void Storyboard_ArrivedHidden(object sender, EventArgs e)
 {
     this.DisplayState = DisplayStates.Hidden;
 }
Пример #23
0
        private void stayOpenTimer_Elapsed(Object sender, EventArgs args)
        {
            // Stop the timer because this should not be an ongoing event.
            this.stayOpenTimer.Stop ();

            if (!this.IsMouseOver)
            {
                // Only start closing the window if the mouse is not over it.
                this.DisplayState = DisplayStates.Hiding;
            }
        }
Пример #24
0
 /// <summary>
 /// Force the window to immediately move to the hidden state.
 /// </summary>
 public void ForceHidden()
 {
     this.DisplayState = DisplayStates.Hidden;
 }
Пример #25
0
 /// <summary>
 /// 当时间线已经到达打开,窗口的状态为已经打开
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void Storyboard_ArrivedOpened(object sender, EventArgs e)
 {
     this.DisplayState = DisplayStates.Opened;
 }
Пример #26
0
        protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
        {
            if (this.DisplayState == DisplayStates.Opened)
            {
                // When the user mouses over and the window is already open, it should stay open.
                // Stop the timer that would have otherwise hidden it.
                this.stayOpenTimer.Stop ();
            }
            else if ((this.DisplayState == DisplayStates.Hidden) ||
                     (this.DisplayState == DisplayStates.Hiding))
            {
                // When the user mouses over and the window is hidden or hiding, it should open.
                this.DisplayState = DisplayStates.Opening;
            }

            base.OnMouseEnter (e);
        }
Пример #27
0
 /// <summary>
 /// 后台线程消失时,触发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 private void stayOpenTimer_Elapsed(Object sender, EventArgs args)
 {
     this.stayOpenTimer.Stop(); // 停止计时器
     if (!this.IsMouseOver)
     {
         this.DisplayState = DisplayStates.Hiding; // 鼠标不再窗口范围里,隐藏
     }
 }
Пример #28
0
        private void OnDisplayStateChanged()
        {
            // The display state has changed.

            // Unless the stortboard as already been created, nothing can be done yet.

            if (this.displayState == DisplayStates.Hidden)
            {
                // Ensure the window is in the hidden position.
                SetInitialLocations (false);

                // Hide the window.
                this.Visibility = Visibility.Hidden;
            }
            else
            {
                if (this.storyboard == null)
                    return;

                // Stop the current animation.
                this.storyboard.Stop (this);

                // Since the storyboard is reused for opening and closing, both possible
                // completed event handlers need to be removed.  It is not a problem if
                // either of them was not previously set.
                this.storyboard.Completed -= arrivedHidden;
                this.storyboard.Completed -= arrivedOpened;

                if (this.displayState != DisplayStates.Hidden)
                {
                    // Unless the window has just arrived at the hidden state, it must be
                    // moving, and should be shown.
                    this.BringToTop ();
                }

                if (this.displayState == DisplayStates.Opened)
                {
                    // The window has just arrived at the opened state.

                    // Because the inital settings of this TaskNotifier depend on the screen's working area,
                    // it is best to reset these occasionally in case the screen size has been adjusted.
                    this.SetInitialLocations (true);

                    if (!this.IsMouseOver)
                    {
                        // The mouse is not within the window, so start the countdown to hide it.
                        this.stayOpenTimer.Stop ();
                        this.stayOpenTimer.Start ();
                    }
                }
                else if (this.displayState == DisplayStates.Opening)
                {
                    // The window should start opening.

                    // Make the window visible.
                    this.Visibility = Visibility.Visible;
                    this.BringToTop ();

                    // Because the window may already be partially open, the rate at which
                    // it opens may be a fraction of the normal rate.
                    // This must be calculated.
                    int milliseconds = this.CalculateMillseconds (this.openingMilliseconds, this.openedTop);

                    if (milliseconds < 1)
                    {
                        // This window must already be open.
                        this.DisplayState = DisplayStates.Opened;
                        return;
                    }

                    // Reconfigure the animation.
                    this.animation.To = this.openedTop;
                    this.animation.Duration = new Duration (new TimeSpan (0, 0, 0, 0, milliseconds));

                    // Set the specific completed event handler.
                    this.storyboard.Completed += arrivedOpened;

                    // Start the animation.
                    this.storyboard.Begin (this, true);
                }
                else if (this.displayState == DisplayStates.Hiding)
                {
                    // The window should start hiding.

                    // Because the window may already be partially hidden, the rate at which
                    // it hides may be a fraction of the normal rate.
                    // This must be calculated.
                    int milliseconds = this.CalculateMillseconds (this.hidingMilliseconds, this.hiddenTop);

                    if (milliseconds < 1)
                    {
                        // This window must already be hidden.
                        this.DisplayState = DisplayStates.Hidden;
                        return;
                    }

                    // Reconfigure the animation.
                    this.animation.To = this.hiddenTop;
                    this.animation.Duration = new Duration (new TimeSpan (0, 0, 0, 0, milliseconds));

                    // Set the specific completed event handler.
                    this.storyboard.Completed += arrivedHidden;

                    // Start the animation.
                    this.storyboard.Begin (this, true);
                }
            }
        }
Пример #29
0
 /// <summary>
 /// 鼠标进入窗口的区域里触发的事件
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
 {
     if (this.DisplayState == DisplayStates.Opened)
     {
         // 当窗口已经打开时,停止计时器,或者窗口会隐藏
         this.stayOpenTimer.Stop();
     }
     else if ((this.DisplayState == DisplayStates.Hidden) ||
              (this.DisplayState == DisplayStates.Hiding))
     {
         // 当鼠标进入窗口区域,而此时窗口隐藏或者正在被隐藏。应打开窗口
         this.DisplayState = DisplayStates.Opening;
     }
     base.OnMouseEnter(e);
 }
Пример #30
0
        private void TaskbarNotifier_Loaded(object sender, RoutedEventArgs e)
        {
            // Set initial settings based on the current screen working area.
            this.SetInitialLocations (false);

            // Start the window in the Hidden state.
            this.DisplayState = DisplayStates.Hidden;

            // Prepare the timer for how long the window should stay open.
            this.stayOpenTimer = new DispatcherTimer ();
            this.stayOpenTimer.Interval = TimeSpan.FromMilliseconds (this.stayOpenMilliseconds);
            this.stayOpenTimer.Tick += new EventHandler (this.stayOpenTimer_Elapsed);

            // Prepare the animation to change the Top property.
            this.animation = new DoubleAnimation ();
            Storyboard.SetTargetProperty (this.animation, new PropertyPath (Window.TopProperty));
            this.storyboard = new Storyboard ();
            this.storyboard.Children.Add (this.animation);
            this.storyboard.FillBehavior = FillBehavior.Stop;

            // Create the event handlers for when the animation finishes.
            this.arrivedHidden = new EventHandler (this.Storyboard_ArrivedHidden);
            this.arrivedOpened = new EventHandler (this.Storyboard_ArrivedOpened);
        }
Пример #31
0
 /// <summary>
 /// 窗口已经打开,并应继续启动计时器重新计算时间来控制窗口的显示状态
 /// </summary>
 public void Notify()
 {
     if (this.DisplayState == DisplayStates.Opened)
     {
         this.stayOpenTimer.Stop();
         this.stayOpenTimer.Start();
     }
     else
     {
         this.DisplayState = DisplayStates.Opening;
     }
 }