Esempio n. 1
0
        private void ShowAdornerInternal()
        {
            if (currentDisplayedAdorner != null)
            {
                return;
            }

            if (AdornerContent != null)
            {
                if (adornerLayer == null)
                {
                    adornerLayer = AdornerLayer.GetAdornerLayer(this);
                }

                if (adornerLayer != null)
                {
                    currentDisplayedAdorner = new FrameworkElementAdorner(AdornerContent, this,
                                                                          HorizontalAdornerPlacement,
                                                                          VerticalAdornerPlacement,
                                                                          AdornerOffsetX, AdornerOffsetY);
                    adornerLayer.Add(currentDisplayedAdorner);
                    UpdateAdornerDataContext();
                }
            }

            adornerShowState = AdornerShowState.Visible;
        }
Esempio n. 2
0
        private void FadeInAdorner()
        {
            if (adornerShowState == AdornerShowState.Visible ||
                adornerShowState == AdornerShowState.FadingIn)
            {
                // Already visible or fading in.
                return;
            }

            ShowAdorner();

            if (adornerShowState != AdornerShowState.FadingOut)
            {
                currentDisplayedAdorner.Opacity = 0.0;
            }

            var doubleAnimation = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(FadeInTime)));

            doubleAnimation.Completed += (sender, args) => adornerShowState = AdornerShowState.Visible;
            doubleAnimation.Freeze();

            currentDisplayedAdorner.BeginAnimation(OpacityProperty, doubleAnimation);

            adornerShowState = AdornerShowState.FadingIn;
        }
        /// <summary>
        /// Fade the adorner out and make it visible.
        /// </summary>
        public void FadeOutAdorner()
        {
            if (adornerShowState == AdornerShowState.FadingOut)
            {
                //
                // Already fading out.
                //
                return;
            }

            if (adornerShowState == AdornerShowState.Hidden)
            {
                //
                // Adorner has already been hidden.
                //
                return;
            }

            DoubleAnimation fadeOutAnimation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(FadeOutTime)));

            fadeOutAnimation.Completed += new EventHandler(fadeOutAnimation_Completed);
            fadeOutAnimation.Freeze();

            adorner.BeginAnimation(FrameworkElement.OpacityProperty, fadeOutAnimation);

            adornerShowState = AdornerShowState.FadingOut;
        }
        /// <summary>
        /// Fade the adorner in and make it visible.
        /// </summary>
        public void FadeInAdorner()
        {
            if (adornerShowState == AdornerShowState.Visible ||
                adornerShowState == AdornerShowState.FadingIn)
            {
                // Already visible or fading in.
                return;
            }

            this.ShowAdorner();

            if (adornerShowState != AdornerShowState.FadingOut)
            {
                adorner.Opacity = 0.0;
            }

            DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(FadeInTime)));

            doubleAnimation.Completed += new EventHandler(fadeInAnimation_Completed);
            doubleAnimation.Freeze();

            adorner.BeginAnimation(FrameworkElement.OpacityProperty, doubleAnimation);

            adornerShowState = AdornerShowState.FadingIn;
        }
Esempio n. 5
0
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 private void fadeInAnimation_Completed(object sender, EventArgs e)
 {
     if (adornerShowState == AdornerShowState.FadingIn)
     {
         // Still fading in, eg it wasn't aborted.
         adornerShowState = AdornerShowState.Visible;
     }
 }
Esempio n. 6
0
        private void HideAdornerInternal()
        {
            if (adornerLayer == null || currentDisplayedAdorner == null)
            {
                return;
            }

            closeAdornerTimer.Stop();
            adornerLayer.Remove(currentDisplayedAdorner);
            currentDisplayedAdorner.DisconnectChild();

            currentDisplayedAdorner = null;
            adornerLayer            = null;

            adornerShowState = AdornerShowState.Hidden;
        }
Esempio n. 7
0
        /// <summary>
        /// Internal method to show the adorner.
        /// </summary>
        private void ShowAdornerInternal()
        {
            if (this.adorner != null)
            {
                // Already adorned.
                return;
            }

            if (this.AdornerContent != null)
            {
                if (this.adornerLayer == null)
                {
                    this.adornerLayer = AdornerLayer.GetAdornerLayer(this);
                }

                if (this.adornerLayer != null)
                {
                    FrameworkElement adornedControl = this; // The control to be adorned defaults to 'this'.

                    if (!string.IsNullOrEmpty(this.AdornedTemplatePartName))
                    {
                        // If 'AdornedTemplatePartName' is set to a valid string then search the visual-tree
                        // for a UI element that has the specified part name.  If we find it then use it as the
                        // adorned control, otherwise throw an exception.
                        adornedControl = FindNamedChild(this, this.AdornedTemplatePartName);
                        if (adornedControl == null)
                        {
                            throw new ApplicationException("Failed to find a FrameworkElement in the visual-tree with the part name '" + this.AdornedTemplatePartName + "'.");
                        }
                    }

                    this.adorner = new FrameworkElementAdorner(
                        this.AdornerContent,
                        adornedControl,
                        this.HorizontalAdornerPlacement,
                        this.VerticalAdornerPlacement,
                        this.AdornerOffsetX,
                        this.AdornerOffsetY);
                    this.adornerLayer.Add(this.adorner);

                    this.UpdateAdornerDataContext();
                }
            }

            this.adornerShowState = AdornerShowState.Visible;
        }
