public MainPage() { InitializeComponent(); _defaultNewFileName = _resourceLoader.GetString("TextEditor_DefaultNewFileName"); NotificationCenter.Instance.SetNotificationDelegate(this); // Setup theme ThemeSettingsService.AppBackground = RootGrid; ThemeSettingsService.SetRequestedTheme(); // Setup custom Title Bar Window.Current.SetTitleBar(AppTitleBar); // Setup status bar ShowHideStatusBar(EditorSettingsService.ShowStatusBar); EditorSettingsService.OnStatusBarVisibilityChanged += (sender, visibility) => ShowHideStatusBar(visibility); // Sharing Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested; Windows.UI.Core.Preview.SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += MainPage_CloseRequested; Window.Current.VisibilityChanged += WindowVisibilityChangedEventHandler; InitControls(); // Init shortcuts _keyboardCommandHandler = GetKeyboardCommandHandler(); }
public SideBySideDiffViewer() { InitializeComponent(); _scrollSynchronizer = new ScrollViewerSynchronizer(new List <ScrollViewer> { LeftScroller, RightScroller }); _diffRenderer = new RichTextBlockDiffRenderer(); _keyboardCommandHandler = GetKeyboardCommandHandler(); LeftBox.SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; RightBox.SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; ThemeSettingsService.OnAccentColorChanged += (sender, color) => { LeftBox.SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; RightBox.SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; }; LayoutRoot.KeyDown += OnKeyDown; KeyDown += OnKeyDown; LeftBox.KeyDown += OnKeyDown; RightBox.KeyDown += OnKeyDown; Loaded += (sender, args) => { Focus(); }; }
public MainPage() { InitializeComponent(); _defaultNewFileName = _resourceLoader.GetString("TextEditor_DefaultNewFileName"); NotificationCenter.Instance.SetNotificationDelegate(this); // Setup theme ThemeSettingsService.AppBackground = RootGrid; ThemeSettingsService.SetRequestedTheme(); // Setup custom Title Bar Window.Current.SetTitleBar(AppTitleBar); // Setup status bar ShowHideStatusBar(EditorSettingsService.ShowStatusBar); EditorSettingsService.OnStatusBarVisibilityChanged += (sender, visibility) => { if (ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.CompactOverlay) { ShowHideStatusBar(visibility); } }; // Session backup and restore toggle EditorSettingsService.OnSessionBackupAndRestoreOptionChanged += (sender, isSessionBackupAndRestoreEnabled) => { if (isSessionBackupAndRestoreEnabled) { SessionManager.IsBackupEnabled = true; SessionManager.StartSessionBackup(startImmediately: true); } else { SessionManager.IsBackupEnabled = false; SessionManager.StopSessionBackup(); SessionManager.ClearSessionData(); } }; // Sharing Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView().DataRequested += MainPage_DataRequested; Windows.UI.Core.Preview.SystemNavigationManagerPreview.GetForCurrentView().CloseRequested += MainPage_CloseRequested; Window.Current.VisibilityChanged += WindowVisibilityChangedEventHandler; Window.Current.SizeChanged += WindowSizeChanged; InitControls(); // Init shortcuts _keyboardCommandHandler = GetKeyboardCommandHandler(); }
public TextEditor() { DefaultStyleKey = nameof(TextEditor); Style = (Style)Application.Current.Resources[nameof(TextEditor)]; IsSpellCheckEnabled = false; TextWrapping = EditorSettingsService.EditorDefaultTextWrapping; FontFamily = new FontFamily(EditorSettingsService.EditorFontFamily); FontSize = EditorSettingsService.EditorFontSize; SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; SelectionHighlightColorWhenNotFocused = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; SelectionFlyout = null; HorizontalAlignment = HorizontalAlignment.Stretch; VerticalAlignment = VerticalAlignment.Stretch; HandwritingView.BorderThickness = new Thickness(0); ContextFlyout = new TextEditorContextFlyout(this); TextChanging += TextEditor_TextChanging; CopyingToClipboard += (sender, args) => CopyPlainTextToWindowsClipboard(args); Paste += async(sender, args) => await PastePlainTextFromWindowsClipboard(args); PointerWheelChanged += OnPointerWheelChanged; SetDefaultTabStop(FontFamily, FontSize); EditorSettingsService.OnFontFamilyChanged += (sender, fontFamily) => { FontFamily = new FontFamily(fontFamily); SetDefaultTabStop(FontFamily, FontSize); }; EditorSettingsService.OnFontSizeChanged += (sender, fontSize) => { FontSize = fontSize; SetDefaultTabStop(FontFamily, FontSize); }; EditorSettingsService.OnDefaultTextWrappingChanged += (sender, textWrapping) => { TextWrapping = textWrapping; }; ThemeSettingsService.OnAccentColorChanged += (sender, color) => { SelectionHighlightColor = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; SelectionHighlightColorWhenNotFocused = Application.Current.Resources["SystemControlForegroundAccentBrush"] as SolidColorBrush; }; // Init shortcuts _keyboardCommandHandler = GetKeyboardCommandHandler(); }
public NotepadsMainPage() { InitializeComponent(); _defaultNewFileName = _resourceLoader.GetString("TextEditor_DefaultNewFileName"); NotificationCenter.Instance.SetNotificationDelegate(this); // Setup theme ThemeSettingsService.OnBackgroundChanged += ThemeSettingsService_OnBackgroundChanged; ThemeSettingsService.OnRequestThemeUpdate += ThemeSettingsService_OnRequestThemeUpdate; ThemeSettingsService.OnRequestAccentColorUpdate += ThemeSettingsService_OnRequestAccentColorUpdate; ThemeSettingsService.SetRequestedTheme(RootGrid, Window.Current.Content, ApplicationView.GetForCurrentView().TitleBar); // Setup custom Title Bar Window.Current.SetTitleBar(AppTitleBar); // Setup status bar ShowHideStatusBar(EditorSettingsService.ShowStatusBar); EditorSettingsService.OnStatusBarVisibilityChanged += async(sender, visibility) => { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (ApplicationView.GetForCurrentView().ViewMode != ApplicationViewMode.CompactOverlay) { ShowHideStatusBar(visibility); } }); }; // Session backup and restore toggle EditorSettingsService.OnSessionBackupAndRestoreOptionChanged += async(sender, isSessionBackupAndRestoreEnabled) => { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, 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; Window.Current.VisibilityChanged += WindowVisibilityChangedEventHandler; Window.Current.SizeChanged += WindowSizeChanged; InitControls(); // Init shortcuts _keyboardCommandHandler = GetKeyboardCommandHandler(); //Register for printing if (!PrintManager.IsSupported()) { MenuPrintButton.Visibility = Visibility.Collapsed; MenuPrintAllButton.Visibility = Visibility.Collapsed; PrintSettingsSeparator.Visibility = Visibility.Collapsed; } else { PrintArgs.RegisterForPrinting(this); } }