private void NewProject_Click(object sender, EventArgs e) { Retry: string NewProjectName = Microsoft.VisualBasic.Interaction.InputBox("Enter project name:", "New Project", "ProjectName"); if (((NewProjectName.IndexOf(" ") + 1) > 0)) { Microsoft.VisualBasic.Interaction.MsgBox("That project name included spaces. Please use only alphanumerical characters."); goto Retry; } string currentProjectsInIni = ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "Projects", "list"); if (((currentProjectsInIni.IndexOf("ERROR:") + 1) > 0)) { currentProjectsInIni = ""; } ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "Projects", "list", (currentProjectsInIni + (NewProjectName + ","))); ProjectSelector.Items.Clear(); GlobalVariables.projects = ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "Projects", "list"); this.PopulateComboBox(); ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "Times", NewProjectName, "0,0,0,0"); ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "History", NewProjectName, ""); }
private void ProjectSelector_SelectedValueChanged(object sender, EventArgs e) { GlobalVariables.CurrentProject = ProjectSelector.SelectedItem.ToString(); if ((ProjectSelector.SelectedItem.ToString() == "Please Select")) { HistoryBox.Text = "Please select or create a Project."; Days.Text = "0"; Hours.Text = "0"; Minutes.Text = "0"; } else { GlobalVariables.CurrentTime = ReadAndWriteIni.ReadIni((Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Timer.ini"), "Times", GlobalVariables.CurrentProject); string[] times = GlobalVariables.CurrentTime.Split(new char[] { ",", c }); Days.Text = times[0]; Hours.Text = times[1]; Minutes.Text = times[2]; Seconds.Text = times[3]; HistoryBox.Text = ("Selected Project: " + (GlobalVariables.CurrentProject + (Environment.NewLine + Environment.NewLine))); this.GetHistory(); } }
private void Timer_Load(object sender, EventArgs e) { GlobalVariables.iniFile = (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/Timer.ini"); GlobalVariables.projects = ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "Projects", "list"); HistoryBox.Text = (HistoryBox.Text + ("Please Selected a project." + Environment.NewLine)); HistoryBox.Text = (HistoryBox.Text + ("Available projects: " + (GlobalVariables.projects + Environment.NewLine))); this.PopulateComboBox(); }
private void DeleteProject_Click(object sender, EventArgs e) { string toBeDeleted = ProjectSelector.SelectedItem.ToString(); string projectsNow = GlobalVariables.projects.Replace((toBeDeleted + ","), ""); ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "Projects", "list", projectsNow); ReadAndWriteIni.deleteKeyFromIni(GlobalVariables.iniFile, "Times", toBeDeleted); ReadAndWriteIni.deleteKeyFromIni(GlobalVariables.iniFile, "History", toBeDeleted); ProjectSelector.Items.Clear(); GlobalVariables.projects = ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "Projects", "list"); this.PopulateComboBox(); }
private void StartStop_Click(object sender, EventArgs e) { DateTime moment = DateTime.Now; if ((StartStop.Text == "Start timer")) { DayTimer.Enabled = true; HourTimer.Enabled = true; MinuteTimer.Enabled = true; SecondTimer.Enabled = true; HistoryBox.Text = (HistoryBox.Text + ("START: " + (moment.ToString() + Environment.NewLine))); } else { DayTimer.Enabled = false; HourTimer.Enabled = false; MinuteTimer.Enabled = false; SecondTimer.Enabled = false; HistoryBox.Text = (HistoryBox.Text + ("STOP: " + (moment.ToString() + Environment.NewLine))); ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "Times", GlobalVariables.CurrentProject, (Days.Text + ("," + (Hours.Text + ("," + (Minutes.Text + ("," + Seconds.Text))))))); string History; History = HistoryBox.Text.Replace(Environment.NewLine, ",").ToString(); ReadAndWriteIni.writeIni(GlobalVariables.iniFile, "History", GlobalVariables.CurrentProject, History.Replace(("Selected Project: " + (GlobalVariables.CurrentProject + ",,")), "")); } if ((StartStop.Text == "Start timer")) { StartStop.Text = "Stop timer"; } else { StartStop.Text = "Start timer"; } }
private void GetHistory() { int amountOfHistoryEntries; amountOfHistoryEntries = (this.FindWords(ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "History", GlobalVariables.CurrentProject), ",") - 1); string[] Entries = null; for (int i = amountOfHistoryEntries; (i <= 0); i = (i + -1)) { Entries = ReadAndWriteIni.ReadIni(GlobalVariables.iniFile, "History", GlobalVariables.CurrentProject).Split(new char[] { ",", c }); } if (!(Entries == null)) { for (int i = 0; (i <= (Entries.Length - 2)); i++) { HistoryBox.Text = (HistoryBox.Text + (Entries[i] + Environment.NewLine)); } } }