Пример #1
0
        static private void TabControlDeseralizer(SeralizeControlCommonFields p)
        {
            Object O = LogicalTreeHelper.FindLogicalNode(MW, p.ControlName);

            if (!(O is TabControl TC))
            {
                return;
            }

            TabControlSaveState pp = new TabControlSaveState( );

            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 = ( TabControlSaveState )o;
            TC.SelectedIndex = pp.SelectedIndex;
        }
Пример #2
0
        static private void SheetTabControlSeralize(UIElement e)
        {
            if (!(e is FrameworkElement FE))
            {
                return;
            }

            if (!(FE is TabControl TC))
            {
                return;
            }

            String nameString = TC.Name;

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

            TabControlSaveState TCS = new TabControlSaveState( );

            TCS.CommonFields.SaveStateFileName   = StateFileName;
            TCS.CommonFields.ControlClass        = nameof(TabControl);
            TCS.CommonFields.ControlName         = TC.Name;
            TCS.CommonFields.UpdatedFromXmlFiles = true;

            XmlSerializer x = new XmlSerializer(TCS.GetType( ));

            XmlWriterSettings s = new XmlWriterSettings
            {
                Indent = true,
                NewLineOnAttributes = true,
                OmitXmlDeclaration  = true
            };
            XmlWriter w = XmlWriter.Create(StateFileName, s);

            x.Serialize(w, TCS);
            w.Close( );
        }