Ejemplo n.º 1
0
    void DoMyWindow(int windowID)
    {
        if (windowID == 1)
        {
            // Open Main Window

            // Draw any controls inside the window here
            GUI.Label(new Rect(7, 10, 100, 30), "ID");
            GUI.Label(new Rect(130, 10, 100, 30), "Name");

            // show tabular patient listing
            GUILayout.BeginArea(new Rect(0, 40, Screen.width / 2 - 100, Screen.height * 2 / 3 - 40));

            // DISPLAY PATIENTS AND SELECT BUTTONS
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(Screen.height * 2 / 3 - 40));

            if (db.GetRowCount(tableName) > 0)
            {
                List <int> ID_list = new List <int>();
                ID_list = db.GetIDValues(tableName, "PatientID");
                for (int i = 0; i < ID_list.Count; i++)
                {
                    List <string> rowList = new List <string>();
                    rowList = db.GetRowValues(tableName, "PatientID", ID_list[i]);
                    GUILayout.BeginHorizontal("box");
                    GUILayout.Space(20);
                    GUILayout.Label(rowList[0], GUILayout.Width(50));                           // ID
                    GUILayout.FlexibleSpace();
                    string name = rowList[1] + ", " + rowList[2];
                    GUILayout.Label(name, GUILayout.Width(150));                                // Last, First
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Select", GUILayout.Width(150)))
                    {
                        selectedID = int.Parse(rowList[0]);
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }

        /*else if (windowID == 2)
         * {
         *      selectedID = -1;
         *
         *      // Open Add Patient Window
         *      GUILayout.BeginArea(new Rect(50, Screen.height/4, Screen.width/3, Screen.height/3));
         *      GUILayout.BeginVertical();
         *
         *      GUILayout.Label("New patient information: ");
         *      GUILayout.Space(10);
         *
         *      GUILayout.BeginHorizontal("box");
         *      GUILayout.Label("Last Name");
         *      newPatientLastName = GUILayout.TextField(newPatientLastName);
         *      GUILayout.EndHorizontal();
         *
         *      GUILayout.BeginHorizontal("box");
         *      GUILayout.Label("First Name");
         *      newPatientFirstName = GUILayout.TextField(newPatientFirstName);
         *      GUILayout.EndHorizontal();
         *
         *      GUILayout.BeginHorizontal("box");
         *      if(GUILayout.Button("Add"))
         *      {
         *              if(newPatientLastName != "" && newPatientFirstName != "")
         *              {
         *                      newpatientEntries.Add(newPatientLastName);
         *                      newpatientEntries.Add(newPatientFirstName);
         *                      db.InsertRow(tableName, newpatientCol, newpatientEntries);
         *
         *                      string newPatientTableName = tablePrefix + db.GetID(
         *                              tableName, "PatientID", "LastName", newPatientLastName, "FirstName", newPatientFirstName);
         *                      db.CreateTable(newPatientTableName, newtableCol, newtableVal);
         *
         *                      newPatientLastName = "";
         *                      newPatientFirstName = "";
         *                      newpatientEntries.Clear();
         *
         *                      window_ID = 1;
         *              }
         *      }
         *      if(GUILayout.Button("Cancel"))
         *      {
         *              window_ID = 1;
         *      }
         *      GUILayout.EndHorizontal();
         *      GUILayout.EndVertical();
         *      GUILayout.EndArea();
         * }*/
        else if (windowID == 3)
        {
            selectedID = -1;

            // Open Delete Patient Window
            GUILayout.BeginArea(new Rect(50, Screen.height / 4, Screen.width / 3, Screen.height / 3));
            GUILayout.BeginVertical("box");

            GUILayout.Label("Enter patient information: ");
            GUILayout.Space(10);
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("ID");
            deletePatientID = GUILayout.TextField(deletePatientID);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal("box");

            if (GUILayout.Button("Delete"))
            {
                /* TO BE ADDED LATER
                 * prompt user if he is sure he would like to delete this patient
                 */
                if (deletePatientID != "")
                {
                    /* TO BE ADDED LATER
                     * if ID not found, show message: "Patient ID not found!"
                     */
                    int deleteID;                       // if string can be converted to int, then delete
                    if (int.TryParse(deletePatientID, out deleteID))
                    {
                        int delID = deleteID;                           // to avoid NullReferenceException
                        db.DeleteRow(tableName, "PatientID", delID);
                        string tabletoDelete = tablePrefix + delID.ToString();
                        db.DeleteTable(tabletoDelete);
                    }
                    deletePatientID = "";

                    window_ID = 1;
                }
            }

            if (GUILayout.Button("Cancel"))
            {
                deletePatientID = "";
                window_ID       = 1;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }
    }
Ejemplo n.º 2
0
    void DoMyWindow(int ID)
    {
        if (windowID == 0)
        {
            // Open Overall Stats Window

            statsSwitch = 0;

            // Draw statistics boxes

            // Total time playing
            GUI.Label(new Rect(50, 50, 300, 140), timeBox);

            // Print overall statistics
            if (LoginScreen.currentID > 0)
            {
                // Calculate overall stats using db.GetColumnValues(patientTable, "Column Name")
                string patientTable = tablePrefix + LoginScreen.currentID;

                // Overall Time
                List <string> timeList = new List <string>();
                timeList = db.GetColumnValues(patientTable, "SessionLength");
                System.TimeSpan timeTotal = System.TimeSpan.Zero;
                foreach (string s in timeList)
                {
                    System.TimeSpan ts = System.TimeSpan.Parse(s);
                    timeTotal = timeTotal.Add(ts);
                }
                string overallTime = timeTotal.ToString();

                // Table showing highest grades for each BBS activity?

                // Print values on drawn boxes
                GUI.Label(new Rect(140, 120, 100, 50), overallTime, summaryStyle);
            }
        }

        else if (windowID == 1)
        {
            // Open Session Stats Window
            if (statsSwitch == 0)
            {
                // Draw any controls inside the window here

                GUI.Label(new Rect(20, 30, 20, 20), "#", colStyle);
                GUI.Label(new Rect(Screen.width / 5, 30, 70, 20), "Date", colStyle);
                GUI.Label(new Rect(Screen.width * 2 / 5, 30, 70, 20), "Time", colStyle);
                GUI.Label(new Rect(Screen.width * 3 / 5, 30, 70, 20), "Duration", colStyle);
                GUI.Label(new Rect(Screen.width * 4 / 5 - 12, 30, 70, 20), "# of Plays", colStyle);

                // show tabular session listing
                GUILayout.BeginArea(new Rect(10, 50, Screen.width - 40, Screen.height - 130));

                if (LoginScreen.currentID > 0)
                {
                    string patientTable = tablePrefix + LoginScreen.currentID;

                    // DISPLAY SESSIONS
                    scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(410));

                    List <int> ID_list = new List <int>();
                    ID_list = db.GetIDValues(patientTable, "SessionID");
                    List <List <string> > listOfRows = new List <List <string> >();
                    listOfRows = db.GetTableValues(patientTable);
                    for (int i = 0; i < ID_list.Count; i++)
                    {
                        List <string> rowList = new List <string>();
                        rowList = listOfRows[i];
                        GUILayout.BeginHorizontal("box");
                        GUILayout.Space(1);
                        GUILayout.Label(rowList[0], idStyle, GUILayout.Width(30));                              // ID
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(rowList[1], normStyle, GUILayout.Width(60));                            // Date
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(rowList[2], normStyle, GUILayout.Width(70));                            // Start Time
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(rowList[3], normStyle, GUILayout.Width(70));                            // Session Length
                        GUILayout.FlexibleSpace();
                        GUILayout.Label(rowList[4], normStyle, GUILayout.Width(20));                            // # of Plays
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }

                    GUILayout.EndScrollView();
                }

                GUILayout.EndArea();
            }

            // Open Play Stats Window
            else if (statsSwitch == 1)
            {
                string patientTable = tablePrefix + LoginScreen.currentID;

                // Draw any controls inside the window here

                GUI.Label(new Rect(50, 40, 100, 30), "BBS Total Score?", normStyle);
                GUI.Label(new Rect(50, 70, 100, 30), "BBS Activity Best Score?", normStyle);

                GUI.Label(new Rect(15, 100, 20, 30), "Play #", colStyle);
                GUI.Label(new Rect(Screen.width / 4 - 18, 100, 50, 30), "Duration", colStyle);
                GUI.Label(new Rect(Screen.width / 2, 100, 100, 30), "Activity", colStyle);
                GUI.Label(new Rect(Screen.width * 3 / 4 - 20, 100, 50, 30), "BBS Grade", colStyle);

                List <string> rowList = new List <string>();
                rowList = db.GetRowValues(patientTable, "SessionID", selectedSession);

                // show tabular play listing
                GUILayout.BeginArea(new Rect(10, 130, Screen.width - 40, Screen.height - 70));

                // DISPLAY PLAYS
                scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Height(330));

                int numPlays = int.Parse(db.GetValue(patientTable, "NumOfPlays", "SessionID", selectedSession));

                for (int i = 0; i < numPlays; i++)
                {
                    GUILayout.BeginHorizontal("box");
                    GUILayout.Space(10);
                    GUILayout.Label((i + 1).ToString(), idStyle, GUILayout.Width(20));                          // Play #
                    GUILayout.FlexibleSpace();

                    string   play      = rowList[5 + i];
                    string[] playStats = play.Split(line);

                    GUILayout.Label(playStats[0], normStyle, GUILayout.Width(70));                      // Duration
                    GUILayout.FlexibleSpace();

                    GUILayout.Label(playStats[1], normStyle, GUILayout.Width(100));                             // BBS Activity
                    GUILayout.FlexibleSpace();

                    GUILayout.Label(playStats[2], normStyle, GUILayout.Width(40));                              // BBS Grade
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                GUILayout.EndScrollView();

                GUILayout.EndArea();
            }
        }
    }