コード例 #1
0
        private void ApplyEyedropperSceneElement(SceneElement hitElement)
        {
            PropertyManager   propertyManager  = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform         = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata = (IPlatformMetadata)platform.Metadata;

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)hitElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object second        = propertyManager.GetValue(propertyReference2);
                        object computedValue = hitElement.GetComputedValue(propertyReference2);
                        if (computedValue != MixedProperty.Mixed && !PropertyUtilities.Compare(computedValue, second, hitElement.ViewModel.DefaultView))
                        {
                            propertyManager.SetValue(propertyReference2, computedValue);
                        }
                    }
                }
            }
            this.UpdateEditTransaction();
        }
コード例 #2
0
        public override object GetValue(PropertyReference propertyReference, PropertyReference.GetValueFlags getValueFlags)
        {
            object second = null;
            bool   flag   = false;

            foreach (SceneNode sceneNode in this.Objects)
            {
                PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty(sceneNode, propertyReference);
                if (propertyReference1 != null)
                {
                    object first;
                    if ((getValueFlags & PropertyReference.GetValueFlags.Computed) != PropertyReference.GetValueFlags.Local)
                    {
                        if (SceneNodeObjectSetBase.IsValidForGetComputedValue(sceneNode))
                        {
                            first = sceneNode.GetComputedValue(propertyReference1);
                        }
                        else
                        {
                            SceneNode         ancestor           = (SceneNode)null;
                            PropertyReference propertyReference2 = propertyReference1;
                            first = !this.ShouldWalkParentsForGetValue || !this.FindAncestor(sceneNode, out ancestor, ref propertyReference2, new Predicate <SceneNode>(SceneNodeObjectSetBase.IsValidForGetComputedValue)) ? sceneNode.GetLocalOrDefaultValue(propertyReference1) : ancestor.GetComputedValue(propertyReference2);
                        }
                    }
                    else
                    {
                        first = sceneNode.GetLocalOrDefaultValue(propertyReference1);
                    }
                    if (!flag)
                    {
                        second = first;
                        flag   = true;
                    }
                    else if (!PropertyUtilities.Compare(first, second, sceneNode.ViewModel.DefaultView))
                    {
                        second = MixedProperty.Mixed;
                        break;
                    }
                }
            }
            if (!flag)
            {
                ReferenceStep referenceStep = propertyReference[propertyReference.Count - 1];
                if (this.designerContext.ActiveView != null)
                {
                    second = referenceStep.GetDefaultValue(referenceStep.TargetType);
                }
            }
            return(second);
        }
コード例 #3
0
 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);
                         }
                     }
                 }
             }
         }
     }
 }