Пример #1
0
        private void DrawAnimate(DrawingContext ctx, Matrix matrix, IEnumerable <IAdornerAnimation> activeAdornerAnimations)
        {
            IAdornerAnimation adornerAnimation = activeAdornerAnimations != null?Enumerable.FirstOrDefault <IAdornerAnimation>(activeAdornerAnimations, (Func <IAdornerAnimation, bool>)(item => item.Name == "PreviewBox")) : (IAdornerAnimation)null;

            if (!this.ShouldDraw || this.Element.Visual == null)
            {
                return;
            }
            Rect elementBounds = this.ElementBounds;
            Pen  pen           = this.BorderPen;

            if (pen.IsFrozen && adornerAnimation != null)
            {
                pen = adornerAnimation.ClientData as Pen;
                if (pen == null)
                {
                    pen = this.BorderPen.Clone();
                    adornerAnimation.ClientData = (object)pen;
                }
            }
            if (adornerAnimation != null)
            {
                pen.Brush.Opacity = adornerAnimation.LerpValue;
            }
            this.DrawBounds(ctx, elementBounds, (Brush)null, pen);
            if (!this.AdornerSet.ToolContext.Tool.ShowDimensions || !this.Element.ViewModel.ElementSelectionSet.Selection.Contains(this.Element) || this.ElementSet.IsPrimaryTransformNonAffine)
            {
                return;
            }
            Matrix computedTransformToRoot = this.DesignerContext.ActiveView.GetComputedTransformToRoot(this.Element);

            SizeAdorner.DrawDimension(ctx, ElementLayoutAdornerType.Right, matrix, computedTransformToRoot, pen, elementBounds, 1.0);
            SizeAdorner.DrawDimension(ctx, ElementLayoutAdornerType.Bottom, matrix, computedTransformToRoot, pen, elementBounds, 1.0);
        }
Пример #2
0
        public static void DrawDimensions(DrawingContext drawingContext, Matrix matrix, Matrix rootMatrix, Pen pen, Rect bounds, EdgeFlags edgeFlags)
        {
            if ((edgeFlags & EdgeFlags.LeftOrRight) != EdgeFlags.None)
            {
                ElementLayoutAdornerType edge = (edgeFlags & EdgeFlags.Top) != EdgeFlags.None ? ElementLayoutAdornerType.Top : ElementLayoutAdornerType.Bottom;
                SizeAdorner.DrawDimension(drawingContext, edge, matrix, rootMatrix, pen, bounds, 1.0);
            }
            if ((edgeFlags & EdgeFlags.TopOrBottom) == EdgeFlags.None)
            {
                return;
            }
            ElementLayoutAdornerType edge1 = (edgeFlags & EdgeFlags.Left) != EdgeFlags.None ? ElementLayoutAdornerType.Left : ElementLayoutAdornerType.Right;

            SizeAdorner.DrawDimension(drawingContext, edge1, matrix, rootMatrix, pen, bounds, 1.0);
        }