public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

#if WPF
            var scaleAnimation = new DoubleAnimation(transform.ScaleX, 1, new Duration(TimeSpan.FromSeconds(Duration)));
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
#elif METRO
            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation{ Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();
#else
            throw new NotImplementedException();
#endif
        }
        /// <summary>
        /// Loads the image into given imageView using defined parameters.
        /// </summary>
        /// <param name="parameters">Parameters for loading the image.</param>
        /// <param name="imageView">Image view that should receive the image.</param>
        public static IScheduledWork Into(this TaskParameter parameters, Image imageView)
        {
            var weakRef = new WeakReference<Image>(imageView);

            Func<Image> getNativeControl = () => {
                Image refView = null;

                if (!weakRef.TryGetTarget(out refView))
                    return null;

                return refView;
            };

            Action<WriteableBitmap, bool, bool> doWithImage = (img, isLocalOrFromCache, isLoadingPlaceholder) => {
                Image refView = getNativeControl();
                if (refView == null)
                    return;

                bool imageChanged = (img != refView.Source);
                if (!imageChanged)
                    return;

                bool isFadeAnimationEnabled = parameters.FadeAnimationEnabled.HasValue ?
                    parameters.FadeAnimationEnabled.Value : ImageService.Config.FadeAnimationEnabled;

                bool isFadeAnimationEnabledForCached = isFadeAnimationEnabled && (parameters.FadeAnimationForCachedImages.HasValue ?
                    parameters.FadeAnimationForCachedImages.Value : ImageService.Config.FadeAnimationForCachedImages);

                if (!isLoadingPlaceholder && isFadeAnimationEnabled && (!isLocalOrFromCache || (isLocalOrFromCache && isFadeAnimationEnabledForCached)))
                {
                    // fade animation
                    int fadeDuration = parameters.FadeAnimationDuration.HasValue ?
                        parameters.FadeAnimationDuration.Value : ImageService.Config.FadeAnimationDuration;
                    DoubleAnimation fade = new DoubleAnimation();
                    fade.Duration = TimeSpan.FromMilliseconds(fadeDuration);
					fade.From = 0f;
					fade.To = 1f;
					fade.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseInOut }; 

					Storyboard fadeInStoryboard = new Storyboard();

#if SILVERLIGHT
                    Storyboard.SetTargetProperty(fade, new PropertyPath("Image.Opacity"));
#else
                    Storyboard.SetTargetProperty(fade, "Image.Opacity");
#endif
                    Storyboard.SetTarget(fade, refView);
					fadeInStoryboard.Children.Add(fade);
					fadeInStoryboard.Begin();
					refView.Source = img;
                }
                else
                {
                    refView.Source = img;
                }
            };

            return parameters.Into(getNativeControl, doWithImage);
        }
示例#3
0
文件: Fader.cs 项目: iainlane/f-spot
 public Fader(Gtk.Window win, double target, int sec)
 {
     this.win = win;
     win.Mapped += HandleMapped;
     win.Unmapped += HandleUnmapped;
     fadin = new DoubleAnimation (0.0, target, new TimeSpan (0, 0, sec), delegate (double opacity) {
         CompositeUtils.SetWinOpacity (win, opacity);
     });
 }
示例#4
0
 public WindowOpacityFader(Gtk.Window win, double target, double msec)
 {
     this.win = win;
     win.Mapped += HandleMapped;
     win.Unmapped += HandleUnmapped;
     fadin = new DoubleAnimation (0.0, target, TimeSpan.FromMilliseconds (msec), opacity => {
         CompositeUtils.SetWinOpacity (win, opacity);
     });
 }
示例#5
0
        public static DoubleAnimation CreateDoubleAnimation(double? From, double? To, long DurationTicks)
        {
            var animation = new DoubleAnimation();
            animation.From = From;
            animation.To = To;
            animation.Duration = new Duration(new TimeSpan(DurationTicks));
#if NETFX_CORE
            animation.EnableDependentAnimation = true;
#endif
            return animation;
        }
示例#6
0
        protected override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();
            var _hideState1 = (base.GetTemplateChild("HideTop") as VisualState);
            var _hideState2 = (base.GetTemplateChild("HideBottom") as VisualState);
            if (_hideState1 != null)
                _hideAnimation1 = _hideState1.Storyboard.Children[0] as DoubleAnimation;
            if (_hideState2 != null)
                _hideAnimation2 = _hideState2.Storyboard.Children[0] as DoubleAnimation;
        }
示例#7
0
		public static void Flip(UIElement parentCtrl, UIElement frontCtrl, UIElement backCtrl, TimeSpan duration, bool transitionToBack, Action completed = null)
		{
			duration = new TimeSpan(duration.Ticks / 2);

			if (!(parentCtrl.Projection is PlaneProjection))
				parentCtrl.Projection = new PlaneProjection();

			var animation = new DoubleAnimation();
			animation.From = 0.0;
			animation.To = 90.0 * (transitionToBack ? 1 : -1);
			animation.Duration = new Duration(duration);

			var story = new Storyboard();
			story.Children.Add(animation);

			Storyboard.SetTarget(animation, parentCtrl.Projection);
#if WINRT
			Storyboard.SetTargetProperty(animation, "RotationY");
#else
			Storyboard.SetTargetProperty(animation, new PropertyPath("RotationY"));
#endif

			story.Completed += delegate
			{
				animation = new DoubleAnimation();
				animation.From = 270.0 * (transitionToBack ? 1 : -1);
				animation.To = 360.0 * (transitionToBack ? 1 : -1);
				animation.Duration = new Duration(duration);

				story = new Storyboard();
				story.Children.Add(animation);

				Storyboard.SetTarget(animation, parentCtrl.Projection);
#if WINRT
				Storyboard.SetTargetProperty(animation, "RotationY");
#else
				Storyboard.SetTargetProperty(animation, new PropertyPath("RotationY"));
#endif

				frontCtrl.Visibility = transitionToBack ? Visibility.Collapsed : Visibility.Visible;
				backCtrl.Visibility = !transitionToBack ? Visibility.Collapsed : Visibility.Visible;

				story.Completed += delegate
				{
					((PlaneProjection)parentCtrl.Projection).RotationY = 0.0;
					if (completed != null)
						completed();
				};
				story.Begin();
			};
			story.Begin();
		}
示例#8
0
        private void RunAnimation(IGraphControl target)
        {
            //create and run animation
            var story = new Storyboard();
            var fadeAnimation = new DoubleAnimation {Duration = new Duration(TimeSpan.FromSeconds(Duration)), FillBehavior = FillBehavior.Stop, From = 1, To = 0};
            fadeAnimation.Completed += (sender, e) => OnCompleted(target);
            story.Children.Add(fadeAnimation);
            Storyboard.SetTarget(fadeAnimation, target as FrameworkElement);
#if WPF
            Storyboard.SetTargetProperty(fadeAnimation, new PropertyPath(UIElement.OpacityProperty));
            story.Begin(target as FrameworkElement);            
#elif METRO
            Storyboard.SetTargetProperty(fadeAnimation, "Opacity");            
            story.Begin();
#else
            throw new NotImplementedException();
#endif
        }
		public static void CreateDoubleAnimations(Storyboard sb, DependencyObject target, string propertyPath, double fromValue = 0, double toValue = 0, int speed = 500)
		{
			var doubleAni = new DoubleAnimation
			{
				To = toValue,
				From = fromValue,
				Duration = new Duration(TimeSpan.FromMilliseconds(speed)),
			};

			Storyboard.SetTarget(doubleAni, target);

#if WINDOWS_STORE
			Storyboard.SetTargetProperty(doubleAni, propertyPath);
#elif WINDOWS_PHONE
			Storyboard.SetTargetProperty(doubleAni, new PropertyPath(propertyPath));
#endif

			sb.Children.Add(doubleAni);
		}
示例#10
0
        /// <summary>
        /// Fades an element in. 
        /// </summary>
        /// <param name="obj">The element to animate. </param>
        /// <param name="duration">The animation duration. </param>
        /// <param name="endOpacity">The opacity at the end of the animation. </param>
        /// <returns>Returns a task. </returns>
        public static void FadeIn(UIElement obj, TimeSpan duration, double endOpacity = 1.0, Action completed = null)
        {
            var animation = new DoubleAnimation();
            animation.EasingFunction = new ExponentialEase() { EasingMode = EasingMode.EaseInOut, Exponent = 1 };
            animation.From = obj.Opacity;
            animation.To = endOpacity;
            animation.Duration = new Duration(duration);

            var story = new Storyboard();
            story.Children.Add(animation);

            Storyboard.SetTarget(animation, obj);
#if WINRT
            Storyboard.SetTargetProperty(animation, "Opacity");
#else
            Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));
#endif
            if (completed != null)
                story.Completed += delegate { completed(); };
            story.Begin();
        }
示例#11
0
        public void AnimateVertex(VertexControl target)
        {
            //get scale transform or create new one
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = Centered ? new Point(.5, .5) : new Point(0, 0);
            }
            //create and run animation
#if WPF
            var scaleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(Duration)));
            scaleAnimation.Completed += (sender, e) =>  OnCompleted(target);
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);            
#elif METRO
            var sb = new Storyboard();
            //create and run animation
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = 0  };
            //scaleAnimation.Completed += (sender, e) => OnCompleted(target as IGraphControl);
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);

            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = 0 };
            scaleAnimation.Completed += (sender, e) => OnCompleted(target as IGraphControl);
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();

#else
            throw new NotImplementedException();
#endif
        }
示例#12
0
        protected override void DrawGeometry(bool withAnimation = true)
        {
            try
            {
                if (this.ClientWidth <= 0.0)
                {
                    return;
                }
                if (this.ClientHeight <= 0.0)
                {
                    return;
                }

                double startHeight = 0;
                if (slice.Height > 0)
                {
                    startHeight = slice.Height;
                }

                DoubleAnimation scaleAnimation = new DoubleAnimation();
                scaleAnimation.From = startHeight;
                scaleAnimation.To = this.ClientHeight * Percentage;
                scaleAnimation.Duration = TimeSpan.FromMilliseconds(withAnimation ? 500: 0);
                scaleAnimation.EasingFunction = new QuarticEase() { EasingMode = EasingMode.EaseOut };
                Storyboard storyScaleX = new Storyboard();
                storyScaleX.Children.Add(scaleAnimation);

                Storyboard.SetTarget(storyScaleX, slice);

            #if NETFX_CORE
                scaleAnimation.EnableDependentAnimation = true;
                Storyboard.SetTargetProperty(storyScaleX, "Height");
            #else
                Storyboard.SetTargetProperty(storyScaleX, new PropertyPath("Height"));
            #endif
                storyScaleX.Begin();

            }
            catch (Exception ex)
            {
            }
        }
示例#13
0
        protected void ApplyHostWindow(IWindowSkin skin, bool saveinformation = true)
        {
            if (skin == HostedWindow)
            {
                return;
            }
            if (HostedWindow != null)
            {
                HostedWindow.DragMoveStart     -= skin_DragMoveStart;
                HostedWindow.DragMoveStop      -= skin_DragMoveStop;
                HostedWindow.ToggleWindowState -= skin_ToggleWindowState;
                HostedWindow.TitleBarMouseMove -= skin_TitleBarMouseMove;
                HostedWindow.DisableWindow();

                var element = (FrameworkElement)HostedWindow;
                ContentGrid.Children.Remove(element);
            }

            skin.CloseRequest      += (s, e) => Close();
            skin.DragMoveStart     += skin_DragMoveStart;
            skin.DragMoveStop      += skin_DragMoveStop;
            skin.ToggleWindowState += skin_ToggleWindowState;
            skin.TitleBarMouseMove += skin_TitleBarMouseMove;

            var appstate = AnyListenSettings.Instance.CurrentState.ApplicationState;

            if (skin != AdvancedWindowSkin && saveinformation)
            {
                appstate.Height = Height;
                appstate.Width  = Width;
            }

            HideEqualizer();

            MaxHeight    = skin.Configuration.MaxHeight;
            MinHeight    = skin.Configuration.MinHeight;
            MaxWidth     = skin.Configuration.MaxWidth;
            MinWidth     = skin.Configuration.MinWidth;
            ShowTitleBar = skin.Configuration.ShowTitleBar;
            ShowSystemMenuOnRightClick = skin.Configuration.ShowSystemMenuOnRightClick;

            if (!_isDragging)
            {
                if (skin.Configuration.IsResizable)
                {
                    WindowHelper.ShowMinimizeAndMaximizeButtons(this);
                    ResizeMode = ResizeMode.CanResize;
                }
                else
                {
                    WindowHelper.HideMinimizeAndMaximizeButtons(this);
                    ResizeMode = ResizeMode.NoResize;
                }
            }

            if (skin == AdvancedWindowSkin && saveinformation)
            {
                Width  = appstate.Width;
                Height = appstate.Height;
            }

            if (skin.Configuration.SupportsCustomBackground)
            {
                SetBackground().Forget();
            }
            else
            {
                BackgroundImage.Visibility = Visibility.Collapsed;
                BackgroundImage.Source     = null;
                BackgroundMediaElement.Stop();
                BackgroundMediaElement.Source     = null;
                BackgroundMediaElement.Visibility = Visibility.Collapsed;
            }
            BackgroundImage.Visibility = skin.Configuration.SupportsCustomBackground ? Visibility.Visible : Visibility.Collapsed;

            if (skin == SmartWindowSkin)
            {
                Width  = 300;
                Height = MagicArrow.DockManager.WindowHeight;
                if (MainViewModel.Instance.MusicManager != null)
                {
                    MainViewModel.Instance.MusicManager.DownloadManager.IsOpen = false;
                }
            }

            ShowMinButton        = skin.Configuration.ShowWindowControls;
            ShowMaxRestoreButton = skin.Configuration.ShowWindowControls;
            ShowCloseButton      = skin.Configuration.ShowWindowControls;

            var newUserControl = (FrameworkElement)skin;

            ContentGrid.Children.Add(newUserControl);
            var animation = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(200));

            newUserControl.BeginAnimation(OpacityProperty, animation);
            HostedWindow = skin;
            HostedWindow.EnableWindow();
        }
