protected override void OnNavigatedTo(NavigationEventArgs e) { //base.OnNavigatedTo(e); if (Transitions != null) { Transitions.Clear(); } App.windowResize(); stopwatch.Start(); }
void OnEntityEditedChanged() { SelectedNode = null; Nodes.Clear(); transitionCreationHelper.Reset(); Transitions.Clear(); offset = Vector2.zero; drag = Vector2.zero; LoadEntity(); }
public StateMachineViewModel() { PendingTransition = new TransitionViewModel(); Runner = new StateMachineRunnerViewModel(this); Blackboard = new BlackboardViewModel() { Actions = new NodifyObservableCollection <BlackboardItemReferenceViewModel>(BlackboardDescriptor.GetAvailableItems <IBlackboardAction>()), Conditions = new NodifyObservableCollection <BlackboardItemReferenceViewModel>(BlackboardDescriptor.GetAvailableItems <IBlackboardCondition>()) }; // public INodifyObservableCollection<T> WhenAdded(Action<T> added) // INodifyObservableCollection<T>, Action<T> 임으로 T는 WhenAdded 의부모 속성을 가지므로 파라미터 하나짜리 익명함수의 경우 해당 파라미터는 부모의 객체 타입이다. // Source 의경우는 TransitionViewModel 객체의 StateViewModel 이다. // public NodifyObservableCollection<StateViewModel> Transitions { get; } = new NodifyObservableCollection<StateViewModel>(); // 초기화 구문 같은데... Transitions.WhenAdded(c => c.Source.Transitions.Add(c.Target)) .WhenRemoved(c => c.Source.Transitions.Remove(c.Target)) .WhenCleared(c => c.ForEach(i => { i.Source.Transitions.Clear(); i.Target.Transitions.Clear(); })); States.WhenAdded(x => x.Graph = this) .WhenRemoved(x => DisconnectState(x)) .WhenCleared(x => { Transitions.Clear(); OnCreateDefaultNodes(); }); OnCreateDefaultKeys(); // 여기서 노드와 arrow 가 생성됨. OnCreateDefaultNodes(); // RequeryCommand ??? RenameStateCommand = new RequeryCommand(() => SelectedStates[0].IsRenaming = true, () => SelectedStates.Count == 1 && SelectedStates[0].IsEditable); DisconnectStateCommand = new RequeryCommand <StateViewModel>(x => DisconnectState(x), x => !IsRunning && x.Transitions.Count > 0); DisconnectSelectionCommand = new RequeryCommand(() => SelectedStates.ForEach(x => DisconnectState(x)), () => !IsRunning && SelectedStates.Count > 0 && Transitions.Count > 0); DeleteSelectionCommand = new RequeryCommand(() => SelectedStates.ToList().ForEach(x => x.IsEditable.Then(() => States.Remove(x))), () => !IsRunning && (SelectedStates.Count > 1 || (SelectedStates.Count == 1 && SelectedStates[0].IsEditable))); AddStateCommand = new RequeryCommand <Point>(p => States.Add(new StateViewModel { Name = "New State", IsRenaming = true, Location = p, ActionReference = Blackboard.Actions.Count > 0 ? Blackboard.Actions[0] : null }), p => !IsRunning); CreateTransitionCommand = new DelegateCommand <(object Source, object?Target)>(s => Transitions.Add(new TransitionViewModel { Source = (StateViewModel)s.Source, Target = (StateViewModel)s.Target ! }), s => !IsRunning && s.Source is StateViewModel source && s.Target is StateViewModel target && target != s.Source && target != States[0] && !source.Transitions.Contains(s.Target));
/// <summary> /// Constructor /// </summary> /// <param name="stateMachine"></param> public TransitionFinder(StateMachine stateMachine) { Utils.FinderRepository.INSTANCE.ClearCache(); Transitions.Clear(); StateMachine = stateMachine; Constants.State initialState = StateMachine.DefaultValue as Constants.State; if (initialState != null) { Transitions.Add(new Rules.Transition(null, null, null, initialState)); } }
/// <summary> /// Clear all observable collections /// </summary> private void ClearData() { InterNodes.Clear(); Connections.Clear(); Connectors.Clear(); Nodes.Clear(); Transitions.Clear(); Inputs.Clear(); Outputs.Clear(); NotInputs.Clear(); NotOutputs.Clear(); }
public void Files_SelectionChanged(SelectionChangedEventArgs args) { Transitions.Clear(); Plotter.Clear(); ImportedFromDatabase.Clear(); SelectedFile = args.AddedItems.Cast <object>().Where(x => x is ListBoxFileItem).Count() == 1 ? args.AddedItems.Cast <ListBoxFileItem>().First() : null; NotifyOfPropertyChange(() => CanDetectPeaks); NotifyOfPropertyChange(() => CanAddToDatabase); }
public void DetectPeaks() { Transitions.Clear(); Plotter.Clear(); string contents = ReadFromFile(SelectedFile.Path); if (!string.IsNullOrEmpty(contents)) { ProcessFile(contents); } NotifyOfPropertyChange(() => CanAddToDatabase); NotifyOfPropertyChange(() => CanSaveImage); NotifyOfPropertyChange(() => CanSaveSpectrum); }
public void AggregateTransitions() { //clear existing transitions Transitions.Clear(); for (int i = 0; i < RawStates.Count - 1; i++) { //starting state TimelineState currentState = RawStates[i]; //non-social state? if (currentState.IsSocialEvent == true) { //try again continue; } //pointer to next index int nextIndex = i + 1; //and the next one TimelineState nextState = RawStates[nextIndex]; //handle social events differently. Like normal, place them in a bucket that is of the form //State -> Social Event. However, do not increment currentState until we find a matching //non-social event. while (nextIndex < RawStates.Count && nextState.IsSocialEvent == true) { KeyValuePair <string, string> transition = new KeyValuePair <string, string>(currentState.State, currentState.State); if (Transitions.ContainsKey(transition) == false) { Transitions.Add(transition, 0); } Transitions[transition]++; nextIndex++; } //at this point, currentState and nextState should both be non-social events. Record transition. KeyValuePair <string, string> key = new KeyValuePair <string, string>(currentState.State, nextState.State); if (Transitions.ContainsKey(key) == false) { Transitions.Add(key, 0); } Transitions[key]++; } }
public void Clear() { States.Clear(); Transitions.Clear(); Items.Clear(); }
public void UpdateAsync() { SendFunction("", true, x => { try { var e = (DownloadStringCompletedEventArgs)x; if (e.Error != null) { OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); return; } if (e.UserState == null) { return; } IsInitializing = true; _logger.Debug("Updating vMix state."); var _temp = Create(e.Result); if (_temp == null) { _logger.Debug("vMix is offline"); _logger.Debug("Firing \"updated\" event."); IsInitializing = false; OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); } _logger.Debug("Calculating difference."); Diff(this, _temp); _logger.Debug("Updating inputs."); if (Inputs == null) { Inputs = new List <Input>(); } if (Overlays == null) { Overlays = new List <Overlay>(); } if (Audio == null) { Audio = new List <Master>(); } if (Transitions == null) { Transitions = new List <Transition>(); } Inputs.Clear(); foreach (var item in _temp.Inputs) { Inputs.Add(item); } Overlays.Clear(); foreach (var item in _temp.Overlays) { Overlays.Add(item); } Audio.Clear(); foreach (var item in _temp.Audio) { Audio.Add(item); } Transitions.Clear(); foreach (var item in _temp.Transitions) { Transitions.Add(item); } Mixes.Clear(); foreach (var item in _temp.Mixes) { Mixes.Add(item); } if (_currentStateText != _temp._currentStateText) { _currentStateText = _temp._currentStateText; } _logger.Debug("Firing \"updated\" event."); IsInitializing = false; OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = true, OldInputs = null, NewInputs = null }); return; } catch (Exception e) { IsInitializing = false; _logger.Error(e, "Exception at UpdateAsync"); } }); }
public bool Update() { try { IsInitializing = true; _logger.Debug("Updating vMix state."); var _temp = Create(); if (_temp == null) { _logger.Debug("vMix is offline"); _logger.Debug("Firing \"updated\" event."); OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = false }); IsInitializing = false; return(false); } _logger.Debug("Calculating difference."); Diff(this, _temp); _logger.Debug("Updating inputs."); Inputs.Clear(); foreach (var item in _temp.Inputs) { Inputs.Add(item); } Overlays.Clear(); foreach (var item in _temp.Overlays) { Overlays.Add(item); } Audio.Clear(); foreach (var item in _temp.Audio) { Audio.Add(item); } Transitions.Clear(); foreach (var item in _temp.Transitions) { Transitions.Add(item); } Mixes.Clear(); foreach (var item in _temp.Mixes) { Mixes.Add(item); } //UpdateChangedInputs(_currentStateText, _temp._currentStateText); if (_currentStateText != _temp._currentStateText) { _currentStateText = _temp._currentStateText; } _logger.Debug("Firing \"updated\" event."); OnStateSynced?.Invoke(this, new StateSyncedEventArgs() { Successfully = true, OldInputs = null, NewInputs = null }); IsInitializing = false; return(true); } catch (Exception e) { IsInitializing = false; _logger.Error(e, "Exception at Update"); return(false); } }
public virtual void Compose(List <State> states) { Transitions.Clear(); }