コード例 #1
0
        private void AddPresenterIfNecessary(DocumentCompositeNode visualTreeNode, SceneElement newElement)
        {
            Type targetType = (Type)null;

            if (PlatformTypes.ContentControl.IsAssignableFrom((ITypeId)newElement.Type))
            {
                targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ContentPresenter).RuntimeType;
            }
            else if (PlatformTypes.ItemsControl.IsAssignableFrom((ITypeId)newElement.Type))
            {
                targetType = newElement.ViewModel.ProjectContext.ResolveType(PlatformTypes.ItemsPresenter).RuntimeType;
            }
            if (!(targetType != (Type)null))
            {
                return;
            }
            DocumentNode node = visualTreeNode.SelectFirstDescendantNode(targetType);

            if (node == null)
            {
                PanelElement panelElement     = (PanelElement)this.SceneViewModel.GetSceneNode((DocumentNode)visualTreeNode);
                SceneElement presenterElement = (SceneElement)this.SceneViewModel.CreateSceneNode(targetType);
                SceneElement sceneElement     = this.PreparePresenter(visualTreeNode, presenterElement);
                GridElement  gridElement      = panelElement as GridElement;
                if (gridElement != null)
                {
                    int count1 = gridElement.ColumnDefinitions.Count;
                    int count2 = gridElement.RowDefinitions.Count;
                    if (count1 > 0)
                    {
                        sceneElement.SetLocalValue(GridElement.ColumnSpanProperty, (object)count1);
                    }
                    if (count2 > 0)
                    {
                        sceneElement.SetLocalValue(GridElement.RowSpanProperty, (object)count2);
                    }
                }
                panelElement.Children.Add((SceneNode)sceneElement);
            }
            else
            {
                SceneElement presenterElement = this.SceneViewModel.GetSceneNode(node) as SceneElement;
                if (presenterElement == null)
                {
                    return;
                }
                this.PreparePresenter(visualTreeNode, presenterElement);
            }
        }
コード例 #2
0
        public static bool UpdateLayoutRounding(SceneElement element)
        {
            if (!LayoutRoundingHelper.ShouldConsiderLayoutRoundingAdjustment(element))
            {
                return(false);
            }
            IPropertyId propertyKey = (IPropertyId)LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)element);

            if (propertyKey == null)
            {
                return(false);
            }
            bool flag1 = element.IsSet(propertyKey) == PropertyState.Set;

            if (PlatformTypes.Path.IsAssignableFrom((ITypeId)element.Type))
            {
                if (!flag1 && (bool)element.GetComputedValue(propertyKey))
                {
                    element.SetLocalValue(Base2DElement.UseLayoutRoundingProperty, (object)false);
                    LayoutRoundingHelper.SetAutoLayoutRounding(element, false);
                    return(true);
                }
            }
            else if (!flag1 || LayoutRoundingHelper.GetAutoLayoutRounding(element))
            {
                bool flag2 = (bool)element.GetComputedValue(propertyKey);
                if (LayoutRoundingHelper.IsAxisAligned(element))
                {
                    if (!flag2)
                    {
                        element.ClearValue(propertyKey);
                        LayoutRoundingHelper.SetAutoLayoutRounding(element, false);
                        return(true);
                    }
                }
                else if (flag2)
                {
                    element.SetValue(propertyKey, (object)false);
                    LayoutRoundingHelper.SetAutoLayoutRounding(element, true);
                    return(true);
                }
            }
            return(false);
        }