diff --git a/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs b/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs index 0546bdab..e87eaf4b 100644 --- a/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs +++ b/src/Caliburn.Micro.Platform/Platforms/uap/AppManifestHelper.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) 2012 Tim Heuer // // Licensed under the Microsoft Public License (Ms-PL) (the "License"); @@ -49,8 +49,8 @@ public async static Task GetManifestVisualElementsAsync() SmallLogoUri = new Uri(string.Format("ms-appx:///{0}", vel.Attribute("Square30x30Logo").Value.Replace(@"\", @"/"))), BackgroundColorAsString = vel.Attribute("BackgroundColor").Value }).FirstOrDefault(); - - if (visualElementNode == null) + + if (visualElementNode == null) throw new ArgumentNullException("Could not parse the VisualElements from the app manifest."); return visualElementNode; @@ -94,23 +94,17 @@ private static Windows.UI.Color ToColor(string hexValue) throw new ArgumentException("This does not appear to be a proper hex color number"); } - byte a = 255; - byte r = 255; - byte g = 255; - byte b = 255; - - int startPosition = 0; + bool isEightCharactersLong = hexValue.Length == 8; + // if the string is 8 characters it includes the a part + int startPosition = isEightCharactersLong ? 2 : 0; // the case where alpha is provided - if (hexValue.Length == 8) - { - a = byte.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber); - startPosition = 2; - } - r = byte.Parse(hexValue.Substring(startPosition, 2), NumberStyles.HexNumber); - g = byte.Parse(hexValue.Substring(startPosition + 2, 2), NumberStyles.HexNumber); - b = byte.Parse(hexValue.Substring(startPosition + 4, 2), NumberStyles.HexNumber); + byte a = isEightCharactersLong ? byte.Parse(hexValue.Substring(0, 2), NumberStyles.HexNumber) : (byte)255; + + byte r = byte.Parse(hexValue.Substring(startPosition, 2), NumberStyles.HexNumber); + byte g = byte.Parse(hexValue.Substring(startPosition + 2, 2), NumberStyles.HexNumber); + byte b = byte.Parse(hexValue.Substring(startPosition + 4, 2), NumberStyles.HexNumber); return Windows.UI.Color.FromArgb(a, r, g, b); } diff --git a/src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs b/src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs index 6d16a42d..44022a03 100644 --- a/src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs +++ b/src/Caliburn.Micro.Platform/Platforms/uap/FrameAdapter.cs @@ -32,7 +32,6 @@ public class FrameAdapter : INavigationService, IDisposable private static readonly ILog Log = LogManager.GetLog(typeof(FrameAdapter)); private const string FrameStateKey = "FrameState"; private const string ParameterKey = "ParameterKey"; - private readonly Frame frame; private readonly bool treatViewAsLoaded; private event NavigatingCancelEventHandler ExternalNavigatingHandler = delegate { }; @@ -50,16 +49,19 @@ public FrameAdapter(Frame frame, bool treatViewAsLoaded = false) this.frame = frame; this.treatViewAsLoaded = treatViewAsLoaded; +#if WINDOWS_UWP + navigationManager = SystemNavigationManager.GetForCurrentView(); +#endif + AddEventHandlers(); + } + + // add evenhandlers for navigating and navigated events + private void AddEventHandlers() + { this.frame.Navigating += OnNavigating; this.frame.Navigated += OnNavigated; #if WINDOWS_UWP - - // This could leak memory if we're creating and destorying navigation services regularly. - // Another unlikely scenario though - - navigationManager = SystemNavigationManager.GetForCurrentView(); - navigationManager.BackRequested += OnBackRequested; #endif }