Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
* release/1.1.0:
  Version change.
  Warning cleanup.
  String resources.
  Added titles to series.
  Added page for all interest rates.
  Refresh graph when line smoothing changes.
  About form.
  Added AboutForm.
  • Loading branch information
Jouni Uusimaa committed Jul 1, 2014
2 parents 0f4a216 + b1a6825 commit ca642e0
Show file tree
Hide file tree
Showing 14 changed files with 837 additions and 92 deletions.
13 changes: 13 additions & 0 deletions EuriborSharp/EuriborSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>EuriborSharpSettings.settings</DependentUpon>
</Compile>
<Compile Include="Interfaces\IAboutFormPresenter.cs" />
<Compile Include="Interfaces\IGraphControl.cs" />
<Compile Include="Interfaces\ILogControl.cs" />
<Compile Include="Interfaces\IMainForm.cs" />
<Compile Include="Model\TheEuribors.cs" />
<Compile Include="Presenters\AboutFormPresenter.cs" />
<Compile Include="Presenters\MainFormPresenter.cs" />
<Compile Include="Views\AboutForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Views\AboutForm.Designer.cs">
<DependentUpon>AboutForm.cs</DependentUpon>
</Compile>
<Compile Include="Views\GraphControl.cs">
<SubType>UserControl</SubType>
</Compile>
Expand All @@ -88,6 +96,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Views\AboutForm.resx">
<DependentUpon>AboutForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Views\GraphControl.resx">
<DependentUpon>GraphControl.cs</DependentUpon>
</EmbeddedResource>
Expand All @@ -105,6 +116,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="EuriborSharpSettings.settings">
Expand All @@ -124,6 +136,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="euro-1.ico" />
<None Include="euro-1.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
7 changes: 7 additions & 0 deletions EuriborSharp/Interfaces/IAboutFormPresenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace EuriborSharp.Interfaces
{
interface IAboutFormPresenter
{
void ShowAboutForm();
}
}
23 changes: 14 additions & 9 deletions EuriborSharp/Model/TheEuribors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using EuriborSharp.Enums;
using EuriborSharp.Properties;

namespace EuriborSharp.Model
{
Expand All @@ -16,7 +17,7 @@ public static class TheEuribors

public static void Save()
{
using (var fs = new FileStream("data.xml", FileMode.Create, FileAccess.Write))
using (var fs = new FileStream(Resources.DATAFILE_NAME, FileMode.Create, FileAccess.Write))
{
var xs = new XmlSerializer(typeof(List<Euribors>));
xs.Serialize(fs, InterestList);
Expand All @@ -27,7 +28,7 @@ public static void Load()
{
try
{
using (var fs = new FileStream("data.xml", FileMode.Open, FileAccess.Read))
using (var fs = new FileStream(Resources.DATAFILE_NAME, FileMode.Open, FileAccess.Read))
{
var xs = new XmlSerializer(typeof (List<Euribors>));
InterestList = (List<Euribors>) xs.Deserialize(fs);
Expand Down Expand Up @@ -67,6 +68,8 @@ public static decimal GetMaximumInterest(TimePeriods periods)
return InterestList.Max(e => e.SixMonths);
case TimePeriods.TwelveMonths:
return InterestList.Max(e => e.TwelveMonths);
case TimePeriods.Default:
return InterestList.Max(e => new List<decimal> {e.OneMonth, e.OneWeek, e.SixMonths, e.ThreeMonths, e.TwelveMonths, e.TwoWeeks}.Max());
default:
throw new ArgumentOutOfRangeException("periods");
}
Expand All @@ -90,6 +93,8 @@ public static decimal GetMinimumInterest(TimePeriods periods)
return InterestList.Min(e => e.SixMonths);
case TimePeriods.TwelveMonths:
return InterestList.Min(e => e.TwelveMonths);
case TimePeriods.Default:
return InterestList.Min(e => new List<decimal> { e.OneMonth, e.OneWeek, e.SixMonths, e.ThreeMonths, e.TwelveMonths, e.TwoWeeks }.Min());
default:
throw new ArgumentOutOfRangeException("periods");
}
Expand Down Expand Up @@ -123,19 +128,19 @@ public static string GetInterestName(TimePeriods period)
switch (period)
{
case TimePeriods.Default:
return String.Empty;
return Resources.CHART_TITLE_ALL;
case TimePeriods.OneWeek:
return "1 week";
return Resources.CHART_TITLE_1W;
case TimePeriods.TwoWeeks:
return "2 weeks";
return Resources.CHART_TITLE_2W;
case TimePeriods.OneMonth:
return "1 month";
return Resources.CHART_TITLE_1;
case TimePeriods.ThreeMonths:
return "3 months";
return Resources.CHART_TITLE_3;
case TimePeriods.SixMonths:
return "6 months";
return Resources.CHART_TITLE_6;
case TimePeriods.TwelveMonths:
return "12 months";
return Resources.CHART_TITLE_12;
default:
throw new ArgumentOutOfRangeException("period");
}
Expand Down
65 changes: 65 additions & 0 deletions EuriborSharp/Presenters/AboutFormPresenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using EuriborSharp.Interfaces;
using EuriborSharp.Views;

namespace EuriborSharp.Presenters
{
class AboutFormPresenter : IAboutFormPresenter
{
public void ShowAboutForm()
{
var form = new AboutForm {StartPosition = FormStartPosition.CenterParent};
form.LinkClicked += form_LinkClicked;

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

form.ShowDialog();
}

static void form_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
var l = e.Link.LinkData.ToString();

if (!String.IsNullOrEmpty(l))
Process.Start(l);
}

#region Assembly Attribute Accessors

private static string AssemblyTitle
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);

if (attributes.Length <= 0) return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);

var titleAttribute = (AssemblyTitleAttribute)attributes[0];

return titleAttribute.Title != "" ? titleAttribute.Title : Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}

private static Version AssemblyVersion
{
get { return Assembly.GetExecutingAssembly().GetName().Version; }
}

private static string AssemblyCopyright
{
get
{
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
return attributes.Length == 0 ? "" : ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
}
}

#endregion
}
}
22 changes: 13 additions & 9 deletions EuriborSharp/Presenters/MainFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class MainFormPresenter : IDisposable
private readonly IGraphControl _graphControl3Month;
private readonly IGraphControl _graphControl6Month;
private readonly IGraphControl _graphControl12Month;
private readonly IGraphControl _graphControlAll;
private readonly IAboutFormPresenter _aboutFormPresenter;

