public MainViewModel(ILogger <MainViewModel> logger, IAcmePdbParser acmePdbParser, Globals globals, IDispatcher dispatcher, ISettingsManager settingsManager, ErrorMessagesViewModel errorMessagesViewModel, IServiceScope scope, IViceBridge viceBridge, IProjectPrgFileWatcher projectPdbFileWatcher, RegistersMapping registersMapping, RegistersViewModel registers, ExecutionStatusViewModel executionStatusViewModel, BreakpointsViewModel breakpointsViewModel) { this.logger = logger; this.acmePdbParser = acmePdbParser; this.Globals = globals; this.dispatcher = dispatcher; this.settingsManager = settingsManager; this.scope = scope; this.viceBridge = viceBridge; this.projectPdbFileWatcher = projectPdbFileWatcher; this.executionStatusViewModel = executionStatusViewModel; RegistersViewModel = registers; BreakpointsViewModel = breakpointsViewModel; executionStatusViewModel.PropertyChanged += ExecutionStatusViewModel_PropertyChanged; uiFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()); commandsManager = new CommandsManager(this, uiFactory); closeOverlaySubscription = dispatcher.Subscribe <CloseOverlayMessage>(CloseOverlay); prgFileChangedSubscription = dispatcher.Subscribe <PrgFileChangedMessage>(PrgFileChanged); prgFilePathChangedSubscription = dispatcher.Subscribe <PrgFilePathChangedMessage>(PrgFilePathChanged); showModalDialogMessageSubscription = dispatcher.Subscribe <ShowModalDialogMessageCore>(OnShowModalDialog); ErrorMessagesViewModel = errorMessagesViewModel; ShowSettingsCommand = commandsManager.CreateRelayCommand(ShowSettings, () => !IsShowingSettings); ShowProjectCommand = commandsManager.CreateRelayCommand(ShowProject, () => !IsShowingProject && IsProjectOpen); TestCommand = commandsManager.CreateRelayCommand(Test, () => !IsBusy); CreateProjectCommand = commandsManager.CreateRelayCommand(CreateProject, () => !IsBusy && !IsDebugging); OpenProjectFromPathCommand = commandsManager.CreateRelayCommand <string>(OpenProjectFromPath, _ => !IsBusy && !IsDebugging); OpenProjectCommand = commandsManager.CreateRelayCommand(OpenProject, () => !IsBusy && !IsDebugging); globals.PropertyChanged += Globals_PropertyChanged; CloseProjectCommand = commandsManager.CreateRelayCommand(CloseProject, () => IsProjectOpen && !IsDebugging); ExitCommand = new RelayCommand(() => CloseApp?.Invoke()); ToggleErrorsVisibilityCommand = new RelayCommand(() => IsShowingErrors = !IsShowingErrors); RunCommand = commandsManager.CreateRelayCommandAsync(StartDebuggingAsync, () => IsProjectOpen && (!IsDebugging || IsDebuggingPaused)); StopCommand = commandsManager.CreateRelayCommand(StopDebugging, () => IsDebugging); PauseCommand = commandsManager.CreateRelayCommand(PauseDebugging, () => IsDebugging && !IsDebuggingPaused && IsViceConnected); StepIntoCommand = commandsManager.CreateRelayCommandAsync(StepIntoAsync, () => IsDebugging && IsDebuggingPaused); StepOverCommand = commandsManager.CreateRelayCommandAsync(StepOverAsync, () => IsDebugging && IsDebuggingPaused); UpdatePdbCommand = commandsManager.CreateRelayCommandAsync(UpdatePdbAsync, () => !IsBusy && IsDebugging); SwitchContent <DebuggerViewModel>(); // by default opens most recent project if (globals.Settings.RecentProjects.Count > 0) { OpenProjectFromPath(globals.Settings.RecentProjects[0]); } stoppedExecution = new TaskCompletionSource(); resumedExecution = new TaskCompletionSource(); viceBridge.ConnectedChanged += ViceBridge_ConnectedChanged; viceBridge.ViceResponse += ViceBridge_ViceResponse; viceBridge.Start(); requiresBreakpointsRefresh = true; if (!Directory.Exists(globals.Settings.VicePath)) { SwitchOverlayContent <SettingsViewModel>(); } }
public ProjectExplorerViewModel(IDispatcher dispatcher, ILogger <ProjectExplorerViewModel> logger, Globals globals, IAcmePdbManager acmePdbManager, BreakpointsViewModel breakpoints) { this.dispatcher = dispatcher; this.logger = logger; this.globals = globals; this.acmePdbManager = acmePdbManager; this.breakpoints = breakpoints; OpenSourceFileCommand = new RelayCommand <object>(OpenSourceFile, canExecute: o => o is AcmeFile || o is AcmeLabel); AddBreakpointOnLabelCommand = new RelayCommandAsync <AcmeLabel>(AddBreakpointOnLabelAsync, CanAddBreakpointOnLabel); globals.PropertyChanged += Globals_PropertyChanged; UpdateNodes(); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="lines"></param> /// <remarks> /// Constructor arguments are passed by <see cref="ServiceProviderExtension.CreateSourceFileViewModel"/>. /// It is mandatory that they are in sync. /// </remarks> public SourceFileViewModel(IViceBridge viceBridge, AcmeFile file, ImmutableArray <LineViewModel> lines, BreakpointsViewModel breakpoints) { this.viceBridge = viceBridge; this.breakpoints = breakpoints; this.file = file; uiFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()); Lines = lines; viceBridge.ConnectedChanged += ViceBridge_ConnectedChanged; AddOrRemoveBreakpointCommand = new RelayCommandAsync <LineViewModel>(AddOrRemoveBreakpointAsync, canExecute: l => l?.Address is not null && viceBridge.IsConnected); var fileBreakpoints = breakpoints.Breakpoints.Where(b => b.File == file).ToImmutableArray(); AddBreakpointsToLine(fileBreakpoints); breakpoints.Breakpoints.CollectionChanged += Breakpoints_CollectionChanged; }