Beispiel #1
0
        public static void DrawSizeAdorner(DrawingContext drawingContext, Point anchorPoint, EdgeFlags edgeFlags, Matrix matrix, Brush brush, Pen pen, Rect bounds, AdornerRenderLocation location)
        {
            if (SizeAdorner.SkipAdorner(edgeFlags, matrix, bounds))
            {
                return;
            }
            Vector vector1 = new Vector(1.0, 0.0) * matrix;
            Vector vector2 = new Vector(0.0, 1.0) * matrix;

            vector1.Normalize();
            vector2.Normalize();
            double num1    = matrix.Determinant < 0.0 ? -1.0 : 1.0;
            Point  point   = anchorPoint;
            Matrix matrix1 = new Matrix(0.0, 1.0 * num1, -1.0 * num1, 0.0, 0.0, 0.0);
            Matrix matrix2 = new Matrix(0.0, -1.0 * num1, 1.0 * num1, 0.0, 0.0, 0.0);
            Vector vector3 = vector1 * matrix1;
            Vector vector4 = vector2 * matrix2;
            Vector vector5 = vector1 * 8.0;
            Vector vector6 = vector2 * 8.0;

            if (location == AdornerRenderLocation.Inside)
            {
                switch (edgeFlags & EdgeFlags.TopOrBottom)
                {
                case EdgeFlags.None:
                    vector1      = vector4;
                    anchorPoint -= 0.5 * (5.0 - pen.Thickness) * vector2;
                    point       += vector2 * 0.5 * 8.0;
                    break;

                case EdgeFlags.Top:
                    vector2      = vector3;
                    anchorPoint += 0.5 * pen.Thickness * vector2;
                    point       += vector2 * 8.0;
                    break;

                case EdgeFlags.Bottom:
                    vector2      = vector3;
                    anchorPoint -= (5.0 - 0.5 * pen.Thickness) * vector2;
                    break;
                }
                switch (edgeFlags & EdgeFlags.LeftOrRight)
                {
                case EdgeFlags.None:
                    anchorPoint -= 0.5 * (5.0 - pen.Thickness) * vector1;
                    point       += vector1 * 0.5 * 8.0;
                    break;

                case EdgeFlags.Left:
                    anchorPoint += 0.5 * pen.Thickness * vector1;
                    point       += vector1 * 8.0;
                    break;

                case EdgeFlags.Right:
                    anchorPoint -= (5.0 - 0.5 * pen.Thickness) * vector1;
                    break;
                }
            }
            else
            {
                switch (edgeFlags & EdgeFlags.TopOrBottom)
                {
                case EdgeFlags.None:
                    vector1      = vector4;
                    anchorPoint -= 0.5 * (5.0 - pen.Thickness) * vector2;
                    point       += vector2 * 0.5 * 8.0;
                    break;

                case EdgeFlags.Top:
                    vector2      = vector3;
                    anchorPoint -= (5.0 - 0.5 * pen.Thickness) * vector2;
                    break;

                case EdgeFlags.Bottom:
                    vector2      = vector3;
                    anchorPoint += 0.5 * pen.Thickness * vector2;
                    point       += vector2 * 8.0;
                    break;
                }
                switch (edgeFlags & EdgeFlags.LeftOrRight)
                {
                case EdgeFlags.None:
                    anchorPoint -= 0.5 * (5.0 - pen.Thickness) * vector1;
                    point       += vector1 * 0.5 * 8.0;
                    break;

                case EdgeFlags.Left:
                    anchorPoint -= (5.0 - 0.5 * pen.Thickness) * vector1;
                    break;

                case EdgeFlags.Right:
                    anchorPoint += 0.5 * pen.Thickness * vector1;
                    point       += vector1 * 8.0;
                    break;
                }
            }
            StreamGeometry        streamGeometry1        = new StreamGeometry();
            StreamGeometryContext streamGeometryContext1 = streamGeometry1.Open();

            streamGeometryContext1.BeginFigure(point - vector5, true, true);
            streamGeometryContext1.LineTo(point - vector5 - vector6, false, false);
            streamGeometryContext1.LineTo(point - vector6, false, false);
            streamGeometryContext1.LineTo(point, false, false);
            streamGeometryContext1.Close();
            streamGeometry1.Freeze();
            drawingContext.DrawGeometry((Brush)Brushes.Transparent, (Pen)null, (System.Windows.Media.Geometry)streamGeometry1);
            double                num2                   = 5.0 - pen.Thickness;
            Vector                vector7                = vector1 * num2;
            Vector                vector8                = vector2 * num2;
            StreamGeometry        streamGeometry2        = new StreamGeometry();
            StreamGeometryContext streamGeometryContext2 = streamGeometry2.Open();

            streamGeometryContext2.BeginFigure(anchorPoint, true, true);
            streamGeometryContext2.LineTo(anchorPoint + vector8, true, false);
            streamGeometryContext2.LineTo(anchorPoint + vector7 + vector8, true, false);
            streamGeometryContext2.LineTo(anchorPoint + vector7, true, false);
            streamGeometryContext2.Close();
            streamGeometry2.Freeze();
            drawingContext.DrawGeometry(brush, pen, (System.Windows.Media.Geometry)streamGeometry2);
        }
