Exemplo n.º 1
0
 private void DisposeCurrentObject(WDevice d, int indexD)
 {
     // Grid.SetRow(null, WDevice.WDrow);
     //  Grid.SetColumn(null, WDevice.WDcolumn);
     grid0.Children.Remove(d);
     ListOfDevices.RemoveAt(indexD);
     d.Dispose();
 }
Exemplo n.º 2
0
        private void FillGrid()
        {
            try
            {
                using (StreamReader instream = new StreamReader("WIFIMonitor.cfg"))
                {
                    string iline;
                    while ((iline = instream.ReadLine()) != null)
                    {
                        if (iline.StartsWith("#")) //comment
                        {
                            continue;
                        }

                        if (iline.Contains("$refresh"))
                        {
                            Configure(iline);
                            continue;
                        }

                        if (iline.Contains("$H")) //http type, WDeviceHttp
                        {
                            string[] ilArrH = new string[2];
                            ilArrH = iline.Split(';');
                            try
                            {
                                WDeviceHttp newBtn = new WDeviceHttp(ilArrH[0], ilArrH[1]);
                                Grid.SetRow(newBtn, WDevice.WDrow);
                                Grid.SetColumn(newBtn, WDevice.WDcolumn);
                                grid0.Children.Add(newBtn);
                                ListOfDevices.Add(newBtn);
                            }
                            catch (IndexOutOfRangeException ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                            catch
                            {
                                MessageBox.Show("Constructor exception");
                            }
                            continue;
                        }



                        string[] ilArr = new string[2];
                        ilArr = iline.Split(';');
                        try
                        {
                            WDevice newBtn = new WDevice(ilArr[0], ilArr[1]);



                            Grid.SetRow(newBtn, WDevice.WDrow);
                            Grid.SetColumn(newBtn, WDevice.WDcolumn);
                            grid0.Children.Add(newBtn);
                            ListOfDevices.Add(newBtn);
                        }
                        catch (IndexOutOfRangeException ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        catch
                        {
                            MessageBox.Show("Constructor exception");
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Configuration file WIFIMonitor.cfg missing or wrong format \n .. or something else happened wrong");
            }
        }