コード例 #1
0
ファイル: RuntimeHostLoader.cs プロジェクト: rinavin/RCJS
        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;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #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);
        }