Skip to content

Commit

Permalink
Menu items implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouni Uusimaa committed Jun 16, 2014
1 parent 180ac79 commit 058f0f1
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 53 deletions.
24 changes: 24 additions & 0 deletions EuriborSharp/EuriborSharpSettings.Designer.cs

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

6 changes: 6 additions & 0 deletions EuriborSharp/EuriborSharpSettings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@
<Setting Name="Xkcd" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="DotLineSelected" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="NormalLineSelected" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
2 changes: 2 additions & 0 deletions EuriborSharp/Interfaces/IGraphControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ interface IGraphControl
void Init(Enums.TimePeriods period, bool smoothSelected, bool xkcd);
void UpdateGraph();
void UpdateSmoothing(bool b);
void SetLineStyleToNormal();
void SetLineStyleToDot();
}
}
2 changes: 2 additions & 0 deletions EuriborSharp/Interfaces/IMainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ interface IMainForm
void AddControl(UserControl control, string tabName);
void UpdateTitle(string s);
void UpdateSmoothSelection(bool selected);
void UpdateLineStyleSelection(bool normalSelected);
void UpdateRendererSelection(bool xkcdSelected);
}
}
3 changes: 0 additions & 3 deletions EuriborSharp/Model/TheEuribors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,5 @@ public class Euribors
public decimal OneWeek { get; set; }
public decimal TwoWeeks { get; set; }
public DateTime Date { get; set; }

