Exemple #1
0
        static private void RadioButtonControlDeseralizer(SeralizeControlCommonFields p)
        {
            Object O = LogicalTreeHelper.FindLogicalNode(MW, p.ControlName);

            if (!(O is RadioButton RB))
            {
                return;
            }

            RadioCheckBoxSaveState pp = new RadioCheckBoxSaveState( );

            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           = ( RadioCheckBoxSaveState )o;
            RB.IsChecked = pp.RadioCheckBoxState;
        }
Exemple #2
0
        static private void RadioCheckBoxSerialize(string nameString, UIElement E)
        {
            if (!(E is RadioButton RB))
            {
                return;
            }

            String StateFileName = String.Format("{0}.xml", nameString);

            RadioCheckBoxSaveState p = new RadioCheckBoxSaveState( );

            p.CommonFields.SaveStateFileName   = StateFileName;
            p.CommonFields.ControlName         = RB.Name;
            p.CommonFields.ControlClass        = nameof(RadioButton);
            p.CommonFields.UpdatedFromXmlFiles = true;

            p.RadioCheckBoxState = RB.IsChecked.Value;
            p.RadioCheckBoxName  = RB.Name;
            p.RadioGroupName     = RB.GroupName;

            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( );
        }