Skip to content

Commit

Permalink
Release v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dziemborowicz committed Jul 17, 2016
2 parents 74b4532 + 39eaa84 commit 7697e17
Show file tree
Hide file tree
Showing 34 changed files with 3,538 additions and 962 deletions.
2 changes: 1 addition & 1 deletion Hourglass.Bundle/Bundle.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="Hourglass" Version="1.5.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="f1d002c9-cfc9-40fb-84af-96e7aec26e0b" IconSourceFile="$(var.Hourglass.ProjectDir)Resources\AppIcon.ico">
<Bundle Name="Hourglass" Version="1.6.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="f1d002c9-cfc9-40fb-84af-96e7aec26e0b" IconSourceFile="$(var.Hourglass.ProjectDir)Resources\AppIcon.ico">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication LicenseFile="MIT.rtf" LogoFile="Logo.png"/>
</BootstrapperApplicationRef>
Expand Down
2 changes: 1 addition & 1 deletion Hourglass.Setup/Product.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
<Product Id="*" Name="Hourglass" Language="1033" Version="1.5.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="172d3713-8820-4374-8195-3e2374e7724f">
<Product Id="*" Name="Hourglass" Language="1033" Version="1.6.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="172d3713-8820-4374-8195-3e2374e7724f">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>

<Icon Id="AppIcon.exe" SourceFile="$(var.Hourglass.ProjectDir)Resources\AppIcon.ico"/>
Expand Down
4 changes: 2 additions & 2 deletions Hourglass.Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("002a4be7-7323-4bf9-ab08-5fc8978d9eb0")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
149 changes: 103 additions & 46 deletions Hourglass/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public static string Usage
public bool ShutDownWhenExpired { get; private set; }

/// <summary>
/// Gets the color of the timer progress bar.
/// Gets the theme of the timer window.
/// </summary>
public Color Color { get; private set; }
public Theme Theme { get; private set; }

/// <summary>
/// Gets the sound to play when the timer expires, or <c>null</c> if no sound is to be played.
Expand All @@ -139,6 +139,11 @@ public static string Usage
/// </summary>
public bool OpenSavedTimers { get; private set; }

/// <summary>
/// Gets or sets a value indicating what information to display in the timer window title.
/// </summary>
public WindowTitleMode WindowTitleMode { get; set; }

/// <summary>
/// Gets a value that indicates whether the timer window is restored, minimized, or maximized.
/// </summary>
Expand Down Expand Up @@ -215,9 +220,10 @@ public TimerOptions GetTimerOptions()
PopUpWhenExpired = this.PopUpWhenExpired,
CloseWhenExpired = this.CloseWhenExpired,
ShutDownWhenExpired = this.ShutDownWhenExpired,
Color = this.Color,
Theme = this.Theme,
Sound = this.Sound,
LoopSound = this.LoopSound,
WindowTitleMode = this.WindowTitleMode,
WindowSize = this.GetWindowSize()
};
}
Expand Down Expand Up @@ -261,10 +267,11 @@ private static CommandLineArguments GetArgumentsFromMostRecentOptions()
PopUpWhenExpired = options.PopUpWhenExpired,
CloseWhenExpired = options.CloseWhenExpired,
ShutDownWhenExpired = options.ShutDownWhenExpired,
Color = options.Color,
Theme = options.Theme,
Sound = options.Sound,
LoopSound = options.LoopSound,
OpenSavedTimers = Settings.Default.OpenSavedTimersOnStartup,
WindowTitleMode = options.WindowTitleMode,
WindowState = windowSize.WindowState != WindowState.Minimized ? windowSize.WindowState : windowSize.RestoreWindowState,
RestoreWindowState = windowSize.RestoreWindowState,
WindowBounds = windowSize.RestoreBounds
Expand Down Expand Up @@ -296,10 +303,11 @@ private static CommandLineArguments GetArgumentsFromFactoryDefaults()
PopUpWhenExpired = defaultOptions.PopUpWhenExpired,
CloseWhenExpired = defaultOptions.CloseWhenExpired,
ShutDownWhenExpired = defaultOptions.ShutDownWhenExpired,
Color = defaultOptions.Color,
Theme = defaultOptions.Theme,
Sound = defaultOptions.Sound,
LoopSound = defaultOptions.LoopSound,
OpenSavedTimers = false,
WindowTitleMode = WindowTitleMode.ApplicationName,
WindowState = defaultOptions.WindowSize.WindowState,
RestoreWindowState = defaultOptions.WindowSize.RestoreWindowState,
WindowBounds = defaultWindowBoundsWithLocation
Expand Down Expand Up @@ -476,17 +484,17 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
argumentsBasedOnFactoryDefaults.ShutDownWhenExpired = shutDownWhenExpired;
break;

