示例#1
0
 private void btnReset_Click(object sender, RoutedEventArgs e)
 {
     int channels = XMLUtil.CHANNEL_COUNT;
     try
     {
         channels = int.Parse( txtChannelNum.Text );
     }
     catch (Exception ex)
     {
         MessageBox.Show( "请输入数字" );
         txtChannelNum.Text = XMLUtil.CHANNEL_COUNT.ToString();
         return;
     }
     XMLUtil.CHANNEL_COUNT = channels;
     _configInfo = XMLUtil.Reset();
     LoadConfig();
 }
示例#2
0
        public static XMLConfigInfo Load()
        {
            if (!File.Exists( CONFIG_FILE_NAME ))
            {
                return GetDefaultConfigInfo();
            }

            XMLConfigInfo config = new XMLConfigInfo();
            config.Decoders = new List<DecoderConfigInfo>();

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(CONFIG_FILE_NAME);
                XmlNodeList channels = doc.SelectNodes(DECODER_XPATH);
                foreach (XmlNode channel in channels)
                {
                    DecoderConfigInfo channelInfo = new DecoderConfigInfo();
                    foreach (XmlAttribute attribute in channel.Attributes)
                    {
                        if (attribute.Name == "Id")
                        {
                            channelInfo.Id = int.Parse(attribute.Value);
                        }
                        else if (attribute.Name == "BiteRate")
                        {
                            channelInfo.BitRate = int.Parse(attribute.Value);
                        }
                        else if (attribute.Name == "FrameRate")
                        {
                            channelInfo.FrameRate = int.Parse(attribute.Value);
                        }
                    }

                    config.Decoders.Add(channelInfo);
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.Message);
                return GetDefaultConfigInfo();
            }

            return config;
        }
示例#3
0
        public static void Save(XMLConfigInfo config)
        {
            XmlDocument doc = new XmlDocument();
            XmlNode node = doc.CreateNode( XmlNodeType.XmlDeclaration, "", "" );
            doc.AppendChild( node );
            XmlElement root = doc.CreateElement( "RTSP" );
            doc.AppendChild( root );

            foreach (DecoderConfigInfo channel in config.Decoders)
            {
                XmlElement channelNode = doc.CreateElement( "Channel" );
                channelNode.SetAttribute( "Id", channel.Id.ToString() );
                channelNode.SetAttribute( "BiteRate", channel.BitRate.ToString() );
                channelNode.SetAttribute("FrameRate", channel.FrameRate.ToString());
                root.AppendChild( channelNode );
            }

            doc.Save( CONFIG_FILE_NAME );
        }
示例#4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ServiceConfigInfo serverInfo = RegUtil.Load();
            if (serverInfo.DirectoryIP != IPAddress.None )
            {
                txtIP.Text = serverInfo.DirectoryIP.ToString();
            }
            if (serverInfo.Port != 0)
            {
                txtPort.Text = serverInfo.Port.ToString();
            }
            if ( !string.IsNullOrEmpty( serverInfo.Web ))
            {
                txtWeb.Text = serverInfo.Web;
            }

            _configInfo = XMLUtil.Load();
            LoadConfig();
        }
示例#5
0
        private static XMLConfigInfo GetDefaultConfigInfo()
        {
            XMLConfigInfo config = new XMLConfigInfo();
            config.Decoders = new List<DecoderConfigInfo>();
            for (int i = 0; i < CHANNEL_COUNT; i++)
            {
                DecoderConfigInfo channel = new DecoderConfigInfo();
                channel.Id = i;
                channel.BitRate = BITE_RATE;
                channel.FrameRate = FRAME_RATE;
                config.Decoders.Add( channel );
            }

            Save( config );

            return config;
        }