Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pt"></param>
        private void runManicTimeReports(HitTestResult pt)
        {
            if (pt == null)
            {
                return;
            }
            int srs = returnPointSeries(pt);

            string[] fl = chart1.Series[srs].Points[pt.PointIndex].ToolTip.ToString().Split(';');
            if (fl.Length < 3)
            {
                return;
            }
            CultureInfo provider = CultureInfo.InvariantCulture;
            string      str1     = fl[0];
            string      str2     = fl[1];
            string      str3     = fl[2];
            DateTime    start    = DateTime.ParseExact(str1, "M/d/yyyy h:m:s tt", null);
            DateTime    end      = DateTime.ParseExact(str2, "M/d/yyyy h:m:s tt", null);

            if (Properties.Settings.Default.ManicTimeEnabled)
            {
                if (radioButtonManicTimeAll.Checked)
                {
                    StaticUtility.listAll3(start, end, displayGrid, Properties.Settings.Default.ManicTimePath);
                }
                if (radioButtonManicTimeGrouped.Checked)
                {
                    StaticUtility.aggregate3(start, end, displayGrid, Properties.Settings.Default.ManicTimePath);
                }
            }
        }
Example #2
0
        private void addTimerRow(ref TableLayoutPanel TLP, string boxText, bool relayout)
        {
            if (TLP.RowCount - StaticUtility.visualNonTimerRows >= StaticUtility.maximumRows) //don't let rows add past limit. Minus 1 is for zero index.
            {
                DialogResult result = MessageBox.Show(
                    "Maximum number of timers have been added. Modify the application config file and restart the application to change the maximum rows."
                    , ""
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Information
                    , MessageBoxDefaultButton.Button1);
                return;
            }

            TLP.SuspendLayout();
            addRow(TLP);
            int cntIx = TLP.RowCount - 1;

            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStartBackColor, theme.defStartForeColor, 1, starts_Click, true, true, 0, cntIx);
            tempLabel.Text = "u";
            StaticUtility.addTextBox(ref TLP, ref tempTextBox, theme.defTxtBxBackColor, theme.defTxtBxForeColor, 0, false, false, 2, cntIx);
            tempTextBox.Text = boxText;
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStartBackColor, theme.defStartForeColor, 0, null, true, false, 3, cntIx);
            tempLabel.Text = "00:00:00";
            TLP.ResumeLayout(false);
            if (relayout)
            {
                TLP.PerformLayout();
            }
        }
