Example #1
0
        private void removeRow(ref TableLayoutPanel TLP, bool relayout)
        {
            int bottomTimerIndex = returnTmrCnt() - 1;// -1 is to get to active's zero index.

            if (!timerCanBeRemoved())
            {
                return;
            }
            if (bottomTimerIndex == TIMEENGINE.getActiveRow())
            {
                TIMEENGINE.changeActive(-1);              // If the active row is to be removed stop.
            }
            TIMEENGINE.resetTimerValue(bottomTimerIndex); // make sure the removed value is zero. It might not be.
            disUpdTotal(TIMEENGINE.engCalcArrayTotal());  // if you removed an existing row you want to reset the total.

            int bottomRowIndex = baseTLP.RowCount - 1;

            TLP.SuspendLayout();
            Control c = TLP.GetControlFromPosition(0, bottomRowIndex);

            TLP.Controls.Remove(c);
            c.Dispose();
            Control d = TLP.GetControlFromPosition(2, bottomRowIndex);

            TLP.Controls.Remove(d);
            d.Dispose();
            Control e = TLP.GetControlFromPosition(3, bottomRowIndex);

            TLP.Controls.Remove(e);
            e.Dispose();
            TLP.RowStyles.RemoveAt(bottomRowIndex);
            TLP.RowCount--;
            TLP.ResumeLayout(false);
            TLP.PerformLayout();
        }
Example #2
0
        /// <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);
        }