示例#14
0
        private Timeline CreateAnimation(double from, double to, DependencyObject target, string property)
        {
            var animation = new DoubleAnimation();
            animation.From = from;
            animation.To = to;
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            animation.EasingFunction = new SineEase { EasingMode = EasingMode.EaseInOut};

            Storyboard.SetTarget(animation, target);
#if WINRT
            Storyboard.SetTargetProperty(animation, property);
#else
            Storyboard.SetTargetProperty(animation, new PropertyPath(property));
#endif
            return animation; 
        }
        private void Refresh()
        {
            double radius = this.backEllipse.Width / 2;

            if (double.IsNaN(radius))
            {
                return;
            }

            this.mainCanvas.Children.Clear();


            //double scaleCounter = 10;

            double step = 270.0 / (this.Maximum - this.Minimum);

            for (int i = 0; i < this.Maximum - this.Minimum; ++i)
            {
                Line lineScale = new Line();

                lineScale.X1 = radius - (radius - 13) * Math.Cos((i * step - 45) * Math.PI / 180);
                lineScale.Y1 = radius - (radius - 13) * Math.Sin((i * step - 45) * Math.PI / 180);
                lineScale.X2 = radius - (radius - 8) * Math.Cos((i * step - 45) * Math.PI / 180);
                lineScale.Y2 = radius - (radius - 8) * Math.Sin((i * step - 45) * Math.PI / 180);

                lineScale.Stroke          = Brushes.White;
                lineScale.StrokeThickness = 1;

                this.mainCanvas.Children.Add(lineScale);
            }
            double scaleStep = 270.0 / Interval;
            int    scaleText = (int)this.Minimum;

            for (int i = 0; i <= Interval; ++i)
            {
                Line lineScale = new Line();
                lineScale.X1              = radius - (radius - 20) * Math.Cos((i * scaleStep - 45) * Math.PI / 180);
                lineScale.Y1              = radius - (radius - 20) * Math.Sin((i * scaleStep - 45) * Math.PI / 180);
                lineScale.X2              = radius - (radius - 8) * Math.Cos((i * scaleStep - 45) * Math.PI / 180);
                lineScale.Y2              = radius - (radius - 8) * Math.Sin((i * scaleStep - 45) * Math.PI / 180);
                lineScale.Stroke          = this.ScaleColor;
                lineScale.StrokeThickness = 1;
                this.mainCanvas.Children.Add(lineScale);


                //
                TextBlock textScale = new TextBlock();
                textScale.Width         = 34;
                textScale.TextAlignment = TextAlignment.Center;
                textScale.FontSize      = this.ScaleTextSize;
                textScale.Text          = (scaleText + (this.Maximum - this.Minimum) / Interval * i).ToString();
                textScale.Foreground    = this.ScaleColor;
                Canvas.SetLeft(textScale, radius - (radius - 36) * Math.Cos((i * scaleStep - 45) * Math.PI / 180) - 17);
                Canvas.SetTop(textScale, radius - (radius - 36) * Math.Sin((i * scaleStep - 45) * Math.PI / 180) - 10);
                this.mainCanvas.Children.Add(textScale);


                //
                string sData = "M{0} {1} A{0} {0} 0 1 1 {1} {2}";
                sData = string.Format(sData, radius / 2, radius, radius * 1.5);
                var converter = TypeDescriptor.GetConverter(typeof(Geometry));
                this.circle.Data = (Geometry)converter.ConvertFrom(sData);


                // this.rtPointer.Angle = this.Value * step - 45;

                DoubleAnimation da = new DoubleAnimation((this.Value - this.Minimum) * step - 45,
                                                         new Duration(TimeSpan.FromMilliseconds(200)));
                this.rtPointer.BeginAnimation(RotateTransform.AngleProperty, da);


                //
                sData             = "M{0},{1},{1},{2},{1},{3}";
                sData             = string.Format(sData, radius * 0.3, radius, radius - 5, radius + 5);
                this.pointer.Data = (Geometry)converter.ConvertFrom(sData);
            }
        }
        // Method for Drawing bar/rectangles
        public void DrawBars()
        {
            float section = 525 / vm.LstHoaDon.Count;

            // space between bars, 20% of section
            rectSpace = (section * 20) / 100;
            // bars Width
            rectWidth = (section * 80) / 100;

            // Actual Drawing
            for (int i = 0; i < vm.LstHoaDon.Count; i++)
            {
                Rectangle rect = new Rectangle();
                rect.Width  = rectWidth;
                rect.Height = vm.LstHoaDon[i].TongTien.Value / 100000;
                rect.Margin = new Thickness(rectSpace, (350 - rect.Height), 0, 25);
                rect.Fill   = BarsColor;

                wPanel.Children.Add(rect);

                // Effect of Animation
                DoubleAnimation ani = new DoubleAnimation
                {
                    From     = 0,
                    To       = vm.LstHoaDon[i].TongTien / 100000,
                    Duration = new TimeSpan(0, 0, 2)
                };
                // Add Animation
                ani.FillBehavior = FillBehavior.HoldEnd;
                rect.BeginAnimation(HeightProperty, ani);
                rect.Effect = new DropShadowEffect
                {
                    Color = new Color {
                        A = 1, R = 0, G = 139, B = 139
                    },
                    Direction   = 45,
                    ShadowDepth = 10,
                    Opacity     = 0.8,
                    BlurRadius  = 10
                };

                // Add lable
                Label lable = new Label();
                lable.Content             = vm.LstHoaDon[i].MaHD;
                lable.Background          = Brushes.Transparent;
                lable.Foreground          = Brushes.SkyBlue;
                lable.Margin              = new Thickness(rectSpace, 320, 0, 0);
                lable.FontSize            = 20 - vm.LstHoaDon[i].MaHD.Length;
                lable.Width               = rect.Width;
                lable.HorizontalAlignment = HorizontalAlignment.Center;
                lable.Height              = 30;
                stkPanel.Children.Add(lable);

                // Show value on mouse hover
                rect.MouseEnter += rect_MouseEnter;
            }
            // Add side line/Scale Lines, each separated by value of 20
            for (int i = 20; i < wPanel.Height; i += 20)
            {
                Line line = new Line();
                line.X1              = 5;
                line.Y1              = i;
                line.X2              = 25;
                line.Y2              = line.Y1;
                line.Stroke          = Brushes.SkyBlue;
                line.StrokeThickness = 1;
                gridThongKe.Children.Add(line);
            }
        }
示例#17
0
		public static bool FadeInBackground(Panel panel, Uri backgroundSourceUri, double opacity, 
			int msecs, Action completed = null)
		{
			if (backgroundSourceUri == null)
				return false;

			var brush = new ImageBrush();
			var image = new BitmapImage { UriSource = backgroundSourceUri };
			brush.Opacity = panel.Background != null ? panel.Background.Opacity : 0.0;
			brush.Stretch = Stretch.UniformToFill;
			brush.ImageSource = image;

			panel.Background = brush;
			brush.ImageOpened += delegate
			{
				var animation = new DoubleAnimation();
				animation.From = panel.Background != null ? panel.Background.Opacity : 0.0;
				animation.To = opacity;
				animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, msecs));

				var story = new Storyboard();
				story.Children.Add(animation);

				Storyboard.SetTarget(animation, brush);
				Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));

				if (completed != null)
					story.Completed += delegate { completed(); };
				story.Begin();
			};
			return true; 
		}
示例#18
0
        protected void BringCardIntoView(Card card)
        {
            // Get the current target viewport (bypass animations in progress)
            GeneralTransform transform = TransformToDescendant(cardsView);

            Rect visibleBounds = transform.TransformBounds(new Rect(0, 0, ActualWidth, ActualHeight));

            var cardRect = new Rect(card.X, card.Y, card.RealWidth, card.RealHeight);

            if (visibleBounds.Contains(cardRect))
            {
                return;                                   // okay, already completely into view
            }
            // Compute the new table bounds
            Rect newBounds = visibleBounds;

            if (cardRect.Left < visibleBounds.Left)
            {
                newBounds.X = cardRect.Left;
            }
            newBounds.Width = Math.Max(visibleBounds.Right, cardRect.Right) - newBounds.Left;
            if (cardRect.Top < visibleBounds.Top)
            {
                newBounds.Y = cardRect.Top;
            }
            newBounds.Height = Math.Max(visibleBounds.Bottom, cardRect.Bottom) - newBounds.Top;

            if (Player.LocalPlayer.InvertedTable)
            {
                // Transform the viewport so that it will fit correctly after the invert transform is applied
                newBounds.X = -newBounds.Right;
                newBounds.Y = -newBounds.Bottom;
            }

            // Compute the zoom and offset corresponding to the new view
            double newZoom = Math.Min(
                (Program.GameEngine.Table.Definition.Width + 2 * _stretchMargins.Width) / newBounds.Width,
                (Program.GameEngine.Table.Definition.Height + 2 * _stretchMargins.Height) / newBounds.Height);
            var newOffset = new Vector(
                -_stretchMargins.Width - newBounds.X * newZoom,
                -_stretchMargins.Height - newBounds.Y * newZoom);

            // Combine new values with the current ones
            // (bypassing animations, e.g. when moving several cards outside the bounds at the same time
            var realZoom = (double)GetAnimationBaseValue(ZoomProperty);

            //var realOffset = (Vector)GetAnimationBaseValue(OffsetProperty);
            if (newZoom > realZoom)
            {
                newZoom = realZoom;
            }
            //if (newOffset.X < realOffset.X) newOffset.X = realOffset.X;
            //if (newOffset.Y < realOffset.Y) newOffset.Y = realOffset.Y;

            double oldZoom   = Zoom;
            Vector oldOffset = Offset;

            Zoom   = newZoom;
            Offset = newOffset;
            // Animate the table with the result
            AnimationTimeline anim = new DoubleAnimation
            {
                From         = oldZoom,
                To           = newZoom,
                Duration     = TimeSpan.FromMilliseconds(150),
                FillBehavior = FillBehavior.Stop
            };

            BeginAnimation(ZoomProperty, anim);
            anim = new VectorAnimation
            {
                From         = oldOffset,
                To           = newOffset,
                Duration     = TimeSpan.FromMilliseconds(150),
                FillBehavior = FillBehavior.Stop
            };
            BeginAnimation(OffsetProperty, anim);

            // Note: the new visibleBounds may end up bigger than newBounds,
            // because the window aspect ratio may be different
        }
示例#19
0
        public TableControl()
        {
            InitializeComponent();
            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }
            var tableDef = Program.GameEngine.Definition.Table;
            var subbed   = SubscriptionModule.Get().IsSubscribed ?? false;

            if (subbed && !String.IsNullOrWhiteSpace(Prefs.DefaultGameBack) && File.Exists(Prefs.DefaultGameBack))
            {
                SetBackground(Prefs.DefaultGameBack, "uniformToFill");
            }
            else
            {
                if (tableDef.Background != null)
                {
                    SetBackground(tableDef);
                }
            }
            Program.GameEngine.BoardImage = Program.GameEngine.GameBoard.Source;
            //if (!Program.GameSettings.HideBoard)
            //    if (tableDef.Board != null)
            //        SetBoard(tableDef);

            if (!Program.GameSettings.UseTwoSidedTable)
            {
                middleLine.Visibility = Visibility.Collapsed;
            }

            if (Player.LocalPlayer.InvertedTable)
            {
                transforms.Children.Insert(0, new ScaleTransform(-1, -1));
            }

            _defaultWidth  = Program.GameEngine.Definition.CardSize.Width;
            _defaultHeight = Program.GameEngine.Definition.CardSize.Height;
            SizeChanged   += delegate
            {
                IsCardSizeValid = false;
                AspectRatioChanged();
            };
            MoveCards.Done  += CardMoved;
            CreateCard.Done += CardCreated;
            Unloaded        += delegate
            {
                MoveCards.Done  -= CardMoved;
                CreateCard.Done -= CardCreated;
            };
            Loaded += delegate { CenterView(); };
            //var didIt = false;
            //Loaded += delegate
            //{
            //if (didIt) return;
            //didIt = true;
            //foreach (var p in Player.AllExceptGlobal.GroupBy(x => x.InvertedTable))
            //{
            //    var sx = Program.GameEngine.BoardMargin.Left;
            //    var sy = Program.GameEngine.BoardMargin.Bottom;
            //    if (p.Key == true)
            //    {
            //        sy = Program.GameEngine.BoardMargin.Top;
            //        sx = Program.GameEngine.BoardMargin.Right;
            //    }
            //    foreach (var player in p)
            //    {
            //        foreach (var tgroup in player.TableGroups)
            //        {
            //            var pile = new AdhocPileControl();
            //            pile.DataContext = tgroup;
            //            PlayerCanvas.Children.Add(pile);
            //            Canvas.SetLeft(pile, sx);
            //            Canvas.SetTop(pile, sy);
            //            if (p.Key)
            //                sx -= Program.GameEngine.Definition.CardWidth * 2;
            //            else
            //                sx += Program.GameEngine.Definition.CardWidth * 2;
            //        }
            //        if (p.Key)
            //            sx -= Program.GameEngine.Definition.CardWidth * 4;
            //        else
            //            sx += Program.GameEngine.Definition.CardWidth * 4;
            //    }
            //}
            //};
            Program.GameEngine.PropertyChanged += GameOnPropertyChanged;
            if (Player.LocalPlayer.InvertedTable)
            {
                var rotateAnimation = new DoubleAnimation(0, 180, TimeSpan.FromMilliseconds(1));
                var rt = (RotateTransform)NoteCanvas.RenderTransform;
                rt.BeginAnimation(RotateTransform.AngleProperty, rotateAnimation);
            }
            //this.IsManipulationEnabled = true;
            //this.ManipulationDelta += OnManipulationDelta;

            Player.LocalPlayer.PropertyChanged += LocalPlayerOnPropertyChanged;
        }
