コード例 #1
0
        /// <summary>
        /// Handles property change events for the listed classes of this rule.
        /// </summary>
        /// <param name="e">The event args.</param>
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            Guard.NotNull(() => e, e);

            if (e.DomainProperty.Id == PropertySchema.TypeDomainPropertyId)
            {
                if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                {
                    var property = (PropertySchema)e.ModelElement;

                    // Clear any previous DefaultValue of the property.
                    var defaultValueName = Reflector <PropertySchema> .GetPropertyName(x => x.RawDefaultValue);

                    var descriptor = TypeDescriptor.GetProperties(property)[defaultValueName];
                    descriptor.ResetValue(property);

                    // Repaint the owners compartment shape (to update the custom displayed text value)
                    if (property.Owner != null)
                    {
                        foreach (var shape in PresentationViewsSubject.GetPresentation(property.Owner))
                        {
                            CompartmentShape compartment = shape as CompartmentShape;
                            if (compartment != null)
                            {
                                compartment.Invalidate();
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Repaints the compartment shape for the given element.
        /// </summary>
        private static void RepaintCompartmentShape(CustomizableElementSchema element)
        {
            Guard.NotNull(() => element, element);

            foreach (var shape in PresentationViewsSubject.GetPresentation(element))
            {
                CompartmentShape compartment = shape as CompartmentShape;
                if (compartment != null)
                {
                    compartment.Invalidate();
                }
            }
        }