/// <summary>
 /// Reviews a session
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonReviewSession_Click(object sender, EventArgs e)
 {
     if (_patient.Sessions[GetSelectedSessionID()].MotionCaptureDataRecorded && _patient.Sessions[GetSelectedSessionID()].SubSessions.Count != 0)
     {
         //Todo instead of calling Start and stop here, open up Run_Review_Session_Form, set the task and then let it control things
         if (_remote_DataManager.PlaybackStatus)
         {
             StopPlayback();
         }
         else
         {
             _remote_DataManager.ClientOpenSessionForPlayback(_selectedPatientIndex, GetSelectedSessionID(), 0);
             _remote_DataManager.ClientRequestUpdatedPatientList();
             _patient = _remote_DataManager.PatientList[_selectedPatientIndex];
             if (_patient.Sessions[GetSelectedSessionID()].MotionCaptureDataRecorded == false)
             {
                 FillInFields();
             }
             else
             {
                 OnHideForm(true);
                 Run_Review_Session_Form form = new Run_Review_Session_Form();
                 form.CurrentSession = _patient.Sessions[_selectedSessionIndex];
                 if (form.ShowDialog() == DialogResult.Cancel) // showdialog rather than show so that we can get data back from it using form.Something
                 {
                     StopPlayback();
                 }
                 form.Dispose();
                 OnHideForm(false);
             }
         }
     }
 }
        /// <summary>
        /// Runs a session
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRunSession_Click(object sender, EventArgs e)
        {
            if (CurrentClinician.RunSessions)
            {
                _selectedSessionIndex = GetSelectedSessionID();
                if (_patient.Sessions[_selectedSessionIndex].Task.FileName != "")
                {
                    //Todo instead of calling Start and stop here, open up Run_Review_Session_Form, set the task and then let it control things
                    if (_remote_DataManager.RecordingStatus)
                    {
                        StopRecording();
                    }
                    else
                    {
                        _patient.Sessions[_selectedSessionIndex].Clinician = CurrentClinician.NameString;
                        _remote_DataManager.ClientUpdatePatient(_patient, _selectedPatientIndex);
                        _remote_DataManager.ClientPrepareToRecordNewSession(_selectedPatientIndex, _selectedSessionIndex);

                        //Hide the main form, load the run_review_session form and wait for it to return
                        OnHideForm(true);
                        Run_Review_Session_Form form = new Run_Review_Session_Form();
                        form.CurrentSession = _patient.Sessions[_selectedSessionIndex];
                        if (form.ShowDialog() == DialogResult.Cancel) // showdialog rather than show so that we can get data back from it using form.Something
                        {
                            StopRecording();
                        }
                        else
                        {
                            _remote_DataManager.ClientRequestUpdatedPatientList();
                            _patient = _remote_DataManager.PatientList[_selectedPatientIndex];
                            FillInFields();
                        }
                        form.Dispose();
                        OnHideForm(false);
                    }
                }
                else
                {
                    MessageBox.Show("You must select a Task before you can run the session.\nSelect the session you want to run, click Edit, and then select a task", "StroMoHab Client", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show(StroMoHab_Client.Properties.Settings.Default.InvalidPermissionsString, "StroMoHab Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Reviews a session
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonReviewSession_Click(object sender, EventArgs e)
        {
            if (_patient.Sessions[GetSelectedSessionID()].MotionCaptureDataRecorded && _patient.Sessions[GetSelectedSessionID()].SubSessions.Count != 0)
            {
                //Todo instead of calling Start and stop here, open up Run_Review_Session_Form, set the task and then let it control things
                if (_remote_DataManager.PlaybackStatus)
                {
                    StopPlayback();
                }
                else
                {
                    _remote_DataManager.ClientOpenSessionForPlayback(_selectedPatientIndex, GetSelectedSessionID(), 0);
                    _remote_DataManager.ClientRequestUpdatedPatientList();
                    _patient = _remote_DataManager.PatientList[_selectedPatientIndex];
                    if (_patient.Sessions[GetSelectedSessionID()].MotionCaptureDataRecorded == false)
                        FillInFields();
                    else
                    {
                        OnHideForm(true);
                        Run_Review_Session_Form form = new Run_Review_Session_Form();
                        form.CurrentSession = _patient.Sessions[_selectedSessionIndex];
                        if (form.ShowDialog() == DialogResult.Cancel) // showdialog rather than show so that we can get data back from it using form.Something
                        {
                            StopPlayback();
                        }
                        form.Dispose();
                        OnHideForm(false);
                    }
                    
                }
            }

        }
        /// <summary>
        /// Runs a session
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRunSession_Click(object sender, EventArgs e)
        {
            if (CurrentClinician.RunSessions)
            {
                _selectedSessionIndex = GetSelectedSessionID();
                if (_patient.Sessions[_selectedSessionIndex].Task.FileName != "")
                {
                    //Todo instead of calling Start and stop here, open up Run_Review_Session_Form, set the task and then let it control things
                    if (_remote_DataManager.RecordingStatus)
                    {

                        StopRecording();
                    }
                    else
                    {
                        _patient.Sessions[_selectedSessionIndex].Clinician = CurrentClinician.NameString;
                        _remote_DataManager.ClientUpdatePatient(_patient, _selectedPatientIndex);
                        _remote_DataManager.ClientPrepareToRecordNewSession(_selectedPatientIndex, _selectedSessionIndex);

                        //Hide the main form, load the run_review_session form and wait for it to return
                        OnHideForm(true);
                        Run_Review_Session_Form form = new Run_Review_Session_Form();
                        form.CurrentSession = _patient.Sessions[_selectedSessionIndex];
                        if (form.ShowDialog() == DialogResult.Cancel) // showdialog rather than show so that we can get data back from it using form.Something
                        {
                            StopRecording();
                        }
                        else
                        {

                            _remote_DataManager.ClientRequestUpdatedPatientList();
                            _patient = _remote_DataManager.PatientList[_selectedPatientIndex];
                            FillInFields();
                        }
                        form.Dispose();
                        OnHideForm(false);
                    }
                }
                else
                    MessageBox.Show("You must select a Task before you can run the session.\nSelect the session you want to run, click Edit, and then select a task", "StroMoHab Client", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
                MessageBox.Show(StroMoHab_Client.Properties.Settings.Default.InvalidPermissionsString, "StroMoHab Client", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }