//TODO: You could make this static by passing it TLP and active. private bool timerCanBeRemoved() { int bottomTimerIndex = returnTmrCnt() - 1; // -1 is to get to active's zero index. if (bottomTimerIndex < 1) // Are you going less than 1 timer? { DialogResult result = MessageBox.Show( "You can't have less than one timer." , "" , MessageBoxButtons.OK , MessageBoxIcon.Information , MessageBoxDefaultButton.Button1); return(false); //Timer can't be removed } if (TIMEENGINE.getTimeValue(bottomTimerIndex) > TimeSpan.Zero || (bottomTimerIndex == TIMEENGINE.getActiveRow())) // test: Does the last row have a non-zero time? Or is it running? { DialogResult result = MessageBox.Show( "You are trying to remove a non-zero timer. The " + (string.IsNullOrEmpty(returnTimerTextBox(bottomTimerIndex)) ? "last" : "\"" + returnTimerTextBox(bottomTimerIndex) + "\"") + " timer will be reset and removed from the total elapsed time. Continue?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); return(result == DialogResult.OK); //Timer can be removed (clicked okay) } else { return(true); // Timer can be removed } }
/// <summary> /// Writes a single row to the file. /// </summary> /// <param name="nowInstant"></param> /// <param name="endInstant"></param> /// <param name="eventDuration"></param> /// <param name="eventDone"></param> /// <param name="activeAction"></param> /// <param name="stopElapsed"></param> /// <returns></returns> public bool writeRow(DateTime nowInstant, DateTime endInstant, TimeSpan eventDuration, string eventDone, int activeAction, TimeSpan stopElapsed) { //Exit if you aren't supposed to be saving if (!Properties.Settings.Default.SaveActions) { return(true); } bool writeSuccess = true; FileInfo fi = new FileInfo(dirString + @"\" + DateTime.Today.ToString("yyyMMdd") + "_Times.csv"); if (!fi.Exists) { initializeFile(); } checkFileHeader(); string textToWrite = endInstant.ToString("G") + "," + nowInstant.ToString("G") + "," + eventDuration.ToString() + "," + eventDone + "," + activeAction.ToString() + "," + (activeAction > -1 ? valCSVstring(DISPLAY.returnTimerTextBox(activeAction)) : "") + "," + TIMEENGINE.engCalcArrayTotal().ToString() + "," + stopElapsed.ToString() + ","; for (int i = 0; i < StaticUtility.maximumRows; i++) { textToWrite += TIMEENGINE.getTimeValue(i).ToString() == "00:00:00" ? "" + "," : TIMEENGINE.getTimeValue(i).ToString() + ","; } try { using (StreamWriter sw = fi.AppendText()) { sw.Write(textToWrite + Environment.NewLine); } } catch (Exception) { writeSuccess = false; writeThrowException(false); } return(writeSuccess); }