예제 #1
0
 private static FixedContentEditor CreateEditor(EditorInfo info, bool isFilled)
 {
     FixedContentEditor geometryEditor = new FixedContentEditor(info.Page, info.Position);
     geometryEditor.GraphicProperties.IsFilled = isFilled;
     geometryEditor.GraphicProperties.FillColor = ColorHelper.GetColor(info.Background, info.Opacity, info.Bounds, info.Angle);
     geometryEditor.GraphicProperties.StrokeColor = ColorHelper.GetColor(info.Stroke, info.Opacity, info.Bounds, info.Angle);
     geometryEditor.GraphicProperties.StrokeDashArray = info.StrokeDashArray;
     geometryEditor.GraphicProperties.StrokeThickness = info.StrokeThickness;
     return geometryEditor;
 }
예제 #2
0
        private static void ExportConnection(RadDiagramConnection connection, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(connection.Bounds.X - enclosingBounds.X, connection.Bounds.Y - enclosingBounds.Y, connection.Bounds.Width, connection.Bounds.Height);

            var pathGeometry = connection.Geometry as PathGeometry;
            var pathBounds = connection.ConnectionType == ConnectionType.Bezier ? pathGeometry.Bounds : new Rect();

            var transformGroup = new TransformGroup();
            transformGroup.Children.Add(new TranslateTransform() { X = bounds.X - pathBounds.X, Y = bounds.Y - pathBounds.Y });
            var position = new MatrixPosition(transformGroup.Value);

            EditorInfo info = new EditorInfo(page, position, connection, bounds, connection.Stroke, 0);
            FixedContentEditor editor = CreateEditor(info, false);
            FixedContentEditor filledEditor = CreateEditor(info, true);

            ExportGeometry(editor, filledEditor, pathGeometry, true);

            if (connection.Content != null)
            {
                var center = bounds.Center();
                ExportContent(connection, bounds, 0, page, (s) => { return new Point(bounds.Center().X - s.Width / 2, center.Y - s.Height / 2); });
            }
        }
예제 #3
0
        private static void ExportShape(RadDiagramShape shape, Rect enclosingBounds, RadFixedPage page)
        {
            var bounds = new Rect(shape.Bounds.X - enclosingBounds.X, shape.Bounds.Y - enclosingBounds.Y, shape.Bounds.Width, shape.Bounds.Height);

            var pathGeometry = shape.Geometry as PathGeometry;
            var transformGroup = new TransformGroup();
#if WPF
            if (pathGeometry == null)
            {
                var streamGeometry = shape.Geometry as StreamGeometry;
                if (streamGeometry != null)
                    pathGeometry = streamGeometry.AsPathGeometry();
            }
#endif

            var geometrySize = shape.Geometry.Bounds.ToSize();
            if (IsValidSize(geometrySize) && (geometrySize.Width != bounds.Width || geometrySize.Width != bounds.Width))
                transformGroup.Children.Add(new ScaleTransform() { ScaleX = bounds.Width / geometrySize.Width, ScaleY = bounds.Height / geometrySize.Height });
            transformGroup.Children.Add(new RotateTransform() { Angle = shape.RotationAngle, CenterX = bounds.Width / 2, CenterY = bounds.Height / 2 });
            transformGroup.Children.Add(new TranslateTransform() { X = bounds.X, Y = bounds.Y });

            var position = new MatrixPosition(transformGroup.Value);

            EditorInfo info = new EditorInfo(page, position, shape, bounds, shape.BorderBrush, shape.RotationAngle);
            FixedContentEditor editor = CreateEditor(info, false);
            FixedContentEditor filledEditor = CreateEditor(info, true);

            ExportGeometry(editor, filledEditor, pathGeometry);

            if (shape.Content != null)
            {
                var center = bounds.Center();
                ExportContent(shape, bounds, shape.RotationAngle, page, (s) => { return new Point(center.X - s.Width / 2, center.Y - s.Height / 2); });
            }
        }