示例#20
0
        public static void CenterSelectedItem(this ListBox listBox)
        {
            Argument.IsNotNull(() => listBox);

            var scrollViewer = listBox.FindVisualDescendantByType <ScrollViewer>();

            if (scrollViewer is null)
            {
                return;
            }

            var selectedItem = listBox.SelectedItem;

            if (selectedItem is null)
            {
                return;
            }

            var isBefore     = true;
            var beforeOffset = 0d;
            var afterOffset  = 0d;

            foreach (var item in listBox.Items)
            {
                var currentItem = ReferenceEquals(item, selectedItem);
                if (currentItem)
                {
                    isBefore = false;
                }

                var container = listBox.ItemContainerGenerator.ContainerFromItem(selectedItem) as FrameworkElement;
                if (container is null)
                {
                    return;
                }

                var width = container.ActualWidth;

                if (isBefore)
                {
                    beforeOffset += width;
                }
                else if (currentItem)
                {
                    beforeOffset += width / 2;
                    afterOffset  += width / 2;
                }
                else
                {
                    afterOffset += width;
                }
            }

            // We now know the actual center, calculate based on the width
            var scrollableArea = scrollViewer.ActualWidth;
            var toValue        = beforeOffset - (scrollableArea / 2);

            if (toValue < 0)
            {
                toValue = 0;
            }

            var horizontalAnimation = new DoubleAnimation();

            horizontalAnimation.From = scrollViewer.HorizontalOffset;
            horizontalAnimation.To   = toValue;
            horizontalAnimation.DecelerationRatio = .2;
            horizontalAnimation.Duration          = new Duration(WizardConfiguration.AnimationDuration);

            var storyboard = new Storyboard();

            storyboard.Children.Add(horizontalAnimation);
            Storyboard.SetTarget(horizontalAnimation, scrollViewer);
            Storyboard.SetTargetProperty(horizontalAnimation, new PropertyPath(HorizontalOffsetProperty));
            storyboard.Begin();
        }
示例#21
0
        /// <summary>
        /// Fly Animation
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="duration"></param>
        /// <param name="isInbound"></param>
        private void FlyAnimation(string direction, double duration, bool isInbound)
        {
            // We might not need both of these, but we add them just in case we have a mid-way compass point
            var trans = new TranslateTransform();

            DoubleAnimation doubleAnimationX = new DoubleAnimation();

            doubleAnimationX.Duration   = TimeSpan.FromMilliseconds(duration);
            doubleAnimationX.Completed += Animation_Completed;

            DoubleAnimation doubleAnimationY = new DoubleAnimation();

            doubleAnimationY.Duration   = TimeSpan.FromMilliseconds(duration);
            doubleAnimationY.Completed += Animation_Completed;

            // Get the viewable window width and height
            int screenWidth  = options.PlayerWidth;
            int screenHeight = options.PlayerHeight;

            int top  = options.top;
            int left = options.left;

            // Where should we end up once we are done?
            if (isInbound)
            {
                // End up at the top/left
                doubleAnimationX.To = left;
                doubleAnimationY.To = top;
            }
            else
            {
                // End up off the screen
                doubleAnimationX.To = screenWidth;
                doubleAnimationY.To = screenHeight;
            }

            // Compass points
            switch (direction)
            {
            case "N":
                if (isInbound)
                {
                    // We come in from the bottom of the screen
                    doubleAnimationY.From = (screenHeight - top);
                }
                else
                {
                    // We go out across the top
                    doubleAnimationY.From = top;
                }

                BeginAnimation(TranslateTransform.YProperty, doubleAnimationY);
                break;

            case "NE":
                if (isInbound)
                {
                    doubleAnimationX.From = (screenWidth - left);
                    doubleAnimationY.From = (screenHeight - top);
                }
                else
                {
                    doubleAnimationX.From = left;
                    doubleAnimationY.From = top;
                }


                trans.BeginAnimation(TranslateTransform.YProperty, doubleAnimationY);
                trans.BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                RenderTransform = trans;
                break;

            case "E":
                if (isInbound)
                {
                    doubleAnimationX.From = -(screenWidth - left);
                }
                else
                {
                    if (left == 0)
                    {
                        doubleAnimationX.From = -left;
                    }
                    else
                    {
                        doubleAnimationX.From = -(screenWidth - left);
                    }
                }

                BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                break;

            case "SE":
                if (isInbound)
                {
                    doubleAnimationX.From = left;
                    doubleAnimationY.From = -(screenHeight - top);
                }
                else
                {
                    doubleAnimationX.From = (screenWidth - left);
                    doubleAnimationY.From = -(screenHeight - top);
                }

                trans.BeginAnimation(TranslateTransform.YProperty, doubleAnimationY);
                trans.BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                RenderTransform = trans;
                break;

            case "S":
                if (isInbound)
                {
                    doubleAnimationX.From = -(screenHeight - top);
                }
                else
                {
                    doubleAnimationX.From = -top;
                }

                BeginAnimation(TranslateTransform.YProperty, doubleAnimationX);
                break;

            case "SW":
                if (isInbound)
                {
                    doubleAnimationX.From = (screenWidth - left);
                    doubleAnimationY.From = -top;
                }
                else
                {
                    doubleAnimationX.From = left;
                    doubleAnimationY.From = -(screenHeight - left);
                }

                trans.BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                trans.BeginAnimation(TranslateTransform.YProperty, doubleAnimationY);
                RenderTransform = trans;
                break;

            case "W":
                if (isInbound)
                {
                    doubleAnimationX.From = (screenWidth - left);
                }
                else
                {
                    doubleAnimationX.From = -left;
                }

                trans.BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                RenderTransform = trans;
                break;

            case "NW":
                if (isInbound)
                {
                    doubleAnimationX.From = (screenWidth - left);
                    doubleAnimationY.From = (screenHeight - top);
                }
                else
                {
                    doubleAnimationX.From = left;
                    doubleAnimationY.From = top;
                }

                trans.BeginAnimation(TranslateTransform.XProperty, doubleAnimationX);
                trans.BeginAnimation(TranslateTransform.YProperty, doubleAnimationY);
                RenderTransform = trans;
                break;
            }
        }
示例#22
0
 public static void SetStoryBoardTarget(DoubleAnimation animation, string targetName)
 {
     animation.SetValue(Storyboard.TargetNameProperty, targetName);
 }
        private DoubleAnimation CreateDouble(double to, int duration, DependencyObject target, string path, EasingFunctionBase easing)
        {
            var anim = new DoubleAnimation();
            anim.To = to;
            anim.Duration = new Duration(TimeSpan.FromMilliseconds(duration));
            anim.EasingFunction = easing;

            Storyboard.SetTarget(anim, target);
#if SILVERLIGHT
            Storyboard.SetTargetProperty(anim, new PropertyPath(path));
#else
            Storyboard.SetTargetProperty(anim, path);
#endif

            return anim;
        }
示例#24
0
        private void MakePieInvisible(PiePiece pClickedPiePiece)
        {
            DoubleAnimation lHide = new DoubleAnimation(0, new Duration(TimeSpan.FromMilliseconds(IsAnimate ? 200 : 0)));

            pClickedPiePiece.BeginAnimation(PiePiece.PushOutProperty, lHide);
        }
示例#25
0
        private void begin(object sender, RoutedEventArgs e)
        {
            champAdressePhysique.Text = "";
            champAux.Text             = "";
            champRam.Text             = "";
            champTPages.Text          = "";
            deroulement.Text          = "";

            stop.IsEnabled             = true;
            suivant.IsEnabled          = true;
            suiteReferences.IsReadOnly = true;
            if (iteration == 0)
            {
                sauvSuite = suiteReferences.Text;
                requete   = sauvSuite.Split(' ').ToList <String>();
            }
            if (iteration < suiteReferences.Text.Split(' ').Length)
            {
                sequence.Push(new List <object> {
                    systemExploitation.Clone(), ram.Clone(), diskDur.Clone(), new List <EntreeTablePage>(tablePages.Select(x => x.Clone())), requete, sauvSuite
                });
                if (requete.Count != 0)
                {
                    String r = requete[iteration];
                    demande.Text = "Demande de l'adresse virtuelle: " + r;
                    try
                    {
                        int tmp = Convert.ToInt32(r);
                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 3:
                            affichMatriceAging();
                            break;
                        }

                        int             sDefaut = systemExploitation.getDefautDePage();
                        int             sNbpage = ram.getNombrepagesLibres();
                        SolidColorBrush myBrush = new SolidColorBrush();
                        myBrush.Color = Colors.White;
                        ColorAnimation ba = new ColorAnimation()
                        {
                            Duration = TimeSpan.FromMilliseconds(1000)
                        };
                        if (tablePages[tmp].getDisponible() == true)
                        {
                            ba.To = Colors.Green;
                        }
                        else
                        {
                            ba.To = Colors.Red;
                        }
                        myBrush.BeginAnimation(SolidColorBrush.ColorProperty, ba);
                        oTable.RowGroups[0].Rows[tmp].Background = myBrush;
                        systemExploitation.gestionRequete(choixAlgorithme.SelectedIndex, tablePages, tmp, ram, diskDur);
                        Line line = new Line()
                        {
                            X1 = 150, Y1 = (tmp + 1) * 51 + 25, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 2
                        };
                        DoubleAnimation animation = new DoubleAnimation(260, TimeSpan.FromSeconds(0.5))
                        {
                            From = 150, AutoReverse = true
                        };

                        memVirtuelle.Children.Add(line);
                        line.BeginAnimation(Line.X2Property, animation);
                        animation.From = line.Y1;
                        animation.To   = 200 + (51) * tablePages[tmp].getPageCorrespandante();
                        line.BeginAnimation(Line.Y2Property, animation);



                        switch (choixAlgorithme.SelectedIndex)
                        {
                        case 0:
                            if (sDefaut < systemExploitation.getDefautDePage() && sNbpage == 0)
                            {
                                aux.Children.RemoveAt(0);
                                aux.Children.RemoveAt(0);
                            }
                            else
                            {
                                if (sDefaut == systemExploitation.getDefautDePage())
                                {
                                    for (int i = 1; i < aux.Children.Count; i = i + 2)
                                    {
                                        if (((TextBlock)aux.Children[i]).Text == r)
                                        {
                                            aux.Children.RemoveRange(i - 1, 2);
                                            for (int k = i - 1; k < aux.Children.Count; k++)
                                            {
                                                DoubleAnimation db = new DoubleAnimation
                                                {
                                                    To       = Canvas.GetLeft(aux.Children[k]) + 10,
                                                    Duration = new Duration(new TimeSpan(1000000))
                                                };
                                                aux.Children[k].BeginAnimation(Canvas.LeftProperty, db);
                                            }

                                            break;
                                        }
                                    }
                                }
                            }
                            ajoutFileLru();
                            break;

                        case 1:
                            if (sDefaut < systemExploitation.getDefautDePage())
                            {
                                if (sNbpage == 0)
                                {
                                    aux.Children.RemoveAt(0);
                                    aux.Children.RemoveAt(0);
                                }

                                ajoutFileFifo();
                            }

                            break;

                        case 2:
                            affichLfu();
                            break;

                        case 3:
                            affichMatriceAging();
                            break;
                        }
                        champTPages.Text = "Mise a jour de la table de pages ";
                        afficherRam(ram);
                        champAdressePhysique.Text = "L'adresse physique de la page " + r + " est: " + tablePages[Convert.ToInt32(r)].getPageCorrespandante().ToString();
                        deroulement.Text          = "Nombre de defauts de page: " + systemExploitation.getDefautDePage().ToString();
                        majTablePage();
                        iteration++;
                    }
                    catch (FormatException)
                    {
                        msgErreur.Text = "erreur dans la suite entrée.";
                    }

                    precedent.IsEnabled = true;
                    if (iteration == suiteReferences.Text.Split(' ').Length)
                    {
                        lancer.IsEnabled  = false;
                        suivant.IsEnabled = false;
                    }
                }
            }
        }
