Пример #1
0
        public ShellViewModel(IEventAggregator eventAggragator, IDialogService dialogService, IMessageBoxService messageBoxService, IFontService fontService, IRecentFilesService recentFilesService)
        {
            this.SetTitle();

            this.eventAggragator    = eventAggragator;
            this.dialogService      = dialogService;
            this.messageBoxService  = messageBoxService;
            this.recentFilesService = recentFilesService;
            this.fontService        = fontService;

            this.FontSizes       = fontService.GetFontSizes();
            this.FontNames       = fontService.GetFontNames();
            this.HighlightColors = fontService.GetHighlightColors();

            this.ClearDataProperties();
            this.DeactivateAdaptersRefreshTrigger();

            this.DelayAfterFirstEdit = TimeSpan.FromSeconds(10);
            this.DelayAfterLastEdit  = TimeSpan.FromSeconds(10);
            this.ZoomLevel           = 1;
            this.FontColor           = Colors.Red;
            this.TextHighlightColor  = Colors.Yellow;

            this.DocumentStatus            = IgWordDocumentStatus.NoDocumentLoaded;
            this.SelectedBackstageMenuItem = "New";

            // TFS 190054 - Workaround: do not initialize the value of the IsBackstageOpen property to true before the ribbon is loaded
            //this.IsBackstageOpened = true;

            this.recentFilesService.SetRepositories(Properties.Settings.Default, p => Properties.Settings.Default.RecentFilesRepo, p => Properties.Settings.Default.RecentFoldersRepo);

            //Subscribe to events
            this.eventAggragator.GetEvent <FileOpenedEvent>().Subscribe(OnFileLoaded);
            this.eventAggragator.GetEvent <FileSavedEvent>().Subscribe(OnFileSaved);
            this.eventAggragator.GetEvent <NewDocumentEvent>().Subscribe(OnNewDocumentEvent);
            this.eventAggragator.GetEvent <CharacterSettingsUpdatedEvent>().Subscribe(OnCharacterSettingsUpdatedEvent);
            this.eventAggragator.GetEvent <ParagraphSettingsUpdatedEvent>().Subscribe(OnParagraphSettingsUpdatedEvent);

            //Commands
            SaveDocumentCommand            = new DelegateCommand(ExecuteSaveDocument);
            CloseDocumentCommand           = new DelegateCommand(ExecuteCloseDocument);
            CreateNewDocumentCommand       = new DelegateCommand <string>(CreateNewDocument);
            ShowFontDialogCommand          = new DelegateCommand <RichTextDocument>(ExecuteShowFontDialog, CanExecuteShowFormattingDialog);
            ShowParagraphDialogCommand     = new DelegateCommand <RichTextDocument>(ExecuteShowParagraphDialog, CanExecuteShowFormattingDialog);
            ShowFindDialogCommand          = new DelegateCommand <FindReplaceManager>(ExecuteShowFindDialog, CanExecuteShowFindReplaceDialog);
            ShowReplaceDialogCommand       = new DelegateCommand <FindReplaceManager>(ExecuteShowReplaceDialog, CanExecuteShowFindReplaceDialog);
            ShowHyperlinkDialogCommand     = new DelegateCommand <RichTextDocument>(ExecuteShowHyperlinkDialog, CanExecuteShowFormattingDialog);
            ShowInsertTableDialogCommand   = new DelegateCommand <RichTextDocument>(ExecuteShowInsertTableDialog, CanExecuteShowFormattingDialog);
            ShowInsertPictureDialogCommand = new DelegateCommand <RichTextDocument>(ExecuteShowInsertPictureDialog, CanExecuteShowFormattingDialog);
            ResetZoomLevelCommand          = new DelegateCommand(ExecuteResetZoomLevel);
            IncreaseZoomLevelCommand       = new DelegateCommand(ExecuteIncreaseZoomLevel);
            DecreaseZoomLevelCommand       = new DelegateCommand(ExecuteDecreaseZoomLevel);
        }