Skip to content

Commit

Permalink
Release v1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dziemborowicz committed Aug 18, 2016
2 parents 7697e17 + 60ffe0b commit 6d162ce
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 85 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.6.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="f1d002c9-cfc9-40fb-84af-96e7aec26e0b" IconSourceFile="$(var.Hourglass.ProjectDir)Resources\AppIcon.ico">
<Bundle Name="Hourglass" Version="1.7.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.6.0.0" Manufacturer="Chris Dziemborowicz" UpgradeCode="172d3713-8820-4374-8195-3e2374e7724f">
<Product Id="*" Name="Hourglass" Language="1033" Version="1.7.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.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
5 changes: 0 additions & 5 deletions Hourglass/Extensions/IRestorableWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ namespace Hourglass.Extensions
/// </summary>
public interface IRestorableWindow
{
/// <summary>
/// Gets the default size of the window.
/// </summary>
Size DefaultSize { get; }

/// <summary>
/// Gets the <see cref="WindowSize"/> for the window persisted in the settings.
/// </summary>
Expand Down
93 changes: 36 additions & 57 deletions Hourglass/Extensions/WindowExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,11 @@ public static void Restore<T>(this T window, WindowSize windowSize, RestoreOptio
windowSize.IsFullScreen);
}

// If the window is restored to a size or position that does not fit on the screen, fallback to center
// If the window is restored to a size or position that is not on the screen, center the window
if (!window.IsOnScreen())
{
window.CenterOnScreen();
}

// If the window still does not fit on the screen, fallback to its default size and state
if (!window.IsOnScreen())
{
window.ResetSizeAndState();
}
}

#endregion
Expand Down Expand Up @@ -394,6 +388,23 @@ private static Rect GetBoundsForNormalState(this Window window)
return new Rect(window.Left, window.Top, window.Width, window.Height);
}

/// <summary>
/// Returns the <see cref="Point"/> at the center of a <see cref="Rect"/>.
/// </summary>
/// <param name="rect">A <see cref="Rect"/>.</param>
/// <returns>The <see cref="Point"/> at the center of a <see cref="Rect"/>.</returns>
private static Point GetCenter(this Rect rect)
{
if (rect.HasSizeAndLocation())
{
return new Point(
(int)(rect.X + (rect.Width / 2)),
(int)(rect.Y + (rect.Height / 2)));
}

return rect.Location;
}

/// <summary>
/// Returns a value indicating whether the <see cref="Rect"/> has a valid location.
/// </summary>
Expand Down Expand Up @@ -425,45 +436,35 @@ private static bool HasSizeAndLocation(this Rect rect)
}

/// <summary>
/// Returns a value indicating whether the size and position of the <see cref="Rect"/> are such that the <see
/// cref="Rect"/> is entirely visible on the screen.
/// Returns a value indicating whether the size and position of the <see cref="Rect"/> are such that the center
/// of the <see cref="Rect"/> is visible on the screen.
/// </summary>
/// <param name="rect">A <see cref="Rect"/>.</param>
/// <returns>A value indicating whether the size and position of the <see cref="Rect"/> are such that the <see
/// cref="Rect"/> is entirely visible on the screen.</returns>
/// <returns>A value indicating whether the size and position of the <see cref="Rect"/> are such that the center
/// of the <see cref="Rect"/> is visible on the screen.</returns>
private static bool IsOnScreen(this Rect rect)
{
Rect virtualScreenRect = new Rect(
SystemParameters.VirtualScreenLeft,
SystemParameters.VirtualScreenTop,
SystemParameters.VirtualScreenWidth,
SystemParameters.VirtualScreenHeight);

if (rect.HasSizeAndLocation())
{
return virtualScreenRect.Contains(rect);
}
else if (rect.HasSize())
if (rect.HasLocation())
{
return rect.Width <= virtualScreenRect.Width && rect.Height <= virtualScreenRect.Height;
}
else if (rect.HasLocation())
{
return virtualScreenRect.Contains(rect.Location);
}
else
{
return true;
Rect virtualScreenRect = new Rect(
SystemParameters.VirtualScreenLeft,
SystemParameters.VirtualScreenTop,
SystemParameters.VirtualScreenWidth,
SystemParameters.VirtualScreenHeight);

return virtualScreenRect.Contains(rect.GetCenter());
}

return true;
}

/// <summary>
/// Returns a value indicating whether the size and position of the window are such that the window is entirely
/// visible on the screen when in its normal state.
/// Returns a value indicating whether the size and position of the window are such that the center of the
/// window is visible on the screen when in its normal state.
/// </summary>
/// <param name="window">A window.</param>
/// <returns>A value indicating whether the size and position of the window are such that the window is entirely
/// visible on the screen when in its normal state.</returns>
/// <returns>A value indicating whether the size and position of the window are such that the center of the
/// window is visible on the screen when in its normal state.</returns>
private static bool IsOnScreen(this Window window)
{
Rect windowRect = window.GetBoundsForNormalState();
Expand Down Expand Up @@ -528,28 +529,6 @@ private static Rect Offset(this Rect rect)
return rect.CenterOnScreen();
}

/// <summary>
/// Resizes a window to its default size (or the <see cref="SystemParameters.WorkArea"/> if it is smaller than
/// its default size) and state.
/// </summary>
/// <typeparam name="T">The type of the window.</typeparam>
/// <param name="window">A window.</param>
private static void ResetSizeAndState<T>(this T window)
where T : Window, IRestorableWindow
{
// Reset state
window.IsFullScreen = false;
window.WindowState = WindowState.Normal;
window.RestoreWindowState = WindowState.Normal;

// Reset size
window.Width = Math.Min(window.DefaultSize.Width, SystemParameters.WorkArea.Width);
window.Height = Math.Min(window.DefaultSize.Height, SystemParameters.WorkArea.Height);

// Center
window.CenterOnScreen();
}

#endregion
}
}
2 changes: 1 addition & 1 deletion Hourglass/Properties/App.manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.6.0.0" name="Hourglass"/>
<assemblyIdentity version="1.7.0.0" name="Hourglass"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
Expand Down
4 changes: 2 additions & 2 deletions Hourglass/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
[assembly: AssemblyCopyright("Copyright © 2016 Chris Dziemborowicz")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: NeutralResourcesLanguageAttribute("en-US")]
[assembly: Guid("83DBAA61-6193-4288-BBB7-BEAEC33FE321")]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
Expand Down
15 changes: 0 additions & 15 deletions Hourglass/Windows/TimerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,21 +238,6 @@ public TimerWindow(TimerStart timerStart)

#region Properties

/// <summary>
/// Gets the default size of the window.
/// </summary>
public Size DefaultSize
{
get
{
TimerOptions defaultOptions = new TimerOptions();

return new Size(
defaultOptions.WindowSize.RestoreBounds.Width,
defaultOptions.WindowSize.RestoreBounds.Height);
}
}

/// <summary>
/// Gets the <see cref="WindowSize"/> for the window persisted in the settings.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion Hourglass/Windows/WindowSize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ public static WindowSize FromWindow<T>(T window)
}

return new WindowSize(
window.RestoreBounds,
window.WindowState == WindowState.Normal
? new Rect(window.Left, window.Top, window.Width, window.Height)
: window.RestoreBounds,
window.WindowState,
window.RestoreWindowState,
window.IsFullScreen);
Expand Down

0 comments on commit 6d162ce

Please sign in to comment.