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