public Euribors()
{}
}
}
50 changes: 30 additions & 20 deletions EuriborSharp/Presenters/MainFormPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace EuriborSharp.Presenters
{
public class MainFormPresenter : IDisposable
{
private const string FEED_ADDRESS = @"http://www.suomenpankki.fi/fi/_layouts/BOF/RSS.ashx/tilastot/Korot/fi";

// Flag: Has Dispose already been called?
private bool _disposed;

Expand Down Expand Up @@ -54,15 +52,15 @@ public MainFormPresenter()
_logControl.AddressChanged += _logControl_AddressChanged;

_graphControl1Month = new GraphControl();
_graphControl1Month.Init(TimePeriods.OneMonth, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl3Month = new GraphControl();
_graphControl3Month.Init(TimePeriods.ThreeMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl6Month = new GraphControl();
_graphControl6Month.Init(TimePeriods.SixMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl12Month = new GraphControl();
_graphControl12Month.Init(TimePeriods.TwelveMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);

InitGraphs();

_mainForm.UpdateSmoothSelection(EuriborSharpSettings.Default.SmoothLine);
_mainForm.UpdateLineStyleSelection(EuriborSharpSettings.Default.NormalLineSelected);
_mainForm.UpdateRendererSelection(EuriborSharpSettings.Default.Xkcd);

_mainForm.AddControl((UserControl) _graphControl1Month, TheEuribors.GetInterestName(TimePeriods.OneMonth));
_mainForm.AddControl((UserControl)_graphControl3Month, TheEuribors.GetInterestName(TimePeriods.ThreeMonths));
Expand All @@ -72,43 +70,55 @@ public MainFormPresenter()
_mainForm.AddControl((UserControl)_logControl, "Log");
#endif

_graphControl1Month.UpdateGraph();
_graphControl3Month.UpdateGraph();
_graphControl6Month.UpdateGraph();
_graphControl12Month.UpdateGraph();

UpdateGraphView();
_logControl.UpdateAddress(EuriborSharpSettings.Default.RssFeedAddress);

_feedReader.RunWorkerAsync();
}

void _mainForm_XkcdChanged(object sender, BooleanEventArg e)
{
EuriborSharpSettings.Default.Xkcd = e.value;
EuriborSharpSettings.Default.Save();
InitGraphs();
UpdateGraphView();
}

private void UpdateGraphView()
{
_graphControl1Month.Init(TimePeriods.OneMonth, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl1Month.UpdateGraph();
_graphControl3Month.Init(TimePeriods.ThreeMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl3Month.UpdateGraph();
_graphControl6Month.Init(TimePeriods.SixMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl6Month.UpdateGraph();
_graphControl12Month.Init(TimePeriods.TwelveMonths, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_graphControl12Month.UpdateGraph();
}

private void InitGraphs()
{
_graphControl1Month.Init(TimePeriods.OneMonth, EuriborSharpSettings.Default.SmoothLine, EuriborSharpSettings.Default.Xkcd);
_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);
}

void _mainForm_LineStyleNormalSelected(object sender, EventArgs e)
{
throw new NotImplementedException();
EuriborSharpSettings.Default.NormalLineSelected = true;
EuriborSharpSettings.Default.Save();
_graphControl1Month.SetLineStyleToNormal();
_graphControl3Month.SetLineStyleToNormal();
_graphControl6Month.SetLineStyleToNormal();
_graphControl12Month.SetLineStyleToNormal();
UpdateGraphView();
}

void _mainForm_LineStyleNoneSelected(object sender, EventArgs e)
{
throw new NotImplementedException();
EuriborSharpSettings.Default.DotLineSelected = true;
EuriborSharpSettings.Default.Save();
_graphControl1Month.SetLineStyleToDot();
_graphControl3Month.SetLineStyleToDot();
_graphControl6Month.SetLineStyleToDot();
_graphControl12Month.SetLineStyleToDot();
UpdateGraphView();
}

void _mainForm_LineSmoothChanged(object sender, BooleanEventArg e)
Expand All @@ -132,12 +142,12 @@ void _mainForm_ExitSelected(object sender, EventArgs e)
_mainForm.Close();
}

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

static void _logControl_AddressChanged(object sender, CustonEventArgs.StringEventArg e)
static void _logControl_AddressChanged(object sender, StringEventArg e)
{
EuriborSharpSettings.Default.RssFeedAddress = e.value;
EuriborSharpSettings.Default.Save();
Expand Down
1 change: 0 additions & 1 deletion EuriborSharp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
12 changes: 12 additions & 0 deletions EuriborSharp/Views/GraphControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public void UpdateSmoothing(bool b)
_euriborSeries.Smooth = b;
}

public void SetLineStyleToNormal()
{
_euriborSeries.LineStyle = LineStyle.Solid;
_graphPlotView.Refresh();
}

public void SetLineStyleToDot()
{
_euriborSeries.LineStyle = LineStyle.Dot;
_graphPlotView.Refresh();
}

private void AddPointsToSeries()
{
if (_euriborSeries == null) return;
Expand Down
54 changes: 27 additions & 27 deletions EuriborSharp/Views/MainForm.Designer.cs

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

17 changes: 15 additions & 2 deletions EuriborSharp/Views/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public void UpdateSmoothSelection(bool selected)
smoothToolStripMenuItem.Checked = selected;
}

public void UpdateLineStyleSelection(bool normalSelected)
{
normalLineStyleToolStripMenuItem.Checked = normalSelected;
dotLineStyleToolStripMenuItem.Checked = !normalSelected;
}

public void UpdateRendererSelection(bool xkcdSelected)
{
xkcdToolStripMenuItem.Checked = xkcdSelected;
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
HelpSelected(this, EventArgs.Empty);
Expand All @@ -50,13 +61,15 @@ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
ExitSelected(this, EventArgs.Empty);
}

private void noneToolStripMenuItem1_Click(object sender, EventArgs e)
private void dotLineStyleToolStripMenuItem_Click(object sender, EventArgs e)
{
normalLineStyleToolStripMenuItem.Checked = false;
LineStyleNoneSelected(this, EventArgs.Empty);
}

private void normalToolStripMenuItem_Click(object sender, EventArgs e)
private void normalLineStyleToolStripMenuItem_Click(object sender, EventArgs e)
{
dotLineStyleToolStripMenuItem.Checked = false;
LineStyleNormalSelected(this, EventArgs.Empty);
}

Expand Down
6 changes: 6 additions & 0 deletions EuriborSharp/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<setting name="Xkcd" serializeAs="String">
<value>True</value>
</setting>
<setting name="DotLineSelected" serializeAs="String">
<value>False</value>
</setting>
<setting name="NormalLineSelected" serializeAs="String">
<value>True</value>
</setting>
</EuriborSharp.EuriborSharpSettings>
</userSettings>
</configuration>

0 comments on commit 058f0f1

Please sign in to comment.