/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { //Resource hackery for .resx files. See WindowsRuntimeResourceManager for details. WindowsRuntimeResourceManager.PatchResourceManagerForResource(typeof(AppResources.Strings)); this.InitializeComponent(); this.Suspending += this.OnSuspending; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { if (_firstLaunch) { // Initialize GlobalSettings.Initialize(); var settings = new GlobalSettings(); HACCP.App.SetBLESettings(settings); _firstLaunch = false; } #if DEBUG if (Debugger.IsAttached) { DebugSettings.EnableFrameRateCounter = true; } #endif UnhandledException += App_UnhandledException; var type = typeof(Legend).GetTypeInfo() .Assembly.GetType("WinRTXamlToolkit.Controls.DataVisualization.Properties.Resources"); WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass( typeof(HACCP.Core.WP.ResourceFiles.AppResources)); WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(type); var 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 { CacheSize = 1 }; // TODO: change this value to a cache size that is appropriate for your application Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } //Check application coming from background // if (e.PreviousExecutionState == ApplicationExecutionState.Running) // { // } // Ensure the current window is active Window.Current.Activate(); // var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); //statusBar. Window.Current.VisibilityChanged -= Current_VisibilityChanged; Window.Current.VisibilityChanged += Current_VisibilityChanged; }
public MainPage() { this.InitializeComponent(); WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(typeof(MainPage).GetTypeInfo().Assembly.GetType("LocalizationResources")); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(typeof(TapFast2.Resx.AppResources)); 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(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; // var otherAssemblies = new[] //{ // typeof(SQLitePCL.SQLite3Provider_e_sqlite3).GetTypeInfo().Assembly, //}; // Initialise Xamarin Forms Xamarin.Forms.Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif UnhandledException += App_UnhandledException; var type = typeof(WinRTXamlToolkit.Controls.DataVisualization.Legend).GetTypeInfo() .Assembly.GetType("WinRTXamlToolkit.Controls.DataVisualization.Properties.Resources"); WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(typeof(AppResources)); WindowsRuntimeResourceManager.InjectIntoResxGeneratedApplicationResourcesClass(type); 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) { _appManager.PreInitialize(); // Create a Frame to act as the navigation context and navigate to the first page. rootFrame = new Frame(); // Associate the frame with a SuspensionManager key. SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); // TODO: Change this value to a cache size that is appropriate for your application. rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate. try { await _appManager.Activated(false); await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { // Something went wrong restoring state. // Assume there is no state and continue. } } else { await _appManager.Initialize(); } // Place the frame in the current Window. Window.Current.Content = rootFrame; } else { await _appManager.Activated(true); } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; _appManager.Start(); } // Ensure the current window is active. Window.Current.Activate(); }