Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
juusimaa committed Jan 21, 2018
2 parents 71f98a2 + 07bcf51 commit a6cc143
Show file tree
Hide file tree
Showing 41 changed files with 713 additions and 2,238 deletions.
10 changes: 4 additions & 6 deletions EuriborSharp.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EuriborSharp", "EuriborSharp\EuriborSharp.csproj", "{6543FB07-BD8D-447E-B956-03B039F35372}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "EuriborSharpSetup", "EuriborSharpSetup\EuriborSharpSetup.vdproj", "{001B324C-6B52-4BC9-B5E9-543F92156913}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Expand All @@ -15,8 +15,6 @@ Global
{6543FB07-BD8D-447E-B956-03B039F35372}.Debug|x86.Build.0 = Debug|x86
{6543FB07-BD8D-447E-B956-03B039F35372}.Release|x86.ActiveCfg = Release|x86
{6543FB07-BD8D-447E-B956-03B039F35372}.Release|x86.Build.0 = Release|x86
{001B324C-6B52-4BC9-B5E9-543F92156913}.Debug|x86.ActiveCfg = Debug
{001B324C-6B52-4BC9-B5E9-543F92156913}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
22 changes: 13 additions & 9 deletions EuriborSharp/EuriborSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@
<ApplicationIcon>euro-1.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="MoreLinq">
<HintPath>..\packages\morelinq.1.1.0\lib\net35\MoreLinq.dll</HintPath>
<Reference Include="MoreLinq, Version=2.9.21302.0, Culture=neutral, PublicKeyToken=384d532d7e88985d, processorArchitecture=MSIL">
<HintPath>..\packages\morelinq.2.9.0\lib\net40\MoreLinq.dll</HintPath>
</Reference>
<Reference Include="OxyPlot">
<HintPath>..\packages\OxyPlot.Core.2014.1.444\lib\portable-net4+sl4+wp71+win8\OxyPlot.dll</HintPath>
<Reference Include="OxyPlot, Version=2014.1.546.0, Culture=neutral, PublicKeyToken=638079a8f0bd61e9, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OxyPlot.Core.2014.1.546\lib\portable-net4+sl4+wp71+win8\OxyPlot.dll</HintPath>
</Reference>
<Reference Include="OxyPlot.WindowsForms">
<HintPath>..\packages\OxyPlot.WindowsForms.2014.1.444\lib\net40\OxyPlot.WindowsForms.dll</HintPath>
<Reference Include="OxyPlot.WindowsForms, Version=2014.1.546.0, Culture=neutral, PublicKeyToken=245eacd6b5d2d338, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OxyPlot.WindowsForms.2014.1.546\lib\net40\OxyPlot.WindowsForms.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -140,11 +145,10 @@
</ItemGroup>
<ItemGroup>
<Content Include="euro-1.ico" />
<EmbeddedResource Include="Resources\EuriborSources.xml" />
<None Include="euro-1.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
Expand Down
6 changes: 3 additions & 3 deletions EuriborSharp/EuriborSharpSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions EuriborSharp/EuriborSharpSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Value Profile="(Default)">http://www.suomenpankki.fi/fi/_layouts/BOF/RSS.ashx/tilastot/Korot/fi</Value>
</Setting>
<Setting Name="SmoothLine" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DotLineSelected" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
Expand All @@ -27,7 +27,7 @@
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="EuriborDefaultUrl" Type="System.String" Scope="User">
<Value Profile="(Default)">http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2014.csv</Value>
<Value Profile="(Default)">http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2015.csv</Value>
</Setting>
<Setting Name="UpdateInterval" Type="System.TimeSpan" Scope="User">
<Value Profile="(Default)">12:00:00</Value>
Expand Down
2 changes: 2 additions & 0 deletions EuriborSharp/Interfaces/IGraphControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ interface IGraphControl
/// Updated all plot data series.
/// </summary>
void UpdateGraph();

void ViewLastDays(int days);
}
}
5 changes: 5 additions & 0 deletions EuriborSharp/Interfaces/IMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ interface IMainForm
/// </summary>
event EventHandler ExitSelected;

