public MainWindowViewModel( ShellModuleConfiguration config, IGpxViewerCommands gpxViewerCommands, IGpxViewerSkinService skinService) { this.Configuration = config; this.GpxViewerCommands = gpxViewerCommands; _srvSkin = skinService; // Apply initial skin if ((!string.IsNullOrEmpty(config.Skin)) && (Enum.TryParse(typeof(AppSkin), config.Skin, true, out var parseResult)) && (parseResult is AppSkin configuredSkin)) { _srvSkin.Skin = configuredSkin; } // Update application title string this.Title = FirLibApplication.IsLoaded ? FirLibApplication.Current.ProductFullName : string.Empty; // Handle skin change this.Command_SetSkin = new DelegateCommand <string>(this.OnCommand_SetSkin_Execute); this.Command_LoadRecentlyOpened = new DelegateCommand <RecentlyOpenedInfo>(this.OnCommand_LoadRecentlyOpened_Execute); this.Command_ShowAboutDialog = new DelegateCommand(async() => { var srvAboutDlg = this.GetViewService <IAboutDialogService>(); await srvAboutDlg.ShowAboutDialogAsync(); }); this.Command_Exit = new DelegateCommand(this.OnCommand_Exit_Execute); }
public FileTreeViewModel(GpxFileRepository fileRepo, IGpxViewerCommands gpxViewerCommands) { _repoGpxFiles = fileRepo; _gpxViewerCommands = gpxViewerCommands; this.TopLevelNodes = new TransformedObservableCollection <FileTreeNodeViewModel, GpxFileRepositoryNode>( fileRepo.TopLevelNodes, nodeModel => new FileTreeNodeViewModel(nodeModel)); this.Command_LoadFile = new DelegateCommand(this.OnCommand_LoadFile_Execute); this.Command_LoadDirectory = new DelegateCommand(this.OnCommand_LoadDirectory_Execute); this.Command_Save = new DelegateCommand( () => this.OnCommand_Save_ExecuteAsync().FireAndForget(), () => _repoGpxFiles.SelectedNode?.ContentsChanged ?? false); this.Command_SaveAll = new DelegateCommand( () => this.OnCommand_SaveAll_ExecuteAsync().FireAndForget(), () => _repoGpxFiles.EnumerateNodesDeep().Any(actNode => actNode.ContentsChanged)); this.Command_Close = new DelegateCommand( this.OnCommand_Close_Execute, () => _repoGpxFiles.SelectedNode != null); this.Command_CloseAll = new DelegateCommand( this.OnCommand_CloseAll_Execute, () => this.TopLevelNodes.Count > 0); this.Command_DeselectAll = new DelegateCommand( () => this.SelectedNode = null, () => this.SelectedNode != null); }