Commit 186b50a3 authored by Curny's avatar Curny
Browse files

Updated to Version 2.0

Fixed bug in minute count, switched to stopwatch
parent 9f3d4b73
......@@ -22,4 +22,11 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01EC7AD5-622E-4A14-9B60-2D935F37352F}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = PrefixedHierarchical
$0.StandardHeader = $2
version = 2.0
EndGlobalSection
EndGlobal
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace Timer
{
public partial class Form1 : Form
{
Stopwatch sw = new Stopwatch();
private string sessionStartDate = null; // session start date
private string sessionStartTime = null; // session start time
private string sessionTime = null; // session last that long
......@@ -16,12 +18,6 @@ namespace Timer
InitializeComponent();
}
// initialize timer values
private int sekunden = 0;
private int sekundentotal = 0;
private int minuten = 0;
private int stunden = 0;
private void Form1_Load(object sender, EventArgs e)
{
// visual setting for startup
......@@ -54,15 +50,14 @@ namespace Timer
// The start button for time logging does the following when pressed:
private void CmdStart_Click(object sender, EventArgs e)
{
sw.Start();
LblCustomerNameHeadline.Enabled = false; // disable headline
CmbCustomer.Enabled = false; // disable customer/project selection
CmdStart.Enabled = false; // disable the start button as it has already been pressed
CmdStop.Enabled = true; // enable the stop button
LblSessionEndTime.Text = ""; // clear the session end time string
LblSessionTimer.Text = "00:00:00"; // set the timer text to 00:00:00
sekunden = sekundentotal - ((sekundentotal / 60) * 60); // calculate the sconds (needed if over 59)
LblSessionTimer.Text = "00:00:00";
sessionStartDate = DateTime.Now.ToShortDateString(); // this stores the start date of the session
sessionStartTime = DateTime.Now.ToLongTimeString(); // we set the start time for this session to now
......@@ -75,6 +70,7 @@ namespace Timer
// The stop button for time logging does the following when pressed:
private void CmdStop_Click(object sender, EventArgs e)
{
sw.Stop();
CmdStop.Enabled = false; // disable the stop button
CmdStart.Enabled = true; // enable the start button
......@@ -87,52 +83,35 @@ namespace Timer
// write the name + dates + times to .csv file
WriteLog.ToFile(Config.LogFileName,
CmbCustomer.SelectedItem.ToString(),
Config.UserName,
sessionTime,
sessionStartDate,
sessionStartTime,
sessionEndDate,
sessionEndTime);
try
{
WriteLog.ToFile(Config.LogFileName,
CmbCustomer.SelectedItem.ToString(),
Config.UserName,
sessionTime,
sessionStartDate,
sessionStartTime,
sessionEndDate,
sessionEndTime);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// re-enable the customer/project selection box and the headline
CmbCustomer.Enabled = true;
LblCustomerNameHeadline.Enabled = true;
// reset session timer
sekunden = 0;
sekundentotal = 0;
minuten = 0;
stunden = 0;
}
// the session timer itself which calculates the time we used for this project/customer
private void SessionTimer_Tick(object sender, EventArgs e)
{
sekundentotal++; // increase the total seconds
sekunden++; // increase the seconds
// make sure that the seconds displayed in the window won't go over 59
if (sekunden > 59)
{
sekunden -= 60;
}
minuten = (sekundentotal / 60); // calculate minutes from the total seconds
stunden = minuten / 60; // calculate hours from the minutes
if (minuten > 59)
{
minuten -= 60;
}
sessionTime = stunden.ToString("D2") + ":" + minuten.ToString("D2") + ":" + sekunden.ToString("D2"); // crate the string for the session time
LblSessionTimer.Text = sessionTime; // write the string to the label in the window
sessionTime = sw.Elapsed.ToString("hh\\:mm\\:ss");
LblSessionTimer.Text = sessionTime;
}
......
......@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Willy Weinmann")]
[assembly: AssemblyProduct("wTimeTracker")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("GPL v3")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.0.0")]
......@@ -27,6 +27,7 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ReleaseVersion>2.0</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment