Skip to content

Commit ca642e0

Browse files
author
Jouni Uusimaa
committed
Merge branch 'release/1.1.0'
* 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.
2 parents 0f4a216 + b1a6825 commit ca642e0

File tree

14 files changed

+837
-92
lines changed

14 files changed

+837
-92
lines changed

EuriborSharp/EuriborSharp.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@
6363
<DesignTimeSharedInput>True</DesignTimeSharedInput>
6464
<DependentUpon>EuriborSharpSettings.settings</DependentUpon>
6565
</Compile>
66+
<Compile Include="Interfaces\IAboutFormPresenter.cs" />
6667
<Compile Include="Interfaces\IGraphControl.cs" />
6768
<Compile Include="Interfaces\ILogControl.cs" />
6869
<Compile Include="Interfaces\IMainForm.cs" />
6970
<Compile Include="Model\TheEuribors.cs" />
71+
<Compile Include="Presenters\AboutFormPresenter.cs" />
7072
<Compile Include="Presenters\MainFormPresenter.cs" />
73+
<Compile Include="Views\AboutForm.cs">
74+
<SubType>Form</SubType>
75+
</Compile>
76+
<Compile Include="Views\AboutForm.Designer.cs">
77+
<DependentUpon>AboutForm.cs</DependentUpon>
78+
</Compile>
7179
<Compile Include="Views\GraphControl.cs">
7280
<SubType>UserControl</SubType>
7381
</Compile>
@@ -88,6 +96,9 @@
8896
</Compile>
8997
<Compile Include="Program.cs" />
9098
<Compile Include="Properties\AssemblyInfo.cs" />
99+
<EmbeddedResource Include="Views\AboutForm.resx">
100+
<DependentUpon>AboutForm.cs</DependentUpon>
101+
</EmbeddedResource>
91102
<EmbeddedResource Include="Views\GraphControl.resx">
92103
<DependentUpon>GraphControl.cs</DependentUpon>
93104
</EmbeddedResource>
@@ -105,6 +116,7 @@
105116
<Compile Include="Properties\Resources.Designer.cs">
106117
<AutoGen>True</AutoGen>
107118
<DependentUpon>Resources.resx</DependentUpon>
119+
<DesignTime>True</DesignTime>
108120
</Compile>
109121
<None Include="app.config" />
110122
<None Include="EuriborSharpSettings.settings">
@@ -124,6 +136,7 @@
124136
</ItemGroup>
125137
<ItemGroup>
126138
<Content Include="euro-1.ico" />
139+
<None Include="euro-1.png" />
127140
</ItemGroup>
128141
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
129142
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace EuriborSharp.Interfaces
2+
{
3+
interface IAboutFormPresenter
4+
{
5+
void ShowAboutForm();
6+
}
7+
}

EuriborSharp/Model/TheEuribors.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text.RegularExpressions;
77
using System.Xml.Serialization;
88
using EuriborSharp.Enums;
9+
using EuriborSharp.Properties;
910

1011
namespace EuriborSharp.Model
1112
{
@@ -16,7 +17,7 @@ public static class TheEuribors
1617

1718
public static void Save()
1819
{
19-
using (var fs = new FileStream("data.xml", FileMode.Create, FileAccess.Write))
20+
using (var fs = new FileStream(Resources.DATAFILE_NAME, FileMode.Create, FileAccess.Write))
2021
{
2122
var xs = new XmlSerializer(typeof(List<Euribors>));
2223
xs.Serialize(fs, InterestList);
@@ -27,7 +28,7 @@ public static void Load()
2728
{
2829
try
2930
{
30-
using (var fs = new FileStream("data.xml", FileMode.Open, FileAccess.Read))
31+
using (var fs = new FileStream(Resources.DATAFILE_NAME, FileMode.Open, FileAccess.Read))
3132
{
3233
var xs = new XmlSerializer(typeof (List<Euribors>));
3334
InterestList = (List<Euribors>) xs.Deserialize(fs);
@@ -67,6 +68,8 @@ public static decimal GetMaximumInterest(TimePeriods periods)
6768
return InterestList.Max(e => e.SixMonths);
6869
case TimePeriods.TwelveMonths:
6970
return InterestList.Max(e => e.TwelveMonths);
71+
case TimePeriods.Default:
72+
return InterestList.Max(e => new List<decimal> {e.OneMonth, e.OneWeek, e.SixMonths, e.ThreeMonths, e.TwelveMonths, e.TwoWeeks}.Max());
7073
default:
7174
throw new ArgumentOutOfRangeException("periods");
7275
}
@@ -90,6 +93,8 @@ public static decimal GetMinimumInterest(TimePeriods periods)
9093
return InterestList.Min(e => e.SixMonths);
9194
case TimePeriods.TwelveMonths:
9295
return InterestList.Min(e => e.TwelveMonths);
96+
case TimePeriods.Default:
97+
return InterestList.Min(e => new List<decimal> { e.OneMonth, e.OneWeek, e.SixMonths, e.ThreeMonths, e.TwelveMonths, e.TwoWeeks }.Min());
9398
default:
9499
throw new ArgumentOutOfRangeException("periods");
95100
}
@@ -123,19 +128,19 @@ public static string GetInterestName(TimePeriods period)
123128
switch (period)
124129
{
125130
case TimePeriods.Default:
126-
return String.Empty;
131+
return Resources.CHART_TITLE_ALL;
127132
case TimePeriods.OneWeek:
128-
return "1 week";
133+
return Resources.CHART_TITLE_1W;
129134
case TimePeriods.TwoWeeks:
130-
return "2 weeks";
135+
return Resources.CHART_TITLE_2W;
131136
case TimePeriods.OneMonth:
132-
return "1 month";
137+
return Resources.CHART_TITLE_1;
133138
case TimePeriods.ThreeMonths:
134-
return "3 months";
139+
return Resources.CHART_TITLE_3;
135140
case TimePeriods.SixMonths:
136-
return "6 months";
141+
return Resources.CHART_TITLE_6;
137142
case TimePeriods.TwelveMonths:
138-
return "12 months";
143+
return Resources.CHART_TITLE_12;
139144
default:
140145
throw new ArgumentOutOfRangeException("period");
141146
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.IO;
4+
using System.Reflection;
5+
using System.Windows.Forms;
6+
using EuriborSharp.Interfaces;
7+
using EuriborSharp.Views;
8+
9+
namespace EuriborSharp.Presenters
10+
{
11+
class AboutFormPresenter : IAboutFormPresenter
12+
{
13+
public void ShowAboutForm()
14+
{
15+
var form = new AboutForm {StartPosition = FormStartPosition.CenterParent};
16+
form.LinkClicked += form_LinkClicked;
17+
18+
form.UpdateTitle(AssemblyTitle);
19+
form.UpdateCopyright(AssemblyCopyright);
20+
form.UpdateVersion(AssemblyVersion.Major + "." + AssemblyVersion.Minor + " (build " + AssemblyVersion.Build + ")");
21+
22+
form.ShowDialog();
23+
}
24+
25+
static void form_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
26+
{
27+
var l = e.Link.LinkData.ToString();
28+
29+
if (!String.IsNullOrEmpty(l))
30+
Process.Start(l);
31+
}
32+
33+
#region Assembly Attribute Accessors
34+
35+
private static string AssemblyTitle
36+
{
37+
get
38+
{
39+
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
40+
41+
if (attributes.Length <= 0) return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
42+
43+
var titleAttribute = (AssemblyTitleAttribute)attributes[0];
44+
45+
return titleAttribute.Title != "" ? titleAttribute.Title : Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
46+
}
47+
}
48+
49+
private static Version AssemblyVersion
50+
{
51+
get { return Assembly.GetExecutingAssembly().GetName().Version; }
52+
}
53+
54+
private static string AssemblyCopyright
55+
{
56+
get
57+
{
58+
var attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
59+
return attributes.Length == 0 ? "" : ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
60+
}
61+
}
62+
63+
#endregion
64+
}
65+
}

EuriborSharp/Presenters/MainFormPresenter.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class MainFormPresenter : IDisposable
2626
private readonly IGraphControl _graphControl3Month;
2727
private readonly IGraphControl _graphControl6Month;
2828
private readonly IGraphControl _graphControl12Month;
29+
private readonly IGraphControl _graphControlAll;
30+
private readonly IAboutFormPresenter _aboutFormPresenter;
2931

3032
private readonly BackgroundWorker _feedReader;
3133

@@ -55,9 +57,12 @@ public MainFormPresenter()
5557
_graphControl3Month = new GraphControl();
5658
_graphControl6Month = new GraphControl();
5759
_graphControl12Month = new GraphControl();
60+
_graphControlAll = new GraphControl();
5861

5962
InitGraphs();
6063

64+
_aboutFormPresenter = new AboutFormPresenter();
65+
6166
_mainForm.UpdateSmoothSelection(EuriborSharpSettings.Default.SmoothLine);
6267
_mainForm.UpdateLineStyleSelection(EuriborSharpSettings.Default.NormalLineSelected);
6368
_mainForm.UpdateRendererSelection(EuriborSharpSettings.Default.Xkcd);
@@ -66,6 +71,7 @@ public MainFormPresenter()
6671
_mainForm.AddControl((UserControl)_graphControl3Month, TheEuribors.GetInterestName(TimePeriods.ThreeMonths));
6772
_mainForm.AddControl((UserControl)_graphControl6Month, TheEuribors.GetInterestName(TimePeriods.SixMonths));
6873
_mainForm.AddControl((UserControl)_graphControl12Month, TheEuribors.GetInterestName(TimePeriods.TwelveMonths));
74+
_mainForm.AddControl((UserControl)_graphControlAll, TheEuribors.GetInterestName(TimePeriods.Default));
6975
#if DEBUG
7076
_mainForm.AddControl((UserControl)_logControl, "Log");
7177
#endif
@@ -89,6 +95,7 @@ private void UpdateGraphView()
8995
_graphControl3Month.UpdateGraph();
9096
_graphControl6Month.UpdateGraph();
9197
_graphControl12Month.UpdateGraph();
98+
_graphControlAll.UpdateGraph();
9299
}
93100

94101
private void InitGraphs()
@@ -97,6 +104,7 @@ private void InitGraphs()
97104
_graphControl3Month.Init(TimePeriods.ThreeMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
98105
_graphControl6Month.Init(TimePeriods.SixMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
99106
_graphControl12Month.Init(TimePeriods.TwelveMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
107+
_graphControlAll.Init(TimePeriods.Default, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
100108
}
101109

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

124132
void _mainForm_LineSmoothChanged(object sender, BooleanEventArg e)
125133
{
134+
EuriborSharpSettings.Default.SmoothLine = e.value;
135+
EuriborSharpSettings.Default.Save();
126136
_graphControl1Month.UpdateSmoothing(e.value);
127-
_graphControl1Month.UpdateGraph();
128137
_graphControl3Month.UpdateSmoothing(e.value);
129-
_graphControl3Month.UpdateGraph();
130138
_graphControl6Month.UpdateSmoothing(e.value);
131-
_graphControl6Month.UpdateGraph();
132139
_graphControl12Month.UpdateSmoothing(e.value);
133-
_graphControl12Month.UpdateGraph();
134-
135-
EuriborSharpSettings.Default.SmoothLine = e.value;
136-
EuriborSharpSettings.Default.Save();
140+
UpdateGraphView();
137141
}
138142

139143
void _mainForm_ExitSelected(object sender, EventArgs e)
@@ -142,9 +146,9 @@ void _mainForm_ExitSelected(object sender, EventArgs e)
142146
_mainForm.Close();
143147
}
144148

145-
static void _mainForm_HelpSelected(object sender, EventArgs e)
149+
void _mainForm_HelpSelected(object sender, EventArgs e)
146150
{
147-
throw new NotImplementedException();
151+
_aboutFormPresenter.ShowAboutForm();
148152
}
149153

150154
static void _logControl_AddressChanged(object sender, StringEventArg e)

EuriborSharp/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
34+
[assembly: AssemblyVersion("1.1.*")]
35+
[assembly: AssemblyFileVersion("1.1.*")]

0 commit comments

Comments
 (0)