示例#26
0
        public static FluentAnimationHelper <T> AnimateTranslateTransform <T>(this T element, Point from, Point to, TimeSpan duration, bool clearAnimationWhenFinished) where T : UIElement
        {
            TranslateTransform transform = null;

            if (element.RenderTransform == null)
            {
                var tg = new TransformGroup();
                transform = new TranslateTransform();
                tg.Children.Add(tg);
                element.RenderTransform = tg;
            }
            else if (element.RenderTransform is TranslateTransform)
            {
                transform = (TranslateTransform)element.RenderTransform;
            }
            else if (element.RenderTransform is TransformGroup)
            {
                var tg = (TransformGroup)element.RenderTransform;
                transform = (TranslateTransform)tg.Children.FirstOrDefault(c => c is TranslateTransform);
                if (transform == null)
                {
                    transform = new TranslateTransform();
                    tg.Children.Add(tg);
                }
            }
            if (transform == null)
            {
                throw new InvalidOperationException("Element has unsupported RenderTransform. Can not AnimateMove.");
            }
            var helper = new FluentAnimationHelper <T>(element, transform, clearAnimationWhenFinished);

            DoubleAnimation animX = new DoubleAnimation();

            animX.From     = from.X;
            animX.To       = to.X;
            animX.Duration = duration;
            bool animXCompleted = false;

            DoubleAnimation animY = new DoubleAnimation();

            animY.From     = from.Y;
            animY.To       = to.Y;
            animY.Duration = duration;
            bool animYCompleted = false;

            animX.Completed += (s, e1) =>
            {
                animXCompleted = true;
                if (!animYCompleted)
                {
                    return;
                }
                helper.ExecuteThen();
            };
            animX.Completed += (s, e1) =>
            {
                animYCompleted = true;
                if (!animXCompleted)
                {
                    return;
                }
                helper.ExecuteThen();
            };
            transform.BeginAnimation(TranslateTransform.XProperty, animX);
            transform.BeginAnimation(TranslateTransform.YProperty, animY);
            return(helper);
        }
示例#27
0
        public static void Animate(DependencyObject target, string property, double from, double to, int duration, AnimateEventHandler completed)
        {
            var animation = new DoubleAnimation();
            animation.From = from;
            animation.To = to;
            animation.Duration = new TimeSpan(0, 0, 0, 0, duration);
            Storyboard.SetTarget(animation, target);
#if !NETFX_CORE
            Storyboard.SetTargetProperty(animation, new PropertyPath(property));
#else
            Storyboard.SetTargetProperty(animation, property);
#endif

            var storyBoard = new Storyboard();
            storyBoard.Children.Add(animation);
            storyBoard.Completed += completed;
            storyBoard.Begin();
        }
        /// <summary>
        /// Walks through the known storyboards in the control's template that
        /// may contain identifying values, storing them for future
        /// use and updates.
        /// </summary>
        private void UpdateAnyAnimationValues()
        {
            if (_knownHeight > 0 && _knownWidth > 0)
            {
                // Initially, before any special animations have been found,
                // the visual state groups of the control must be explored.
                // By definition they must be at the implementation root of the
                // control.
                if (_specialAnimations == null)
                {
                    _specialAnimations = new List <AnimationValueAdapter>();

                    foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(this))
                    {
                        if (group == null)
                        {
                            continue;
                        }
                        foreach (VisualState state in group.States)
                        {
                            if (state != null)
                            {
                                Storyboard sb = state.Storyboard;

                                if (sb != null)
                                {
                                    // Examine all children of the storyboards,
                                    // looking for either type of double
                                    // animation.
                                    foreach (Timeline timeline in sb.Children)
                                    {
                                        DoubleAnimation da = timeline as DoubleAnimation;
                                        DoubleAnimationUsingKeyFrames dakeys = timeline as DoubleAnimationUsingKeyFrames;
                                        if (da != null)
                                        {
                                            ProcessDoubleAnimation(da);
                                        }
                                        else if (dakeys != null)
                                        {
                                            ProcessDoubleAnimationWithKeys(dakeys);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Update special animation values relative to the current size.
                UpdateKnownAnimations();

                // HACK: force storyboard to use new values
                foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(this))
                {
                    if (group == null)
                    {
                        continue;
                    }
                    foreach (VisualState state in group.States)
                    {
                        if (state != null)
                        {
                            Storyboard sb = state.Storyboard;

                            if (sb != null)
                            {
                                // need to kick the storyboard, otherwise new values are not taken into account.
                                // it's sad, really don't want to start storyboards in vsm, but I see no other option
                                sb.Begin(this);
                            }
                        }
                    }
                }
            }
        }
示例#29
0
        // <SnippetBeginAnimationHandoff>
        private void myFrameNavigated(object sender, NavigationEventArgs args)
        {
            DoubleAnimation myFadeInAnimation = (DoubleAnimation)this.Resources["MyFadeInAnimationResource"];

            myFrame.BeginAnimation(Frame.OpacityProperty, myFadeInAnimation, HandoffBehavior.SnapshotAndReplace);
        }
示例#30
0
        private void UpdateOpenStoryboard()
        {
            mainButtonOpenStoryboard = null;
            if (panel == null)
            {
                return;
            }

            var duration = mainButtonAnimationDuration / 2;

            var ease1 = new CubicEase()
            {
                EasingMode = EasingMode.EaseOut
            };
            var ease2 = new ElasticEase()
            {
                Oscillations = 1, EasingMode = EasingMode.EaseOut
            };

            var sb = new Storyboard();
            var x  = ActualWidth / 15;
            var y  = -ActualHeight / 15;

            if (ItemsPosition == GooeyButtonItemsPosition.LeftTop)
            {
                x = -Math.Abs(x);
                y = -Math.Abs(y);
            }
            else if (ItemsPosition == GooeyButtonItemsPosition.RightTop)
            {
                x = Math.Abs(x);
                y = -Math.Abs(y);
            }
            else if (ItemsPosition == GooeyButtonItemsPosition.LeftBottom)
            {
                x = -Math.Abs(x);
                y = Math.Abs(y);
            }
            else if (ItemsPosition == GooeyButtonItemsPosition.RightBottom)
            {
                x = Math.Abs(x);
                y = Math.Abs(y);
            }

            var dax = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(dax, BackgroundShapeTranslate);
            Storyboard.SetTargetProperty(dax, "X");
            dax.Duration = TimeSpan.FromSeconds(mainButtonAnimationDuration);
            dax.KeyFrames.Add(new EasingDoubleKeyFrame()
            {
                KeyTime        = TimeSpan.FromSeconds(mainButtonAnimationDuration / 3),
                Value          = x,
                EasingFunction = ease1
            });
            dax.KeyFrames.Add(new EasingDoubleKeyFrame()
            {
                KeyTime        = TimeSpan.FromSeconds(mainButtonAnimationDuration),
                Value          = 0,
                EasingFunction = ease2
            });

            var day = new DoubleAnimationUsingKeyFrames();

            Storyboard.SetTarget(day, BackgroundShapeTranslate);
            Storyboard.SetTargetProperty(day, "Y");
            day.Duration = TimeSpan.FromSeconds(mainButtonAnimationDuration);
            day.KeyFrames.Add(new EasingDoubleKeyFrame()
            {
                KeyTime        = TimeSpan.FromSeconds(mainButtonAnimationDuration / 3),
                Value          = y,
                EasingFunction = ease1
            });
            day.KeyFrames.Add(new EasingDoubleKeyFrame()
            {
                KeyTime        = TimeSpan.FromSeconds(mainButtonAnimationDuration),
                Value          = 0,
                EasingFunction = ease2
            });

            var baan = new DoubleAnimation();

            Storyboard.SetTarget(baan, this);
            Storyboard.SetTargetProperty(baan, "BlurAmount");
            baan.EnableDependentAnimation = true;
            baan.To             = 0d;
            baan.Duration       = TimeSpan.FromSeconds(0.3);
            baan.EasingFunction = new CircleEase()
            {
                EasingMode = EasingMode.EaseIn
            };

            sb.Children.Add(dax);
            sb.Children.Add(day);
            //sb.Children.Add(wdax);
            //sb.Children.Add(wday);
            sb.Children.Add(baan);
            mainButtonOpenStoryboard = sb;
        }
示例#31
0
        void CollectRise()
        {
            //Console.WriteLine($"鼠标移出{this.ActualWidth}");
            if (!isMove || animationRight != null)
            {
                return;
            }
            var xProp = this.ActualWidth - miniWdith;

            animationRight = new DoubleAnimation
            {
                To             = xProp,
                Duration       = new Duration(TimeSpan.FromMilliseconds(500)),
                EasingFunction = new SineEase {
                    EasingMode = EasingMode.EaseIn
                },
            };
            animationRight.Completed += (s1, e1) =>
            {
                Console.WriteLine($"收起translateForm.X:{translateForm.X}");
                if (animationRightBurden != null)
                {
                    animationRightBurden = null;
                }
                isLeave = true;
                isMove  = false;
            };
            translateForm.BeginAnimation(TranslateTransform.XProperty, animationRight);


            #region 注释
            //if (!IsEdgeHide || animationRight!=null)
            //    return;
            //if (!isMove)
            //    return;
            //EasingFunctionBase easeFunction = new SineEase()
            //{
            //    EasingMode = EasingMode.EaseIn,
            //};
            //animationRight = new DoubleAnimation
            //{
            //    To = desktopWorkingArea.Width - miniWdith,
            //    Duration = new Duration(TimeSpan.FromMilliseconds(500)),
            //    EasingFunction = easeFunction,
            //};
            //animationRight.Completed += (s1, e1) =>
            //{
            //    Console.WriteLine($"收起this.Left:{this.Left}");
            //    if (animationRightBurden != null)
            //    {
            //        animationRightBurden = null;
            //    }
            //    var widthAnimation = new DoubleAnimation
            //    {
            //        To = miniWdith,
            //        Duration = new Duration(TimeSpan.FromMilliseconds(300)),
            //        EasingFunction = easeFunction
            //    };
            //    widthAnimation.Completed += (s2, e2) =>
            //    {
            //        isLeave = true;
            //        isMove = false;
            //    };
            //    this.BeginAnimation(WidthProperty, widthAnimation);
            //    //this.Width = miniWdith;
            //};
            //this.BeginAnimation(LeftProperty, animationRight);
            #endregion
        }
        private static void Changing(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            var anim = new DoubleAnimation((double)e.OldValue, (double)e.NewValue, System.TimeSpan.FromMilliseconds(150));

            (obj as ProgressBar).BeginAnimation(ProgressBar.ValueProperty, anim, HandoffBehavior.Compose);
        }
示例#33
0
        private void ZoomLevelAnimationCompleted(object sender, object e)
        {
            if (zoomLevelAnimation != null)
            {
                zoomLevelAnimation.Completed -= ZoomLevelAnimationCompleted;
                zoomLevelAnimation = null;

                InternalSetValue(ZoomLevelProperty, TargetZoomLevel);
                RemoveAnimation(ZoomLevelProperty); // remove holding animation in WPF

                UpdateTransform(true);
            }
        }
        private void nextSFXStep()
        {
            if (sfxQueue != null)
            {
                sfxQueue.RemoveAt(0);
                if (sfxQueue.Count > 0)
                {
                    playSoundEffect(sfxQueue[0]);
                    if (countDown.Visibility == System.Windows.Visibility.Visible)
                    {
                        countDown.Text = Convert.ToString(sfxQueue.Count - 1);
                    }

                    if (sfxQueue.Count == 1)
                    {
                        // Hide the count
                        countDown.Visibility = System.Windows.Visibility.Hidden;
                        countDown.Text       = "3";

                        // Take the photo
                        freezePhoto = true;

                        // Flash the white
                        //DoubleAnimation daFlashW = AnimationHelper.CreateDoubleAnimation(0, this.Width, null, new Duration(TimeSpan.FromSeconds(0.2)));
                        //DoubleAnimation daFlashH = AnimationHelper.CreateDoubleAnimation(0, this.Height, null, new Duration(TimeSpan.FromSeconds(0.2)));
                        DoubleAnimation daFlashOpacity = new DoubleAnimation(0, .8, new Duration(TimeSpan.FromSeconds(0.1)));
                        daFlashOpacity.AutoReverse = true;

                        //camFlash.BeginAnimation(Ellipse.WidthProperty, daFlashW);
                        //camFlash.BeginAnimation(Ellipse.HeightProperty, daFlashH);
                        camFlash.BeginAnimation(Ellipse.OpacityProperty, daFlashOpacity);
                    }
                }
                else
                {
                    sfxQueue = null;
                    // Done
                    destroySFXPlayer();

                    // Show retake photo
                    txtTakePhoto.Text = "RE-TAKE PHOTO";
                    DoubleAnimation daOpacity = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.5)));
                    daOpacity.BeginTime = TimeSpan.FromSeconds(6);
                    txtTakePhoto.BeginAnimation(TextBlock.OpacityProperty, daOpacity);
                    txtStartCountdown.BeginAnimation(TextBlock.OpacityProperty, daOpacity);
                    takePhoto.BeginAnimation(Button.OpacityProperty, daOpacity);
                    takePhoto.IsHitTestVisible = true;

                    // show yes or no button
                    DoubleAnimation daHeight  = new DoubleAnimation(150, 0, new Duration(TimeSpan.FromSeconds(0.3)));
                    DoubleAnimation daHeightF = new DoubleAnimation(150, 0, new Duration(TimeSpan.FromSeconds(0.3)));
                    SineEase        ease      = new SineEase();
                    ease.EasingMode          = EasingMode.EaseOut;
                    daHeight.EasingFunction  = ease;
                    daHeightF.EasingFunction = ease;
                    daHeight.BeginTime       = TimeSpan.FromSeconds(6);
                    daHeightF.BeginTime      = TimeSpan.FromSeconds(6.2);
                    // Add a tiny delay
                    YNSpacer.BeginAnimation(Canvas.HeightProperty, daHeight);
                    YNSpacer2.BeginAnimation(Canvas.HeightProperty, daHeightF);

                    // Captions
                    requestNewCaption(ApplicationStates.STATE_LOOKINGGOOD, false);
                    requestNewCaption(ApplicationStates.STATE_SUBMISSION_AGREE, true);
                    requestNewCaption(ApplicationStates.STATE_YES_NOPHOTO, true);

                    // Re-enable the cursors
                    if (_mainWin != null)
                    {
                        _mainWin.enableDisableAllCursors(true);
                    }
                }
            }
        }
示例#35
0
        /// <summary>
        /// Begins the animation when a tile is selected as a 'winner' of the draw.
        /// This adds a new item to the canvas.
        /// </summary>
        /// <param name="selectedTileControl"></param>
        private void InitializeAndBeginAnimation(TileUserControl selectedTileControl)
        {
            var absoluteTilePosition = selectedTileControl.TransformToAncestor(this).Transform(new Point(0, 0));

            var tileViewModel = selectedTileControl.DataContext as TileViewModel;

            var selectedTile = new TileUserControl(tileViewModel)
            {
                Width  = selectedTileControl.ActualWidth,
                Height = selectedTileControl.ActualHeight
            };

            Canvas.SetLeft(selectedTile, absoluteTilePosition.X);
            Canvas.SetTop(selectedTile, absoluteTilePosition.Y);

            var targetXPos = ActualWidth * 0.5d - WinnerTileTargetWidth * 0.5d;
            var targetYPos = ActualHeight * 0.5d - WinnerTileTargetHeight * 0.5d;

            var animWidth = new DoubleAnimation
            {
                From     = selectedTile.Width,
                To       = 800,
                Duration = new Duration(TimeSpan.FromSeconds(2))
            };

            var animHeight = new DoubleAnimation
            {
                From     = selectedTile.Height,
                To       = 500,
                Duration = new Duration(TimeSpan.FromSeconds(2))
            };

            var animXPos = new DoubleAnimation
            {
                From     = absoluteTilePosition.X,
                To       = targetXPos,
                Duration = new Duration(TimeSpan.FromSeconds(2))
            };

            var animYPos = new DoubleAnimation
            {
                From     = absoluteTilePosition.Y,
                To       = targetYPos,
                Duration = new Duration(TimeSpan.FromSeconds(2))
            };

            Storyboard.SetTarget(animWidth, selectedTile);
            Storyboard.SetTarget(animHeight, selectedTile);
            Storyboard.SetTarget(animXPos, selectedTile);
            Storyboard.SetTarget(animYPos, selectedTile);
            Storyboard.SetTargetProperty(animWidth, new PropertyPath(WidthProperty));
            Storyboard.SetTargetProperty(animHeight, new PropertyPath(HeightProperty));
            Storyboard.SetTargetProperty(animXPos, new PropertyPath(LeftProperty));
            Storyboard.SetTargetProperty(animYPos, new PropertyPath(TopProperty));

            var storyboard = new Storyboard();

            storyboard.Children.Add(animWidth);
            storyboard.Children.Add(animHeight);
            storyboard.Children.Add(animXPos);
            storyboard.Children.Add(animYPos);

            Canvas.Children.Add(selectedTile);

            storyboard.Begin(this);
        }
示例#36
0
 private void ShowLoggedInUserImg(bool show)
 {
     if (show)
     {
         Storyboard      storyboard       = new Storyboard();
         DoubleAnimation doubleAnimation1 = new DoubleAnimation();
         double?         nullable1        = new double?(44.0);
         doubleAnimation1.To = nullable1;
         int num1 = 0;
         ((Timeline)doubleAnimation1).AutoReverse = (num1 != 0);
         List <UserLike> users1 = this._likesInfo.users;
         // ISSUE: explicit non-virtual call
         Duration duration1 = (TimeSpan.FromSeconds((users1 != null ? (users1.Count > 0 ? 1 : 0) : 0) != 0 ? 0.25 : 0.0));
         ((Timeline)doubleAnimation1).Duration = duration1;
         CubicEase cubicEase1 = new CubicEase();
         doubleAnimation1.EasingFunction = ((IEasingFunction)cubicEase1);
         DoubleAnimation doubleAnimation2 = doubleAnimation1;
         Storyboard.SetTargetProperty((Timeline)doubleAnimation2, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)", new object[0]));
         Storyboard.SetTarget((Timeline)doubleAnimation2, (DependencyObject)this._canvasUserImages);
         ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)doubleAnimation2);
         Image     imageLoggedInUser = this._imageLoggedInUser;
         double    num2   = 0.0;
         Thickness margin = ((FrameworkElement)this._imageLoggedInUser).Margin;
         // ISSUE: explicit reference operation
         double    top       = ((Thickness)@margin).Top;
         double    num3      = 0.0;
         double    num4      = 0.0;
         Thickness thickness = new Thickness(num2, top, num3, num4);
         ((FrameworkElement)imageLoggedInUser).Margin = thickness;
         DoubleAnimation doubleAnimation3 = new DoubleAnimation();
         List <UserLike> users2           = this._likesInfo.users;
         // ISSUE: explicit non-virtual call
         TimeSpan?nullable2 = new TimeSpan?(TimeSpan.FromSeconds((users2 != null ? (users2.Count > 0 ? 1 : 0) : 0) != 0 ? 0.25 : 0.0));
         ((Timeline)doubleAnimation3).BeginTime = nullable2;
         double?nullable3 = new double?(1.0);
         doubleAnimation3.To = nullable3;
         int num5 = 0;
         ((Timeline)doubleAnimation3).AutoReverse = (num5 != 0);
         Duration duration2 = (TimeSpan.FromSeconds(0.25));
         ((Timeline)doubleAnimation3).Duration = duration2;
         CubicEase cubicEase2 = new CubicEase();
         doubleAnimation3.EasingFunction = ((IEasingFunction)cubicEase2);
         DoubleAnimation doubleAnimation4 = doubleAnimation3;
         Storyboard.SetTargetProperty((Timeline)doubleAnimation4, new PropertyPath("Opacity", new object[0]));
         Storyboard.SetTarget((Timeline)doubleAnimation4, (DependencyObject)this._imageLoggedInUser);
         ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)doubleAnimation4);
         storyboard.Begin();
     }
     else
     {
         Storyboard      storyboard       = new Storyboard();
         DoubleAnimation doubleAnimation1 = new DoubleAnimation();
         double?         nullable1        = new double?(0.0);
         doubleAnimation1.To = nullable1;
         int num1 = 0;
         ((Timeline)doubleAnimation1).AutoReverse = (num1 != 0);
         Duration duration1 = (TimeSpan.FromSeconds(0.25));
         ((Timeline)doubleAnimation1).Duration = duration1;
         CubicEase cubicEase1 = new CubicEase();
         doubleAnimation1.EasingFunction = ((IEasingFunction)cubicEase1);
         DoubleAnimation doubleAnimation2 = doubleAnimation1;
         Storyboard.SetTargetProperty((Timeline)doubleAnimation2, new PropertyPath("Opacity", new object[0]));
         Storyboard.SetTarget((Timeline)doubleAnimation2, (DependencyObject)this._imageLoggedInUser);
         ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)doubleAnimation2);
         DoubleAnimation doubleAnimation3 = new DoubleAnimation();
         TimeSpan?       nullable2        = new TimeSpan?(TimeSpan.FromSeconds(0.25));
         ((Timeline)doubleAnimation3).BeginTime = nullable2;
         double?nullable3 = new double?(0.0);
         doubleAnimation3.To = nullable3;
         int num2 = 0;
         ((Timeline)doubleAnimation3).AutoReverse = (num2 != 0);
         List <UserLike> users = this._likesInfo.users;
         // ISSUE: explicit non-virtual call
         Duration duration2 = (TimeSpan.FromSeconds((users != null ? (users.Count > 0 ? 1 : 0) : 0) != 0 ? 0.25 : 0.0));
         ((Timeline)doubleAnimation3).Duration = duration2;
         CubicEase cubicEase2 = new CubicEase();
         doubleAnimation3.EasingFunction = ((IEasingFunction)cubicEase2);
         DoubleAnimation doubleAnimation4 = doubleAnimation3;
         Storyboard.SetTargetProperty((Timeline)doubleAnimation4, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.X)", new object[0]));
         Storyboard.SetTarget((Timeline)doubleAnimation4, (DependencyObject)this._canvasUserImages);
         ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)doubleAnimation4);
         storyboard.Begin();
     }
 }
