Пример #1
0
        public static void DetectLayoutOverrides(SceneElement element, PropertyReference propertyReference)
        {
            if (!element.IsAttached || LayoutUtilities.InLayoutMode)
            {
                return;
            }
            ReferenceStep   referenceStep    = propertyReference[0];
            LayoutOverrides layoutOverrides1 = LayoutOverrides.None;

            if (referenceStep.Equals((object)BaseFrameworkElement.HorizontalAlignmentProperty))
            {
                layoutOverrides1 |= LayoutOverrides.HorizontalAlignment;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.VerticalAlignmentProperty))
            {
                layoutOverrides1 |= LayoutOverrides.VerticalAlignment;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.MarginProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Margin;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.WidthProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Width;
            }
            else if (referenceStep.Equals((object)BaseFrameworkElement.HeightProperty))
            {
                layoutOverrides1 |= LayoutOverrides.Height;
            }
            if (layoutOverrides1 == LayoutOverrides.None)
            {
                return;
            }
            LayoutOverrides layoutOverrides2 = LayoutUtilities.GetLayoutOverrides(element);
            LayoutOverrides flags            = layoutOverrides2 & ~layoutOverrides1;

            if (layoutOverrides2 == flags)
            {
                return;
            }
            LayoutUtilities.SetLayoutOverrides(element, flags);
        }
Пример #2
0
        public static LayoutSettings GetLayoutSettingsFromElement(SceneElement element)
        {
            LayoutSettings layoutSettings = new LayoutSettings();

            layoutSettings.LayoutOverrides = (LayoutOverrides)element.GetComputedValue(DesignTimeProperties.LayoutOverridesProperty);
            if (element.Parent is GridElement)
            {
                layoutSettings.GridBox = LayoutUtilities.GetGridBoxFromElement(element);
                if (LayoutUtilities.PropertyIsExpression((SceneNode)element, GridElement.ColumnProperty) || LayoutUtilities.PropertyIsExpression((SceneNode)element, GridElement.ColumnSpanProperty) || (LayoutUtilities.PropertyIsExpression((SceneNode)element, GridElement.RowProperty) || LayoutUtilities.PropertyIsExpression((SceneNode)element, GridElement.RowSpanProperty)))
                {
                    layoutSettings.LayoutOverrides |= LayoutOverrides.GridBox;
                }
            }
            layoutSettings.HorizontalAlignment = (HorizontalAlignment)element.GetComputedValue(BaseFrameworkElement.HorizontalAlignmentProperty);
            if (LayoutUtilities.PropertyIsExpression((SceneNode)element, BaseFrameworkElement.HorizontalAlignmentProperty))
            {
                layoutSettings.LayoutOverrides |= LayoutOverrides.HorizontalAlignment;
            }
            layoutSettings.VerticalAlignment = (VerticalAlignment)element.GetComputedValue(BaseFrameworkElement.VerticalAlignmentProperty);
            if (LayoutUtilities.PropertyIsExpression((SceneNode)element, BaseFrameworkElement.VerticalAlignmentProperty))
            {
                layoutSettings.LayoutOverrides |= LayoutOverrides.VerticalAlignment;
            }
            layoutSettings.Width = (double)element.GetComputedValue(BaseFrameworkElement.WidthProperty);
            if (LayoutUtilities.PropertyIsExpression((SceneNode)element, BaseFrameworkElement.WidthProperty))
            {
                layoutSettings.LayoutOverrides |= LayoutOverrides.Width;
            }
            layoutSettings.Height = (double)element.GetComputedValue(BaseFrameworkElement.HeightProperty);
            if (LayoutUtilities.PropertyIsExpression((SceneNode)element, BaseFrameworkElement.HeightProperty))
            {
                layoutSettings.LayoutOverrides |= LayoutOverrides.Height;
            }
            layoutSettings.Margin = (Thickness)element.GetComputedValueAsWpf(BaseFrameworkElement.MarginProperty);
            if (LayoutUtilities.PropertyIsExpression((SceneNode)element, BaseFrameworkElement.MarginProperty))
            {
                layoutSettings.LayoutOverrides |= LayoutOverrides.Margin;
            }
            return(layoutSettings);
        }