示例#1
0
        /// <summary>
        /// save the info into file:
        /// Note each subform is saved in another file.
        /// </summary>
        internal static void SerializeToFiles(Dictionary <object, ComponentWrapper> componentWrapperList)
        {
            Dictionary <String, Dictionary <object, ComponentWrapper> > dictPerFileName = new Dictionary <String, Dictionary <object, ComponentWrapper> >();

            CreateDictionaryPerForm(dictPerFileName, componentWrapperList);

            // create file for each form or subform
            foreach (var filename in dictPerFileName.Keys)
            {
                RuntimeDesignerSerializer.SerializeToFile(filename, dictPerFileName[filename]);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        public static bool ControlsPersistencyClearPropertiesAndSaveVisiblePropertyOnly(String fileName)
        {
            bool success = true;

            if (File.Exists(fileName))
            {
                List <ControlItem> orgControlItems = RuntimeDesignerSerializer.DeSerializeFromFile(fileName);
                List <ControlItem> newControlItems = new List <ControlItem>();

                //for each control item save the Visible property and add it to the newProperties
                foreach (ControlItem controlItem in orgControlItems)
                {
                    List <PropertyItem> newProperties = new List <PropertyItem>();

                    foreach (PropertyItem propertyItem in controlItem.Properties)
                    {
                        if (propertyItem.Key.Equals(Constants.WinPropVisible))
                        {
                            newProperties.Add(propertyItem);
                        }
                    }

                    //only if there is property visible we need to add it to the newControlItems
                    if (newProperties.Count > 0)
                    {
                        controlItem.Properties = newProperties;
                        newControlItems.Add(controlItem);
                    }
                }

                // serialize newControlItems to file
                success = RuntimeDesignerSerializer.SerializeToFile(fileName, newControlItems);
            }

            return(success);
        }