case "--color":
case "-c":
ThrowIfDuplicateSwitch(specifiedSwitches, "--color");
case "--theme":
case "-m":
ThrowIfDuplicateSwitch(specifiedSwitches, "--theme");

Color color = GetColorValue(
Theme theme = GetThemeValue(
arg,
remainingArgs,
argumentsBasedOnMostRecentOptions.Color);
argumentsBasedOnMostRecentOptions.Theme);

argumentsBasedOnMostRecentOptions.Color = color;
argumentsBasedOnFactoryDefaults.Color = color;
argumentsBasedOnMostRecentOptions.Theme = theme;
argumentsBasedOnFactoryDefaults.Theme = theme;
break;

case "--sound":
Expand Down Expand Up @@ -528,17 +536,17 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
argumentsBasedOnFactoryDefaults.OpenSavedTimers = openSavedTimers;
break;

case "--window-bounds":
case "-b":
ThrowIfDuplicateSwitch(specifiedSwitches, "--window-bounds");
case "--window-title":
case "-i":
ThrowIfDuplicateSwitch(specifiedSwitches, "--window-title");

Rect windowBounds = GetRectValue(
WindowTitleMode windowTitleMode = GetWindowTitleModeValue(
arg,
remainingArgs,
argumentsBasedOnMostRecentOptions.WindowBounds);
argumentsBasedOnMostRecentOptions.WindowTitleMode);

argumentsBasedOnMostRecentOptions.WindowBounds = argumentsBasedOnMostRecentOptions.WindowBounds.Merge(windowBounds);
argumentsBasedOnFactoryDefaults.WindowBounds = argumentsBasedOnFactoryDefaults.WindowBounds.Merge(windowBounds);
argumentsBasedOnMostRecentOptions.WindowTitleMode = windowTitleMode;
argumentsBasedOnFactoryDefaults.WindowTitleMode = windowTitleMode;
break;

case "--window-state":
Expand All @@ -554,6 +562,19 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
argumentsBasedOnFactoryDefaults.WindowState = windowState;
break;

case "--window-bounds":
case "-b":
ThrowIfDuplicateSwitch(specifiedSwitches, "--window-bounds");

Rect windowBounds = GetRectValue(
arg,
remainingArgs,
argumentsBasedOnMostRecentOptions.WindowBounds);

argumentsBasedOnMostRecentOptions.WindowBounds = argumentsBasedOnMostRecentOptions.WindowBounds.Merge(windowBounds);
argumentsBasedOnFactoryDefaults.WindowBounds = argumentsBasedOnFactoryDefaults.WindowBounds.Merge(windowBounds);
break;

case "--use-factory-defaults":
case "-d":
ThrowIfDuplicateSwitch(specifiedSwitches, "--use-factory-defaults");
Expand Down Expand Up @@ -651,7 +672,7 @@ private static bool GetBoolValue(string arg, Queue<string> remainingArgs)
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value)
switch (value.ToLowerInvariant())
{
case "on":
return true;
Expand Down Expand Up @@ -684,7 +705,7 @@ private static bool GetBoolValue(string arg, Queue<string> remainingArgs, bool l
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value)
switch (value.ToLowerInvariant())
{
case "on":
return true;
Expand All @@ -707,48 +728,41 @@ private static bool GetBoolValue(string arg, Queue<string> remainingArgs, bool l
}

/// <summary>
/// Returns the next <see cref="Color"/> value in <paramref name="remainingArgs"/>, or throws an exception if
/// Returns the next <see cref="Theme"/> value in <paramref name="remainingArgs"/>, or throws an exception if
/// <paramref name="remainingArgs"/> is empty or the next argument is not "last" or a valid representation of a
/// <see cref="Color"/>.
/// <see cref="Theme"/>.
/// </summary>
/// <param name="arg">The name of the argument for which the value is to be returned.</param>
/// <param name="remainingArgs">The unparsed arguments.</param>
/// <param name="last">The value of the argument returned when the user specifies "last".</param>
/// <returns>The next <see cref="Color"/> value in <paramref name="remainingArgs"/></returns>
/// <returns>The next <see cref="Theme"/> value in <paramref name="remainingArgs"/></returns>
/// <exception cref="ParseException">If <paramref name="remainingArgs"/> is empty or the next argument is not
/// "last" or a valid representation of a <see cref="Color"/>.</exception>
private static Color GetColorValue(string arg, Queue<string> remainingArgs, Color last)
/// "last" or a valid representation of a <see cref="Theme"/>.</exception>
private static Theme GetThemeValue(string arg, Queue<string> remainingArgs, Theme last)
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value)
switch (value.ToLowerInvariant())
{
case "last":
return last;

default:
Color color = ColorManager.Instance.GetColorByName(value, StringComparison.CurrentCultureIgnoreCase);
Theme theme = ThemeManager.Instance.GetThemeByIdentifier(value.ToLowerInvariant()) ??
ThemeManager.Instance.GetThemeByName(value, StringComparison.CurrentCultureIgnoreCase);

if (color == null)
if (theme == null)
{
try
{
color = new Color(value);
ColorManager.Instance.Add(color);
}
catch
{
string message = string.Format(
Resources.ResourceManager.GetEffectiveProvider(),
Resources.CommandLineArgumentsParseExceptionInvalidValueForSwitchFormatString,
arg,
value);
string message = string.Format(
Resources.ResourceManager.GetEffectiveProvider(),
Resources.CommandLineArgumentsParseExceptionInvalidValueForSwitchFormatString,
arg,
value);

throw new ParseException(message);
}
throw new ParseException(message);
}

return color;
return theme;
}
}