示例#37
0
        private Storyboard CreateStory(Control control, double start, double end, EventHandler<object> callback = null)
#endif
        {
            var story = new Storyboard();
            var fadeAnimation = new DoubleAnimation()
            {
                From = start,
                To = end,
                Duration = new Duration(Duration)
            };
            if (callback != null) story.Completed += callback;
            story.Children.Add(fadeAnimation);
            Storyboard.SetTarget(fadeAnimation, control);
#if WPF
            Storyboard.SetTargetProperty(fadeAnimation, new PropertyPath(Control.OpacityProperty));
#elif METRO
            Storyboard.SetTargetProperty(fadeAnimation, "Opacity");
#endif
            return story;
        }
示例#38
0
        public void BeginQuestions()
        {
            Duration        duration      = new Duration(new TimeSpan(0, 0, 1));
            DoubleAnimation nextToCurrent = new DoubleAnimation(TRANSFORM_DISTANCE, 0, duration);
            DoubleAnimation currentToPrev = new DoubleAnimation(0, TRANSFORM_DISTANCE * -1, duration);

            if (OldStyleCountdown != null)
            {
                OldStyleCountdown.OnCountdownCompleted -= oldStyleCompleted;
                mSoundPlayerIntro.Stop();
            }

            currentToPrev.AccelerationRatio = 0.5;
            nextToCurrent.AccelerationRatio = 0.5;
            currentToPrev.DecelerationRatio = 0.5;
            nextToCurrent.DecelerationRatio = 0.5;

            mNextQuestion.NextEnabled     = ExistingQuestions.Count() > 1;
            mNextQuestion.PreviousEnabled = false;

            nextToCurrent.Completed += (s, e) =>
            {
                mPreviousQuestion = null;
                mActiveQuestion   = mNextQuestion;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentRound)));
                if (gParentGrid.Children.Contains(TitleScreen))
                {
                    gParentGrid.Children.Remove(TitleScreen);
                }
                if (gParentGrid.Children.Contains(OldStyleCountdown))
                {
                    gParentGrid.Children.Remove(OldStyleCountdown);
                }
                if (gParentGrid.Children.Contains(IntroPlaceholderBorder))
                {
                    gParentGrid.Children.Remove(IntroPlaceholderBorder);
                }

                currentQuestion = 0;

                AttachNextPrevClickEvents();

                if (currentQuestion < ExistingQuestions.Length - 1)
                {
                    mNextQuestion = ExistingQuestions[currentQuestion + 1];

                    SetNextTransform(mNextQuestion);
                    gParentGrid.Children.Add(mNextQuestion as Control);
                }
                else
                {
                    mNextQuestion = null;
                }

                SetActiveTransform(mActiveQuestion);
                SetNextTransform(mNextQuestion);

                AttachQuestionShownEvents();
                (mActiveQuestion as SingleQuestionControl)?.ShowQuestion();
            };

            (mNextQuestion as Control).RenderTransform.BeginAnimation(TranslateTransform.XProperty, nextToCurrent);
            //titleScreen.RenderTransform.BeginAnimation(TranslateTransform.XProperty, currentToPrev);

            mMediaPlayerQuestion.Position = new TimeSpan(0, 0, 0);
            mMediaPlayerQuestion.IsMuted  = false;
            mMediaPlayerQuestion.Volume   = 0.75;
            mMediaPlayerQuestion.Play();

            this.KeyUp += KeyPressed;
        }
示例#39
0
        public SlideShow(BrowsablePointer item, uint interval_ms, bool init)
            : base()
        {
            this.item = item;
            DoubleBuffered = false;
            AppPaintable = true;
            CanFocus = true;
            item.Changed += HandleItemChanged;

            foreach (TransitionNode transition in AddinManager.GetExtensionNodes ("/FSpot/SlideShow")) {
                if (this.transition == null)
                    this.transition = transition.Transition;
                transitions.Add (transition.Transition);
            }

            flip = new DelayedOperation (interval_ms, delegate {item.MoveNext (true); return true;});
            animation = new DoubleAnimation (0, 1, new TimeSpan (0, 0, 2), HandleProgressChanged, GLib.Priority.Default);

            if (init) {
                HandleItemChanged (null, null);
            }
        }
