Example #1
0
        private void AddGeometryDrawing(ConvertibleDrawing.DrawingStackEntry entry)
        {
            GeometryDrawing geometryDrawing = entry.Drawing as GeometryDrawing;
            Path            path            = new Path();

            ConvertibleDrawing.SetPositionInCanvas((UIElement)path, entry.Offset);
            if (entry.Transform != Transform.Identity)
            {
                ConvertibleDrawing.SetValueIfNotDefault(UIElement.RenderTransformProperty, (DependencyObject)path, (object)entry.Transform);
            }
            entry.Canvas.Children.Add((UIElement)path);
            ConvertibleDrawing.SetValueIfNotDefault(Shape.FillProperty, (DependencyObject)path, (object)geometryDrawing.Brush);
            if (geometryDrawing.Pen != null)
            {
                Pen pen = geometryDrawing.Pen;
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeProperty, (DependencyObject)path, (object)pen.Brush);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeDashArrayProperty, (DependencyObject)path, (object)pen.DashStyle.Dashes);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeDashCapProperty, (DependencyObject)path, (object)pen.DashCap);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeDashOffsetProperty, (DependencyObject)path, (object)pen.DashStyle.Offset);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeEndLineCapProperty, (DependencyObject)path, (object)pen.EndLineCap);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeLineJoinProperty, (DependencyObject)path, (object)pen.LineJoin);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeMiterLimitProperty, (DependencyObject)path, (object)pen.MiterLimit);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeStartLineCapProperty, (DependencyObject)path, (object)pen.StartLineCap);
                ConvertibleDrawing.SetValueIfNotDefault(Shape.StrokeThicknessProperty, (DependencyObject)path, (object)pen.Thickness);
            }
            path.Data = geometryDrawing.Geometry;
        }
Example #2
0
        private Canvas AddCanvasLevel(ConvertibleDrawing.DrawingStackEntry entry)
        {
            Canvas       canvas       = new Canvas();
            DrawingGroup drawingGroup = entry.Drawing as DrawingGroup;

            if (entry.Transform != Transform.Identity)
            {
                CanonicalTransform canonicalTransform = new CanonicalTransform(entry.Transform);
                if (drawingGroup.Transform != null)
                {
                    canonicalTransform = new CanonicalTransform(entry.Transform.Value * drawingGroup.Transform.Value);
                }
                ConvertibleDrawing.SetValueIfNotDefault(UIElement.RenderTransformProperty, (DependencyObject)canvas, (object)canonicalTransform.TransformGroup);
            }
            ConvertibleDrawing.SetPositionInCanvas((UIElement)canvas, entry.Offset);
            ConvertibleDrawing.SetValueIfNotDefault(UIElement.BitmapEffectProperty, (DependencyObject)canvas, (object)drawingGroup.BitmapEffect);
            ConvertibleDrawing.SetValueIfNotDefault(UIElement.BitmapEffectInputProperty, (DependencyObject)canvas, (object)drawingGroup.BitmapEffectInput);
            ConvertibleDrawing.SetValueIfNotDefault(UIElement.OpacityProperty, (DependencyObject)canvas, (object)drawingGroup.Opacity);
            ConvertibleDrawing.SetValueIfNotDefault(UIElement.OpacityMaskProperty, (DependencyObject)canvas, (object)drawingGroup.OpacityMask);
            ConvertibleDrawing.SetValueIfNotDefault(UIElement.ClipProperty, (DependencyObject)canvas, (object)drawingGroup.ClipGeometry);
            if (!double.IsInfinity(drawingGroup.Bounds.Height))
            {
                ConvertibleDrawing.SetValueIfNotDefault(FrameworkElement.HeightProperty, (DependencyObject)canvas, (object)drawingGroup.Bounds.Height);
            }
            if (!double.IsInfinity(drawingGroup.Bounds.Width))
            {
                ConvertibleDrawing.SetValueIfNotDefault(FrameworkElement.WidthProperty, (DependencyObject)canvas, (object)drawingGroup.Bounds.Width);
            }
            entry.Canvas.Children.Add((UIElement)canvas);
            return(canvas);
        }
Example #3
0
        private void AddImageDrawing(ConvertibleDrawing.DrawingStackEntry entry)
        {
            ImageDrawing imageDrawing = entry.Drawing as ImageDrawing;

            if (this.projectPath != null)
            {
                imageDrawing = (ImageDrawing)MakeDrawingBrushCommand.SimplifyImageDrawing(imageDrawing, this.projectPath);
            }
            Image image = new Image();

            ConvertibleDrawing.SetValueIfNotDefault(FrameworkElement.HeightProperty, (DependencyObject)image, (object)imageDrawing.Bounds.Height);
            ConvertibleDrawing.SetValueIfNotDefault(FrameworkElement.WidthProperty, (DependencyObject)image, (object)imageDrawing.Bounds.Width);
            ConvertibleDrawing.SetValueIfNotDefault(Image.SourceProperty, (DependencyObject)image, (object)imageDrawing.ImageSource);
            ConvertibleDrawing.SetPositionInCanvas((UIElement)image, entry.Offset);
            if (entry.Transform != Transform.Identity)
            {
                ConvertibleDrawing.SetValueIfNotDefault(UIElement.RenderTransformProperty, (DependencyObject)image, (object)entry.Transform);
            }
            entry.Canvas.Children.Add((UIElement)image);
        }
Example #4
0
        private void AddGlyphRunDrawing(ConvertibleDrawing.DrawingStackEntry entry)
        {
            GlyphRunDrawing glyphRunDrawing = entry.Drawing as GlyphRunDrawing;

            System.Windows.Media.Geometry geometry = (System.Windows.Media.Geometry)null;
            if (glyphRunDrawing.GlyphRun != null)
            {
                geometry = glyphRunDrawing.GlyphRun.BuildGeometry();
            }
            Path path = new Path();

            ConvertibleDrawing.SetValueIfNotDefault(Shape.FillProperty, (DependencyObject)path, (object)glyphRunDrawing.ForegroundBrush);
            ConvertibleDrawing.SetValueIfNotDefault(Path.DataProperty, (DependencyObject)path, (object)geometry);
            ConvertibleDrawing.SetPositionInCanvas((UIElement)path, entry.Offset);
            if (entry.Transform != Transform.Identity)
            {
                ConvertibleDrawing.SetValueIfNotDefault(UIElement.RenderTransformProperty, (DependencyObject)path, (object)entry.Transform);
            }
            entry.Canvas.Children.Add((UIElement)path);
        }