public static LayoutRoundingStatus GetLayoutRoundingStatus(SceneElement element) { if (!LayoutRoundingHelper.ShouldConsiderLayoutRoundingAdjustment(element)) { return(LayoutRoundingStatus.Off); } IProperty property = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)element); if (property == null || !LayoutRoundingHelper.GetUseLayoutRounding(element)) { return(LayoutRoundingStatus.Off); } LayoutRoundingStatus layoutRoundingStatus = LayoutRoundingStatus.On; bool flag = element.IsSet((IPropertyId)property) == PropertyState.Set; if (!flag && PlatformTypes.Path.IsAssignableFrom((ITypeId)element.Type)) { layoutRoundingStatus |= LayoutRoundingStatus.ShouldTurnOff; } else if (LayoutRoundingHelper.IsAxisAligned(element)) { layoutRoundingStatus |= LayoutRoundingStatus.ShouldSnapToPixel; } else if (!flag || LayoutRoundingHelper.GetAutoLayoutRounding(element)) { layoutRoundingStatus |= LayoutRoundingStatus.ShouldTurnOff; } return(layoutRoundingStatus); }
public void Restore(bool forceClearPropertyInspector) { if (this.storedValues == null) { return; } IProperty propertyKey = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)Enumerable.FirstOrDefault <SceneElement>((IEnumerable <SceneElement>) this.storedValues.Keys)); if (propertyKey != null) { foreach (KeyValuePair <SceneElement, bool?> keyValuePair in this.storedValues) { IViewObject viewObject = keyValuePair.Key.ViewObject; if (keyValuePair.Key.IsViewObjectValid) { bool?nullable = keyValuePair.Value; if (nullable.HasValue) { viewObject.SetValue((ITypeResolver)keyValuePair.Key.ProjectContext, propertyKey, (object)(bool)(nullable.Value ? true : false)); } else { viewObject.ClearValue(propertyKey); if (forceClearPropertyInspector) { LayoutRoundingOverride.ForceClearPropertyInspector((IPropertyId)propertyKey, keyValuePair.Key); } } LayoutRoundingOverride.InvalidateMeasure(viewObject); } } } this.storedValues = (Dictionary <SceneElement, bool?>)null; }
internal void SetValue(IEnumerable <SceneElement> elements, bool value) { if (elements == null) { throw new ArgumentNullException("elements"); } this.Restore(false); IProperty propertyKey = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)Enumerable.FirstOrDefault <SceneElement>(elements)); if (propertyKey == null) { return; } this.storedValues = new Dictionary <SceneElement, bool?>(); foreach (SceneElement element in elements) { IViewObject viewObject = element.ViewObject; if (element.IsViewObjectValid && !value.Equals(viewObject.GetValue(propertyKey)) && LayoutRoundingHelper.GetLayoutRoundingStatus(element) == LayoutRoundingStatus.On) { this.storedValues[element] = !viewObject.IsSet(propertyKey) ? new bool?() : new bool?((bool)viewObject.GetValue(propertyKey)); viewObject.SetValue((ITypeResolver)element.ProjectContext, propertyKey, (object)(bool)(value ? true : false)); LayoutRoundingOverride.InvalidateMeasure(viewObject); } } }
public static void ExplicitlyChangeLayoutRounding(SceneNode targetNode, PropertyReference filteredProperty) { Base2DElement base2Delement = targetNode as Base2DElement; if (base2Delement == null || !LayoutRoundingHelper.IsUseLayoutRoundingProperty(targetNode, (IProperty)filteredProperty.LastStep)) { return; } LayoutRoundingHelper.SetAutoLayoutRounding((SceneElement)base2Delement, false); }
public static bool UpdateLayoutRounding(IEnumerable <SceneElement> elements) { bool flag = false; if (elements != null && LayoutRoundingHelper.ShouldConsiderLayoutRoundingAdjustment(Enumerable.FirstOrDefault <SceneElement>(elements))) { foreach (SceneElement element in elements) { flag |= LayoutRoundingHelper.UpdateLayoutRounding(element); } } return(flag); }
public static bool IsUseLayoutRoundingProperty(SceneNode node, IProperty property) { SceneElement sceneElement = node as SceneElement; if (sceneElement != null) { IProperty property1 = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)sceneElement); if (property1 != null && property1.Equals((object)property)) { return(true); } } return(false); }
public static Rect GetRoundedUpChildRect(ILayoutDesigner designer, BaseFrameworkElement element) { IPlatformGeometryHelper geometryHelper = element.Platform.GeometryHelper; IViewVisual visual = element.ViewObject as IViewVisual; if (geometryHelper.NeedRoundupLayoutRect(visual)) { using (IDisposable disposable = LayoutRoundingHelper.TurnOffLayoutRounding(element)) { if (disposable != null) { Rect childRect = designer.GetChildRect(element); return(geometryHelper.RoundupLayoutRect(childRect)); } } } return(designer.GetChildRect(element)); }
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); }
public static bool GetUseLayoutRounding(SceneElement element) { if (element != null && element.Type != null) { IProperty propertyKey = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)element); if (propertyKey != null) { if (propertyKey.DeclaringType.IsAssignableFrom((ITypeId)element.Type)) { return((bool)element.GetComputedValue((IPropertyId)propertyKey)); } FrameworkTemplateElement frameworkTemplateElement = element as FrameworkTemplateElement; if (frameworkTemplateElement != null) { IViewObject viewTargetElement = frameworkTemplateElement.ViewTargetElement; if (viewTargetElement != null && propertyKey.DeclaringType.IsAssignableFrom((ITypeId)viewTargetElement.GetIType((ITypeResolver)element.ProjectContext))) { return((bool)viewTargetElement.GetCurrentValue(propertyKey)); } } } } return(false); }