private void SetupAndALaunchApp(string arguments)
{
// Check the args for prevent crash
if(!String.IsNullOrWhiteSpace(arguments))
{
string lowerArgs = arguments.ToLower();
if(lowerArgs.Contains(c_protocolPreventCrashesDisabled))
{
BaconMan.UiSettingsMan.Developer_StopFatalCrashesAndReport = false;
}
else if (lowerArgs.Contains(c_protocolPreventCrashesEnabled))
{
BaconMan.UiSettingsMan.Developer_StopFatalCrashesAndReport = true;
}
}
// If we are on Xbox disable the blank border around the app. Ideally we would give the user the option to re-enable this.
if(DeviceHelper.CurrentDevice() == DeviceTypes.Xbox)
{
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
}
// Grab the accent color and make our custom accent color brushes.
if (!Current.Resources.ContainsKey(AccentColorLevel1Resource))
{
Color accentColor = ((SolidColorBrush)Current.Resources["SystemControlBackgroundAccentBrush"]).Color;
accentColor.A = 200;
Current.Resources[AccentColorLevel1Resource] = new SolidColorBrush(accentColor);
accentColor.A = 137;
Current.Resources[AccentColorLevel2Resource] = new SolidColorBrush(accentColor);
accentColor.A = 75;
Current.Resources[AccentColorLevel3Resource] = new SolidColorBrush(accentColor);
accentColor.A = 50;
Current.Resources[AccentColorLevel4Resource] = new SolidColorBrush(accentColor);
}
// Register for back, if we haven't already.
if (!m_hasRegisteredForBack)
{
m_hasRegisteredForBack = true;
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
}
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), arguments);
}
else
{
// If we have already navigated, we should tell the main page
// we are being activated again.
if (rootFrame.Content.GetType() == typeof(MainPage))
{
MainPage main = (MainPage)rootFrame.Content;
main.OnReActivated(arguments);
}
}
// We have to get the screen res before we call activate or it will be wrong and include the system tray.
var bounds = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds;
var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
BaconMan.BackgroundMan.ImageUpdaterMan.LastKnownScreenResoultion = new Size(bounds.Width * scaleFactor, bounds.Height * scaleFactor);
// Ensure the current window is active
Window.Current.Activate();
}