Exemple #1
0
        /// <summary>
        /// Open canvas.
        /// </summary>
        private void OpenSushiBar()
        {
            // Finish current animation.
            var currentHeight = this.AbortSushiBarAnimation();

            Debug.WriteLine("OpenSushiBar: Begin: " + showingState);

            canvasHeightAnimation = new DelegatedAnimation(
                this,
                new PropertyPath("(Canvas.Height)"),
                currentHeight,
                SushiRotatorResources.CanvasHeight,
                SushiRotatorResources.CanvasReopenDuration / SushiRotatorResources.CanvasHeight * (SushiRotatorResources.CanvasHeight - currentHeight));

            canvasHeightAnimation.Completed += (s, e) =>
            {
                Debug.WriteLine("OpenSushiBar: Finished: " + showingState);
                showingState = ShowingStates.Opened;
            };

            // Start animation.
            this.Visibility = Visibility.Visible;
            showingState    = ShowingStates.Opening;
            canvasHeightAnimation.Begin();

            // Stop reopen timer.
            canvasReopenTimer.Stop();
        }
Exemple #2
0
        /// <summary>
        /// Close canvas.
        /// </summary>
        private void CloseSushiBar()
        {
            // Finish current animation.
            var currentHeight = this.AbortSushiBarAnimation();

            Debug.WriteLine("CloseSushiBar: Begin: " + showingState);

            canvasHeightAnimation = new DelegatedAnimation(
                this,
                new PropertyPath("(Canvas.Height)"),
                currentHeight,
                0,
                SushiRotatorResources.CanvasClosingDuration / SushiRotatorResources.CanvasHeight * currentHeight);

            canvasHeightAnimation.Completed += (s, e) =>
            {
                Debug.WriteLine("CloseSushiBar: Finished: " + showingState);

                if (showingState != ShowingStates.Closing)
                {
                    this.Visibility = Visibility.Collapsed;
                }
                showingState = ShowingStates.Closed;

                // Start reopen timer.
                canvasReopenTimer.Interval =
                    TimeSpan.FromMilliseconds(SushiRotatorResources.CanvasReopenDelay);
                canvasReopenTimer.Start();
            };

            // Start animation.
            showingState = ShowingStates.Closing;
            canvasHeightAnimation.Begin();
        }