public ManageUsersTool(string id) { InitializeComponent(); //verbinden met de server om registratie af te handelen TcpClient TcpClient = new TcpClient(_server, _port); _client = new ClientTcpConnector(TcpClient, _server); this._id = id; _labelRemoveTimer = new Timer(); _labelRemoveTimer.Interval = 3000; _labelRemoveTimer.Tick += UpdateLabel; this.FormClosing += ManageUsersTool_FormClosing; this.dataGridView1.EditingControlShowing += this.dataGridView1_EditingControlShowing; this.dataGridView1.CellFormatting += dataGridView1_CellFormatting; this.dataGridView1.CellValueChanged += dataGridView1_CellValueChanged; this.dataGridView1.CellLeave += dataGridView1_CellLeave; this.dataGridView1.CellBeginEdit += dataGridView1_CellBeginEdit; _client.sendFirstConnectPacket(id + "m", "nopassword"); Console.WriteLine(_client.ReadMessage()._message); LoadUsers(false); }
public DoctorClient() { InitializeComponent(); setVisibility(false); this.FormClosing += on_Window_Closed_Event; //opzetten tcp connectie TcpClient TcpClient = new TcpClient(server, port); client = new ClientTcpConnector(TcpClient, server); // haalt de de actieve clients op elke 1s getActiveClientsTimer = new System.Windows.Forms.Timer(); getActiveClientsTimer.Interval = 1000; getActiveClientsTimer.Tick += updateActiveClients; // timer voor het verwijderen van de errortekst na 3s, 'cosmetisch' labelRemoveTimer = new System.Windows.Forms.Timer(); labelRemoveTimer.Interval = 3000; labelRemoveTimer.Tick += UpdateLabel; // height moet je handmatig zetten..... OverviewTable.RowTemplate.MinimumHeight = 50; new Thread(() => { while (true) { if (userIsAuthenticated) { Packet packet = null; if (client.isConnected()) { packet = client.ReadMessage(); if (packet != null) { processPacket(packet); } } } } }).Start(); }
public ClientGui() { bool success = false; InitializeComponent(); _graph = new Graph(); _graph.Initialize_Checkboxes_Client(); _graph.InitializeChart_Client(); _graph.InitializeGraph(); AddGraphToForm(); this.FormClosing += on_Window_Closed_Event; setVisibility(false); // update waarden met de data van de fiets _updateDataTimer = new Timer(); _updateDataTimer.Interval = 1000; _updateDataTimer.Tick += UpdateGUI; // timer voor het verwijderen van de errortekst, 'cosmetisch' _labelRemoveTimer = new Timer(); _labelRemoveTimer.Interval = 3000; _labelRemoveTimer.Tick += UpdateLabel; if(SIM_ON) { Connect("SIM"); } else { Connect(""); } _bikeController.LockPower(); try { //opzetten tcp connectie TcpClient TcpClient = new TcpClient(_server, _port); _client = new ClientTcpConnector(TcpClient, _server); new System.Threading.Thread(() => { while (true) { if (_userIsAuthenticated) { Packet packet = null; if (_client.isConnected() && !this.IsDisposed) { //Console.WriteLine("Reading message\n"); packet = _client.ReadMessage(); if (packet != null) { processPacket(packet); } } } System.Threading.Thread.Sleep(5); } }).Start(); success = true; } catch (SocketException) { MessageBox.Show("Could not connect to the server, trying to reconnect"); success = false; } catch (TimeoutException) { MessageBox.Show("Lost connection to the server (timed out), trying to reconnect"); success = false; } catch (Exception e) { MessageBox.Show("An error occured: " + e.Message); success = false; } //rewrite this to make the the reconnection finally { if (!success) { //opzetten tcp connectie TcpClient TcpClient = new TcpClient(_server, _port); _client = new ClientTcpConnector(TcpClient, _server); new System.Threading.Thread(() => { while (true) { if (_userIsAuthenticated) { Packet packet = null; if (_client.isConnected() && !this.IsDisposed) { //Console.WriteLine("Reading message\n"); packet = _client.ReadMessage(); if (packet != null) { processPacket(packet); } } } System.Threading.Thread.Sleep(5); } }).Start(); } } }
public DoctorClient() { InitializeComponent(); bool success = false; setVisibility(false); this.FormClosing += on_Window_Closed_Event; // timer voor het verwijderen van de errortekst na 3s, 'cosmetisch' _labelRemoveTimer = new System.Windows.Forms.Timer(); _labelRemoveTimer.Interval = 3000; _labelRemoveTimer.Tick += UpdateLabel; // height van de table moet je handmatig setten..... OverviewTable.RowTemplate.MinimumHeight = 50; try { //opzetten tcp connectie TcpClient TcpClient = new TcpClient(_server, _port); _client = new ClientTcpConnector(TcpClient, _server); // haalt de de actieve clients op elke 1s _getActiveClientsTimer = new System.Windows.Forms.Timer(); _getActiveClientsTimer.Interval = 1000; _getActiveClientsTimer.Tick += updateActiveClients; new Thread(() => { while (true) { if (_userIsAuthenticated) { Packet packet = null; if (_client.isConnected() && !this.IsDisposed) { packet = _client.ReadMessage(); if (packet != null) { processPacket(packet); } } } Thread.Sleep(5); } }).Start(); success = true; } catch (SocketException) { MessageBox.Show("Could not connect to the server, trying to reconnect"); success = false; } catch (TimeoutException) { MessageBox.Show("Server Time Out, trying to reconnect"); success = false; } finally { if (!success) { //opzetten tcp connectie TcpClient TcpClient = new TcpClient(_server, _port); _client = new ClientTcpConnector(TcpClient, _server); // haalt de de actieve clients op elke 1s _getActiveClientsTimer = new System.Windows.Forms.Timer(); _getActiveClientsTimer.Interval = 1000; _getActiveClientsTimer.Tick += updateActiveClients; new Thread(() => { while (true) { if (_userIsAuthenticated) { Packet packet = null; if (_client.isConnected() && !this.IsDisposed) { packet = _client.ReadMessage(); if (packet != null) { processPacket(packet); } } } Thread.Sleep(5); } }).Start(); } } }