// Be sure to call the base class constructor.
        public SelectionAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            m_brush = new VisualBrush(adornedElement);
            ((FrameworkElement)adornedElement).SizeChanged += AdornedElementSizeChanged;
            m_child = new Rectangle
            {
                Width           = adornedElement.RenderSize.Width,
                Height          = adornedElement.RenderSize.Height,
                Stroke          = Brushes.Red,
                StrokeThickness = 2,
                StrokeDashCap   = PenLineCap.Round,
                StrokeDashArray = new DoubleCollection(new double[] { 1, 3 }),
            };

            var animation = new DoubleAnimation(0.3, 0.6, new Duration(TimeSpan.FromSeconds(0.5)))
            {
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            m_brush.BeginAnimation(Brush.OpacityProperty, animation);

            //_child.Fill = _brush;
        }
Beispiel #2
0
        public DragAdorner(UIElement adorned)
            : base(adorned)
        {
            var brush = new VisualBrush(adorned)
            {
                Stretch = Stretch.None, AlignmentX = AlignmentX.Left
            };

            // HACK: this makes the markers work properly,
            // even after adding 4+ markers and then removing to 3-,
            // and then shift-dragging (in which case the size of the adorner is correct,
            // but the VisualBrush tries to render the now invisible number.
            _child = new Rectangle();
            _child.BeginInit();
            _child.Width            = adorned.RenderSize.Width;
            _child.Height           = adorned.RenderSize.Height;
            _child.Fill             = brush;
            _child.IsHitTestVisible = false;
            _child.EndInit();

            var animation = new DoubleAnimation(0.6, 0.85, new Duration(TimeSpan.FromMilliseconds(500)))
            {
                AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever
            };

            animation.Freeze();

            brush.BeginAnimation(Brush.OpacityProperty, animation);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DropPreviewAdorner"/> class.
        /// </summary>
        /// <param name="adornedElement">The adorned element.</param>
        /// <param name="adorningElement">The adorning element.</param>
        public DropPreviewAdorner(UIElement adornedElement, UIElement adorningElement)
            : base(adornedElement)
        {
            VisualBrush brush = new VisualBrush(adorningElement);

            this.child                  = new Rectangle();
            this.child.Width            = adorningElement.RenderSize.Width;
            this.child.Height           = adorningElement.RenderSize.Height;
            this.child.Fill             = brush;
            this.child.IsHitTestVisible = false;
            System.Windows.Media.Animation.DoubleAnimation animation;
            animation                = new System.Windows.Media.Animation.DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)));
            animation.AutoReverse    = true;
            animation.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
            brush.BeginAnimation(System.Windows.Media.Brush.OpacityProperty, animation);
        }
Beispiel #4
0
        // Be sure to call the base class constructor.
        public SimpleCircleAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            VisualBrush _brush = new VisualBrush(adornedElement);

            _child = new Rectangle();
            _child.Width = adornedElement.RenderSize.Width;
            _child.Height = adornedElement.RenderSize.Height;
           

            DoubleAnimation animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)));
            animation.AutoReverse = true;
            animation.RepeatBehavior =  System.Windows.Media.Animation.RepeatBehavior.Forever;
            _brush.BeginAnimation(System.Windows.Media.Brush.OpacityProperty, animation);

            _child.Fill = _brush;
        }
Beispiel #5
0
        public MoveScaleAdornerSelected(UIElement adornedElement)
            : base(adornedElement)
        {
            _adornedElement = adornedElement;
            var brush     = new VisualBrush(adornedElement);
            var animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)))
            {
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            brush.BeginAnimation(Brush.OpacityProperty, animation);
            visualChildren            = new VisualCollection(this);
            customControl             = new MoveScaleAdornerVisualSelected( );
            customControl.DataContext = _adornedElement;
            visualChildren.Add(customControl);
        }
        public DragNDropAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            _adornedElement = adornedElement;
            //Console.WriteLine($"here adorned {adornedElement}");
            var brush = new VisualBrush(adornedElement);

            var animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)))
            {
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            brush.BeginAnimation(Brush.OpacityProperty, animation);
            visualChildren            = new VisualCollection(this);
            customControl             = new DragNDropAdornerVisual();
            customControl.DataContext = _adornedElement;
            visualChildren.Add(customControl);
        }
