public async Task PrintAll(ITextEditor[] textEditors) { if (App.IsGameBarWidget) { return; } if (textEditors == null || textEditors.Length == 0) { return; } // Initialize print content PrintArgs.PreparePrintContent(textEditors); if (PrintManager.IsSupported() && HaveNonemptyTextEditor(textEditors)) { // Show print UI await PrintArgs.ShowPrintUIAsync(); } else if (!PrintManager.IsSupported()) { // Printing is not supported on this device NotificationCenter.Instance.PostNotification(_resourceLoader.GetString("Print_NotificationMsg_PrintNotSupported"), 1500); } }
public NotepadsMainPage() { InitializeComponent(); _defaultNewFileName = _resourceLoader.GetString("TextEditor_DefaultNewFileName"); // Set custom title bar dragging area Window.Current.SetTitleBar(AppTitleBar); InitializeNotificationCenter(); InitializeThemeSettings(); InitializeStatusBar(); InitializeControls(); InitializeMainMenu(); InitializeKeyboardShortcuts(); // Session backup and restore toggle AppSettingsService.OnSessionBackupAndRestoreOptionForInstanceChanged += OnSessionBackupAndRestoreOptionForInstanceChanged; AppSettingsService.OnSessionBackupAndRestoreOptionChanged += OnSessionBackupAndRestoreOptionChanged; // Register for printing if (PrintManager.IsSupported()) { PrintArgs.RegisterForPrinting(this); } // Register for content Sharing Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested; Windows.UI.Core.Preview.SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += MainPage_CloseRequested; if (App.IsGameBarWidget) { TitleBarReservedArea.Width = .0f; } else { Window.Current.SizeChanged += WindowSizeChanged; Window.Current.VisibilityChanged += WindowVisibilityChanged; } }
public NotepadsMainPage() { InitializeComponent(); _defaultNewFileName = _resourceLoader.GetString("TextEditor_DefaultNewFileName"); NotificationCenter.Instance.SetNotificationDelegate(this); // Setup theme ThemeSettingsService.SetRequestedTheme(RootGrid, Window.Current.Content, ApplicationView.GetForCurrentView().TitleBar, Application.Current.RequestedTheme); ThemeSettingsService.OnBackgroundChanged += ThemeSettingsService_OnBackgroundChanged; ThemeSettingsService.OnThemeChanged += ThemeSettingsService_OnThemeChanged; ThemeSettingsService.OnAccentColorChanged += ThemeSettingsService_OnAccentColorChanged; // Setup custom Title Bar Window.Current.SetTitleBar(AppTitleBar); // Setup status bar ShowHideStatusBar(EditorSettingsService.ShowStatusBar); EditorSettingsService.OnStatusBarVisibilityChanged += async(sender, visibility) => { await ThreadUtility.CallOnUIThreadAsync(Dispatcher, () => { if (ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.CompactOverlay) { ShowHideStatusBar(visibility); } }); }; // Session backup and restore toggle EditorSettingsService.OnSessionBackupAndRestoreOptionChanged += async(sender, isSessionBackupAndRestoreEnabled) => { await ThreadUtility.CallOnUIThreadAsync(Dispatcher, async() => { if (isSessionBackupAndRestoreEnabled) { SessionManager.IsBackupEnabled = true; SessionManager.StartSessionBackup(startImmediately: true); } else { SessionManager.IsBackupEnabled = false; SessionManager.StopSessionBackup(); await SessionManager.ClearSessionDataAsync(); } }); }; // Sharing Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested; Windows.UI.Core.Preview.SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += MainPage_CloseRequested; if (App.IsGameBarWidget) { TitleBarReservedArea.Width = .0f; } else { Window.Current.SizeChanged += WindowSizeChanged; Window.Current.VisibilityChanged += WindowVisibilityChangedEventHandler; } InitControls(); // Init shortcuts _keyboardCommandHandler = GetKeyboardCommandHandler(); //Register for printing if (!PrintManager.IsSupported()) { MenuPrintButton.Visibility = Visibility.Collapsed; MenuPrintAllButton.Visibility = Visibility.Collapsed; MenuPrintSeparator.Visibility = Visibility.Collapsed; } else { PrintArgs.RegisterForPrinting(this); } }
private void EndPrintChanged(object sender, PrintArgs e) { _logger.LogInfo($"{e.Name} ({e.Model}) end printing!"); }
private void OnStartPrintChange(object sender, PrintArgs eventArgs) { StartPrintChange?.Invoke(this, eventArgs); }