Esempio n. 8
0
        /// <summary>
        /// Internal method to hide the adorner.
        /// </summary>
        private void HideAdornerInternal()
        {
            if (this.adornerLayer == null || this.adorner == null)
            {
                // Not already adorned.
                return;
            }
            // Stop the timer that might be about to fade out the adorner.
            this.adornerLayer.Remove(this.adorner);
            this.adorner.DisconnectChild();

            this.adorner      = null;
            this.adornerLayer = null;
            // Ensure that the state of the adorned control reflects that
            // the the adorner is no longer.
            this.adornerShowState = AdornerShowState.Hidden;
        }
Esempio n. 9
0
        private void FadeOutAdorner()
        {
            if (adornerShowState == AdornerShowState.FadingOut ||
                adornerShowState == AdornerShowState.Hidden)
            {
                return;
            }

            var fadeOutAnimation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(FadeOutTime)));

            fadeOutAnimation.Completed += (sender, args) =>
            {
                if (adornerShowState == AdornerShowState.FadingOut)
                {
                    HideAdorner();
                }
            };
            fadeOutAnimation.Freeze();

            currentDisplayedAdorner.BeginAnimation(OpacityProperty, fadeOutAnimation);

            adornerShowState = AdornerShowState.FadingOut;
        }
Esempio n. 10
0
        /// <summary>
        /// Remove the adorner from the adorner layer and let it be garbage collected.
        /// </summary>
        private void RemoveAdorner()
        {
            //
            // Stop the timer that might be about to fade out the adorner.
            //
            closeAdornerTimer.Stop();

            if (this.adornerLayer != null && this.adorner != null)
            {
                this.adornerLayer.Remove(this.adorner);
                this.adorner.DisconnectChild();
            }

            this.adorner      = null;
            this.adornerLayer = null;

            //
            // Ensure that the state of the adorned control reflects that
            // the the adorner is no longer.
            //
            this.IsAdornerVisible = false;
            this.adornerShowState = AdornerShowState.Hidden;
        }
Esempio n. 11
0
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 private void fadeInAnimation_Completed(object sender, EventArgs e)
 {
     adornerShowState = AdornerShowState.Visible;
 }
Esempio n. 12
0
        /// <summary>
        /// Hide the _adorner.
        /// </summary>
        public void HideAdorner()
        {
            if (IsAlwaysVisible == true)
            {
                return;
            }

            IsAdornerVisible = false;

            closeAdornerTimer.Stop();
            _adornerShowState = AdornerShowState.Hidden;
        }
Esempio n. 13
0
        /// <summary>
        /// Internal method to show the adorner.
        /// </summary>
        private void ShowAdornerInternal()
        {
            if (this.adorner != null)
            {
                // Already adorned.
                return;
            }

            if (this.AdornerContent != null)
            {
                if (this.adornerLayer == null)
                {
                    this.adornerLayer = AdornerLayer.GetAdornerLayer(this);
                }

                if (this.adornerLayer != null)
                {
                    FrameworkElement adornedControl = this; // The control to be adorned defaults to 'this'.

                    if (!string.IsNullOrEmpty(this.AdornedTemplatePartName))
                    {
                        //
                        // If 'AdornedTemplatePartName' is set to a valid string then search the visual-tree
                        // for a UI element that has the specified part name.  If we find it then use it as the
                        // adorned control, otherwise throw an exception.
                        //
                        adornedControl = FindNamedChild(this, this.AdornedTemplatePartName);
                        if (adornedControl == null)
                        {
                            throw new ApplicationException("Failed to find a FrameworkElement in the visual-tree with the part name '" + this.AdornedTemplatePartName + "'.");
                        }
                    }

                    this.adorner = new FrameworkElementAdorner(this.AdornerContent, adornedControl,
                                                               this.HorizontalAdornerPlacement, this.VerticalAdornerPlacement,
                                                               this.AdornerOffsetX, this.AdornerOffsetY);
                    this.adornerLayer.Add(this.adorner);

                    UpdateAdornerDataContext();
                }
            }

            this.adornerShowState = AdornerShowState.Visible;
        }
Esempio n. 14
0
        /// <summary>
        /// Internal method to hide the adorner.
        /// </summary>
        private void HideAdornerInternal()
        {
            if (this.adornerLayer == null || this.adorner == null)
            {
                // Not already adorned.
                return;
            }

            //
            // Stop the timer that might be about to fade out the adorner.
            //
            closeAdornerTimer.Stop();
            this.adornerLayer.Remove(this.adorner);
            this.adorner.DisconnectChild();

            this.adorner = null;
            this.adornerLayer = null;

            //
            // Ensure that the state of the adorned control reflects that
            // the the adorner is no longer.
            //
            this.adornerShowState = AdornerShowState.Hidden;
        }
