Пример #1
0
        /// <summary>
        /// components dropped on tab page panel - set the layer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void MgTabControl_ComponentDropped(object sender, ComponentDroppedArgs e)
        {
            int layer = GetCurrentTabControlLayer((MgTabControl)((Control)sender).Parent.Parent);

            foreach (Object item in e.Components)
            {
                if (item is Control)
                {
                    ComponentWrapper cw = ComponentsDictionary[item];
                    cw.PropertiesDescriptors[Constants.WinPropLayer].SetValue(cw, layer);
                }
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal string GetFileName()
        {
            RuntimeHostSurface runtimeHostSurface = this.CurrentDocumentsHostControl.HostSurface;
            Form   form     = CurrentDocumentsHostControl.DesignerHost.RootComponent as Form;
            String fileName = "";

            if (runtimeHostSurface.ComponentsDictionary.ContainsKey(form))
            {
                ComponentWrapper   cw = runtimeHostSurface.ComponentsDictionary[form];
                PropertyDescriptor pd = cw.PropertiesDescriptors[Constants.ConfigurationFilePropertyName];
                if (pd != null) //for tests
                {
                    fileName = pd.GetValue(form) as String;
                }
            }

            return(fileName);
        }
Пример #3
0
        private void DeserializeXMLfile(String fileName)
        {
            // get the file info
            List <ControlItem> controlItemsList = RuntimeDesignerSerializer.DeSerializeFromFile(fileName);

            if (controlItemsList != null && IsControlItemsListValid(fileName, controlItemsList))
            {
                // loop on all components
                foreach (var keyValue in runtimeHostSurface.ComponentsDictionary) // key - component, value - ComponentWrapper
                {
                    Control             control             = (Control)keyValue.Key;
                    ComponentWrapper    cw                  = keyValue.Value;
                    ControlDesignerInfo controlDesignerInfo = ((ControlDesignerInfo)control.Tag);
                    if (fileName.Equals(controlDesignerInfo.FileName))
                    {
                        int isn = controlDesignerInfo.Isn;
                        // try and get the info for this component from the file info
                        ControlItem controlItem = controlItemsList.Find(x => x.Isn == isn);
                        if (controlItem != null && controlItem.Properties != null)
                        {
                            if (!controlDesignerInfo.ControlType.ToString().Equals(controlItem.ControlType))
                            {
                                return;
                            }

                            // set the value for and every each property
                            foreach (var item in controlItem.Properties)
                            {
                                object value = item.GetValue();
                                if (ComponentWrapper.IsCoordinateProperty(item.Key))
                                {
                                    value = ((int)value) + controlDesignerInfo.GetPlacementForProp(item.Key);
                                }
                                cw.PropertiesDescriptors[item.Key].SetValue(keyValue.Key, value);
                                if (item.Key == Constants.WinPropVisible)
                                {
                                    control.Visible = false;
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
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);
        }
Пример #5
0
 /// <summary>
 /// Create the ComponentWrapper object for this component
 /// </summary>
 /// <param name="control"></param>
 internal void CreateComponentWrapper(Control control)
 {
     Debug.Assert(!componentsDictionary.ContainsKey(control));
     componentsDictionary[control] = new ComponentWrapper(control, AdminMode);
 }