示例#40
0
        ///<summary>显示树结构分解视图</summary>
        public void showModel()
        {
            DoubleAnimation da;
            ImageBrush lbrush;
            SolidColorBrush mmainbrush = null;// mtopbrush;
            lbrush = (((zlabel as GeometryModel3D).Material as MaterialGroup).Children[0] as DiffuseMaterial).Brush as ImageBrush;
            //mtopbrush = ((((zmodel as Model3DGroup).Children[0] as GeometryModel3D).Material as MaterialGroup).Children[0] as DiffuseMaterial).Brush as ImageBrush;
            //mmainbrush = ((((zmodel as Model3DGroup).Children[1] as GeometryModel3D).Material as MaterialGroup).Children[0] as DiffuseMaterial).Brush as ImageBrush;
            if (zmodel is GeometryModel3D)
                mmainbrush = ((((zmodel as GeometryModel3D)).Material as MaterialGroup).Children[0] as DiffuseMaterial).Brush as SolidColorBrush;
            else
                mmainbrush = ((((zmodel as Model3DGroup).Children[0] as GeometryModel3D).Material as MaterialGroup).Children[0] as DiffuseMaterial).Brush as SolidColorBrush;

            TranslateTransform3D translate;
            switch (behavior)
            {
                case EBehavior.扩展子项:
                    da = new DoubleAnimation(1, 0, duration, FillBehavior.Stop);
                    da.Completed += new EventHandler(da_Completed);
                    //mtopbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    //mtopbrush.Opacity = 0;
                    mmainbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    mmainbrush.Opacity = 0;
                    translateModel(oldTranslate, absoluteTranslateVec, oldTranslate);

                    lbrush.BeginAnimation(ImageBrush.OpacityProperty, da);
                    lbrush.Opacity = 0;
                    translateLabel(oldTranslate, absoluteTranslateVec, oldTranslate);
                    break;
                case EBehavior.被扩展:
                    da = new DoubleAnimation(0, 1, duration, FillBehavior.Stop);
                    //mtopbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    //mtopbrush.Opacity = 1;
                    mmainbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    mmainbrush.Opacity = 1;
                    translateModel(parent.oldTranslate, absoluteTranslateVec, oldTranslate);

                    lbrush.BeginAnimation(ImageBrush.OpacityProperty, da);
                    lbrush.Opacity = 1;
                    translateLabel(parent.oldTranslate, absoluteTranslateVec, oldTranslate);
                    break;
                case EBehavior.收缩子项:
                    da = new DoubleAnimation(0, 1, duration, FillBehavior.Stop);
                    da.Completed += new EventHandler(da_Completed);
                    //mtopbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    //mtopbrush.Opacity = 1;
                    mmainbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    mmainbrush.Opacity = 1;
                    translateModel(nodes[0].absoluteTranslateVec, absoluteTranslateVec, oldTranslate);

                    lbrush.BeginAnimation(ImageBrush.OpacityProperty, da);
                    lbrush.Opacity = 1;
                    translateLabel(nodes[0].absoluteTranslateVec, absoluteTranslateVec, oldTranslate);
                    break;
                case EBehavior.被收缩:
                    da = new DoubleAnimation(1, 0, duration, FillBehavior.Stop);
                    //mtopbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    //mtopbrush.Opacity = 0;
                    mmainbrush.BeginAnimation(SolidColorBrush.OpacityProperty, da);
                    mmainbrush.Opacity = 0;
                    translateModel(oldTranslate, parent.absoluteTranslateVec, oldTranslate);

                    lbrush.BeginAnimation(ImageBrush.OpacityProperty, da);
                    lbrush.Opacity = 0;
                    translateLabel(oldTranslate, parent.absoluteTranslateVec, oldTranslate);
                    break;
                case EBehavior.无:
                    if (isVisual)
                    {
                        owner.mgModel.Children.Add(zmodel);
                        translate = null;
                        foreach (Transform3D one in (zmodel.Transform as Transform3DGroup).Children)
                        {
                            if (one is TranslateTransform3D)
                            {
                                translate = one as TranslateTransform3D;
                                break;
                            }
                        }
                        if (translate == null)
                            return;

                        //translate = (zmodel.Transform as Transform3DGroup).Children[1] as TranslateTransform3D;
                        translate.OffsetX = absoluteTranslateVec.X;
                        //translate.OffsetY = absoluteTranslateVec.Y;
                        translate.OffsetZ = absoluteTranslateVec.Z;

                        owner.mgLabel.Children.Add(zlabel);
                        translate = (zlabel.Transform as Transform3DGroup).Children[1] as TranslateTransform3D;
                        translate.OffsetX = absoluteTranslateVec.X;
                        translate.OffsetY = absoluteTranslateVec.Y + zmodel.Bounds.SizeY * 1.01 + 1;
                        translate.OffsetZ = absoluteTranslateVec.Z;

                    }

                    break;
            }
            if (haveChild)
                foreach (SettleNode e0 in nodes)
                    e0.showModel();


        }
示例#41
0
            override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var hideState = (base.GetTemplateChild(HideStateName) as VisualState);
            if (hideState != null)
                _hideAnimation = hideState.Storyboard.Children[0] as DoubleAnimation;
        }
		private DoubleAnimation CreateDoubleAnimations(Storyboard sb, DependencyObject target, string propertyPath, double toValue = 0, double fromValue = 0)
		{
			var doubleAni = new DoubleAnimation
			{
				To = toValue,
				From = fromValue,
				Duration = AnimationDuration
			};

			Storyboard.SetTarget(doubleAni, target);
			Storyboard.SetTargetProperty(
                doubleAni, 
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                propertyPath
#elif WINDOWS_PHONE
                new PropertyPath(propertyPath)
#endif
            );

			sb.Children.Add(doubleAni);
			return doubleAni;
		}
示例#43
0
		public static bool FadeOutBackground(Panel panel, int msecs, Action completed = null)
		{
			if (panel.Background == null || panel.Background.Opacity == 0.0)
				return false;

			var animation = new DoubleAnimation();
			animation.From = panel.Background.Opacity;
			animation.To = 0.0;
			animation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, msecs));

			var story = new Storyboard();
			story.Children.Add(animation);

			Storyboard.SetTarget(animation, panel.Background);
			Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));

			story.Completed += delegate
			{
				panel.Background = null;
				if (completed != null)
					completed();
			};

			story.Begin();
			return true; 
		}
示例#44
0
        private void BuildTransitionAnimation()
        {
            transition_animation = new DoubleAnimation ("Opacity");
            transition_animation
                .Throttle (250)
                .Compose ((a, p) => {
                    var opacity = a.StartState == 0 ? p : 1 - p;
                    if (p == 1) {
                        if (a.StartState == 1) {
                            UpdateMetadataDisplay ();
                        }

                        if (a.ToValue == 1) {
                            a.Expire ();
                        } else {
                            a.Reverse ();
                        }
                    }

                    return opacity * text_opacity;
                }).Ease (Easing.QuadraticInOut);
        }
示例#45
0
        private void Expander_Collapsed(object sender, RoutedEventArgs e)
        {
            var scratchHeightDaV = new DoubleAnimation(270.255, 194.618, new Duration(TimeSpan.FromSeconds(0.25)));

            BeginAnimation(HeightProperty, scratchHeightDaV);
        }
示例#46
0
        public Filmstrip(BrowsablePointer selection, bool squaredThumbs)
        {
            CanFocus = true;
            this.selection = selection;
            this.selection.Changed += HandlePointerChanged;
            this.selection.Collection.Changed += HandleCollectionChanged;
            this.selection.Collection.ItemsChanged += HandleCollectionItemsChanged;
            SquaredThumbs = squaredThumbs;
            thumb_cache = new DisposableCache<SafeUri, Pixbuf> (30);
            ThumbnailLoader.Default.OnPixbufLoaded += HandlePixbufLoaded;

            animation = new DoubleAnimation (0, 0, TimeSpan.FromSeconds (1.5), SetPositionCore, new CubicEase (EasingMode.EaseOut));
        }
示例#47
0
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            if (this.Items != null)
            {
                if (this.Items.Count < 100)
                {
                    int index = this.ItemContainerGenerator.IndexFromContainer(element);
                    var lb = (ContentPresenter)element;

                    TimeSpan waitTime = TimeSpan.FromMilliseconds(index * (500.0 / this.Items.Count));

                    lb.Opacity = 0.0;
                    DoubleAnimation anm = new DoubleAnimation();
                    anm.From = 0;
                    anm.To = 1;
                    anm.Duration = TimeSpan.FromMilliseconds(250);
                    anm.BeginTime = waitTime;

                    Storyboard storyda = new Storyboard();
                    storyda.Children.Add(anm);
                    Storyboard.SetTarget(storyda, lb);
#if NETFX_CORE
                    Storyboard.SetTargetProperty(storyda, "Opacity");
#else
                    Storyboard.SetTargetProperty(storyda, new PropertyPath(OpacityProperty));
#endif
                    storyda.Begin();
                }
            }

            base.PrepareContainerForItemOverride(element, item);
        }
示例#48
0
        private void InitializeImages()
        {
            ImageBrush ib = new ImageBrush();

            ib.ImageSource             = new BitmapImage(new Uri(startupPath + "/images/GameBoard" + engine.GameBoardNumber + ".png", UriKind.Absolute));
            BoardBackground.Background = ib;

            ImageBrush gb = new ImageBrush();

            gb.ImageSource = new BitmapImage(new Uri(startupPath + "/images/GameBackground.jpg", UriKind.Absolute));
            backgroundButton.Background = gb;

            ImageBrush sb = new ImageBrush();

            if (SoundSetting.SoundOn)
            {
                sb.ImageSource = new BitmapImage(new Uri(startupPath + "/images/soundOnButton.png", UriKind.Absolute));
            }
            else
            {
                sb.ImageSource = new BitmapImage(new Uri(startupPath + "/images/soundOffButton.png", UriKind.Absolute));
            }
            toggleSound_Btn.Background = sb;

            ImageBrush mb = new ImageBrush();

            if (SoundSetting.MusicOn)
            {
                mb.ImageSource = new BitmapImage(new Uri(startupPath + "/images/musicOnButton.png", UriKind.Absolute));
            }
            else
            {
                mb.ImageSource = new BitmapImage(new Uri(startupPath + "/images/musicOffButton.png", UriKind.Absolute));
            }
            toggleMusicBtn.Background = mb;

            ImageBrush ButtonImage = new ImageBrush();

            ButtonImage.ImageSource = new BitmapImage(new Uri(startupPath + "/images/GenericPlan.png", UriKind.Absolute));
            ApplyBackgroundButtons(ButtonImage);

            ImageBrush RedConquer = new ImageBrush();

            RedConquer.ImageSource      = new BitmapImage(new Uri(startupPath + "/images/PlanConquerRed.png", UriKind.Absolute));
            planetConquerOne.Background = RedConquer;

            ImageBrush sh  = new ImageBrush();
            ImageBrush msh = new ImageBrush();

            sh.ImageSource            = new BitmapImage(new Uri(startupPath + "/images/screenHelpButton.png", UriKind.Absolute));
            msh.ImageSource           = new BitmapImage(new Uri(startupPath + "/images/HardGameScreenHelp.png", UriKind.Absolute));
            screenHelpBtn.Background  = sh;
            GameScreenHelp.Background = msh;

            ImageBrush BlueConquer = new ImageBrush();

            BlueConquer.ImageSource     = new BitmapImage(new Uri(startupPath + "/images/PlanConquerBlue.png", UriKind.Absolute));
            planetConquerTwo.Background = BlueConquer;

            DoubleAnimation fadeInAnimation = new DoubleAnimation();

            fadeInAnimation.From     = 0.0;
            fadeInAnimation.To       = 1.0;
            fadeInAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));

            DoubleAnimation fadeOutAnimation = new DoubleAnimation();

            fadeOutAnimation.From     = 1.0;
            fadeOutAnimation.To       = 0.1;
            fadeOutAnimation.Duration = new Duration(TimeSpan.FromSeconds(2));

            DoubleAnimation planetConquerOneAnimation = new DoubleAnimation();

            planetConquerOneAnimation.From        = 0.0;
            planetConquerOneAnimation.To          = 1.0;
            planetConquerOneAnimation.Duration    = new Duration(TimeSpan.FromSeconds(0.6));
            planetConquerOneAnimation.AutoReverse = true;

            DoubleAnimation planetConquerTwoAnimation = new DoubleAnimation();

            planetConquerTwoAnimation.From        = 0.0;
            planetConquerTwoAnimation.To          = 1.0;
            planetConquerTwoAnimation.Duration    = new Duration(TimeSpan.FromSeconds(0.6));
            planetConquerTwoAnimation.AutoReverse = true;

            DoubleAnimation helpScreenAnimation = new DoubleAnimation();

            helpScreenAnimation.From     = -1440;
            helpScreenAnimation.To       = 0;
            helpScreenAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.4));

            DoubleAnimation helpScreenAnimation2 = new DoubleAnimation();

            helpScreenAnimation2.From     = 0;
            helpScreenAnimation2.To       = -1440;
            helpScreenAnimation2.Duration = new Duration(TimeSpan.FromSeconds(0.4));

            ImageBrush ab = new ImageBrush();

            ab.ImageSource           = new BitmapImage(new Uri(startupPath + "/images/homeButton.png", UriKind.Absolute));
            advanceButton.Background = ab;

            DoubleAnimation forfeitAnimation = new DoubleAnimation();

            forfeitAnimation.From     = -250;
            forfeitAnimation.To       = 0;
            forfeitAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.4));

            DoubleAnimation forfeitAnimation2 = new DoubleAnimation();

            forfeitAnimation2.From     = 0;
            forfeitAnimation2.To       = -250;
            forfeitAnimation2.Duration = new Duration(TimeSpan.FromSeconds(0.4));

            forfeitStoryboard  = new Storyboard();
            forfeitStoryboard2 = new Storyboard();

            forfeitStoryboard.Children.Add(forfeitAnimation);
            forfeitStoryboard2.Children.Add(forfeitAnimation2);

            Storyboard.SetTargetName(forfeitAnimation, ForfeitScreen.Name);
            Storyboard.SetTargetProperty(forfeitAnimation, new PropertyPath(Canvas.BottomProperty));
            Storyboard.SetTargetName(forfeitAnimation2, ForfeitScreen.Name);
            Storyboard.SetTargetProperty(forfeitAnimation2, new PropertyPath(Canvas.BottomProperty));

            helpStoryboard  = new Storyboard();
            helpStoryboard2 = new Storyboard();

            helpStoryboard.Children.Add(helpScreenAnimation);
            helpStoryboard2.Children.Add(helpScreenAnimation2);

            gameOverStoryboard     = new Storyboard();
            HumanConquerStoryboard = new Storyboard();
            AIConquerStoryboard    = new Storyboard();

            gameOverStoryboard.Children.Add(fadeInAnimation);
            gameOverStoryboard.Children.Add(fadeOutAnimation);
            HumanConquerStoryboard.Children.Add(planetConquerOneAnimation);
            AIConquerStoryboard.Children.Add(planetConquerTwoAnimation);

            Storyboard.SetTargetName(fadeInAnimation, WinnerLabel.Name);
            Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(Rectangle.OpacityProperty));
            Storyboard.SetTargetName(fadeOutAnimation, GameBackground.Name);
            Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(Rectangle.OpacityProperty));

            Storyboard.SetTargetName(planetConquerOneAnimation, planetConquerOne.Name);
            Storyboard.SetTargetProperty(planetConquerOneAnimation, new PropertyPath(Rectangle.OpacityProperty));

            Storyboard.SetTargetName(planetConquerTwoAnimation, planetConquerTwo.Name);
            Storyboard.SetTargetProperty(planetConquerTwoAnimation, new PropertyPath(Rectangle.OpacityProperty));
            Storyboard.SetTargetName(helpScreenAnimation, GameScreenHelp.Name);
            Storyboard.SetTargetProperty(helpScreenAnimation, new PropertyPath(Canvas.LeftProperty));
            Storyboard.SetTargetName(helpScreenAnimation2, GameScreenHelp.Name);
            Storyboard.SetTargetProperty(helpScreenAnimation2, new PropertyPath(Canvas.LeftProperty));
        }