Expand All @@ -767,7 +781,7 @@ private static Sound GetSoundValue(string arg, Queue<string> remainingArgs, Soun
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value)
switch (value.ToLowerInvariant())
{
case "none":
return null;
Expand All @@ -793,6 +807,49 @@ private static Sound GetSoundValue(string arg, Queue<string> remainingArgs, Soun
}
}

/// <summary>
/// Returns the next <see cref="WindowTitleMode"/> value in <paramref name="remainingArgs"/>, or throws an
/// exception if <paramref name="remainingArgs"/> is empty or the next argument is not "app", "left", "elapsed",
/// "title", or "last".
/// </summary>
/// <param name="arg">The name of the argument for which the value is to be returned.</param>
/// <param name="remainingArgs">The unparsed arguments.</param>
/// <param name="last">The value of the argument returned when the user specifies "last".</param>
/// <returns>The next <see cref="WindowTitleMode"/> value in <paramref name="remainingArgs"/>.</returns>
/// <exception cref="ParseException">If <paramref name="remainingArgs"/> is empty or the next argument is not
/// "app", "left", "elapsed", "title", or "last".</exception>
private static WindowTitleMode GetWindowTitleModeValue(string arg, Queue<string> remainingArgs, WindowTitleMode last)
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value.ToLowerInvariant())
{
case "app":
return WindowTitleMode.ApplicationName;

case "left":
return WindowTitleMode.TimeLeft;

case "elapsed":
return WindowTitleMode.TimeElapsed;

case "title":
return WindowTitleMode.TimerTitle;

case "last":
return last;

default:
string message = string.Format(
Resources.ResourceManager.GetEffectiveProvider(),
Resources.CommandLineArgumentsParseExceptionInvalidValueForSwitchFormatString,
arg,
value);

throw new ParseException(message);
}
}

/// <summary>
/// Returns the next <see cref="WindowState"/> value in <paramref name="remainingArgs"/>, or throws an
/// exception if <paramref name="remainingArgs"/> is empty or the next argument is not "normal", "maximized",
Expand All @@ -808,7 +865,7 @@ private static WindowState GetWindowStateValue(string arg, Queue<string> remaini
{
string value = GetRequiredValue(arg, remainingArgs);

switch (value)
switch (value.ToLowerInvariant())
{
case "normal":
return WindowState.Normal;
Expand Down
44 changes: 44 additions & 0 deletions Hourglass/Extensions/ColorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ColorExtensions.cs" company="Chris Dziemborowicz">
// Copyright (c) Chris Dziemborowicz. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Hourglass.Extensions
{
using System;
using System.Windows.Media;

/// <summary>
/// Provides utility methods for the <see cref="Color"/> struct.
/// </summary>
public static class ColorExtensions
{
/// <summary>
/// Converts a <see cref="Color"/> to an <see cref="int"/> representation.
/// </summary>
/// <param name="color">A <see cref="Color"/>.</param>
/// <returns>An <see cref="int"/> for <paramref name="color"/>.</returns>
public static int ToInt(this Color color)
{
return (color.R << 0) | (color.G << 8) | (color.B << 16);
}

/// <summary>
/// Converts a <see cref="string"/> representation of a <see cref="Color"/> into a <see cref="Color"/>.
/// </summary>
/// <param name="colorString">A <see cref="string"/> representation of a <see cref="Color"/>.</param>
/// <returns>A <see cref="Color"/>.</returns>
public static Color FromString(string colorString)
{
object color = ColorConverter.ConvertFromString(colorString);

if (color == null)
{
throw new ArgumentException("colorString");
}

return (Color)color;
}
}
}
Loading

0 comments on commit 7697e17

Please sign in to comment.