Exemplo n.º 1
0
        private void OnStepCompleteMessage(StepCompleteMessage msg)
        {
            if (_autoStepOver)
            {
                if (_multiChannel)
                {
                    OnStepCompleteMessageMultiChannel(msg);
                }
                else
                {
                    Task.Run(async() =>
                    {
                        await Task.Delay(50);

                        StepViewModel newSelection = GetNextStep();

                        if (newSelection != null)
                        {
                            DispatcherHelperEx.CheckBeginInvokeOnUI(() => Selected = newSelection);
                        }
                        //if (newSelection != null) Selected = newSelection;
                    });
                }
            }
        }
Exemplo n.º 2
0
        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)
                {
                    _stepObserver.SetFarwardIndex(i);
                    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();
                    });
                }
            }
        }
Exemplo n.º 3
0
 private void OnUnloadStepsMessage(UnloadStepsMessage msg)
 {
     if (Steps.Count > 0)
     {
         Selected = Steps[0];
         Steps.Clear();
         Selected = null;
     }
 }
Exemplo n.º 4
0
        private void ManageFarwardSelectionChangedStatic(StepViewModel selected, StepViewModel lastSelected)
        {
            for (int i = lastSelected.Index + 1; i <= selected.Index; i++)
            {
                var svm = Steps[i];

                _stepObserver.SetFarwardIndex(i);
                svm.UpdateLazys();
                svm.ExecuteFarward();
            }
        }
Exemplo n.º 5
0
 private void ManageFarwardSelectionChanged(StepViewModel selected, StepViewModel lastSelected)
 {
     if (_autoStepOver && _multiChannel)
     {
         ManageFarwardSelectionChangedDynamic(selected, lastSelected);
     }
     else
     {
         ManageFarwardSelectionChangedStatic(selected, lastSelected);
     }
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        private void ManageBackSelectionChanged(StepViewModel selected, StepViewModel lastSelected)
        {
            MessengerInstance.Send(new SuspendPlaybackSettingsMessage());

            for (int i = lastSelected.Index; i > selected.Index; i--)
            {
                _stepObserver.SetBackIndex(i);
                Steps[i].ExecuteBack();
            }

            MessengerInstance.Send(new ResumePlaybackSettingsMessage());

            if (Selected.Index == 0)
            {
                _channelFreeBackNotifyId.Clear();
                _channelState.Clear();
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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 MeVmMG.BackNotificationMessage()
                            {
                                DestinationId = id
                            });
                        }
                    }
                }
                else
                {
                    StepViewModel newSelection = GetNextStep();

                    if (newSelection != null)
                    {
                        DispatcherHelperEx.CheckBeginInvokeOnUI(() => Selected = newSelection);
                    }
                }
            });
        }
Exemplo n.º 11
0
        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
            });
        }