private void TextBoxTime_OnSelectionChanged(object sender, RoutedEventArgs e)
 {
     if (IsRunning && TextBoxTime.SelectionLength != 0)
     {
         TextBoxTime.Select(0, 0);
     }
 }
        private void TextBoxTime_MouseEnter(object sender, MouseEventArgs e)
        {
            if (IsRunning)
            {
                return;
            }

            TextBoxTime.Focus();
            if (TextBoxTime.SelectionLength != 0)
            {
                return;
            }
            TextBoxTime.SelectAll();
        }
        private void TextBoxTime_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DisplayTotalTime = !DisplayTotalTime;

            var timeElapsed = DisplayTotalTime ? TotalTimeElapsed : _stopwatch.Elapsed;
            var oneDay      = new TimeSpan(1, 0, 0, 0, 0);

            if (timeElapsed < oneDay)
            {
                _elapsedTimeFormat = TimeFormats.Default;
                _longIntervalPassTimer.Interval = oneDay.Subtract(timeElapsed);
            }
            else
            {
                _elapsedTimeFormat = TimeFormats.Long;
            }

            if (!IsRunning)
            {
                TextBoxTime.Text = ElapsedTimeString;
            }
            TextBoxTime.Select(0, 0);
        }
Exemple #4
0
        /// <summary>
        /// Populate the listboxes.
        /// </summary>
        private void InitaliseList()
        {
            //First get the note IDs of the notes from the
            //database that contain the correct student ID
            try
            {
                SqlConnector db = new SqlConnector();
                snl = db.GetStudentNoteLink_ByStudentID(student.StudentID);
            }
            catch
            {
                MyMessageBox.ShowMessage("Failed to load Student Note Link data from the database.");
                return;
            }
            //Display them in the appropriate listbox
            ListBoxNoteList.DataSource    = snl;
            ListBoxNoteList.DisplayMember = "NoteNumber";

            //If the snl list contains items, get the note
            //contents from the note IDs we just retrieved
            if (snl.Count() > 0)
            {
                try
                {
                    SqlConnector db = new SqlConnector();
                    notes = db.GetNote_ByNoteID(snl[ListBoxNoteList.SelectedIndex].NoteID);
                }
                catch
                {
                    MyMessageBox.ShowMessage("Failed to load notes from the database.");
                    return;
                }
                //Display the selected note in TextBoxNoteViewer
                TextBoxNoteViewer.Text = notes[0].NoteContents;
            }
            else
            {
                TextBoxNoteViewer.Clear();
            }

            //First get the message IDs of the messages from the
            //database that contain the correct student ID
            try
            {
                SqlConnector db = new SqlConnector();
                sml = db.GetStudentMessageLink_ByStudentID(student.StudentID);
            }
            catch
            {
                MyMessageBox.ShowMessage("Failed to load Student Message Link data from the database.");
                return;
            }
            //Display these in the listbox
            ListBoxMessageList.DataSource    = sml;
            ListBoxMessageList.DisplayMember = "MessageNumber";

            //If sml list contains items, get the messages by
            //their message ID we just retrieved
            if (sml.Count() > 0)
            {
                try
                {
                    SqlConnector db = new SqlConnector();
                    messages = db.GetMessage_ByMessageID(sml[ListBoxMessageList.SelectedIndex].MessageID);
                }
                catch
                {
                    MyMessageBox.ShowMessage("Failed to load pinned messages from the database.");
                    return;
                }
                //Display the selected message in the text box
                TextBoxMessageViewer.Text = messages[0].MessageContents;
            }
            else
            {
                TextBoxMessageViewer.Clear();
                TextBoxDate.Clear();
                TextBoxTime.Clear();
            }
        }