private void MainForm_Load(object sender, EventArgs e) { try { Config.Load("config.xml"); ConsoleMessage("Data loaded successfully."); image = new GrayImage(Config.getInstance().ResolutionX, Config.getInstance().ResolutionY); image.ImageGenerated += image_ImageGenerated; image.StartGenerate(Config.getInstance().FrameRate); connection = new TcpConnection(Config.getInstance().Ip, Config.getInstance().Port.ToString()); connection.DataSent += connection_DataSent; connection.ShowMessage += ConsoleMessage; connection.StartSend(Config.getInstance().NetSpeed); } catch (ArgumentException ex) { ConsoleMessage(ex.Message); return; } catch (FormatException ex) { ConsoleMessage(ex.Message); return; } catch (Exception ex) { ConsoleMessage(ex.Message); ConsoleMessage("Default data loaded."); } }