Esempio n. 15
0
        /// <summary>
        /// Fade the adorner in and make it visible.
        /// </summary>
        public void FadeInAdorner()
        {
            if (adornerShowState == AdornerShowState.Visible ||
                adornerShowState == AdornerShowState.FadingIn)
            {
                // Already visible or fading in.
                return;
            }

            this.ShowAdorner();

            if (adornerShowState != AdornerShowState.FadingOut)
            {
                adorner.Opacity = 0.0;
            }

            DoubleAnimation doubleAnimation = new DoubleAnimation(1.0, new Duration(TimeSpan.FromSeconds(FadeInTime)));
            doubleAnimation.Completed += new EventHandler(fadeInAnimation_Completed);
            doubleAnimation.Freeze();

            adorner.BeginAnimation(FrameworkElement.OpacityProperty, doubleAnimation);

            adornerShowState = AdornerShowState.FadingIn;
        }
Esempio n. 16
0
        /// <summary>
        /// Fade the adorner out and make it visible.
        /// </summary>
        public void FadeOutAdorner()
        {
            if (adornerShowState == AdornerShowState.FadingOut)
            {
                //
                // Already fading out.
                //
                return;
            }

            if (adornerShowState == AdornerShowState.Hidden)
            {
                //
                // Adorner has already been hidden.
                //
                return;
            }

            DoubleAnimation fadeOutAnimation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(FadeOutTime)));
            fadeOutAnimation.Completed += new EventHandler(fadeOutAnimation_Completed);
            fadeOutAnimation.Freeze();

            adorner.BeginAnimation(FrameworkElement.OpacityProperty, fadeOutAnimation);

            adornerShowState = AdornerShowState.FadingOut;
        }
Esempio n. 17
0
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void OnFadeInAnimationCompleted(object sender, EventArgs e)
 {
     this.adornerShowState = AdornerShowState.Visible;
 }
Esempio n. 18
0
        /// <summary>
        /// Remove the _adorner from the _adorner layer and let it be garbage collected.
        /// </summary>
        private void RemoveAdorner()
        {
            //
            // Stop the timer that might be about to fade out the _adorner.
            //
            closeAdornerTimer.Stop();

            if (this._adornerLayer != null && this._adorner != null)
            {
                this._adornerLayer.Remove(this._adorner);
                this._adorner.DisconnectChild();
            }

            this._adorner = null;
            this._adornerLayer = null;

            //
            // Ensure that the state of the adorned control reflects that
            // the the _adorner is no longer.
            //
            this.IsAdornerVisible = false;
            this._adornerShowState = AdornerShowState.Hidden;
        }
        /// <summary>
        /// Hide the adorner.
        /// </summary>
        public void HideAdorner()
        {
            IsAdornerVisible = false;

            closeAdornerTimer.Stop();
            adornerShowState = AdornerShowState.Hidden;
        }
        /// <summary>
        /// Show the adorner.
        /// </summary>
        public void ShowAdorner()
        {
            IsAdornerVisible = true;

            adornerShowState = AdornerShowState.Visible;

            if (IsMouseOverShowEnabled && !IsMouseOver)
            {
                closeAdornerTimer.Start();
            }
        }
Esempio n. 21
0
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void OnFadeInAnimationCompleted(object sender, EventArgs e)
 {
     this.adornerShowState = AdornerShowState.Visible;
 }
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 private void fadeInAnimation_Completed(object sender, EventArgs e)
 {
     adornerShowState = AdornerShowState.Visible;
 }
Esempio n. 23
0
        /// <summary>
        /// Show the _adorner.
        /// </summary>
        public void ShowAdorner()
        {
            IsAdornerVisible = true;

            _adornerShowState = AdornerShowState.Visible;

            if (IsMouseOverShowEnabled
                && !IsMouseOver
                && IsAlwaysVisible == false)
            {
                closeAdornerTimer.Start();
            }
        }
Esempio n. 24
0
 /// <summary>
 /// Event raised when the fade in animation has completed.
 /// </summary>
 private void fadeInAnimation_Completed(object sender, EventArgs e)
 {
     if (_adornerShowState == AdornerShowState.FadingIn)
     {
         // Still fading in, eg it wasn't aborted.
         _adornerShowState = AdornerShowState.Visible;
     }
 }
 /// <summary>
 /// Shared mouse leave code.
 /// </summary>
 private void MouseLeaveLogic()
 {
     if (!IsMouseOverShowEnabled)
     {
         return;
     }
     if (Math.Abs(CloseAdornerTimeOut) < 0.001)
     {
         HideAdorner();
         adornerShowState=AdornerShowState.Hidden;
     }
     else
         closeAdornerTimer.Start();
 }