/// <summary>
/// Occurs when view last 30 days is selected from the menu.
/// </summary>
event EventHandler<BooleanEventArg> View30DaysSelected;

void Close();
void Dispose();
void AddControl(UserControl control, string tabName);
Expand Down
58 changes: 39 additions & 19 deletions EuriborSharp/Model/TheEuribors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,64 @@
using EuriborSharp.Enums;
using EuriborSharp.Properties;
using MoreLinq;
using System.Xml.Serialization;

namespace EuriborSharp.Model
{
[Serializable]
public static class TheEuribors
{
public static Dictionary<string, string> urlList = new Dictionary<string, string>
{
{ "hist_EURIBOR_2014.csv", "http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2014.csv" },
{ "hist_EURIBOR_2013.csv", "http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2013.csv"},
{ "hist_EURIBOR_2012.csv", "http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2012.csv"},
{ "hist_EURIBOR_2011.csv", "http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2011.csv"},
{ "hist_EURIBOR_2010.csv", "http://www.emmi-benchmarks.eu/assets/modules/rateisblue/processed_files/hist_EURIBOR_2010.csv" }
};
public static List<EuriborFile> EuriborFiles = new List<EuriborFile>();

public static List<NewEuriborClass> NewInterestList { get; private set; }

static TheEuribors()
{
DeserializeList();
NewInterestList = new List<NewEuriborClass>();
}

private static void SerialzeList()
{
using (var fs = new FileStream("EuriborSources.xml", FileMode.Create, FileAccess.Write))
{
var ser = new XmlSerializer(typeof(List<EuriborFile>));
ser.Serialize(fs, EuriborFiles);
}
}

private static void DeserializeList()
{
using (var fs = new FileStream("EuriborSources.xml", FileMode.Open, FileAccess.Read))
{
var ser = new XmlSerializer(typeof(List<EuriborFile>));
EuriborFiles = (List<EuriborFile>)ser.Deserialize(fs);
}
}

/// <summary>
/// Checks if downloaded history data is older than UPDATE_INTERVAL_IN_DAYS.
/// </summary>
/// <returns>Returns true is newest history data is older than UPDATE_INTERVAL_IN_DAYS. Otherwise returns false.</returns>
public static bool NeedUpdatating()
{
var latest = DateTime.Now - File.GetLastWriteTime("hist_EURIBOR_2014.csv");
var latest = DateTime.Now - File.GetLastWriteTime("hist_EURIBOR_2015.csv");

return (latest > EuriborSharpSettings.Default.UpdateInterval);
}

public static DateTime GetLastUpdateTime()
{
return File.GetLastWriteTime("hist_EURIBOR_2014.csv");
return File.GetLastWriteTime("hist_EURIBOR_2015.csv");
}

public static void ParseValues()
{
try
{
foreach (var item in urlList)
foreach (var item in EuriborFiles)
{
using (var sr = new StreamReader(item.Key))
using (var sr = new StreamReader(item.Filename))
{
string line;

Expand All @@ -63,15 +76,15 @@ public static void ParseValues()
while ((line = sr.ReadLine()) != null)
{
if (line.StartsWith(","))
dates = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
dates = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
else if (line.StartsWith("1m"))
oneMonthValues = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
oneMonthValues = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
else if (line.StartsWith("3m"))
threeMonthValues = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
threeMonthValues = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
else if (line.StartsWith("6m"))
sixMonthValues = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
sixMonthValues = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
else if (line.StartsWith("12m"))
twelveMonthValues = line.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList();
twelveMonthValues = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}

// remove first item (label)
Expand Down Expand Up @@ -155,8 +168,8 @@ public static decimal GetMinimumInterest(TimePeriods periods)
: NewInterestList.MinBy(r => r.EuriborValue).EuriborValue;
}

return NewInterestList.Count == 0 ?
0M :
return NewInterestList.Count == 0 ?
0M :
NewInterestList.Where(e => e.TimePeriod == periods).MinBy(r => r.EuriborValue).EuriborValue;
}

Expand Down Expand Up @@ -202,4 +215,11 @@ public NewEuriborClass(TimePeriods t, DateTime d, decimal e)
EuriborValue = e;
}
}

public class EuriborFile
{
public string Url { get; set; }
public string Filename { get; set; }
public DateTime Year { get; set; }
}
}
2 changes: 1 addition & 1 deletion EuriborSharp/Presenters/AboutFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void ShowAboutForm()

_form.UpdateTitle(AssemblyTitle);
_form.UpdateCopyright(AssemblyCopyright);
_form.UpdateVersion(AssemblyVersion.Major + "." + AssemblyVersion.Minor + " (build " + AssemblyVersion.Build + ")");
_form.UpdateVersion(AssemblyVersion.Major + "." + AssemblyVersion.Minor + "." + AssemblyVersion.Build);

_form.ShowDialog();
}
Expand Down
45 changes: 41 additions & 4 deletions EuriborSharp/Presenters/MainFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using EuriborSharp.Interfaces;
using EuriborSharp.Model;
using EuriborSharp.Views;
using System.Reflection;

