| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace FietsClient
- {
- public partial class DoctorForm : Form
- {
- private DoctorModel doctorModel;
- public Forms.DoctorSummaryUC summaryUserControl { get; private set; }
- public DoctorForm(TcpConnection connection)
- {
- InitializeComponent();
- doctorModel = DoctorModel.doctorModel;
- doctorModel.doctorform = this;
- doctorModel.tcpConnection = connection;
- this.summaryUserControl = doctorSummaryUC1;
- DataHandler.IncomingErrorEvent += HandleError;
- connection.IncomingChatmessageEvent += new TcpConnection.ChatmassegeDelegate(printMessage);
- }
- private void HandleError(string error)
- {
- switch (error)
- {
- default:
- break;
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void messageBox_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == '\r')
- {
- messageButton_Click(sender, e);
- }
- }
- private void messageButton_Click(object sender, EventArgs e)
- {
- if (messageBox.Text != null)
- {
- String[] data = new String[2];
- data[0] = messageBox.Text;
- //current patient:
- data[1] = doctorTabControl.SelectedTab.Name;
- messageBox.Clear();
- doctorModel.tcpConnection.SendChatMessage(data);
- }
- }
- private void printMessage(string[] data)
- {
- string finalMessage = data[0] + ":\t\t" + data[2] + "\r\n";
- chatBox.Invoke((MethodInvoker) delegate ()
- {
- chatBox.AppendText(finalMessage);
- });
- }
- public void AddSessionToTabcontrol(string patientID)
- {
- TabPage page = new TabPage("Patientsession " + patientID);
- page.Name = patientID;
- Forms.DoctorSessionUC sessionUC = new Forms.DoctorSessionUC(patientID);
- sessionUC.Name = "sessionUC" + patientID;
- doctorModel.doctorSessions.Add(patientID, sessionUC);
- doctorModel.doctorSessions.TryGetValue(patientID, out sessionUC);
- page.Controls.Add(sessionUC);
- doctorTabControl.TabPages.Add(page);
- }
- public void RemoveSessionFromTabcontrol(string patientID)
- {
- doctorTabControl.TabPages.RemoveByKey(patientID);
- }
- private void DoctorForm_FormClosing(object sender, FormClosingEventArgs e)
- {
- doctorModel.stopAskingData();
- doctorModel.tcpConnection.disconnect();
- Application.Exit();
- }
- }
- }
|