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); }
//loads of data etc... (joke) public clientTab(string tabName, ClientTcpConnector client, string id) { this._client = client; this._id = id; this._tabName = tabName; graph = new Graph(); graph.Initialize_Checkboxes_Doctor(); graph.InitializeChart_Doctor(); graph.InitializeGraph(); AddGraphToForm(); #region Close Buttons //close button closeButton.Location = new System.Drawing.Point(1070, 600); closeButton.Text = "Close"; //close all but this button closeAllButThisButton.Location = new System.Drawing.Point(1150, 600); closeAllButThisButton.Text = "Close all"; #endregion #region chatbox //ChatBox chatBox.AllowDrop = true; chatBox.BackColor = System.Drawing.Color.WhiteSmoke; chatBox.Location = new System.Drawing.Point(20, 350); chatBox.Multiline = true; chatBox.Name = "txtLog"; chatBox.ReadOnly = true; chatBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; chatBox.Size = new System.Drawing.Size(980, 250); chatBox.TabIndex = 6; chatBox.TextChanged += new System.EventHandler(this.txtLog_TextChanged); //TypeBox typeBox.Location = new System.Drawing.Point(20, 603); typeBox.Name = "typeBox"; typeBox.Size = new System.Drawing.Size(902, 20); typeBox.TabIndex = 9; typeBox.KeyDown += new System.Windows.Forms.KeyEventHandler(txtLog_KeyDown); //sendButton sendButtonClient.Location = new System.Drawing.Point(928, 600); sendButtonClient.Name = "SendMessage"; sendButtonClient.Size = new System.Drawing.Size(75, 23); sendButtonClient.TabIndex = 10; sendButtonClient.Text = "Send"; sendButtonClient.UseVisualStyleBackColor = true; sendButtonClient.Click += new System.EventHandler(this.sendButton_Click); #endregion #region update Power Button // // updatePowerButton // updatePowerButton.Location = new System.Drawing.Point(760, 437); updatePowerButton.Name = "updatePowerButton"; updatePowerButton.Size = new System.Drawing.Size(63, 35); updatePowerButton.TabIndex = 38; updatePowerButton.Text = "Update"; updatePowerButton.UseVisualStyleBackColor = true; #endregion #region TimeRunning // // TIME // TimeRunning_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); TimeRunning_Box.ImeMode = System.Windows.Forms.ImeMode.Hiragana; TimeRunning_Box.Location = new System.Drawing.Point(220, 20); TimeRunning_Box.Name = "TimeRunning_Box"; TimeRunning_Box.ReadOnly = true; TimeRunning_Box.Size = new System.Drawing.Size(200, 30); TimeRunning_Box.TabIndex = 21; TimeRunning_Box.TabStop = false; timeRunningLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); timeRunningLabel.Location = new System.Drawing.Point(20, 20); timeRunningLabel.Name = "label1"; timeRunningLabel.Size = new System.Drawing.Size(200, 30); timeRunningLabel.TabIndex = 20; timeRunningLabel.Text = "Time Running"; #endregion #region speed // // SPEED // speedLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); speedLabel.Location = new System.Drawing.Point(20, 55); speedLabel.Name = "label7"; speedLabel.Size = new System.Drawing.Size(200, 30); speedLabel.TabIndex = 27; speedLabel.Text = "Speed"; Speed_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Speed_Box.Location = new System.Drawing.Point(220, 55); Speed_Box.Name = "Speed_Box"; Speed_Box.ReadOnly = true; Speed_Box.Size = new System.Drawing.Size(200, 30); Speed_Box.TabIndex = 34; #endregion #region Distance // // DISTANCE // distanceLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); distanceLabel.Location = new System.Drawing.Point(20, 90); distanceLabel.Name = "label2"; distanceLabel.Size = new System.Drawing.Size(200, 30); distanceLabel.TabIndex = 22; distanceLabel.Text = "Distance"; Distance_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Distance_Box.Location = new System.Drawing.Point(220, 90); Distance_Box.Name = "Distance_Box"; Distance_Box.ReadOnly = true; Distance_Box.Size = new System.Drawing.Size(200, 30); Distance_Box.TabIndex = 33; #endregion #region Brake // // BRAKE // brakeLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); brakeLabel.Location = new System.Drawing.Point(20, 125); brakeLabel.Name = "label6"; brakeLabel.Size = new System.Drawing.Size(200, 30); brakeLabel.TabIndex = 26; brakeLabel.Text = "Brake"; Brake_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Brake_Box.Location = new System.Drawing.Point(220, 125); Brake_Box.Name = "Brake_Box"; Brake_Box.ReadOnly = true; Brake_Box.Size = new System.Drawing.Size(200, 30); Brake_Box.TabIndex = 32; #endregion #region Power // // POWER // Power_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Power_Box.Location = new System.Drawing.Point(220, 160); Power_Box.Name = "Power_Box"; Power_Box.ReadOnly = true; Power_Box.Size = new System.Drawing.Size(200, 30); Power_Box.TabIndex = 31; powerLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); powerLabel.Location = new System.Drawing.Point(20, 160); powerLabel.Name = "label5"; powerLabel.Size = new System.Drawing.Size(200, 30); powerLabel.TabIndex = 25; powerLabel.Text = "Power"; #endregion #region Energy // // ENERGY // Energy_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Energy_Box.Location = new System.Drawing.Point(220, 195); Energy_Box.Name = "Energy_Box"; Energy_Box.ReadOnly = true; Energy_Box.Size = new System.Drawing.Size(200, 30); Energy_Box.TabIndex = 30; energyLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); energyLabel.Location = new System.Drawing.Point(20, 195); energyLabel.Name = "label3"; energyLabel.Size = new System.Drawing.Size(200, 30); energyLabel.TabIndex = 23; energyLabel.Text = "Energy"; #endregion #region Heart Beats // // HEARTBEATS // heartBeatsLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); heartBeatsLabel.Location = new System.Drawing.Point(20, 230); heartBeatsLabel.Name = "label4"; heartBeatsLabel.Size = new System.Drawing.Size(200, 30); heartBeatsLabel.TabIndex = 24; heartBeatsLabel.Text = "Heartbeats"; Heartbeats_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Heartbeats_Box.Location = new System.Drawing.Point(220, 230); Heartbeats_Box.Name = "Heartbeats_Box"; Heartbeats_Box.ReadOnly = true; Heartbeats_Box.Size = new System.Drawing.Size(200, 30); Heartbeats_Box.TabIndex = 29; #endregion #region RPM // // RPM // RPM_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); RPM_Box.Location = new System.Drawing.Point(220, 265); RPM_Box.Name = "RPM_Box"; RPM_Box.ReadOnly = true; RPM_Box.Size = new System.Drawing.Size(200, 30); RPM_Box.TabIndex = 28; RPMLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); RPMLabel.Location = new System.Drawing.Point(20, 265); RPMLabel.Name = "label8"; RPMLabel.Size = new System.Drawing.Size(200, 30); RPMLabel.TabIndex = 35; RPMLabel.Text = "RPM"; #endregion #region New Powerbox // // NEW POERRBOX // newPowerBox.AcceptsReturn = true; newPowerBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); newPowerBox.Location = new System.Drawing.Point(220, 310); newPowerBox.Name = "newPowerBox"; newPowerBox.Size = new System.Drawing.Size(200, 30); newPowerBox.TabIndex = 37; newPowerBox.Text = "Enter new value"; newPowerBox.GotFocus += new System.EventHandler(this.newPowerBox_GotFocus); newPowerBox.Leave += new System.EventHandler(this.newPowerBox_Leave); newPowerBox.KeyDown += new System.Windows.Forms.KeyEventHandler(newPowerBox_KeyDown); newPowerLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); newPowerLabel.Location = new System.Drawing.Point(20, 310); newPowerLabel.Name = "label9"; newPowerLabel.Size = new System.Drawing.Size(200, 30); newPowerLabel.TabIndex = 36; newPowerLabel.Text = "New power"; #endregion #region add components //add components this.Controls.Add(closeButton); this.Controls.Add(closeAllButThisButton); this.Controls.Add(chatBox); this.Controls.Add(typeBox); this.Controls.Add(sendButtonClient); this.Controls.Add(updatePowerButton); this.Controls.Add(newPowerBox); this.Controls.Add(newPowerLabel); this.Controls.Add(RPMLabel); this.Controls.Add(Speed_Box); this.Controls.Add(Distance_Box); this.Controls.Add(Brake_Box); this.Controls.Add(Power_Box); this.Controls.Add(Energy_Box); this.Controls.Add(Heartbeats_Box); this.Controls.Add(RPM_Box); this.Controls.Add(speedLabel); this.Controls.Add(brakeLabel); this.Controls.Add(powerLabel); this.Controls.Add(heartBeatsLabel); this.Controls.Add(energyLabel); this.Controls.Add(distanceLabel); this.Controls.Add(TimeRunning_Box); this.Controls.Add(timeRunningLabel); #endregion //set tab Settings this.Cursor = System.Windows.Forms.Cursors.Default; this.Location = new System.Drawing.Point(4, 22); this.Name = tabName; this.Padding = new System.Windows.Forms.Padding(3); this.Size = new System.Drawing.Size(1232, 631); //this.TabIndex = this.tabControl1.TabCount + 1; NOT NEEDED??? this.Text = tabName; this.UseVisualStyleBackColor = true; }
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(); } } }