Exemplo n.º 1
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;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public List <ControlItem> ExecuteDeSerializeFromFileCommand()
 {
     return(RuntimeDesignerSerializer.DeSerializeFromFile(GetFileName()));
 }
Exemplo n.º 3
0
        public void ExecuteSaveCommand()
        {
            RuntimeDesignerSerializer.SerializeToFiles(RuntimeHostSurface.ComponentsDictionary);

            RuntimeDesignerHandleState.SaveState(GetFileName(), RuntimeHostSurface.ComponentsDictionary);
        }