Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
Version 1.0.1
Browse files Browse the repository at this point in the history
* Now saving settings when hit start.
* Added Newtonsoft.Json.dll
  • Loading branch information
Exel80 committed Nov 2, 2016
1 parent 539e097 commit 7a26698
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 4 deletions.
Binary file added Builded/Newtonsoft.Json.dll
Binary file not shown.
Binary file modified Builded/Timer.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions Timer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
19 changes: 19 additions & 0 deletions Timer/Storing.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Timer
{
class Storing
{
// Set timer
public int hours { get; set; }
public int minutes { get; set; }
public int seconds { get; set; }

// Output
public string path { get; set; }
public string format { get; set; }
}
}
49 changes: 47 additions & 2 deletions Timer/Timer.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Newtonsoft.Json;

namespace Timer
{
public partial class Timer : Form
Expand All @@ -17,6 +21,9 @@ public Timer()
{
InitializeComponent();
updateTimerLabels();

if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/Settings.json"))
readData();
}

#region Numerics
Expand Down Expand Up @@ -49,6 +56,8 @@ private void buttonStart_Click(object sender, EventArgs e)
return;
}

writeData();

CooldownTimer.Start();
CooldownTimer.Enabled = true;

Expand Down Expand Up @@ -108,6 +117,10 @@ private void CooldownTimer_Tick(object sender, EventArgs e)
{
CooldownTimer.Stop();
CooldownTimer.Enabled = false;

buttonStart.Enabled = true;
buttonPause.Enabled = false;
buttonStop.Enabled = false;
}
}
private void updateOutput(string path)
Expand Down Expand Up @@ -145,11 +158,43 @@ private void updateTimerLabels()
Hours.Text = numericHours.Value.ToString();
}
}
#endregion

private void label2_Click(object sender, EventArgs e)
{
MessageBox.Show("{0} = Time will be print here.\n^ This must be included in format! Other ways timer will not been shown!\n\nHere is one example format what you can try out:\nStream start soon, {0}!");
}
#endregion

#region JSON
private void writeData()
{
Storing _storing = new Storing();

_storing.hours = Convert.ToInt32(numericHours.Value);
_storing.minutes = Convert.ToInt32(numericMinutes.Value);
_storing.seconds = Convert.ToInt32(numericSeconds.Value);

_storing.path = ouputText.Text;
_storing.format = Format.Text;

Debug.WriteLine(JsonConvert.SerializeObject(_storing));

using (StreamWriter file = File.CreateText(AppDomain.CurrentDomain.BaseDirectory + "/Settings.json"))
{
JsonSerializer serializer = new JsonSerializer();
serializer.Serialize(file, _storing);
}
}
private void readData()
{
Storing _storing = JsonConvert.DeserializeObject<Storing>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Settings.json"));

numericHours.Value = _storing.hours;
numericMinutes.Value = _storing.minutes;
numericSeconds.Value = _storing.seconds;

ouputText.Text = _storing.path;
Format.Text = _storing.format;
}
#endregion
}
}
17 changes: 17 additions & 0 deletions Timer/Timer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -31,7 +34,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net35\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -43,6 +54,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Storing.cs" />
<Compile Include="Timer.cs">
<SubType>Form</SubType>
</Compile>
Expand All @@ -63,6 +75,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -74,6 +87,10 @@
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 4 additions & 0 deletions Timer/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net35" />
</packages>

0 comments on commit 7a26698

Please sign in to comment.