Beispiel #2
0
        private void DrawEdgeAdorner(DrawingContext drawingContext, Point anchorPoint, Matrix matrix, Brush brush, Pen pen, Rect bounds)
        {
            if (SizeAdorner.SkipAdorner(this.EdgeFlags, matrix, bounds))
            {
                return;
            }
            Vector vector1 = new Vector(1.0, 0.0) * matrix;
            Vector vector2 = new Vector(0.0, 1.0) * matrix;

            vector1.Normalize();
            vector2.Normalize();
            double num1 = this.TestFlags(EdgeFlags.Right) ? -1.0 : 1.0;
            double num2 = this.TestFlags(EdgeFlags.Bottom) ? -1.0 : 1.0;

            switch (this.EdgeFlags & EdgeFlags.TopOrBottom)
            {
            case EdgeFlags.None:
                anchorPoint -= 0.5 * (13.0 - pen.Thickness) * vector2;
                break;

            case EdgeFlags.Top:
            case EdgeFlags.Bottom:
                anchorPoint -= (15.0 - 0.5 * pen.Thickness) * vector2 * num2;
                break;
            }
            switch (this.EdgeFlags & EdgeFlags.LeftOrRight)
            {
            case EdgeFlags.None:
                anchorPoint -= 0.5 * (13.0 - pen.Thickness) * vector1;
                break;

            case EdgeFlags.Left:
            case EdgeFlags.Right:
                anchorPoint -= (15.0 - 0.5 * pen.Thickness) * vector1 * num1;
                break;
            }
            bool   flag = this.TestFlags(EdgeFlags.LeftOrRight);
            double num3 = (flag ? 4.0 : 13.0) - pen.Thickness;
            double num4 = (flag ? 13.0 : 4.0) - pen.Thickness;

            vector1 *= num3 * num1;
            Vector                vector3               = vector2 * (num4 * num2);
            StreamGeometry        streamGeometry        = new StreamGeometry();
            StreamGeometryContext streamGeometryContext = streamGeometry.Open();

            streamGeometryContext.BeginFigure(anchorPoint, true, true);
            streamGeometryContext.LineTo(anchorPoint + vector3, true, false);
            streamGeometryContext.LineTo(anchorPoint + vector1 + vector3, true, false);
            streamGeometryContext.LineTo(anchorPoint + vector1, true, false);
            streamGeometryContext.Close();
            streamGeometry.Freeze();
            if (this.IsEnabled)
            {
                drawingContext.DrawGeometry(brush, pen, (System.Windows.Media.Geometry)streamGeometry);
            }
            else
            {
                drawingContext.DrawGeometry((Brush)Brushes.Transparent, (Pen)null, (System.Windows.Media.Geometry)streamGeometry);
                Vector vector4 = flag ? vector3 : vector1;
                drawingContext.DrawLine(pen, anchorPoint, anchorPoint + vector4);
            }
        }