///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes an instance of the <c>MainWindow</c> class. /// </summary> public MainWindow() { // Register UI providers before doing anything else, including InitializeComponent ApplicationCommands.RegisterUIProvidersForNonRibbonCommands(); InitializeComponent(); // Populate some sample recent documents DocumentReferenceGenerator.BindRecentDocumentManager(recentDocManager); // Store this container reference in the Ribbon's Tag property ribbon.Tag = this; // Create a new document DocumentData.NewDocumentCount = 0; this.CurrentDocumentData = DocumentData.CreateNewDocument(); // Add command bindings this.CommandBindings.Add(new CommandBinding(ApplicationCommands.ApplicationExit, applicationExitCommand_Execute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.Help, applicationHelpCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.ApplicationOptions, applicationOptionsCommand_Execute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.Close, fileCloseCommand_Execute, fileRequired_CanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Comments, commentsCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.CoverPage, coverPageCommand_Execute)); this.CommandBindings.Add(new CommandBinding(RibbonCommands.CustomizeQuickAccessToolBar, customizeQuickAccessToolBarCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Disabled, null, disabledCommand_CanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.FileNewRtfDocument, fileNewRtfDocumentCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.FileNewTextDocument, fileNewTextDocumentCommand_Execute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.New, fileNewCommand_Execute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.Open, fileOpenCommand_Execute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.Save, fileSaveCommand_Execute, fileRequired_CanExecute)); this.CommandBindings.Add(new CommandBinding(System.Windows.Input.ApplicationCommands.Find, findCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.ShowDialog, showDialogCommand_Execute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.ToggleContextualTabGroup, toggleContextualTabGroupCommand_Execute, toggleContextualTabGroupCommand_CanExecute)); this.CommandBindings.Add(new CommandBinding(ApplicationCommands.ToggleFlowDirection, toggleFlowDirectionCommand_Execute)); }
/// <summary> /// Occurs when the <see cref="RoutedCommand"/> is executed. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">An <see cref="ExecutedRoutedEventArgs"/> that contains the event data.</param> private void fileNewTextDocumentCommand_Execute(object sender, ExecutedRoutedEventArgs e) { // Create a new document this.CurrentDocumentData = DocumentData.CreateNewDocument(".txt"); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a <see cref="DocumentData"/> for a new document. /// </summary> /// <returns>The <see cref="DocumentData"/> that was created.</returns> public static DocumentData CreateNewDocument() { return(DocumentData.CreateNewDocument(".rtf")); }