Example #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="TimerRow"></param>
 /// <param name="text"></param>
 public void setTimerTextBox(int TimerRow, string text)
 {
     if (!timerRowInRange(TimerRow))
     {
         return;
     }
     StaticUtility.setTextBoxYX(baseTLP, TimerRow + StaticUtility.visualNonTimerRows, 2, text);
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="timerRow2Change">Row to affect;</param>
 /// <param name="running">TRUE change it to running; FALSE change it stopped;</param>
 public void disSetRunTimer(int timerRow2Change, bool running)
 {
     if (!timerRowInRange(timerRow2Change))
     {
         return;
     }
     StaticUtility.setRunningRow(ref baseTLP, running, timerRow2Change, theme);
 }
Example #5
0
 /// <summary>
 /// This should update the timer row specified with the time specified.
 /// </summary>
 /// <param name="TimerRow">0 index; Timer to update;</param>
 /// <param name="time">TimeSpan to pass in.</param>
 public void disUpd1Row(int TimerRow, TimeSpan time)
 {
     if (!timerRowInRange(TimerRow))
     {
         return;
     }
     StaticUtility.getLabelYX(baseTLP, TimerRow + StaticUtility.visualNonTimerRows, 3).Text = time.ToString();
 }
Example #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="TimerRow"></param>
 /// <returns>Gets the text in the textbox.</returns>
 public string returnTimerTextBox(int TimerRow)
 {
     if (!timerRowInRange(TimerRow))
     {
         return("");
     }
     return(StaticUtility.getTextBoxYX(baseTLP, TimerRow + StaticUtility.visualNonTimerRows, 2).Text.Trim());
 }
Example #7
0
 /// <summary>
 /// Returns the values of all text boxes.
 /// </summary>
 /// <returns></returns>
 public string[] returnTextBoxList()
 {
     string[] outStringText = new string[returnTmrCnt()];
     for (int i = 0; i < returnTmrCnt(); i++)
     {
         outStringText[i] += StaticUtility.getTextBoxYX(baseTLP, i + StaticUtility.visualNonTimerRows, 2).Text.Trim();
     }
     return(outStringText);
 }
Example #8
0
        /// <summary>
        /// Define action that occurs each timer tick.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void windowUpdateTimer_Tick(object sender, EventArgs e)
        {
            if (active > -1)
            {
                currentDiff = StaticUtility.SubTime(DateTime.Now, activeTimeStamp);
                DISPLAY.disUpd1Row(active, StaticUtility.AddTime(activeTimeArray[active], currentDiff));

                TimeSpan newTotal = StaticUtility.AddTime(StaticUtility.SubTime(StaticUtility.AddTime(tempTotal, currentDiff), activeTimeArray[active]), activeTimeArray[active]);
                DISPLAY.disUpdTotal(newTotal);
            }
        }
Example #9
0
        private void deleteStartupShortCut()
        {
            string shortcutName     = StaticUtility.returnTitleName();
            string shortcutPath     = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            string shortcutLocation = Path.Combine(shortcutPath, shortcutName + ".lnk");

            try { if (System.IO.File.Exists(shortcutLocation))
                  {
                      System.IO.File.Delete(shortcutLocation);
                  }
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="stopped">TRUE set it stopped; FALSE set it out of false</param>
 public void disSetStopped(bool stopped)
 {
     StaticUtility.setStopped(ref baseTLP, stopped, theme);
     if (stopped)
     {
         stopFlashTimer.Start();
     }
     else
     {
         stopFlashTimer.Stop();
         BackColor = theme.defWindowColor;
     }
 }
Example #11
0
        /// <summary>
        /// Will load an existing file if one exists.
        /// </summary>
        /// <returns>TRUE if it had to load an existing file; FALSE if existing file doesn't exist or can't be loaded.</returns>
        public bool loadExistingFile()
        {
            FileInfo fi = new FileInfo(dirString + @"\" + DateTime.Today.ToString("yyyMMdd") + "_Times.csv");

            if (!fi.Exists)
            {
                return(false);
            }
            string[] arrLines = File.ReadAllLines(fi.ToString());

            string[] versionRow = StaticUtility.parseFileRow(arrLines[0]);
            string   head       = returnHeaderLine(1);

            if (head == versionRow[0] + "," + versionRow[1]) //Don't allow version skew
            {
                int      highestName     = 0;
                int      highestCnt      = 0;
                string   stoppedDuration = "";
                string[] cntrArray       = new string[StaticUtility.maximumRows];
                string[] nmArray         = new string[StaticUtility.maximumRows];

                string[] headerRow = StaticUtility.parseFileRow(arrLines[1]);
                string[] lastRow   = StaticUtility.parseFileRow(arrLines.Last());

                stoppedDuration = lastRow[7];
                for (int i = 8; i < StaticUtility.maximumRows + 8; i++)
                {
                    if (headerRow[i] != "")
                    {
                        highestName = i - 8;
                    }
                    if (lastRow[i] != "")
                    {
                        highestCnt = i - 8;
                    }
                    nmArray[i - 8]   = headerRow[i];
                    cntrArray[i - 8] = lastRow[i];
                }
                int needTimerRows = Math.Max(highestName, highestCnt) + 1;
                TIMEENGINE.setAll(nmArray, cntrArray, stoppedDuration, needTimerRows);
                TIMEENGINE.changeActive(-1);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #12
0
        private void createStartupShortCut()
        {
            string shortcutName     = StaticUtility.returnTitleName();
            string shortcutPath     = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
            string shortcutLocation = Path.Combine(shortcutPath, shortcutName + ".lnk");

            deleteStartupShortCut();
            WshShell     shell    = new WshShell();
            IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);

            shortcut.Description = StaticUtility.returnTitleName() + " startup shortcut. Instead of deleting this it's recommended to uncheck the box in the application."; // The description of the shortcut
            //shortcut.IconLocation = @"c:\myicon.ico";         // The icon of the shortcut
            shortcut.TargetPath = Application.ExecutablePath;                                                                                                               // The path of the file that will launch when the shortcut is run
            try { shortcut.Save(); }                                                                                                                                        // Save the shortcut
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Example #13
0
        /// <summary>
        /// Handles stop looking correct.
        /// </summary>
        /// <param name="TLP"></param>
        /// <param name="stopped">TRUE means you should show stopped.</param>
        public static void setStopped(ref TableLayoutPanel TLP, bool stopped, xColors thm)
        {
            Label lbl = StaticUtility.getLabelYX(TLP, 0, 0);

            if (stopped)
            {
                lbl.Text      = "Stopped";
                lbl.ForeColor = thm.STOPPEDForeColor;
                lbl.BackColor = thm.STOPPEDBackColor;
            }
            else
            {
                lbl.Text      = "Stop";
                lbl.ForeColor = thm.defStopForeColor;
                lbl.BackColor = thm.defStopBackColor;
            }
        }
Example #14
0
        /// <summary>
        /// Changes the running timer or current action to a different action.
        /// </summary>
        /// <param name="newActive">Action to change to.</param>
        public void changeActive(int newActive)
        {
            if (active == newActive)
            {
                return;                      //nothing changed
            }
            currentDiff = StaticUtility.SubTime(DateTime.Now, activeTimeStamp);

            if (active > -1) // At button press something was running. Turn the active timer off and write to file.
            {
                DISPLAY.disSetRunTimer(active, false);
                activeTimeArray[active] = StaticUtility.AddTime(currentDiff, activeTimeArray[active]);
                DISPLAY.disUpd1Row(active, activeTimeArray[active]);
                FILEMECH.writeRow(DateTime.Now, activeTimeStamp, currentDiff, "[TIME]", active, stopElapsed);
            }

            if (active == -1) // system was stopped
            {
                stopElapsed = StaticUtility.AddTime(currentDiff, stopElapsed);
                FILEMECH.writeRow(DateTime.Now, activeTimeStamp, currentDiff, "[STOP]", active, stopElapsed);
                DISPLAY.disSetStopped(false);
            }

            // Update the total to window
            DISPLAY.disUpdTotal(engCalcArrayTotal());

            activeTimeStamp = DateTime.Now;
            active          = newActive;

            if (newActive > -1) // Thing to go to is a timer
            {
                tempTotal = engCalcArrayTotal();
                DISPLAY.disUpd1Row(active, activeTimeArray[active]);
                DISPLAY.disSetRunTimer(active, true);
                windowUpdateTimer.Start();
            }

            if (newActive == -1) // Thing to go to is stopped
            {
                DISPLAY.disSetStopped(true);
                windowUpdateTimer.Stop();
            }
        }
Example #15
0
        /// <summary>
        /// Used to set the application to the the most recent value in the file.
        /// </summary>
        /// <param name="names"></param>
        /// <param name="counters"></param>
        /// <param name="stoppedTotal"></param>
        /// <param name="numCntrs"></param>
        public void setAll(string[] names, string[] counters, string stoppedTotal, int numCntrs)
        {
            string[] tmpSpn            = new string[3];
            int      currentTimerTexts = DISPLAY.returnTextBoxList().Length;

            //set correct number of timers
            if (numCntrs < currentTimerTexts)
            {
                //I commented this out. I can't figure out why it can't delete rows so now it just defaults in.
                //for (int i = 0; i < currentTimerTexts - numCntrs; i++) DISPLAY.deleteRow();
            }
            else
            {
                for (int i = currentTimerTexts; i < numCntrs; i++)
                {
                    DISPLAY.createRow(names[i]);
                }
            }

            //set actual time array values for timers
            for (int i = 0; i < StaticUtility.maximumRows; i++)
            {
                if (counters[i] == "")
                {
                    activeTimeArray[i] = new TimeSpan(0, 0, 0);
                    continue;
                }
                activeTimeArray[i] = StaticUtility.stringToTimeSpan(counters[i]);
            }

            //update the text boxes
            for (int i = 0; i < numCntrs; i++)
            {
                DISPLAY.setTimerTextBox(i, names[i]);
                DISPLAY.disUpd1Row(i, activeTimeArray[i]);
            }

            //update the total and stopped value
            DISPLAY.disUpdTotal(engCalcArrayTotal());
            stopElapsed = StaticUtility.stringToTimeSpan(stoppedTotal);
            FILEMECH.writeRow(DateTime.Now, DateTime.Now, new TimeSpan(0, 0, 0), "[LOAD]", -2, stopElapsed);
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        private void initializeWindow()
        {
            Text = StaticUtility.returnTitleName() + " - Report";

            initializeControlSettings();
            refreshConfigFromFile(); //Want to update before we put all the event handlers in.

            //Report Tab Event Handlers
            Shown            += new EventHandler(config_Shown);
            chart1.MouseDown += new MouseEventHandler(mouseDown_Click);

            reportDiffFileButton.Click += new EventHandler(reportDiffFileButton_Click);
            radioButtonManicTimeGrouped.CheckedChanged  += new EventHandler(radioButtons_ReportPage);
            radioButtonManicTimeAll.CheckedChanged      += new EventHandler(radioButtons_ReportPage);
            radioButtonManicTimeCategory.CheckedChanged += new EventHandler(radioButtons_ReportPage);
            radioButtonWorkWinderData.CheckedChanged    += new EventHandler(radioButtons_ReportPage);

            //Application Settings EventHandlers
            checkFlashStop.CheckedChanged        += new EventHandler(checkFlashStop_CheckedChanged);
            checkBox_RunOnStartup.CheckedChanged += new EventHandler(runOnStartUp_CheckedChanged);
            buttonSaveColumnConfig.Click         += new EventHandler(saveColumnConfigButton_Click);
            //themeComboBox.SelectedIndexChanged += new EventHandler(themeComboBox_IndexChanged);

            //ManicTime Integration EventHandlers
            radioButtonManicTime_Disabled.CheckedChanged += new EventHandler(radioButtons_ManicTime_Changed);
            radioButtonManicTime_Enabled.CheckedChanged  += new EventHandler(radioButtons_ManicTime_Changed);
            button_ManicTime_DirectoryDialog.Click       += new EventHandler(button_ManicTime_DirectoryDialog_Click);
            linkLabel_DatabaseLocation.LinkClicked       += new LinkLabelLinkClickedEventHandler(clicked_ManicTimeDBHelp);

            //Event Saving EventHandlers
            radioButtonEventSaving_Disabled.CheckedChanged += new EventHandler(radioButtons_SaveEvents_Changed);
            radioButtonEventSaving_Default.CheckedChanged  += new EventHandler(radioButtons_SaveEvents_Changed);
            radioButtonEventSaving_Custom.CheckedChanged   += new EventHandler(radioButtons_SaveEvents_Changed);
            button_EventSaving_DirectoryDialog.Click       += new EventHandler(button_EventSaving_DirectoryDialog_Click);

            //General Help EventHandler
            linkLabelWorkWinderHelp.LinkClicked += new LinkLabelLinkClickedEventHandler(clicked_WorkWinderHelp);
            linkLabelFeedback.LinkClicked       += new LinkLabelLinkClickedEventHandler(clicked_linkFeedback);
        }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="total"></param>
 public void disUpdTotal(TimeSpan total)
 {
     StaticUtility.getLabelYX(baseTLP, 0, 2).Text = "Total: " + total.ToString();
 }
Example #18
0
        private void initializeTLP(ref TableLayoutPanel TLP)
        {
            FormClosing += new FormClosingEventHandler(workWinder_FormClosing); //unrelated but I need to do this somewhere

            TLP = new TableLayoutPanel();
            TLP.SuspendLayout();
            SuspendLayout();

            //Set Window Properties
            BackColor    = theme.defWindowColor;
            Text         = StaticUtility.returnTitleName();
            AutoSize     = true;
            AutoSizeMode = AutoSizeMode.GrowAndShrink;
            MinimumSize  = new Size(Properties.Settings.Default.MainFormWindowWidth, 50);
            MaximizeBox  = false;

            //Define Column Settings
            TLP.ColumnCount = 4;
            TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F));
            TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 40F));
            TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
            TLP.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 80F));

            //Add Rows
            addRow(TLP);
            addRow(TLP);

            //Set TableLayoutPanel Settings
            TLP.Dock     = DockStyle.Fill;
            TLP.Location = new Point(0, 0);
            TLP.Margin   = new Padding(0);
            TLP.Padding  = new Padding(2);
            TLP.AutoSize = true;
            Controls.Add(TLP);

            //Stop Button
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defStopBackColor, theme.defStopForeColor, 2, stop_Click, true, true, 0, 0);
            tempLabel.Text = "Stop";
            //Total label
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defTotalBackColor, theme.defTotalForeColor, 0, null, true, true, 2, 0);
            tempLabel.Text = "Total: 00:00:00";
            //Up button
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 1, up_Click, true, false, 0, 1);
            tempLabel.Text = "p";
            //Down button
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 1, down_Click, true, false, 1, 1);
            tempLabel.Text = "q";
            //Open Report
            StaticUtility.addLabel(ref TLP, ref tempLabel, theme.defUpDwBackColor, theme.defUpDwForeColor, 2, config_Click, true, true, 2, 1);
            tempLabel.Text = "Report && Configuration";

            //Setup the default name settings
            string[] nameLiDefault = Properties.Settings.Default.NameList.Split(new char[] { ',' });

            for (int i = 0; i < nameLiDefault.Length; i++)
            {
                textBoxNamesArray[i] = nameLiDefault[i];
                addTimerRow(ref TLP, textBoxNamesArray[i], false);
            }

            TLP.ResumeLayout(false);
            TLP.PerformLayout();
            ResumeLayout(false);
            PerformLayout();
        }