Example #1
0
        /// <summary>
        /// Create a PropertyDescriptor which wraps a real property of the control
        /// </summary>
        /// <param name="keyProp"></param>
        /// <param name="controlDesignerInfo"></param>
        /// <param name="component"></param>
        /// <param name="nativeProp"></param>
        /// <returns></returns>
        private static PropertyDescriptor CreateDescriptorForRealProperty(KeyValuePair <string, DesignerPropertyInfo> keyProp, ControlDesignerInfo controlDesignerInfo, object component, PropertyDescriptor nativeProp, string name)
        {
            object valueItem = keyProp.Value.Value;

            ISetPropertyData setPropertyData = GetSetDataStrategy(ref keyProp, ref valueItem,
                                                                  controlDesignerInfo, component);

            Attribute[] attrs = GetAttribute(keyProp);

            RTDesignerPropertyDescriptor propertyDescriptor = new RTDesignerPropertyDescriptor(component, nativeProp, valueItem, name ?? nativeProp.DisplayName, attrs)
            {
                SetDataStrategy = setPropertyData
            };

            propertyDescriptor.SetTranslator(GetTranslator(component, keyProp.Key));

            propertyDescriptor.CanResetStrategy = GetCanRestStrategy(component, keyProp.Key);

            return(propertyDescriptor);
        }
Example #2
0
        /// <summary>
        /// returns the SetPropertyData strategy for this control and property
        /// </summary>
        /// <param name="keyProp"></param>
        /// <param name="valueItem"></param>
        /// <param name="controlDesignerInfo"></param>
        /// <param name="setPropertyData"></param>
        /// <param name="component"></param>
        private static ISetPropertyData GetSetDataStrategy(ref KeyValuePair <string, DesignerPropertyInfo> keyProp, ref object valueItem, ControlDesignerInfo controlDesignerInfo, object component)
        {
            ISetPropertyData setPropertyData = null;

            if (ComponentWrapper.IsCoordinateProperty(keyProp.Key))
            {
                valueItem       = ((int)valueItem) + controlDesignerInfo.GetPlacementForProp(keyProp.Key);
                setPropertyData = new RuntimeControlCoordinateStrategy((Control)component, keyProp.Key);
            }
            else if (keyProp.Key.Equals(Constants.WinPropBackColor))
            {
                setPropertyData = new BackgroundColorStrategy((Control)component);
            }
            else if (keyProp.Key.Equals(Constants.WinPropForeColor))
            {
                setPropertyData = new ForegroundColorStrategy((Control)component);
            }
            else if (keyProp.Key.Equals(Constants.WinPropFont))
            {
                setPropertyData = new FontStrategy((Control)component);
            }

            return(setPropertyData);
        }