private void connection_test_button_Click(object sender, EventArgs e) { AlertGUI temp5 = new AlertGUI(); temp5.setMessage("Attempting to connect to server....", ""); temp5.Show(); try { PDA_GUI.ServerConnection conn = new PDA_GUI.ServerConnection(); conn.connect(); temp5.Close(); temp5.Dispose(); conn.disconnect(); AlertGUI temp3 = new AlertGUI(); temp3.setMessage("Server Connected Successfully!", ""); temp3.Show(); } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Could not find server"); //temp2.ShowDialog(); temp2.Show(); temp5.Close(); temp5.Dispose(); } }
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"); //temp.ShowDialog(); temp.Show(); 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"); //temp2.ShowDialog(); temp2.Show(); temp2.Dispose(); } } catch { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("File Not Written"); //temp2.ShowDialog(); temp2.Show(); } } }
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"); // temp.ShowDialog(); temp.Show(); createConfigFile(); } }
private void quit_button_Click(object sender, EventArgs e) { myWiiRemoteConnection.disconnect(); //save summary of days tasks try { string statsFilePath = "\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "\\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.step_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"); temp2.ShowDialog(); } //sending data to the server try { PDA_GUI.ServerConnection conn = new PDA_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(); } statsDialog.Close(); tasksDialog.Close(); this.Close(); }
//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 \""); //temp.ShowDialog(); temp.Show(); return false; } if (hostname.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); return false; } if (password.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); return false; } if (patient_name.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); 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 quit_button_Click(object sender, EventArgs e) { myWiiRemoteConnection.disconnect(); //save summary of days tasks try { string statsFilePath = "\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "\\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.step_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"); temp2.ShowDialog(); } //sending data to the server try { PDA_GUI.ServerConnection conn = new PDA_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(); } statsDialog.Close(); tasksDialog.Close(); this.Close(); }
//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 \""); //temp.ShowDialog(); temp.Show(); return(false); } if (hostname.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); return(false); } if (password.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); return(false); } if (patient_name.Contains('"')) { AlertGUI temp = new AlertGUI(); temp.setMessage("Do not add \""); //temp.ShowDialog(); temp.Show(); 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 = "\\ActivityMonitor\\PreviousStats.stats"; string activityMonitorDirectory = "\\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"); temp2.ShowDialog(); } }
private void new_timer_Tick(object sender, EventArgs e) { if (mainMenuPointer.goodConnection == false) { AlertGUI temp2 = new AlertGUI(); temp2.setMessage("Connection to server lost: Setting default task"); temp2.Show(); temp2.BringToFront(); mainMenuPointer.goodConnection = true; } if (mainMenuPointer.wiimoteCon == false) { AlertGUI temp = new AlertGUI(); temp.setMessage("Wiimote not connected"); temp.Show(); temp.BringToFront(); mainMenuPointer.wiimoteCon = true; } mainMenuPointer.ProcessSteps(); this.Refresh(); this.steps_value.Text = mainMenuPointer.getSteps().ToString(); this.Refresh(); if (mainMenuPointer.isON) { this.Show(); } dis_counter++; seconds++; stepsMin();//calculates and sets the steps per minuite field this.distance_value.Text = (mainMenuPointer.getSteps() * .003).ToString() + " mi"; if (seconds == 60) { seconds = 0; sec = "00"; minutes++; } if (seconds < 10) { sec = "0" + seconds.ToString(); } if (seconds >= 10) { sec = seconds.ToString(); } if (minutes == 60) { minutes = 0; min = "00"; hours++; } if (minutes < 10) { min = "0" + minutes.ToString(); } if (minutes >= 10) { min = minutes.ToString(); } if (hours < 10) { hr = "0" + hours.ToString(); } if (hours >= 10) { hr = hours.ToString(); } this.time_walking_value.Text = hr + ":" + min + ":" + sec; }