示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="runtimeHostSurface"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        internal bool OnClose(RuntimeHostSurface runtimeHostSurface, String fileName)
        {
            bool cancelClose = false;

            if (HasBeenModified(fileName, runtimeHostSurface.ComponentsDictionary))
            {
                string       message = RuntimeHostSurface.GetTranslatedString(runtimeHostSurface, "Save changes?");
                string       title   = RuntimeHostSurface.GetTranslatedString(runtimeHostSurface, "Confirmation");
                DialogResult dr      = MessageBox.Show(message, title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

                switch (dr)
                {
                case DialogResult.Yes:
                    RuntimeDesignerSerializer.SerializeToFiles(runtimeHostSurface.ComponentsDictionary);
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                    cancelClose = true;
                    break;
                }
            }

            if (!cancelClose)
            {
                DropState(fileName);
            }

            return(cancelClose);
        }
示例#2
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]);
            }
        }
示例#3
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);
        }
示例#4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fileName"></param>
 internal String StateAsString(Dictionary <object, ComponentWrapper> componentWrapperList)
 {
     return(RuntimeDesignerSerializer.SerializeToString(componentWrapperList));
 }