private readonly BackgroundWorker _feedReader;

Expand Down Expand Up @@ -55,9 +57,12 @@ public MainFormPresenter()
_graphControl3Month = new GraphControl();
_graphControl6Month = new GraphControl();
_graphControl12Month = new GraphControl();
_graphControlAll = new GraphControl();

InitGraphs();

_aboutFormPresenter = new AboutFormPresenter();

_mainForm.UpdateSmoothSelection(EuriborSharpSettings.Default.SmoothLine);
_mainForm.UpdateLineStyleSelection(EuriborSharpSettings.Default.NormalLineSelected);
_mainForm.UpdateRendererSelection(EuriborSharpSettings.Default.Xkcd);
Expand All @@ -66,6 +71,7 @@ public MainFormPresenter()
_mainForm.AddControl((UserControl)_graphControl3Month, TheEuribors.GetInterestName(TimePeriods.ThreeMonths));
_mainForm.AddControl((UserControl)_graphControl6Month, TheEuribors.GetInterestName(TimePeriods.SixMonths));
_mainForm.AddControl((UserControl)_graphControl12Month, TheEuribors.GetInterestName(TimePeriods.TwelveMonths));
_mainForm.AddControl((UserControl)_graphControlAll, TheEuribors.GetInterestName(TimePeriods.Default));
#if DEBUG
_mainForm.AddControl((UserControl)_logControl, "Log");
#endif
Expand All @@ -89,6 +95,7 @@ private void UpdateGraphView()
_graphControl3Month.UpdateGraph();
_graphControl6Month.UpdateGraph();
_graphControl12Month.UpdateGraph();
_graphControlAll.UpdateGraph();
}

private void InitGraphs()
Expand All @@ -97,6 +104,7 @@ private void InitGraphs()
_graphControl3Month.Init(TimePeriods.ThreeMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl6Month.Init(TimePeriods.SixMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl12Month.Init(TimePeriods.TwelveMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControlAll.Init(TimePeriods.Default, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
}

void _mainForm_LineStyleNormalSelected(object sender, EventArgs e)
Expand All @@ -123,17 +131,13 @@ void _mainForm_LineStyleNoneSelected(object sender, EventArgs e)

void _mainForm_LineSmoothChanged(object sender, BooleanEventArg e)
{
EuriborSharpSettings.Default.SmoothLine = e.value;
EuriborSharpSettings.Default.Save();
_graphControl1Month.UpdateSmoothing(e.value);
_graphControl1Month.UpdateGraph();
_graphControl3Month.UpdateSmoothing(e.value);
_graphControl3Month.UpdateGraph();
_graphControl6Month.UpdateSmoothing(e.value);
_graphControl6Month.UpdateGraph();
_graphControl12Month.UpdateSmoothing(e.value);
_graphControl12Month.UpdateGraph();

EuriborSharpSettings.Default.SmoothLine = e.value;
EuriborSharpSettings.Default.Save();
UpdateGraphView();
}

void _mainForm_ExitSelected(object sender, EventArgs e)
Expand All @@ -142,9 +146,9 @@ void _mainForm_ExitSelected(object sender, EventArgs e)
_mainForm.Close();
}

static void _mainForm_HelpSelected(object sender, EventArgs e)
void _mainForm_HelpSelected(object sender, EventArgs e)
{
throw new NotImplementedException();
_aboutFormPresenter.ShowAboutForm();
}

static void _logControl_AddressChanged(object sender, StringEventArg e)
Expand Down
4 changes: 2 additions & 2 deletions EuriborSharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.*")]
[assembly: AssemblyFileVersion("1.1.*")]
Loading

0 comments on commit ca642e0

Please sign in to comment.