public Form1() { InitializeComponent(); System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; this.conf = new VilcomConfiguration(); this.conf = this.conf.loadFromFile(); this.excludes = new VilcomExcludes(); this.excludes = this.excludes.loadFromFile(); timer1.Enabled = true; Client = new UdpClient(conf.port); //загрузим парсер try { parseConf = new Parser(); parseConf.loadFromFile(); foreach (ParserRule ruleConf in parseConf.ruleList) { TrapGrid.Columns.Add(ruleConf.param, ruleConf.name); } _debug("Конфигурация парсера загружена!"); } catch (Exception excp) { //MessageBox.Show("Внимание! Файл конфигурации парсера не найден или был утерян"); } //попытаемся подгрузить данные из трапа if (File.Exists("state.data")) { tList.loadFromFile(); foreach (Trap trapTemp in tList.dataList) { addTrapToGrid(trapTemp); } } taskbarNotifier = new TaskbarNotifier(); taskbarNotifier.SetBackgroundBitmap("notifyback.bmp", Color.FromArgb(255, 0, 255)); taskbarNotifier.SetCloseBitmap("close.bmp", Color.FromArgb(255, 0, 255), new Point(220, 8)); taskbarNotifier.TitleRectangle = new Rectangle(20, 9, 70, 2); taskbarNotifier.ContentRectangle = new Rectangle(8, 20, 200, 68); taskbarNotifier.NormalContentFont = new Font("Arial",9); //taskbarNotifier.TitleClick += new EventHandler(TitleClick); //taskbarNotifier.ContentClick += new EventHandler(ContentClick); taskbarNotifier.CloseClick += new EventHandler(Close2Click); }
public VilcomConfiguration loadFromFile() { VilcomConfiguration self; try { //try to read from file XmlSerializer deserializer = new XmlSerializer(typeof(VilcomConfiguration)); TextReader textReader = new StreamReader(@filename); self = (VilcomConfiguration)deserializer.Deserialize(textReader); textReader.Close(); } catch (Exception e) { //set do default value self = new VilcomConfiguration(); self.port = 162; self.version = "v2"; self.community = "public"; } return self; }