private void connection_test_button_Click(object sender, EventArgs e) { AlertGUI temp3 = new AlertGUI(); temp3.setMessage("Attempting to connect to server....", ""); temp3.Show(); try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); temp3.Close(); temp3.Dispose(); AlertGUI temp5 = new AlertGUI(); conn.disconnect(); temp5.setMessage("Server Connected Successfully!", ""); Cursor.Current = Cursors.WaitCursor; temp5.ShowDialog(); Cursor.Current = Cursors.Arrow; } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find server"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; temp3.Close(); temp3.Dispose(); } }
public void ConnectionStuff() { try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); Server_Connection.DailyTask[] dts = conn.getTasks(); DailyTaskID = dts[0].idDailyTask; todaysTask = new WalkingTask(((Server_Connection.WalkingTask)dts[0]).steps); conn.disconnect(); } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Connection to server lost: Setting default task"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; todaysTask = new WalkingTask(500); } current_task = todaysTask.display(); tasksDialog.setStuff(this); this.myWiiData = new WiiRemoteData(); myWiiRemoteConnection = new WiiRemoteConnection(); myWiiRemoteConnection.connect(); this.myWiiData.processData(myWiiRemoteConnection); this.TodaysStats = new Queue <Stats>(); }
public void ConnectionStuff() { try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); Server_Connection.DailyTask[] dts = conn.getTasks(); DailyTaskID = dts[0].idDailyTask; todaysTask = new WalkingTask(((Server_Connection.WalkingTask)dts[0]).steps); conn.disconnect(); } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Connection to server lost: Setting default task"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; todaysTask = new WalkingTask(500); } current_task = todaysTask.display(); tasksDialog.setStuff(this); this.myWiiData = new WiiRemoteData(); myWiiRemoteConnection = new WiiRemoteConnection(); myWiiRemoteConnection.connect(); this.myWiiData.processData(myWiiRemoteConnection); this.TodaysStats = new Queue<Stats>(); }
override public void connect() { try { wm.Connect(); } catch { AlertGUI temp = new AlertGUI(); temp.setMessage("Wiimote not connected"); temp.ShowDialog(); } wm.SetReportType(InputReport.IRAccel, true); wm.SetLEDs(false, true, true, false); return; }
private void CreateControls() { tasksDialog = new DailyTasks(); statsDialog = new Statistics(); clinicianDialog = new ClinicianGUI(); alertDialog = new AlertGUI(); clinicianDialog.ControlBox = false; tasksDialog.ControlBox = false; statsDialog.ControlBox = false; alertDialog.ControlBox = false; statsDialog.Activate(); statsDialog.new_timer.Enabled = true; }
public override void connect() { try { wm.Connect(); } catch { AlertGUI temp = new AlertGUI(); temp.setMessage("Wiimote not connected"); temp.ShowDialog(); } wm.SetReportType(InputReport.IRAccel, true); wm.SetLEDs(false, true, true, false); return; }
public void exrtactConfigFile() { //Config file testing if (configFileExists()) { StreamReader readConfigFile = new StreamReader(configFilePath); string lastKnownTasks = killBrackets(readConfigFile.ReadLine()); string patientName = killBrackets(readConfigFile.ReadLine()); string hostname = killBrackets(readConfigFile.ReadLine()); string username = killBrackets(readConfigFile.ReadLine()); string password = killBrackets(readConfigFile.ReadLine()); string startTime = killBrackets(readConfigFile.ReadLine()); string endTime = killBrackets(readConfigFile.ReadLine()); string date = killBrackets(readConfigFile.ReadLine()); readConfigFile.Close(); mainMenuPointer.myConfig.lastKnownTasks = lastKnownTasks; mainMenuPointer.myConfig.patientName = patientName; mainMenuPointer.myConfig.hostname = hostname; mainMenuPointer.myConfig.username = username; mainMenuPointer.myConfig.password = password; mainMenuPointer.myConfig.startTime = startTime; mainMenuPointer.myConfig.endTime = endTime; mainMenuPointer.myConfig.date = date; } //else create new config file else { AlertGUI temp = new AlertGUI(); temp.setMessage("Config File doesnt exist"); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; createConfigFile(); } }
private void save_setup_button_Click(object sender, EventArgs e) { try { if (writeConfigFile(null, this.patient_name_textbox.Text, this.hostname_textbox.Text, this.username_textbox.Text, this.password_textbox.Text)) { AlertGUI temp = new AlertGUI(); temp.setMessage("File Written", "whatever"); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; temp.Dispose(); } } catch { try { if (writeConfigFile(null, this.patient_name_textbox.Text, this.hostname_textbox.Text, this.username_textbox.Text, this.password_textbox.Text)) { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("File Written", "whatever"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; temp2.Dispose(); } } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("File Not Written"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } } }
//Create a config file public bool writeConfigFile(string[] tasks, string patient_name, string hostname, string username, string password) { string tasks_string = ""; if (tasks == null) { } else { for (int i = 0; i < tasks.Length; ++i) { if ((i = tasks.Length - 1) > 0) { tasks_string += tasks[i]; } else { tasks_string += tasks[i] + ", "; } } } if (!Directory.Exists(activityMonitorDirectory)) { Directory.CreateDirectory(activityMonitorDirectory); } if (username.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return(false); } if (hostname.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return(false); } if (password.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return(false); } if (patient_name.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return(false); } //if config file exists, delete and create a new one if (configFileExists()) { deleteConfigFile(); } StreamWriter writeConfigFile = new StreamWriter(configFilePath); writeConfigFile.WriteLine("Last Known Tasks:\t {" + tasks_string + "}"); writeConfigFile.WriteLine("Patient Name:\t {" + patient_name + "}"); writeConfigFile.WriteLine("Hostname:\t {" + hostname + "}"); writeConfigFile.WriteLine("Username:\t {" + username + "}"); writeConfigFile.WriteLine("Password:\t {" + password + "}"); writeConfigFile.WriteLine("Starttime:\t {00:00:00}"); writeConfigFile.WriteLine("Endtime:\t {00:00:00}"); writeConfigFile.WriteLine("Date:\t {00/00/00}"); writeConfigFile.Close(); return(true); }
private void save_setup_button_Click(object sender, EventArgs e) { try { if (writeConfigFile(null, this.patient_name_textbox.Text, this.hostname_textbox.Text, this.username_textbox.Text, this.password_textbox.Text)) { AlertGUI temp = new AlertGUI(); temp.setMessage("File Written", "whatever"); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; temp.Dispose(); } } catch { try { if (writeConfigFile(null, this.patient_name_textbox.Text, this.hostname_textbox.Text, this.username_textbox.Text, this.password_textbox.Text)) { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("File Written","whatever"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; temp2.Dispose(); } } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("File Not Written"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } } }
//Create a config file public bool writeConfigFile(string[] tasks, string patient_name, string hostname, string username, string password) { string tasks_string = ""; if (tasks == null) { } else { for (int i = 0; i < tasks.Length; ++i) { if ((i = tasks.Length - 1) > 0) { tasks_string += tasks[i]; } else { tasks_string += tasks[i] + ", "; } } } if (!Directory.Exists(activityMonitorDirectory)) { Directory.CreateDirectory(activityMonitorDirectory); } if (username.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return false; } if (hostname.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return false; } if (password.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return false; } if (patient_name.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); Cursor.Current = Cursors.WaitCursor; temp.ShowDialog(); Cursor.Current = Cursors.Arrow; return false; } //if config file exists, delete and create a new one if (configFileExists()) { deleteConfigFile(); } StreamWriter writeConfigFile = new StreamWriter(configFilePath); writeConfigFile.WriteLine("Last Known Tasks:\t {" + tasks_string + "}"); writeConfigFile.WriteLine("Patient Name:\t {" + patient_name + "}"); writeConfigFile.WriteLine("Hostname:\t {" + hostname + "}"); writeConfigFile.WriteLine("Username:\t {" + username + "}"); writeConfigFile.WriteLine("Password:\t {" + password + "}"); writeConfigFile.WriteLine("Starttime:\t {00:00:00}"); writeConfigFile.WriteLine("Endtime:\t {00:00:00}"); writeConfigFile.WriteLine("Date:\t {00/00/00}"); writeConfigFile.Close(); return true; }
private void PreviousStats() { try { string statsFilePath = "C:\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "C:\\ActivityMonitor"; if (File.Exists(statsFilePath)) { StreamReader ReadStatsFile = new StreamReader(statsFilePath); Queue <string> previous = new Queue <string>(); int a = 7; while (a > 0) { a--; if (ReadStatsFile.EndOfStream == false) { previous.Enqueue(ReadStatsFile.ReadLine()); } else { previous.Enqueue("No stats saved,No stats saved"); } } //string TodaysStats = STEPS.ToString() + " Steps, " + statsDialog.steps_min_value.Text + " Steps/Min"; //previous.Push(TodaysStats); ReadStatsFile.Close(); Past[0] = previous.Dequeue(); Past[1] = previous.Dequeue(); Past[2] = previous.Dequeue(); Past[3] = previous.Dequeue(); Past[4] = previous.Dequeue(); Past[5] = previous.Dequeue(); Past[6] = previous.Dequeue(); } else { Past[0] = "No stats saved,No stats saved"; Past[1] = "No stats saved,No stats saved"; Past[2] = "No stats saved,No stats saved"; Past[3] = "No stats saved,No stats saved"; Past[4] = "No stats saved,No stats saved"; Past[5] = "No stats saved,No stats saved"; Past[6] = "No stats saved,No stats saved"; } } catch { Past[0] = "No stats saved,No stats saved"; Past[1] = "No stats saved,No stats saved"; Past[2] = "No stats saved,No stats saved"; Past[3] = "No stats saved,No stats saved"; Past[4] = "No stats saved,No stats saved"; Past[5] = "No stats saved,No stats saved"; Past[6] = "No stats saved,No stats saved"; AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find previous stats"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } }
private void quit_button_Click(object sender, EventArgs e) { //save summary of days tasks try { string statsFilePath = "C:\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "C:\\ActivityMonitor"; if(File.Exists(statsFilePath)) { StreamReader ReadStatsFile = new StreamReader(statsFilePath); Queue<string> previous= new Queue<string>(); int a = 6; while (a>0) { a--; previous.Enqueue(ReadStatsFile.ReadLine()); } string TodaysStats = STEPS.ToString() + "," + statsDialog.steps_min_value.Text ; //previous.Push(TodaysStats); ReadStatsFile.Close(); StreamWriter writeStatsFile = new StreamWriter(statsFilePath); writeStatsFile.WriteLine(TodaysStats); while(previous.Count()>0) { writeStatsFile.WriteLine(previous.Dequeue()); } writeStatsFile.Close(); } else { if (File.Exists(statsFilePath)) { return; } //if directory exists, create file if (Directory.Exists(activityMonitorDirectory)) { FileStream createConfigFile = File.Create(statsFilePath); createConfigFile.Close(); return; } //if directory doesnt exist, create file and directory if (!Directory.Exists(activityMonitorDirectory)) { Directory.CreateDirectory(activityMonitorDirectory); FileStream createConfigFile = File.Create(statsFilePath); createConfigFile.Close(); return; } } } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not save daily tasks"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } //sending data to the server try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); conn.setMainMenu(this); conn.sendStats(); } catch (Exception e5) { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find server"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } statsDialog.Close(); tasksDialog.Close(); Application.Exit(); Environment.Exit(0); }
private void connection_test_button_Click(object sender, EventArgs e) { AlertGUI temp3 = new AlertGUI(); temp3.setMessage("Attempting to connect to server....", ""); temp3.Show(); try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); temp3.Close(); temp3.Dispose(); AlertGUI temp5 = new AlertGUI(); conn.disconnect(); temp5.setMessage("Server Connected Successfully!",""); Cursor.Current = Cursors.WaitCursor; temp5.ShowDialog(); Cursor.Current = Cursors.Arrow; } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find server"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; temp3.Close(); temp3.Dispose(); } }
private void PreviousStats() { try { string statsFilePath = "C:\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "C:\\ActivityMonitor"; if (File.Exists(statsFilePath)) { StreamReader ReadStatsFile = new StreamReader(statsFilePath); Queue<string> previous = new Queue<string>(); int a = 7; while (a > 0) { a--; if (ReadStatsFile.EndOfStream == false) previous.Enqueue(ReadStatsFile.ReadLine()); else previous.Enqueue("No stats saved,No stats saved"); } //string TodaysStats = STEPS.ToString() + " Steps, " + statsDialog.steps_min_value.Text + " Steps/Min"; //previous.Push(TodaysStats); ReadStatsFile.Close(); Past[0] = previous.Dequeue(); Past[1] = previous.Dequeue(); Past[2] = previous.Dequeue(); Past[3] = previous.Dequeue(); Past[4] = previous.Dequeue(); Past[5] = previous.Dequeue(); Past[6] = previous.Dequeue(); } else { Past[0] = "No stats saved,No stats saved"; Past[1] = "No stats saved,No stats saved"; Past[2] = "No stats saved,No stats saved"; Past[3] = "No stats saved,No stats saved"; Past[4] = "No stats saved,No stats saved"; Past[5] = "No stats saved,No stats saved"; Past[6] = "No stats saved,No stats saved"; } } catch { Past[0] = "No stats saved,No stats saved"; Past[1] = "No stats saved,No stats saved"; Past[2] = "No stats saved,No stats saved"; Past[3] = "No stats saved,No stats saved"; Past[4] = "No stats saved,No stats saved"; Past[5] = "No stats saved,No stats saved"; Past[6] = "No stats saved,No stats saved"; AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find previous stats"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } }
private void quit_button_Click(object sender, EventArgs e) { //save summary of days tasks try { string statsFilePath = "C:\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "C:\\ActivityMonitor"; if (File.Exists(statsFilePath)) { StreamReader ReadStatsFile = new StreamReader(statsFilePath); Queue <string> previous = new Queue <string>(); int a = 6; while (a > 0) { a--; previous.Enqueue(ReadStatsFile.ReadLine()); } string TodaysStats = STEPS.ToString() + "," + statsDialog.steps_min_value.Text; //previous.Push(TodaysStats); ReadStatsFile.Close(); StreamWriter writeStatsFile = new StreamWriter(statsFilePath); writeStatsFile.WriteLine(TodaysStats); while (previous.Count() > 0) { writeStatsFile.WriteLine(previous.Dequeue()); } writeStatsFile.Close(); } else { if (File.Exists(statsFilePath)) { return; } //if directory exists, create file if (Directory.Exists(activityMonitorDirectory)) { FileStream createConfigFile = File.Create(statsFilePath); createConfigFile.Close(); return; } //if directory doesnt exist, create file and directory if (!Directory.Exists(activityMonitorDirectory)) { Directory.CreateDirectory(activityMonitorDirectory); FileStream createConfigFile = File.Create(statsFilePath); createConfigFile.Close(); return; } } } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not save daily tasks"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } //sending data to the server try { Laptop_GUI.ServerConnection conn = new Laptop_GUI.ServerConnection(); conn.connect(); conn.setMainMenu(this); conn.sendStats(); } catch (Exception e5) { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find server"); Cursor.Current = Cursors.WaitCursor; temp2.ShowDialog(); Cursor.Current = Cursors.Arrow; } statsDialog.Close(); tasksDialog.Close(); Application.Exit(); Environment.Exit(0); }