示例#1
0
        public ShellViewModel(IEventAggregator eventAggragator, IDialogService dialogService, IMessageBoxService messageBoxService, IFontService fontService, IStyleService styleService, IRecentFilesService recentFilesService)
        {
            this.eventAggragator    = eventAggragator;
            this.dialogService      = dialogService;
            this.messageBoxService  = messageBoxService;
            this.recentFilesService = recentFilesService;
            this.styleService       = styleService;

            this.FontSizes   = fontService.GetFontSizes();
            this.FontNames   = fontService.GetFontNames();
            this.TableStyles = styleService.GetAllTableStyles();
            this.CellStyles  = styleService.GetAllCellStyles();
            this.GoodBadAndNeutralCellStyles = styleService.GetGoodBadAndNeutralCellStyles();
            this.DataAndModelCellStyles      = styleService.GetDataAndModelCellStyles();
            this.TitlesAndHeadingsCellStyles = styleService.GetTitlesAndHeadingsCellStyles();
            this.NumberFormatCellStyles      = styleService.GetNumberFormatCellStyles();
            this.ThemedCellStyles            = styleService.GetThemedCellStyles();

            this.IsUiPartEnabled = false;
            this.SetTitle();

            this.SelectedBackstageMenuItem = ShellParameters.NewTabName;

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

            this.ZoomLevel = 100;

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

            this.eventAggragator.GetEvent <FileOpenedEvent>().Subscribe(OnFileLoaded);
            this.eventAggragator.GetEvent <FileSavedEvent>().Subscribe(OnFileSaved);
            this.eventAggragator.GetEvent <NewDocumentEvent>().Subscribe(OnNewDocumentEvent);
            this.eventAggragator.GetEvent <TableAddedEvent>().Subscribe(OnTableAddedEvent);
            this.eventAggragator.GetEvent <CustomZoomLevelChangedEvent>().Subscribe(OnCustomZoomLevelChangedEvent);
            this.eventAggragator.GetEvent <PasswordToOpenEnteredEvent>().Subscribe(OnPasswordToOpenEnteredEvent);
            this.eventAggragator.GetEvent <PasswordToModifyEnteredEvent>().Subscribe(OnPasswordToModifyEnteredEvent);

            //Commands
            this.ShowNumberSettingsDialogCommand    = new DelegateCommand <object>(ExecuteShowNumberSettingsDialog);
            this.ShowFontSettingsDialogCommand      = new DelegateCommand <object>(ExecuteShowFontSettingsDialog);
            this.ShowFillSettingsDialogCommand      = new DelegateCommand <object>(ExecuteShowFillSettingsDialog);
            this.ShowAlignmnetSettingsDialogCommand = new DelegateCommand <object>(ExecuteShowAlignmnetSettingsDialog);
            this.ShowDimensionDialogCommand         = new DelegateCommand <DimensionDialogMode?>(ExecuteShowDimensionDialog);
            this.CloseDocumentCommand            = new DelegateCommand(ExecuteCloseDocument);
            this.FormatAsTableCommand            = new DelegateCommand <string>(ExecuteFormatAsTable);
            this.SaveDocumentCommand             = new DelegateCommand(ExecuteSaveDocument);
            this.CreateNewDocumentCommand        = new DelegateCommand <string>(CreateNewDocument);
            this.ShowZoomDialogCommand           = new DelegateCommand(ExecuteShowZoomDialog);
            this.ShowDataValidationDialogCommand = new DelegateCommand(ExecuteShowDataValidationDialog);

            this.PropertyChanged += OnPropertyChanged;
        }