private void ManageFarwardSelectionChangedDynamic(StepViewModel selected, StepViewModel lastSelected) { HashSet <int> set = new HashSet <int>(); for (int i = lastSelected.Index + 1; i <= selected.Index; i++) { var svm = Steps[i]; if (svm.Channel == 0) { svm.UpdateLazys(); svm.ExecuteFarward(); break; } else if ((svm.Channel > 0) && !set.Contains(svm.Channel)) { set.Add(svm.Channel); _channelState.AddOrUpdate(svm.Channel, true, (k, v) => true); Task.Run(() => { svm.UpdateLazys(); svm.ExecuteFarward(); }); } } }
private void OnUnloadStepsMessage(UnloadStepsMessage msg) { if (Steps.Count > 0) { Selected = Steps[0]; Steps.Clear(); Selected = null; } }
private void ManageFarwardSelectionChanged(StepViewModel selected, StepViewModel lastSelected) { for (int i = lastSelected.Index + 1; i <= selected.Index; i++) { var svm = Steps[i]; svm.UpdateLazys(); svm.ExecuteFarward(); } }
private void ManageBackSelectionChanged(StepViewModel selected, StepViewModel lastSelected) { MessengerInstance.Send(new SuspendPlaybackSettingsMessage()); for (int i = lastSelected.Index; i > selected.Index; i--) { Steps[i].ExecuteBack(); } MessengerInstance.Send(new ResumePlaybackSettingsMessage()); }
private void ManageFarwardSelectionChanged(StepViewModel selected, StepViewModel lastSelected) { if (_autoStepOver && _multiChannel) { ManageFarwardSelectionChangedDynamic(selected, lastSelected); } else { ManageFarwardSelectionChangedStatic(selected, lastSelected); } }
private bool IsChannelWaiter(StepViewModel step, int channel) { bool result = false; if ((step.FarwardActions.Count == 1) && (step.FarwardActions[0].Action is ChannelWaiterAction action) && (action.ChannelToWait == channel)) { result = true; } return(result); }
private void OnStepCompleteMessage(StepCompleteMessage msg) { if (_autoStepOver) { Task.Run(async() => { await Task.Delay(50); StepViewModel newSelection = GetNextStep(); if (newSelection != null) { DispatcherHelper.CheckBeginInvokeOnUI(() => Selected = newSelection); } }); } }
private void ManageBackSelectionChanged(StepViewModel selected, StepViewModel lastSelected) { MessengerInstance.Send(new SuspendPlaybackSettingsMessage()); for (int i = lastSelected.Index; i > selected.Index; i--) { Steps[i].ExecuteBack(); } MessengerInstance.Send(new ResumePlaybackSettingsMessage()); if (Selected.Index == 0) { _channelFreeBackNotifyId.Clear(); _channelState.Clear(); } }
private StepViewModel GetNextStep(int channel, int fromIndex) { StepViewModel nextStep = null; for (int i = fromIndex + 1; i < Steps.Count; i++) { if (Steps[i].Channel == channel) { nextStep = Steps[i]; break; } else if (IsChannelWaiter(Steps[i], channel)) { break; } } return(nextStep); }
private StepViewModel GetNextStep() { StepViewModel newSelection = null; if (_selected == null) { newSelection = Steps[0]; } else { int index = Steps.IndexOf(Selected) + 1; if (index < Steps.Count()) { newSelection = Steps[index]; } } return(newSelection); }
private void OnStepCompleteMessageMultiChannel(StepCompleteMessage msg) { Task.Run(async() => { await Task.Delay(50); if (msg.Channel > 0) { var step = GetNextStep(msg.Channel, msg.Index); if (_channelState.AddOrUpdate(msg.Channel, step != null, (k, v) => step != null)) { step.UpdateLazys(); step.ExecuteFarward(); } else { if (_channelFreeBackNotifyId.TryRemove(msg.Channel, out int id)) { MessengerInstance.Send(new BackNotificationMessage() { DestinationId = id }); } } } else { StepViewModel newSelection = GetNextStep(); if (newSelection != null) { DispatcherHelper.CheckBeginInvokeOnUI(() => Selected = newSelection); } } }); }
private void ManageSelectionChanged(StepViewModel selected, StepViewModel lastSelected) { if (lastSelected == null) { ManageFarwardSelectionChanged(selected, Steps[0]); } else if (selected == null) { // per il momento non faccio nulla } else if (selected.Index > lastSelected.Index) { ManageFarwardSelectionChanged(selected, lastSelected); } else if (selected.Index < lastSelected.Index) { ManageBackSelectionChanged(selected, lastSelected); } MessengerInstance.Send(new UpdateStepTimeMessage() { Time = (Selected != null) ? Selected.EvolutionTime : 0.0 }); }