public WorkflowPage() { InitializeComponent(); // Allow for multiple "main" pages rootPage = currentPage = this; // Set data context to this page for picking up labels and properties DataContext = this; // Initialize workflow app heading with unknown printer WorkflowHeadingLabel = string.Format(workflowHeadingFormat, workflowHeadingLabel, unknownPrinterLabel); // Activate window at required size Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetPreferredMinSize(new Windows.Foundation.Size(320, 150)); Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TryResizeView(new Windows.Foundation.Size(300, 230)); // Handle the HostedViewCLosing event to buy extra time before the background is cancelled var currentView = CoreApplication.GetCurrentView(); if (!currentView.IsMain) { // Register for hosted view closing to revert lockdown currentView.HostedViewClosing += OnHostedViewClosing; } // Create event which signals UI has all required information uiComplete = new ManualResetEvent(false); // Retrieve last standalone run settings, if any localStorage = new LocalStorageUtilities(); if (localStorage.GetUseStandaloneSettings()) { WatermarkTextBox.Text = localStorage.GetWatermarkTextFromLocalStorage(); localStorage.GetImagePropertiesFromLocalStorage(out string imageFile, out double dpiX, out double dpiY, out int imageWidth, out int imageHeight); if (imageFile != null) { SetLogoCheckBoxImage(imageFile); ImageCheckBox.IsChecked = true; } // Set the "use standlaone settings" check box without triggering the callback UseStandaloneSettingsCheckBox.Checked -= UseStandaloneSettingsCheckBox_Checked; UseStandaloneSettingsCheckBox.IsChecked = true; UseStandaloneSettingsCheckBox.Checked += UseStandaloneSettingsCheckBox_Checked; } // Default to standalone, as the foreground task always will overwrite this value shortly after construction this.LaunchType = WorkflowPageLaunchType.Standalone; }
protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { // If this is standalone, and the checkbox to save settings is set... save them if (LaunchType == WorkflowPageLaunchType.Standalone) { LocalStorageUtilities localStorage = new LocalStorageUtilities(); if (localStorage.GetUseStandaloneSettings()) { // If the "use standalone settings" check box has been checked then also save watermark text to local storage localStorage.SaveWatermarkTextToLocalStorage(Watermark); } } base.OnNavigatingFrom(e); }