示例#49
0
        private void TransformToNextQuestion()
        {
            lock (lockObject)
            {
                if (isTransitioning)
                {
                    return;
                }
                isTransitioning = true;
            }
            gParentGrid.Children.Remove(mPreviousQuestion as Control);
            mPreviousQuestion = null;

            Duration        duration      = new Duration(new TimeSpan(0, 0, 1));
            DoubleAnimation nextToCurrent = new DoubleAnimation(TRANSFORM_DISTANCE, 0, duration);
            DoubleAnimation currentToPrev = new DoubleAnimation(0, TRANSFORM_DISTANCE * -1, duration);

            currentToPrev.AccelerationRatio = 0.5;
            nextToCurrent.AccelerationRatio = 0.5;
            currentToPrev.DecelerationRatio = 0.5;
            nextToCurrent.DecelerationRatio = 0.5;

            mNextQuestion.NextEnabled = currentQuestion + 1 < ExistingQuestions.Length - 1;

            nextToCurrent.Completed += (s, e) =>
            {
                mPreviousQuestion = mActiveQuestion;
                mActiveQuestion   = mNextQuestion;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentRound)));
                currentQuestion++;

                AttachNextPrevClickEvents();

                if (currentQuestion < ExistingQuestions.Length - 1)
                {
                    mNextQuestion = ExistingQuestions[currentQuestion + 1];

                    SetNextTransform(mNextQuestion);
                    gParentGrid.Children.Add(mNextQuestion as Control);
                }
                else
                {
                    mNextQuestion = null;
                }

                SetActiveTransform(mActiveQuestion);
                SetNextTransform(mNextQuestion);

                AttachQuestionShownEvents();
                (mActiveQuestion as SingleQuestionControl)?.ShowQuestion();
                lock (lockObject)
                {
                    isTransitioning = false;
                }
            };

            (mNextQuestion as Control).RenderTransform.BeginAnimation(TranslateTransform.XProperty, nextToCurrent);
            (mActiveQuestion as Control).RenderTransform.BeginAnimation(TranslateTransform.XProperty, currentToPrev);

            mMediaPlayerQuestion.Position = new TimeSpan(0, 0, 0);
            mMediaPlayerQuestion.IsMuted  = false;
            mMediaPlayerQuestion.Play();
        }
示例#50
0
        public override void Plot(bool animate = true)
        {
            var chart = Chart as StackedBarChart;

            if (chart == null)
            {
                return;
            }

            var serieIndex = Chart.Series.IndexOf(this);
            var unitW      = ToPlotArea(1, AxisTags.X) - Chart.PlotArea.X + 5;
            var overflow   = unitW - chart.MaxColumnWidth > 0 ? unitW - chart.MaxColumnWidth : 0;

            unitW = unitW > chart.MaxColumnWidth ? chart.MaxColumnWidth : unitW;
            var       pointPadding  = .1 * unitW;
            const int seriesPadding = 2;
            var       barW          = unitW - 2 * pointPadding;

            for (var index = 0; index < PrimaryValues.Count; index++)
            {
                var d = PrimaryValues[index];

                var t = new TranslateTransform();
                var r = new Rectangle
                {
                    StrokeThickness = StrokeThickness,
                    Stroke          = new SolidColorBrush {
                        Color = Color
                    },
                    Fill = new SolidColorBrush {
                        Color = Color, Opacity = .8
                    },
                    Width           = barW - seriesPadding,
                    Height          = 0,
                    RenderTransform = t
                };

                var helper   = chart.IndexTotals[index];
                var barH     = ToPlotArea(Chart.Min.Y, AxisTags.Y) - ToPlotArea(helper.Total, AxisTags.Y);
                var rh       = barH * (d / helper.Total);
                var stackedH = barH * (helper.Stacked[serieIndex].Stacked / helper.Total);

                Canvas.SetLeft(r, ToPlotArea(index, AxisTags.X) + pointPadding + overflow / 2);

                Chart.Canvas.Children.Add(r);
                Shapes.Add(r);

                var hAnim = new DoubleAnimation
                {
                    To       = rh,
                    Duration = TimeSpan.FromMilliseconds(300)
                };
                var rAnim = new DoubleAnimation
                {
                    From     = ToPlotArea(Chart.Min.Y, AxisTags.Y),
                    To       = ToPlotArea(Chart.Min.Y, AxisTags.Y) - rh - stackedH,
                    Duration = TimeSpan.FromMilliseconds(300)
                };

                var animated = false;
                if (!Chart.DisableAnimation)
                {
                    if (animate)
                    {
                        r.BeginAnimation(FrameworkElement.HeightProperty, hAnim);
                        t.BeginAnimation(TranslateTransform.YProperty, rAnim);
                        animated = true;
                    }
                }

                if (!animated)
                {
                    r.Height = rh;
                    t.Y      = (double)rAnim.To;
                }

                if (!Chart.Hoverable)
                {
                    continue;
                }
                r.MouseEnter += Chart.OnDataMouseEnter;
                r.MouseLeave += Chart.OnDataMouseLeave;
                Chart.HoverableShapes.Add(new HoverableShape
                {
                    Serie  = this,
                    Shape  = r,
                    Target = r,
                    Value  = new Point(index, d)
                });
            }
        }
示例#51
0
        /// <summary>
        /// Draws the geometry.
        /// </summary>
        /// <param name="context">The context.</param>
        private void DrawGeometry()
        {    
            try
            {
                if (this.ClientWidth <= 0.0)
                {
                    return;
                }
                if (this.ClientHeight <= 0.0)
                {
                    return;
                }

                double startWidth = 0;
                if (slice.Width > 0)
                {
                    startWidth = slice.Width;
                }

                DoubleAnimation scaleAnimation = new DoubleAnimation();
                scaleAnimation.From = startWidth;
                scaleAnimation.To = this.ClientWidth * Percentage;
                scaleAnimation.Duration = TimeSpan.FromMilliseconds(500);
                scaleAnimation.EasingFunction = new QuarticEase() { EasingMode = EasingMode.EaseOut };
                Storyboard storyScaleX = new Storyboard();
                storyScaleX.Children.Add(scaleAnimation);
                
                Storyboard.SetTarget(storyScaleX, slice);

#if NETFX_CORE
                scaleAnimation.EnableDependentAnimation = true;
                Storyboard.SetTargetProperty(storyScaleX, "Width");
#else
                Storyboard.SetTargetProperty(storyScaleX, new PropertyPath("Width"));
#endif
                storyScaleX.Begin();
         
                
                //SetValue(ColumnPiece.ColumnHeightProperty, this.ClientHeight * Percentage);
            }
            catch (Exception ex)
            {
            }
        }
示例#52
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var parentGrid = new Grid();
            var grid       = new Grid();
            var content    = new ContentControl();

            grid.Background   = Brushes.Transparent;
            grid.ClipToBounds = true;
            parentGrid.Children.Add(grid);
            parentGrid.Children.Add(content);

            var c = Content;

            this.Content    = parentGrid;
            content.Content = c;

            grid.SetBinding(WidthProperty, new Binding("ActualWidth")
            {
                Source = parentGrid
            });
            grid.SetBinding(HeightProperty, new Binding("ActualHeight")
            {
                Source = parentGrid
            });

            parentGrid.PreviewMouseDown += (sender, e) =>
            {
                var targetWidth   = (Math.Max(ActualWidth, ActualHeight) * 2) / ExpandTime * (ExpandTime + FadeTime);
                var mousePosition = (e as MouseButtonEventArgs).GetPosition(this);
                var startMargin   = new Thickness(mousePosition.X, mousePosition.Y, 0, 0);
                var endMargin     = new Thickness(mousePosition.X - targetWidth / 2, mousePosition.Y - targetWidth / 2, 0, 0);

                var ellipse = new Ellipse()
                {
                    Fill = Brushes.White,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment   = VerticalAlignment.Top,
                    Opacity             = Opacity
                };
                ellipse.Margin = startMargin;
                ellipse.SetBinding(HeightProperty, new Binding("Width")
                {
                    Source = ellipse
                });

                Storyboard storyboard = new Storyboard();

                var expand = new DoubleAnimation(0, targetWidth, new Duration(TimeSpan.FromSeconds(ExpandTime + FadeTime)));
                storyboard.Children.Add(expand);
                Storyboard.SetTarget(expand, ellipse);
                Storyboard.SetTargetProperty(expand, new PropertyPath(WidthProperty));

                var marginShrink = new ThicknessAnimation(startMargin, endMargin, new Duration(TimeSpan.FromSeconds(ExpandTime + FadeTime)));
                storyboard.Children.Add(marginShrink);
                Storyboard.SetTarget(marginShrink, ellipse);
                Storyboard.SetTargetProperty(marginShrink, new PropertyPath(MarginProperty));

                var opacity = new DoubleAnimation(Opacity, 0, new Duration(TimeSpan.FromSeconds(FadeTime)));
                opacity.BeginTime = TimeSpan.FromSeconds(ExpandTime);
                storyboard.Children.Add(opacity);
                Storyboard.SetTarget(opacity, ellipse);
                Storyboard.SetTargetProperty(opacity, new PropertyPath(Ellipse.OpacityProperty));

                grid.Children.Add(ellipse);

                storyboard.Begin();

                var waitTime = ExpandTime + FadeTime;
                Task.Run(() =>
                {
                    Thread.Sleep(TimeSpan.FromSeconds(waitTime));
                    Dispatcher.Invoke(() =>
                    {
                        grid.Children.Remove(ellipse);
                    });
                });
                e.Handled = false;
            };
        }
示例#53
0
        private void BlendImages()
        {
            #if WINDOWS_RUNTIME
            var duration = TimeSpan.Zero; // animation not working in Windows Runtime (?)
            #else
            var duration = Tile.AnimationDuration;
            #endif
            var mapImage = (MapImage)Children[currentImageIndex];
            var fadeOut = new DoubleAnimation { To = 0d, Duration = duration };

            if (mapImage.Source != null)
            {
                mapImage.BeginAnimation(UIElement.OpacityProperty,
                    new DoubleAnimation { To = 1d, Duration = duration });

                fadeOut.BeginTime = duration;
            }

            mapImage = (MapImage)Children[(currentImageIndex + 1) % 2];
            mapImage.BeginAnimation(UIElement.OpacityProperty, fadeOut);

            updateInProgress = false;
        }
