コード例 #1
0
        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;
        }
コード例 #2
0
        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);
                }
            }
        }