Ejemplo n.º 1
0
        public static void DrawAdorner(DrawingContext drawingContext, Point anchorPoint, EdgeFlags edgeFlags, Matrix matrix, Brush brush)
        {
            Vector transformedXAxis = new Vector(1.0, 0.0) * matrix;
            Vector transformedYAxis = new Vector(0.0, 1.0) * matrix;

            transformedXAxis.Normalize();
            transformedYAxis.Normalize();
            System.Windows.Media.Geometry geometry;
            Transform transform;

            if (Math.Abs(transformedXAxis * transformedYAxis) < 0.01)
            {
                if (!RotateAdornerHelper.sharedGeometries.TryGetValue(edgeFlags, out geometry))
                {
                    geometry = RotateAdornerHelper.GetGeometry(edgeFlags, new Vector(1.0, 0.0), new Vector(0.0, 1.0), false);
                    RotateAdornerHelper.sharedGeometries.Add(edgeFlags, geometry);
                }
                transform = (Transform) new MatrixTransform(transformedXAxis.X, transformedXAxis.Y, transformedYAxis.X, transformedYAxis.Y, anchorPoint.X, anchorPoint.Y);
            }
            else
            {
                bool isFlipped = matrix.Determinant < 0.0;
                geometry  = RotateAdornerHelper.GetGeometry(edgeFlags, transformedXAxis, transformedYAxis, isFlipped);
                transform = (Transform) new TranslateTransform(anchorPoint.X, anchorPoint.Y);
            }
            transform.Freeze();
            drawingContext.PushTransform(transform);
            drawingContext.DrawGeometry(brush, (Pen)null, geometry);
            drawingContext.Pop();
        }
Ejemplo n.º 2
0
        public static void DrawAdorner(DrawingContext drawingContext, Point anchorPoint, EdgeFlags edgeFlags, Matrix matrix, Brush brush, Rect bounds)
        {
            Size ofTransformedRect = Adorner.GetSizeOfTransformedRect(bounds, matrix);

            if ((edgeFlags == EdgeFlags.Top || edgeFlags == EdgeFlags.Bottom) && (ofTransformedRect.Width < RotateAdornerHelper.Radius * 2.0 || ofTransformedRect.Height < SizeAdorner.Size) || (edgeFlags == EdgeFlags.Left || edgeFlags == EdgeFlags.Right) && (ofTransformedRect.Height < RotateAdornerHelper.Radius * 2.0 || ofTransformedRect.Width < SizeAdorner.Size) || (edgeFlags == EdgeFlags.TopLeft || edgeFlags == EdgeFlags.TopRight || (edgeFlags == EdgeFlags.BottomLeft || edgeFlags == EdgeFlags.BottomRight)) && (ofTransformedRect.Width < SizeAdorner.Size && ofTransformedRect.Height < SizeAdorner.Size))
            {
                return;
            }
            RotateAdornerHelper.DrawAdorner(drawingContext, anchorPoint, edgeFlags, matrix, brush);
        }
Ejemplo n.º 3
0
        public override void Draw(DrawingContext ctx, Matrix matrix)
        {
            if (!this.ShouldDraw || PlatformTypes.IsInstance(this.PlatformBrush, PlatformTypes.LinearGradientBrush, (ITypeResolver)this.Element.ProjectContext) && this.AdornerSet.Behavior.Tool is GradientBrushTool)
            {
                return;
            }
            Rect brushBounds = this.BrushBounds;

            if (brushBounds.Width > 0.0 && brushBounds.Height > 0.0)
            {
                Point  anchorPoint = this.GetAnchorPoint(matrix);
                Matrix matrix1     = this.GetCompleteBrushTransformMatrix(true) * matrix;
                RotateAdornerHelper.DrawAdorner(ctx, anchorPoint, this.EdgeFlags, matrix1, (Brush)Brushes.Transparent);
            }
            else
            {
                if (brushBounds.Width <= 0.0 && brushBounds.Height <= 0.0 || this.EdgeFlags != EdgeFlags.TopLeft && this.EdgeFlags != EdgeFlags.BottomRight)
                {
                    return;
                }
                Point anchorPoint = this.GetAnchorPoint(matrix);
                ctx.DrawEllipse((Brush)Brushes.Transparent, (Pen)null, anchorPoint, RotateAdornerHelper.Radius, RotateAdornerHelper.Radius);
            }
        }