public override void SelectElement(SceneElement element, SceneNodeProperty editingProperty) { if (element == null || editingProperty == null) { return; } string description = string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.PropertyChangeUndoDescription, new object[1] { (object)((PropertyEntry)editingProperty).get_PropertyName() }); using (SceneEditTransaction editTransaction = editingProperty.SceneNodeObjectSet.ViewModel.CreateEditTransaction(description)) { element.EnsureNamed(); editingProperty.SetValue((object)element.Name); editTransaction.Commit(); } }
public override void SelectElement(SceneElement element, SceneNodeProperty editingProperty) { if (element == null || editingProperty == null || (editingProperty.SceneNodeObjectSet == null || editingProperty.IsMixedValue)) { return; } SceneNodeObjectSet sceneNodeObjectSet = editingProperty.SceneNodeObjectSet; BindingSceneNode bindingSceneNode = sceneNodeObjectSet.ViewModel.CreateSceneNode(PlatformTypes.Binding) as BindingSceneNode; LayoutPathNode layoutPathNode = sceneNodeObjectSet.ViewModel.CreateSceneNode(ProjectNeutralTypes.LayoutPath) as LayoutPathNode; using (SceneEditTransaction editTransaction = sceneNodeObjectSet.ViewModel.CreateEditTransaction(StringTable.AddLayoutPathUndo)) { using (sceneNodeObjectSet.ViewModel.ForceBaseValue()) { element.EnsureNamed(); editTransaction.Update(); bindingSceneNode.ElementName = element.Name; layoutPathNode.SetValue(LayoutPathNode.SourceElementProperty, (object)bindingSceneNode.DocumentNode); editingProperty.AddValue((object)layoutPathNode.DocumentNode); editTransaction.Commit(); } } }
internal void ApplyAfterInsertionDefaultsToElements(IList <SceneNode> nodes, SceneNode rootNode) { foreach (SceneNode node in (IEnumerable <SceneNode>)nodes) { SceneElement element = node as SceneElement; if (element != null) { string name = element.Name; if (name == null) { StyleAsset relatedUserThemeAsset = this.GetRelatedUserThemeAsset(node, rootNode); if (relatedUserThemeAsset != null) { DocumentCompositeNode documentCompositeNode = relatedUserThemeAsset.ResourceModel.ValueNode as DocumentCompositeNode; if (documentCompositeNode != null) { name = documentCompositeNode.GetValue <string>(DesignTimeProperties.StyleDefaultContentProperty); double num1 = documentCompositeNode.GetValue <double>(DesignTimeProperties.ExplicitWidthProperty); if (num1 > 0.0) { DefaultTypeInstantiator.SetIfUnset(node, BaseFrameworkElement.WidthProperty, (object)num1); } double num2 = documentCompositeNode.GetValue <double>(DesignTimeProperties.ExplicitHeightProperty); if (num2 > 0.0) { DefaultTypeInstantiator.SetIfUnset(node, BaseFrameworkElement.HeightProperty, (object)num2); } } } } if (name == null) { name = element.TargetType.Name; } if (element.Name == null && this.ViewModel.DesignerContext.ProjectManager.OptionsModel.NameInteractiveElementsByDefault && Enumerable.FirstOrDefault <ITypeId>((IEnumerable <ITypeId>)DefaultTypeInstantiator.InteractiveElementTypes, (Func <ITypeId, bool>)(i => { IType type = this.ViewModel.ProjectContext.ResolveType(i); if (type != null) { return(type.IsAssignableFrom((ITypeId)element.Type)); } return(false); })) != null) { element.EnsureNamed(); } if (ProjectNeutralTypes.HeaderedContentControl.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetIfUnset(node, HeaderedControlProperties.HeaderedContentHeaderProperty, (object)name); } else if (ProjectNeutralTypes.HeaderedItemsControl.IsAssignableFrom((ITypeId)node.Type) && !PlatformTypes.ToolBar.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetIfUnset(node, HeaderedControlProperties.HeaderedItemsHeaderProperty, (object)name); } else if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)node.Type) && !PlatformTypes.ScrollViewer.IsAssignableFrom((ITypeId)node.Type) && !PlatformTypes.UserControl.IsAssignableFrom((ITypeId)node.Type)) { if (ProjectNeutralTypes.TabItem.IsAssignableFrom((ITypeId)node.Type) && this.ViewModel.ProjectContext.IsCapabilitySet(PlatformCapability.UseHeaderOnTabItem)) { IPropertyId property = (IPropertyId)ProjectNeutralTypes.TabItem.GetMember(MemberType.LocalProperty, "Header", MemberAccessTypes.Public); DefaultTypeInstantiator.SetIfUnset(node, property, (object)name); } else { DefaultTypeInstantiator.SetIfUnset(node, ContentControlElement.ContentProperty, (object)name); } } else { BaseTextElement baseTextElement; if ((baseTextElement = node as BaseTextElement) != null) { if (string.IsNullOrEmpty(baseTextElement.Text.Trim())) { baseTextElement.Text = name; } if (PlatformTypes.TextBox.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetAsWpfIfUnset(node, TextBoxElement.TextWrappingProperty, (object)TextWrapping.Wrap); } if (!node.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) && PlatformTypes.RichTextBox.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetAsWpfIfUnset(node, RichTextBoxElement.TextWrappingProperty, (object)TextWrapping.Wrap); } } else if (PlatformTypes.TextBlock.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetIfUnset(node, TextBlockElement.TextProperty, (object)name); DefaultTypeInstantiator.SetAsWpfIfUnset(node, TextBlockElement.TextWrappingProperty, (object)TextWrapping.Wrap); } else if (PlatformTypes.ListView.IsAssignableFrom((ITypeId)node.Type)) { GridViewElement gridViewElement = (GridViewElement)node.ViewModel.CreateSceneNode(PlatformTypes.GridView); SceneNode sceneNode = node.ViewModel.CreateSceneNode(PlatformTypes.GridViewColumn); gridViewElement.Columns.Add(sceneNode); node.SetValueAsSceneNode(DefaultTypeInstantiator.ListViewViewProperty, (SceneNode)gridViewElement); } else if (PlatformTypes.Border.IsAssignableFrom((ITypeId)node.Type)) { DefaultTypeInstantiator.SetAsWpfIfUnset(node, BorderElement.BorderBrushProperty, (object)Brushes.Black); DefaultTypeInstantiator.SetAsWpfIfUnset(node, BorderElement.BorderThicknessProperty, (object)new Thickness(1.0)); } else if (typeof(FlowDocumentScrollViewer).IsAssignableFrom(node.TargetType)) { DefaultTypeInstantiator.SetIfUnset(node, FlowDocumentScrollViewerElement.DocumentProperty, (object)new FlowDocument((Block) new Paragraph((Inline) new Run(name)))); } else if (typeof(Glyphs).IsAssignableFrom(node.TargetType)) { DefaultTypeInstantiator.SetIfUnset(node, DefaultTypeInstantiator.GlyphsUnicodeStringProperty, (object)name); DefaultTypeInstantiator.SetIfUnset(node, DefaultTypeInstantiator.GlyphsFillProperty, (object)Brushes.Black); DefaultTypeInstantiator.SetIfUnset(node, DefaultTypeInstantiator.GlyphsFontRenderingSizeEmProperty, (object)12.0); } else if (typeof(Viewport3D).IsAssignableFrom(node.TargetType)) { Viewport3DElement viewport3Delement = node as Viewport3DElement; if (viewport3Delement != null) { Camera camera1 = (Camera)Viewport3D.CameraProperty.DefaultMetadata.DefaultValue; Camera camera2 = (Camera)viewport3Delement.GetComputedValue(Viewport3DElement.CameraProperty); if (camera2 == null || PropertyUtilities.Compare((object)camera1, (object)camera2, this.sceneView)) { Camera perspectiveCamera = Helper3D.CreateEnclosingPerspectiveCamera(45.0, 1.0, new Rect3D(-1.0, -1.0, -1.0, 2.0, 2.0, 2.0), 1.0); DefaultTypeInstantiator.SetIfUnset((SceneNode)viewport3Delement, Viewport3DElement.CameraProperty, (object)perspectiveCamera); } } } } } } }