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; }
public void Execute() { if (!this.IsEnabled) { return; } ResourceEntryItem resourceEntryItem = (ResourceEntryItem)this.resourceManager.SelectedItems.Selection[0]; SceneNode sceneNode = resourceEntryItem.Container.ViewModel.GetSceneNode(resourceEntryItem.Resource.ValueNode); ConvertibleDrawing convertibleDrawing = ConvertibleDrawing.CreateConvertibleDrawing((object)(Brush)this.designerContext.ActiveSceneViewModel.CreateInstance(sceneNode.DocumentNodePath), sceneNode.ProjectContext.ProjectPath); if (convertibleDrawing == null) { return; } DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)sceneNode.DocumentNode; string valueAsString = DocumentPrimitiveNode.GetValueAsString(resourceEntryItem.Resource.KeyNode); string documentUrl = documentCompositeNode.DocumentRoot.DocumentContext.DocumentUrl; SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel; using (SceneEditTransaction editTransaction = activeSceneViewModel.CreateEditTransaction(this.CommandName)) { BaseFrameworkElement child = (BaseFrameworkElement)activeSceneViewModel.CreateSceneNode((object)convertibleDrawing.Convert()); activeSceneViewModel.ActiveSceneInsertionPoint.Insert((SceneNode)child); child.SetLocalValue(DesignTimeProperties.BrushDocumentReferenceProperty, (object)documentUrl); child.SetLocalValue(DesignTimeProperties.BrushKeyProperty, (object)valueAsString); child.Name = valueAsString + "_1"; this.point *= ElementUtilities.GetInverseMatrix(activeSceneViewModel.DefaultView.GetComputedTransformToRoot(activeSceneViewModel.ActiveSceneInsertionPoint.SceneElement)); Rect rect = new Rect(this.point, new Size(child.Width, child.Height)); activeSceneViewModel.GetLayoutDesignerForChild((SceneElement)child, true).SetChildRect(child, rect, LayoutOverrides.None, LayoutOverrides.Width | LayoutOverrides.Height, LayoutOverrides.None); this.designerContext.SelectionManager.ElementSelectionSet.SetSelection((SceneElement)child); editTransaction.Commit(); } }
internal static bool ContainsVideoDrawing(DocumentNode node) { DocumentCompositeNode documentCompositeNode1 = node as DocumentCompositeNode; if (PlatformTypes.DrawingBrush.IsAssignableFrom((ITypeId)node.Type)) { documentCompositeNode1 = documentCompositeNode1.Properties[ConvertibleDrawing.DrawingBrushDrawingProperty] as DocumentCompositeNode; } if (documentCompositeNode1 != null && PlatformTypes.Drawing.IsAssignableFrom((ITypeId)documentCompositeNode1.Type)) { if (PlatformTypes.VideoDrawing.IsAssignableFrom((ITypeId)documentCompositeNode1.Type)) { return(true); } if (PlatformTypes.DrawingGroup.IsAssignableFrom((ITypeId)documentCompositeNode1.Type)) { DocumentCompositeNode documentCompositeNode2 = documentCompositeNode1.Properties[ConvertibleDrawing.DrawingGroupChildrenProperty] as DocumentCompositeNode; if (documentCompositeNode2 != null) { foreach (DocumentNode node1 in (IEnumerable <DocumentNode>)documentCompositeNode2.Children) { if (ConvertibleDrawing.ContainsVideoDrawing(node1)) { return(true); } } } } } return(false); }
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); }
public static bool CanCreateConvertibleDrawing(DocumentNode resourceNode) { if (ConvertibleDrawing.IsResourceTypeSupported(resourceNode.Type)) { return(!ConvertibleDrawing.ContainsVideoDrawing(resourceNode)); } return(false); }
internal static bool ContainsVideoDrawing(Drawing drawing) { if (drawing is VideoDrawing) { return(true); } DrawingGroup drawingGroup = drawing as DrawingGroup; if (drawingGroup != null) { foreach (Drawing drawing1 in drawingGroup.Children) { if (ConvertibleDrawing.ContainsVideoDrawing(drawing1)) { return(true); } } } return(false); }
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); }
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); }
public void UpdateIsEnabled() { bool flag = false; if (this.designerContext.ActiveSceneViewModel != null && this.designerContext.ActiveSceneViewModel.ActiveSceneInsertionPoint != null && (this.resourceManager.SelectedItems.Count == 1 && this.designerContext.ActiveSceneViewModel.ActiveSceneInsertionPoint != null)) { ResourceEntryItem resourceEntryItem = this.resourceManager.SelectedItems.Selection[0] as ResourceEntryItem; if (resourceEntryItem != null) { DocumentNode valueNode = resourceEntryItem.Resource.ValueNode; this.isVisible = ConvertibleDrawing.IsResourceTypeSupported(valueNode.Type); flag = ConvertibleDrawing.CanCreateConvertibleDrawing(valueNode); } } else { flag = false; this.isVisible = false; } this.IsEnabled = flag; }
protected static void SetPositionInCanvas(UIElement element, Point offset) { ConvertibleDrawing.SetValueIfNotDefault(Canvas.TopProperty, (DependencyObject)element, (object)offset.Y); ConvertibleDrawing.SetValueIfNotDefault(Canvas.LeftProperty, (DependencyObject)element, (object)offset.X); }