private void Configure(WorkspaceStateMachine m) { m.OnTransitioned(t => _writeLog($"w: {t.Source} -> ({t.Trigger}) -> {t.Destination}")); m.OnUnhandledTrigger((s, t) => _writeLog($"w: Cannot trigger {t} in state {s}")); m.Configure(S.NotLoaded) .OnEntryFrom(T.Unload, OnUnload) .OnEntryFrom(T.Detach, OnDetach) .OnEntryFromAsync(T.Sync.With <WorkspaceInfoData>(), async data => await OnSyncAsync(data)) .InternalTransition(T.Load.With <WorkspaceLoadData>(), (data, _) => OnLoad(data)) .Ignore(T.SolutionLoaded) .Ignore(T.ProjectDebugStart) .Ignore(T.ProjectDebugStop) .Ignore(T.ProjectBuildStart) .Ignore(T.ProjectBuildStop) .Ignore(T.Start) .Ignore(T.Stop) .PermitDynamic(T.Sync.With <WorkspaceInfoData>(), GetSyncState); m.Configure(S.Idle) .SubstateOf(S.Active) .OnEntryFromAsync(T.Sync.With <WorkspaceInfoData>(), async data => await OnSyncAsync(data)) .OnEntryFrom(T.Stop, OnStop) .OnEntryFrom(T.Load.With <WorkspaceLoadData>(), OnLoad) .OnEntryFrom(T.Error, OnError) .PermitDynamic(T.Sync.With <WorkspaceInfoData>(), GetSyncState) .Permit(T.Unload, S.NotLoaded) .Permit(T.Detach, S.NotLoaded) .Permit(T.Start, S.Running); m.Configure(S.Running) .SubstateOf(S.Active) .OnEntryFromAsync(T.Sync.With <WorkspaceInfoData>(), async data => await OnSyncAsync(data)) .OnEntryFrom(T.Start, OnStart) .PermitDynamic(T.Sync.With <WorkspaceInfoData>(), GetSyncState) .Permit(T.Error, S.Idle) .Permit(T.Stop, S.Idle) .Permit(T.Detach, S.NotLoaded); m.Configure(S.Active) .InternalTransition(T.ProjectDebugStart.With <RunnableNames>(), (d, _) => OnProjectDebugStart(d)) .InternalTransition(T.ProjectDebugStop.With <RunnableName>(), (d, _) => OnProjectDebugStop(d)) .InternalTransition(T.ProjectBuildStart.With <RunnableName>(), (d, _) => OnProjectBuildStart(d)) .InternalTransition(T.ProjectBuildStop.With <RunnableName>(), (d, _) => OnProjectBuildStop(d)) .InternalTransition(T.SolutionDebugStop, OnSolutionDebugStop) .InternalTransition(T.SolutionLoaded.With <SolutionLoadedData>(), (d, _) => OnSolutionLoaded(d)) .InternalTransition(T.SolutionUnloaded, OnSolutionUnloaded) .InternalTransition(T.SolutionBuildStart, OnSolutionBuildStart) .InternalTransition(T.SolutionBuildStop, OnSolutionBuildStop) .Permit(T.Unload, S.NotLoaded) .Permit(T.Stop, S.Idle) .Permit(T.Error, S.Idle);
public RingWindowViewModel(SolutionStateMachine slnFsm, WorkspaceStateMachine wsFsm, SolutionViewModel slnVm, WorkspaceViewModel wsViewModel ) { _workspaceMachine = wsFsm; _solutionMachine = slnFsm; Workspace = wsViewModel; Solution = slnVm; _workspaceMachine.Activate(); _solutionMachine.Activate(); }
public RingWindowControl() { ThreadHelper.ThrowIfNotOnUIThread(); var workspaceMachine = new WorkspaceStateMachine(); var solutionMachine = new SolutionStateMachine(); var commandQueue = new Queue <IRingCommand>(); var ringClient = new RingClient(new Uri(_ringServerUri), commandQueue, OutputWriteLine); var solution = new SolutionViewModel(solutionMachine, workspaceMachine, OutputWriteLine, commandQueue); _workspace = new WorkspaceViewModel(solutionMachine, workspaceMachine, OutputWriteLine, commandQueue); _ringManager = new RingManager(ringClient, OutputWriteLine); DataContext = new RingWindowViewModel(solutionMachine, workspaceMachine, solution, _workspace); InitializeComponent(); }
public WorkspaceViewModel(SolutionStateMachine solutionMachine, WorkspaceStateMachine workspaceMachine, Action <string> writeLog, ISender <IRingCommand> commandSender) { _writeLog = writeLog; _commandSender = commandSender; _runnables = new RunnablesViewModel(writeLog); _solutionMachine = solutionMachine; _workspaceFsm = workspaceMachine; _root = new SubWorkspaceVm(commandSender, writeLog, new WorkspaceInfo("", new RunnableInfo[0], ServerState.IDLE, WorkspaceState.IDLE)); Status = new WorkspaceStatusVm(); Status.None(); IsSyncButtonEnabled = true; IsOpenButtonEnabled = false; FilePathVisibility = Visibility.Collapsed; Configure(_workspaceFsm); }
public SolutionViewModel(SolutionStateMachine slnMachine, WorkspaceStateMachine wsMachine, Action <string> writeLog, ISender <IRingCommand> commandQueue) { ThreadHelper.ThrowIfNotOnUIThread(); _writeLog = writeLog; _commandQueue = commandQueue; _wsMachine = wsMachine; _slnMachine = slnMachine; Configure(_slnMachine); var debugStartCmd = Dte.Commands.Item("Debug.Start"); _solutionEventsHandler = new SolutionsEventsHandler(Sln); _debuggerEventsHandler = new DebuggerEventsHandler(Debugger); _projStartDebugEvent = Dte.Events.CommandEvents["{" + VSConstants.VSStd2K + "}", (int)VSConstants.VSStd2KCmdID.PROJSTARTDEBUG]; _projStepIntoEvent = Dte.Events.CommandEvents["{" + VSConstants.VSStd2K + "}", (int)VSConstants.VSStd2KCmdID.PROJSTEPINTO]; _debugStartEvent = Dte.Events.CommandEvents[debugStartCmd.Guid, debugStartCmd.ID]; _debuggerEvents = Dte.Events.DebuggerEvents; _buildEvents = Dte.Events.BuildEvents; _buildEvents.OnBuildBegin += BuildBegin; _buildEvents.OnBuildDone += BuildDone; _buildEvents.OnBuildProjConfigBegin += ProjectBuildBegin; _buildEvents.OnBuildProjConfigDone += ProjectBuildDone; _projStepIntoEvent.BeforeExecute += DebugProjectsAdd; _projStartDebugEvent.BeforeExecute += DebugProjectsAdd; _debugStartEvent.BeforeExecute += DebugStart; _debuggerEvents.OnEnterDesignMode += DebugStop; _solutionEventsHandler.OnAfterOpen += Load; _solutionEventsHandler.OnAfterClose += Unload; _debuggerEventsHandler.OnProcessCreated += DebugProcessAdd; _debuggerEventsHandler.OnProcessRemoved += DebugRemove; _projectProcesses = new ProjectsProcesses(writeLog); //TODO: handle debug detach (probably kill detached the process - figure out how to get it - potentially get PID on creation) //TODO: handle clean up - what should happen if a project or whole solution is cleaned up? Should ring run in a degraded state (With "big exclamation marks" in the window) }