#endregion

Expand All @@ -33,6 +34,8 @@ public class MainFormPresenter : IDisposable

public MainFormPresenter()
{
WriteResourcesToDisk();

_downloader = new BackgroundWorker {WorkerSupportsCancellation = true};
_downloader.DoWork += _downloader_DoWork;
_downloader.RunWorkerCompleted += _downloader_RunWorkerCompleted;
Expand All @@ -46,6 +49,7 @@ public MainFormPresenter()
_mainForm.DotLineSelected += _mainForm_DotLineSelected;
_mainForm.UpdateIntervalChanged += _mainForm_UpdateIntervalChanged;
_mainForm.UpdateRequested += _mainForm_UpdateRequested;
_mainForm.View30DaysSelected += _mainForm_View30DaysSelected;

_logControl = new LogControl();
_logControl.Init();
Expand Down Expand Up @@ -90,6 +94,39 @@ public MainFormPresenter()
#endif
}

void WriteResourcesToDisk()
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EuriborSharp.Resources.EuriborSources.xml"))
{
using (FileStream fileStream = new FileStream("EuriborSources.xml", FileMode.Create))
{
stream.CopyTo(fileStream);
}
}
}

void _mainForm_View30DaysSelected(object sender, BooleanEventArg e)
{
InitGraphs();

if (e.value)
{
_graphControl1Month.ViewLastDays(30);
_graphControl3Month.ViewLastDays(30);
_graphControl6Month.ViewLastDays(30);
_graphControl12Month.ViewLastDays(30);
_graphControlAll.ViewLastDays(30);
}
else
{
_graphControl1Month.UpdateGraph();
_graphControl3Month.UpdateGraph();
_graphControl6Month.UpdateGraph();
_graphControl12Month.UpdateGraph();
_graphControlAll.UpdateGraph();
}
}

void _mainForm_UpdateRequested(object sender, EventArgs e)
{
_downloader.RunWorkerAsync();
Expand Down Expand Up @@ -122,12 +159,12 @@ void _downloader_DoWork(object sender, DoWorkEventArgs e)

var downloader = new WebClient();

foreach (var item in TheEuribors.urlList)
foreach (var item in TheEuribors.EuriborFiles)
{
if (!File.Exists(item.Key) || item.Key.Contains("2014"))
if (!File.Exists(item.Filename) || item.Year.Year == DateTime.Now.Year)
{
downloader.DownloadFile(new Uri(item.Value), item.Key);
_logControl.AddText("Downloading " + item.Value + Environment.NewLine, true);
downloader.DownloadFile(new Uri(item.Url), item.Filename);
_logControl.AddText("Downloading " + item.Url + Environment.NewLine, true);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions EuriborSharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Jouni Uusimaa")]
[assembly: AssemblyProduct("EuriborSharp")]
[assembly: AssemblyCopyright("Copyright © Jouni Uusimaa")]
[assembly: AssemblyCopyright("Copyright 2018 © Jouni Uusimaa")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -31,5 +31,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.4.*")]
[assembly: AssemblyFileVersion("1.4.*")]
[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.7.1.0")]
Loading

0 comments on commit a6cc143

Please sign in to comment.