Permalink
Browse files

Removed an unused function, and added further comments to the code.

  • Loading branch information...
1 parent 133c502 commit eed67764be8c29112c4809bcef2831f66963900e @barrylapthorn committed Feb 8, 2012
@@ -70,7 +70,6 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
- <Compile Include="Models\EnumExtension.cs" />
<Compile Include="Models\ISettingsModel.cs" />
<Compile Include="Models\ITimerModel.cs" />
<Compile Include="Models\SettingsModelFactory.cs" />
@@ -80,6 +79,7 @@
<Compile Include="Models\TimerModel.cs" />
<Compile Include="Models\TimerModelEventArgs.cs" />
<Compile Include="Models\TimerModelFactory.cs" />
+ <Compile Include="Models\TimerState.cs" />
<Compile Include="ViewModels\AboutViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\TimerViewModel.cs" />
@@ -21,27 +21,28 @@
namespace Btl
{
/// <summary>
- /// Interaction logic for MainWindow.xaml
+ /// Most of the cruft in this class is to manage the taskbar item preview
+ /// and the window title.
/// </summary>
public partial class MainWindow : Window
{
-
public MainWindow()
{
InitializeComponent();
+ // Reposition the window to where it last was.
LoadWindowPosition();
// Consume any TaskbarItemMessages that are being dispatched around
// the mvvm framework.
Messenger.Default.Register<TaskbarItemMessage>(this, ConsumeTaskbarItemMessage);
Messenger.Default.Register<SimpleMessage>(this, ConsumeSimpleMessage);
- WindowTitle = this.Title;
+ WindowTitle = Title;
}
/// <summary>
- /// Update the TaskbarItemInfo values with whatever is specifed in the
+ /// Update the TaskbarItemInfo values with whatever is specified in the
/// message.
/// </summary>
/// <param name="message"></param>
@@ -50,35 +51,43 @@ void ConsumeTaskbarItemMessage(TaskbarItemMessage message)
if (message == null)
return;
- this.TaskbarItemInfo.ProgressState = message.State;
+ TaskbarItemInfo.ProgressState = message.State;
+ // if the taskbar item message carried a (percentage) value,
+ // update the taskbar progressvalue with it.
if (message.HasValue)
- this.TaskbarItemInfo.ProgressValue = message.Value;
+ TaskbarItemInfo.ProgressValue = message.Value;
}
+ /// <summary>
+ /// If the user has changed the settings, the only thing that affects
+ /// the MainWindow state is its TopMost value.
+ /// </summary>
private void OnSettingsChanged()
{
var settings = SettingsModelFactory.GetNewSettings();
- this.Topmost = settings.TopMost;
+ Topmost = settings.TopMost;
}
/// <summary>
- /// Only respond to settings that directly affect this main window.
+ /// Only respond to settings that directly affect this main window,
+ /// and do not handle the rest.
/// </summary>
/// <param name="message"></param>
private void ConsumeSimpleMessage(SimpleMessage message)
{
switch (message.Type)
{
+ case SimpleMessage.MessageType.TimerTick:
+ // this happens the most so put it first
+ Title = message.Message;
+ break;
case SimpleMessage.MessageType.SettingsChanged:
OnSettingsChanged();
break;
case SimpleMessage.MessageType.TimerStop:
Title = WindowTitle;
break;
- case SimpleMessage.MessageType.TimerTick:
- Title = message.Message;
- break;
case SimpleMessage.MessageType.TimerReset:
// restore window title if we reset.
Title = WindowTitle;
@@ -87,12 +96,13 @@ private void ConsumeSimpleMessage(SimpleMessage message)
}
/// <summary>
- /// Window closing event.
+ /// Window closing event. Save the window position.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
+ // Persist the window position.
SaveWindowPosition();
}
@@ -129,6 +139,9 @@ private void LoadWindowPosition()
this.Topmost = settings.TopMost;
}
+ /// <summary>
+ /// Store the window title away as we change it later.
+ /// </summary>
private string WindowTitle { get; set; }
}
@@ -17,6 +17,11 @@
namespace Btl.Models
{
+ /// <summary>
+ /// A simple message class that we use to pass messages around the application
+ /// via the Messenger singleton, but keep the parts sufficiently decoupled
+ /// for the MVVM style of work.
+ /// </summary>
public class SimpleMessage
{
public SimpleMessage() : this(MessageType.SwitchToTimerView)
@@ -19,13 +19,6 @@
namespace Btl.Models
{
- public enum TimerState
- {
- Running,
- Paused,
- Complete
- }
-
internal class TimerModel : ITimerModel
{
#region Members
@@ -14,7 +14,6 @@
//
// You are free to fork this via github: https://github.com/barrylapthorn/countdown_timer
-
namespace Btl.Models
{
public class TimerModelFactory
Oops, something went wrong.

0 comments on commit eed6776

Please sign in to comment.