Exemplo n.º 1
0
        static private void H_SliderUserControlDeseralizer(SeralizeControlCommonFields p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            Object O = LogicalTreeHelper.FindLogicalNode(MW, p.ControlName);

            if (!(O is H_Slider_UserControl1 HC))
            {
                return;
            }

            H_Slider_UserControl1_SaveState_Class pp = new H_Slider_UserControl1_SaveState_Class( );
            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                = ( H_Slider_UserControl1_SaveState_Class )o;
            HC.SliderValue    = pp.ResetValue;
            HC.SliderMaxValue = pp.MaxValue;
            HC.SliderMinValue = pp.MinValue;
        }
        public static void Seralize_H__Slider_UserControl1_SaveState(string ControlName, String StateFileName, H_Slider_UserControl1 ttyy)
        {
            H_Slider_UserControl1_SaveState_Class p = new H_Slider_UserControl1_SaveState_Class();

            p.SeralizeControlCommonFields.ControlClass      = nameof(H_Slider_UserControl1);
            p.SeralizeControlCommonFields.ControlName       = ControlName;
            p.SeralizeControlCommonFields.SaveStateFileName = StateFileName;
            p.ResetValue = ttyy.SliderValue;
            p.MaxValue   = ( float )ttyy.SliderMaxValue;
            p.MinValue   = ( float )ttyy.SliderMinValue;

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

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

            x.Serialize(w, p);
            w.Close( );
        }
        public static H_Slider_UserControl1_SaveState_Class Deseralize_H_Slider_UserControl1(String F, H_Slider_UserControl1 HC)
        {
            Debug.WriteLine(String.Format("{0} {1}", nameof(Deseralize_H_Slider_UserControl1), F));

            if (!System.IO.File.Exists(F))
            {
                return(null);
            }

            String XmlFileContents = System.IO.File.ReadAllText(F);

            StringReader XmlStringReader = new StringReader(XmlFileContents);

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
            {
                IgnoreComments = true,
                IgnoreProcessingInstructions = true,
                IgnoreWhitespace             = true
            };

            XmlReader xmlReader = XmlReader.Create(XmlStringReader, xmlReaderSettings);

            while (!xmlReader.EOF)
            {
                switch (xmlReader.NodeType)
                {
                case XmlNodeType.Attribute:
                case XmlNodeType.CDATA:
                case XmlNodeType.Comment:
                case XmlNodeType.Document:
                case XmlNodeType.DocumentFragment:
                case XmlNodeType.DocumentType:

                case XmlNodeType.Element:

                    H_Slider_UserControl1_SaveState_Class pp = new H_Slider_UserControl1_SaveState_Class( );
                    XmlSerializer x = new XmlSerializer(pp.GetType( ));

                    object o = x.Deserialize(xmlReader);
                    pp = ( H_Slider_UserControl1_SaveState_Class )o;

                    HC.SliderValue    = pp.ResetValue;
                    HC.SliderMaxValue = pp.MaxValue;
                    HC.SliderMinValue = pp.MinValue;
                    return(pp);

                case XmlNodeType.EndElement:
                case XmlNodeType.EndEntity:
                case XmlNodeType.Entity:
                case XmlNodeType.EntityReference:
                case XmlNodeType.None:
                case XmlNodeType.Notation:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Text:
                case XmlNodeType.Whitespace:
                case XmlNodeType.XmlDeclaration:
                    break;

                default:
                    break;
                }

                Boolean State = xmlReader.Read( );
            }

            return(null);
        }