static private void WindowsControlDeseralizer(Window C) { if (C == null) { return; } DMT_Main_Window_Control_SaveState pp = new DMT_Main_Window_Control_SaveState( ); XmlSerializer x = new XmlSerializer(pp.GetType( )); StringReader XmlStringReader = new StringReader(XmlFileContents); XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { IgnoreComments = true, IgnoreProcessingInstructions = true, IgnoreWhitespace = true }; XmlReader xmlReader = XmlReader.Create(XmlStringReader, xmlReaderSettings); Object o = x.Deserialize(xmlReader); pp = ( DMT_Main_Window_Control_SaveState )o; C.Left = pp.Left; C.Top = pp.Top; }
static private void DMT_Main_Window_Control_SaveState_Seralize(UIElement E) { FrameworkElement FE = E as FrameworkElement; String StateFileName = String.Format("{0}.xml", FE.Name); DMT_Main_Window_Control_SaveState p = new DMT_Main_Window_Control_SaveState( ); p.CommonFields.ControlClass = nameof(Window); p.CommonFields.ControlName = FE.Name; p.CommonFields.SaveStateFileName = StateFileName; p.CommonFields.UpdatedFromXmlFiles = true; Window W = FE as Window; p.Left = W.Left; p.Top = W.Top; XmlSerializer x = new XmlSerializer(p.GetType( )); XmlWriterSettings s = new XmlWriterSettings { Indent = true, NewLineOnAttributes = true, OmitXmlDeclaration = true }; XmlWriter w = XmlWriter.Create(StateFileName, s); x.Serialize(w, p); w.Close( ); }