示例#54
0
        internal override void DataMouseEnter(object sender, MouseEventArgs e)
        {
            if (DataTooltip == null)
            {
                return;
            }

            DataTooltip.Visibility = Visibility.Visible;
            TooltipTimer.Stop();

            var senderShape = ShapesMapper.FirstOrDefault(s => Equals(s.HoverShape, sender));

            if (senderShape == null)
            {
                return;
            }
            var pieSlice = senderShape.HoverShape as PieSlice;

            if (pieSlice == null)
            {
                return;
            }

            var xi = senderShape.Series.ScalesXAt;
            var yi = senderShape.Series.ScalesYAt;

            var labels = AxisX[xi].Labels != null ? AxisX[xi].Labels.ToArray() : null;

            senderShape.Shape.Opacity = .8;
            var vx = senderShape.ChartPoint.X;

            var indexedToolTip = DataTooltip as IndexedTooltip;

            if (indexedToolTip != null)
            {
                indexedToolTip.Header = null;
                //labels == null
                //    ? (AxisX.LabelFormatter == null
                //        ? vx.ToString(CultureInfo.InvariantCulture)
                //        : AxisX.LabelFormatter(vx))
                //    : (labels.Length > vx
                //        ? labels[(int)vx]
                //        : "");
                indexedToolTip.Data = new[]
                {
                    new IndexedTooltipData
                    {
                        Index  = (int)vx,
                        Stroke = senderShape.HoverShape.Stroke,
                        Fill   = senderShape.HoverShape.Fill,
                        Series = senderShape.Series,
                        Point  = senderShape.ChartPoint,
                        Value  = AxisY[yi].LabelFormatter == null
                            ? senderShape.ChartPoint.Y.ToString(CultureInfo.InvariantCulture)
                            : AxisY[yi].LabelFormatter(senderShape.ChartPoint.Y)
                    }
                };
            }

            var alpha         = pieSlice.RotationAngle + pieSlice.WedgeAngle * .5 + 180;
            var alphaRad      = alpha * Math.PI / 180;
            var sliceMidAngle = alpha - 180;

            DataTooltip.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var y = Canvas.ActualHeight * .5 + (sliceMidAngle > 90 && sliceMidAngle < 270 ? -1 : 0) * DataTooltip.DesiredSize.Height - Math.Cos(alphaRad) * 15;
            var x = Canvas.ActualWidth * .5 + (sliceMidAngle > 0 && sliceMidAngle < 180 ? -1 : 0) * DataTooltip.DesiredSize.Width + Math.Sin(alphaRad) * 15;

            var p = new Point(x, y);

            DataTooltip.BeginAnimation(Canvas.LeftProperty, new DoubleAnimation
            {
                To       = p.X,
                Duration = TimeSpan.FromMilliseconds(200)
            });
            DataTooltip.BeginAnimation(Canvas.TopProperty, new DoubleAnimation
            {
                To       = p.Y,
                Duration = TimeSpan.FromMilliseconds(200)
            });

            pieSlice.Opacity = .8;

            var anim = new DoubleAnimation
            {
                To       = 5,
                Duration = TimeSpan.FromMilliseconds(150)
            };

            pieSlice.BeginAnimation(PieSlice.PushOutProperty, anim);
        }
示例#55
0
        public SeekableTrackInfoDisplay()
        {
            Spacing = 3;

            Children.Add (cover_art = new CoverArtDisplay ());
            Children.Add (new StackPanel () {
                Orientation = Orientation.Vertical,
                Spacing = 4,
                Children = {
                    (title = new TextBlock () { Opacity = text_opacity }),
                    (seek_bar = new Slider ()),
                    (time_bar = new StackPanel () {
                        Spacing = 10,
                        Children = {
                            (elapsed = new TextBlock ()   { HorizontalAlignment = 0.0, Opacity = text_opacity + 0.25 }),
                            (seek_to = new TextBlock ()   { HorizontalAlignment = 0.5, Opacity = text_opacity + 0.25 }),
                            (remaining = new TextBlock () { HorizontalAlignment = 1.0, Opacity = text_opacity })
                        }
                    })
                }
            });

            seek_to.Opacity = 0;
            seek_to_animation = new DoubleAnimation ("Opacity");
            seek_to_animation.Repeat (1);

            seek_bar.PendingValueChanged += (o, e) => OnSeekPendingValueChanged (seek_bar.PendingValue);
            seek_bar.ValueChanged += (o, e) => OnSeekValueChanged (seek_bar.Value);

            UpdateMetadataDisplay ();
            BuildTransitionAnimation ();
        }
        public override void Begin(Action completionAction)
        {
            Storyboard = new Storyboard();

            double liCounter    = 0;
            var    listBoxItems = ListBox.GetVisualDescendants().OfType <ListBoxItem>().Where(lbi => IsOnCurrentPage(lbi) && lbi.IsEnabled).ToList();

            if (HoldSelectedItem && Direction == Directions.Out && ListBox.SelectedItem != null)
            {
                //move selected container to end
                var selectedContainer = ListBox.ItemContainerGenerator.ContainerFromItem(ListBox.SelectedItem);
                listBoxItems.Remove(selectedContainer);
                listBoxItems.Add(selectedContainer);
            }

            foreach (ListBoxItem li in listBoxItems)
            {
                GeneralTransform gt               = li.TransformToVisual(RootElement);
                Point            globalCoords     = gt.Transform(new Point(0, 0));
                double           heightAdjustment = li.Content is FrameworkElement ? ((li.Content as FrameworkElement).ActualHeight / 2) : (li.ActualHeight / 2);
                //double yCoord = globalCoords.Y + ((((System.Windows.FrameworkElement)(((System.Windows.Controls.ContentControl)(li)).Content)).ActualHeight) / 2);
                double yCoord = globalCoords.Y + heightAdjustment;

                double offsetAmount = (RootElement.ActualHeight / 2) - yCoord;

                PlaneProjection pp = new PlaneProjection();
                pp.GlobalOffsetY     = offsetAmount * -1;
                pp.CenterOfRotationX = 0;
                li.Projection        = pp;

                CompositeTransform ct = new CompositeTransform();
                ct.TranslateY      = offsetAmount;
                li.RenderTransform = ct;

                var beginTime = TimeSpan.FromMilliseconds((FeatherDelay * liCounter) + InitialDelay);

                if (Direction == Directions.In)
                {
                    li.Opacity = 0;

                    DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();

                    EasingDoubleKeyFrame edkf1 = new EasingDoubleKeyFrame();
                    edkf1.KeyTime = beginTime;
                    edkf1.Value   = Angle;
                    daukf.KeyFrames.Add(edkf1);

                    EasingDoubleKeyFrame edkf2 = new EasingDoubleKeyFrame();
                    edkf2.KeyTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);
                    edkf2.Value   = 0;

                    ExponentialEase ee = new ExponentialEase();
                    ee.EasingMode = EasingMode.EaseOut;
                    ee.Exponent   = 6;

                    edkf2.EasingFunction = ee;
                    daukf.KeyFrames.Add(edkf2);

                    Storyboard.SetTarget(daukf, li);
                    Storyboard.SetTargetProperty(daukf, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
                    Storyboard.Children.Add(daukf);

                    DoubleAnimation da = new DoubleAnimation();
                    da.Duration  = TimeSpan.FromMilliseconds(0);
                    da.BeginTime = beginTime;
                    da.To        = 1;

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
                    Storyboard.Children.Add(da);
                }
                else
                {
                    li.Opacity = 1;

                    DoubleAnimation da = new DoubleAnimation();
                    da.BeginTime = beginTime;
                    da.Duration  = TimeSpan.FromMilliseconds(Duration);
                    da.To        = Angle;

                    ExponentialEase ee = new ExponentialEase();
                    ee.EasingMode = EasingMode.EaseIn;
                    ee.Exponent   = 6;

                    da.EasingFunction = ee;

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Projection).(PlaneProjection.RotationY)"));
                    Storyboard.Children.Add(da);

                    da           = new DoubleAnimation();
                    da.Duration  = TimeSpan.FromMilliseconds(10);
                    da.To        = 0;
                    da.BeginTime = TimeSpan.FromMilliseconds(Duration).Add(beginTime);

                    Storyboard.SetTarget(da, li);
                    Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.Opacity)"));
                    Storyboard.Children.Add(da);
                }

                liCounter++;
            }

            base.Begin(completionAction);
        }
示例#57
0
        private void OpInW()
        {
            var OpIn = new DoubleAnimation(1, TimeSpan.FromSeconds(0.5));

            this.BeginAnimation(OpacityProperty, OpIn);
        }
        public GradientUserControl()
        {
            InitializeComponent();

            //Title = "GradientStop Animation Example";
            Background = Brushes.White;

            // Create a NameScope for the page so that
            // Storyboards can be used.
            NameScope.SetNameScope(this, new NameScope());

            // Create a rectangle. This rectangle will
            // be painted with a gradient.
            Rectangle aRectangle = new Rectangle();
            aRectangle.Width = 200;
            aRectangle.Height = 100;
            aRectangle.Stroke = Brushes.Black;
            aRectangle.StrokeThickness = 1;

            // Create a LinearGradientBrush to paint
            // the rectangle's fill.
            LinearGradientBrush gradientBrush = new LinearGradientBrush();

            // Create gradient stops for the brush.
            GradientStop stop1 = new GradientStop(Colors.MediumBlue, 0.0);
            //GradientStop stop2 = new GradientStop(Colors.Purple, 0.5);
            GradientStop stop3 = new GradientStop(Colors.Red, 1.0);

            // Register a name for each gradient stop with the
            // page so that they can be animated by a storyboard.
            this.RegisterName("GradientStop1", stop1);
            //this.RegisterName("GradientStop2", stop2);
            this.RegisterName("GradientStop3", stop3);

            // Add the stops to the brush.
            gradientBrush.GradientStops.Add(stop1);
            //gradientBrush.GradientStops.Add(stop2);
            gradientBrush.GradientStops.Add(stop3);

            // Apply the brush to the rectangle.
            aRectangle.Fill = gradientBrush;

            //
            // Animate the first gradient stop's offset from
            // 0.0 to 1.0 and then back to 0.0.
            //
            DoubleAnimation offsetAnimation = new DoubleAnimation();
            offsetAnimation.From = 0.0;
            offsetAnimation.To = 1.0;
            offsetAnimation.Duration = TimeSpan.FromSeconds(1.5);
            offsetAnimation.AutoReverse = true;
            Storyboard.SetTargetName(offsetAnimation, "GradientStop1");
            Storyboard.SetTargetProperty(offsetAnimation,
                new PropertyPath(GradientStop.OffsetProperty));

            ////
            //// Animate the second gradient stop's color from
            //// Purple to Yellow and then back to Purple.
            ////
            //ColorAnimation gradientStopColorAnimation = new ColorAnimation();
            //gradientStopColorAnimation.From = Colors.Purple;
            //gradientStopColorAnimation.To = Colors.Yellow;
            //gradientStopColorAnimation.Duration = TimeSpan.FromSeconds(1.5);
            //gradientStopColorAnimation.AutoReverse = true;
            //Storyboard.SetTargetName(gradientStopColorAnimation, "GradientStop2");
            //Storyboard.SetTargetProperty(gradientStopColorAnimation,
            //    new PropertyPath(GradientStop.ColorProperty));

            //// Set the animation to begin after the first animation
            //// ends.
            //gradientStopColorAnimation.BeginTime = TimeSpan.FromSeconds(3);

            ////
            //// Animate the third gradient stop's color so
            //// that it becomes transparent.
            ////
            //ColorAnimation opacityAnimation = new ColorAnimation();

            //// Reduces the target color's alpha value by 1,
            //// making the color transparent.
            //opacityAnimation.By = Color.FromScRgb(-1.0F, 0F, 0F, 0F);
            //opacityAnimation.Duration = TimeSpan.FromSeconds(1.5);
            //opacityAnimation.AutoReverse = true;
            //Storyboard.SetTargetName(opacityAnimation, "GradientStop3");
            //Storyboard.SetTargetProperty(opacityAnimation,
            //    new PropertyPath(GradientStop.ColorProperty));

            //// Set the animation to begin after the first two
            //// animations have ended.
            //opacityAnimation.BeginTime = TimeSpan.FromSeconds(6);

            // Create a Storyboard to apply the animations.
            Storyboard gradientStopAnimationStoryboard = new Storyboard();
            gradientStopAnimationStoryboard.Children.Add(offsetAnimation);
            //gradientStopAnimationStoryboard.Children.Add(gradientStopColorAnimation);
            //gradientStopAnimationStoryboard.Children.Add(opacityAnimation);

            // Begin the storyboard when the left mouse button is
            // pressed over the rectangle.
            aRectangle.MouseLeftButtonDown += delegate (object sender, MouseButtonEventArgs e)
            {
                gradientStopAnimationStoryboard.Begin(this);
            };

            StackPanel mainPanel = new StackPanel();
            mainPanel.Margin = new Thickness(10);
            mainPanel.Children.Add(aRectangle);
            Content = mainPanel;
        }
示例#59
0
 public static Timeline CreateDoubleAnimation(this Storyboard storyboard,
 Duration duration, double from, double to, EasingFunctionBase easingFunction)
 {
     var animation = new DoubleAnimation
       {
     From = from,
     To = to,
     Duration = duration,
     EasingFunction = easingFunction
       };
       return animation;
 }
示例#60
-1
        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
            }

#if WPF
            var scaleAnimation =new DoubleAnimation(1, ScaleTo, new Duration(TimeSpan.FromSeconds(Duration)));
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
#elif METRO
            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();
#else
            throw new NotImplementedException();
#endif

        }