Beispiel #7
0
        public VisualAdorner(UIElement ue, UIElement visual)
            : base(ue)
        {
            VisualBrush vb = new VisualBrush(visual);

            _child = new Rectangle();

            _child.Width  = ue.RenderSize.Width;
            _child.Height = ue.RenderSize.Height;


            DoubleAnimation animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)));

            animation.AutoReverse    = true;
            animation.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
            vb.BeginAnimation(System.Windows.Media.Brush.OpacityProperty, animation);

            _child.Fill = vb;
        }
        // Be sure to call the base class constructor.
        public DesignAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            var brush = new VisualBrush(adornedElement);

            _child = new Rectangle
            {
                Width  = adornedElement.RenderSize.Width,
                Height = adornedElement.RenderSize.Height
            };

            var animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)))
            {
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            brush.BeginAnimation(Brush.OpacityProperty, animation);

            _child.Fill = brush;
        }
Beispiel #9
0
        public RectAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            Path  p  = (Path)(adornedElement);
            Cover c  = p.ToolTip as Cover;
            Point cp = new Point();

            cp.X = ((c.Location.X - App.Tiles[0].X) / App.Tiles[0].Dx);
            cp.Y = ((App.Tiles[0].Y - c.Location.Y) / App.Tiles[0].Dy);

            _child        = new Rectangle();
            _child.Width  = App.StrokeThinkness * 2;
            _child.Height = App.StrokeThinkness * 2;

            VisualBrush _brush = new VisualBrush(adornedElement);

            DoubleAnimation animation = new DoubleAnimation(0.3, 1, new Duration(TimeSpan.FromSeconds(1)));

            animation.AutoReverse    = true;
            animation.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
            _brush.BeginAnimation(System.Windows.Media.Brush.OpacityProperty, animation);

            _child.Fill = _brush;
        }
Beispiel #10
0
        protected override void BeginTransition3D(TransitionPresenter transitionElement, ContentPresenter oldContent, ContentPresenter newContent, Viewport3D viewport)
        {
            Size size = transitionElement.RenderSize;

            // Create a rectangle
            MeshGeometry3D mesh = CreateMesh(new Point3D(),
                                             new Vector3D(size.Width, 0, 0),
                                             new Vector3D(0, size.Height, 0),
                                             1,
                                             1,
                                             new Rect(0, 0, 1, 1));

            GeometryModel3D geometry = new GeometryModel3D();

            geometry.Geometry = mesh;
            VisualBrush clone = new VisualBrush(oldContent);

            geometry.Material = new DiffuseMaterial(clone);

            ModelVisual3D model = new ModelVisual3D();

            model.Content = geometry;

            viewport.Children.Add(model);

            Vector3D axis;
            Point3D  center = new Point3D();

            switch (Direction)
            {
            case RotateDirection.Left:
                axis = new Vector3D(0, 1, 0);
                break;

            case RotateDirection.Right:
                axis   = new Vector3D(0, -1, 0);
                center = new Point3D(size.Width, 0, 0);
                break;

            case RotateDirection.Up:
                axis = new Vector3D(-1, 0, 0);
                break;

            default:
                axis   = new Vector3D(1, 0, 0);
                center = new Point3D(0, size.Height, 0);
                break;
            }
            AxisAngleRotation3D rotation = new AxisAngleRotation3D(axis, 0);

            model.Transform = new RotateTransform3D(rotation, center);

            DoubleAnimation da = new DoubleAnimation(0, Duration);

            clone.BeginAnimation(Brush.OpacityProperty, da);

            da            = new DoubleAnimation(90, Duration);
            da.Completed += delegate
            {
                EndTransition(transitionElement, oldContent, newContent);
            };
            rotation.BeginAnimation(AxisAngleRotation3D.AngleProperty, da);
        }