Exemplo n.º 1
0
        // <MenuItem Name="WiFi">
        //    <Threshold SigalBar="3" Count="1" />
        // </MenuItem>
        public static Config_TestWifi LoadFromXml(XElement elMenu)
        {
            Config_TestWifi config = new Config_TestWifi();

            if (elMenu == null)
            {
                return(config);
            }

            LoadFromXml(elMenu, config);
            foreach (XNode node in elMenu.Nodes())
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    XElement elMenuItem = node as XElement;
                    if (elMenuItem == null)
                    {
                        continue;
                    }

                    if (elMenuItem.Name == "Threshold") // only one is allowed
                    {
                        foreach (XAttribute attr in elMenuItem.Attributes())
                        {
                            if (attr.Name.LocalName == "SignalBar")
                            {
                                uint value = 0;
                                if ((attr.Value != null) &&
                                    uint.TryParse(attr.Value, out value))
                                {
                                    if (value > MAX_SIGSTRENTH_SIGBAR)
                                    {
                                        value = MAX_SIGSTRENTH_SIGBAR;                                // UI presentation
                                    }
                                    config.SigStrength_ThresholdSigBar = value;
                                }
                            }
                            else if (attr.Name.LocalName == "SignalQuality")
                            {
                                uint value = 0;
                                if ((attr.Value != null) &&
                                    uint.TryParse(attr.Value, out value))
                                {
                                    if (value > MAX_SIGSTRENTH_SIGQUALITY)
                                    {
                                        value = MAX_SIGSTRENTH_SIGQUALITY;                                    // in percentage
                                    }
                                    config.SigStrength_ThresholdSigQuality = value;
                                }
                            }
                            else if (attr.Name.LocalName == "Count")
                            {
                                uint value = 0;
                                if ((attr.Value != null) &&
                                    uint.TryParse(attr.Value, out value))
                                {
                                    if (value > MAX_SIGSTRENGTH_THRESHOLDCOUNT)
                                    {
                                        value = MAX_SIGSTRENGTH_THRESHOLDCOUNT;                                         // in percentage
                                    }
                                    config.SigStrength_ThresholdCount = value;
                                }
                            }
                        }
                    }
                }
            }
            return(config);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor of class TestWiFi
 /// </summary>
 public TestWiFi()
 {
     this.InitializeComponent();
     curConfig     = App.ConfigTestWifi;
     txtTitle.Text = String.Format(CultureInfo.CurrentCulture, App.LoadString("Test"), App.LoadString("Wifi"));
 }