public static void StopCountdown(this State state, string input, int index) { state?.SendFunction( "Function", "StopCountdown", "Input", input, "SelectedIndex", index.ToString()); }
public static void TitleSetImage(this State state, string input, string value, int index) { state?.SendFunction("Function", "SetImage", "Value", value, "Input", input.ToString(), "SelectedIndex", index.ToString()); }
public static void SetCountdown(this State state, string input, int index, string duration) { state?.SendFunction("Function", "SetCountdown", "Input", input, "Value", duration, "SelectedIndex", index.ToString()); }
public static void OverlayInputOut(this State state, int overlay) { state?.SendFunction( "Function", string.Format("OverlayInput{0}Out", overlay)); }
public static void OverlayInputToggle(this State state, string input, int overlay) { state?.SendFunction( "Function", string.Format("OverlayInput{0}", overlay), "Input", input); }
public static void InputLoopOff(this State state, int input) { state?.SendFunction( "Function", "LoopOff", "Input", input.ToString()); }
public static void InputSetPosition(this State state, int input, int milliseconds) { state?.SendFunction("Function", "SetPosition", "Input", input.ToString(), "Value", milliseconds.ToString()); }
public static void InputSelectIndex(this State state, string input, int index) { state?.SendFunction("Function", "SelectIndex", "Input", input, "Value", index.ToString()); }
public static void FadeToBlack(this State state) { state?.SendFunction( "Function", "FadeToBlack"); }
public static void ActiveInput(this State state, int input) { state?.SendFunction( "Function", "ActiveInput", "Input", input.ToString()); }
public static void PreviewInput(this State state, int input) { state?.SendFunction( "Function", "PreviewInput", "Input", input.ToString()); }
private void ExecutionThread(object _state) { vMixAPI.State state = (vMixAPI.State)_state; Stack <bool?> _conditions = new Stack <bool?>(); int _waitBeforeUpdate = -1; for (int _pointer = 0; _pointer < _commands.Count; _pointer++) { if (_stopThread) { return; } var cmd = _commands[_pointer]; var cond = new bool?(true); if (_conditions.Count > 0) { cond = _conditions.Peek(); } if ((cond.HasValue && cond.Value) || (cmd.Action.Function == NativeFunctions.CONDITIONEND || cmd.Action.Function == NativeFunctions.CONDITION || cmd.Action.Function == NativeFunctions.HASVARIABLE)) { if (cmd.Action.Native) { switch (cmd.Action.Function) { case NativeFunctions.TIMER: Thread.Sleep(CalculateExpression <int>(cmd.Parameter)); break; case NativeFunctions.UPDATESTATE: Dispatcher.Invoke(() => state?.UpdateAsync()); break; case NativeFunctions.UPDATEINTERNALBUTTONSTATE: Dispatcher.Invoke(() => _internalState?.UpdateAsync()); break; case NativeFunctions.GOTO: _pointer = CalculateExpression <int>(cmd.Parameter) - 1; break; case NativeFunctions.EXECLINK: Dispatcher.Invoke(() => Messenger.Default.Send <string>(cmd.StringParameter)); break; case NativeFunctions.LIVETOGGLE: Dispatcher.Invoke(() => Messenger.Default.Send <LIVEToggleMessage>(new LIVEToggleMessage() { State = 2 })); break; case NativeFunctions.LIVEOFF: Dispatcher.Invoke(() => Messenger.Default.Send <LIVEToggleMessage>(new LIVEToggleMessage() { State = 0 })); break; case NativeFunctions.LIVEON: Dispatcher.Invoke(() => Messenger.Default.Send <LIVEToggleMessage>(new LIVEToggleMessage() { State = 1 })); break; case NativeFunctions.CONDITION: _conditions.Push(cond.HasValue && cond.Value ? new bool?(TestCondition(cmd)) : null); break; case NativeFunctions.HASVARIABLE: _conditions.Push(cond.HasValue && cond.Value ? new bool?(GetVariableIndex(CalculateExpression <int>(cmd.Parameter)) != -1) : null); break; case NativeFunctions.CONDITIONEND: _conditions.Pop(); break; case NativeFunctions.SETVARIABLE: var idx = GetVariableIndex(CalculateExpression <int>(cmd.Parameter)); if (idx == -1) { Dispatcher.Invoke(() => _variables.Add(new Pair <int, object>() { A = CalculateExpression <int>(cmd.Parameter), B = CalculateObjectParameter(cmd) })); } else { Dispatcher.Invoke(() => _variables[idx].B = CalculateObjectParameter(cmd)); } break; } } else if (state != null) { var input = state.Inputs.Where(x => x.Key == cmd.InputKey).FirstOrDefault()?.Number; if (!cmd.Action.StateDirect) { state.SendFunction(string.Format(cmd.Action.FormatString, cmd.InputKey, CalculateExpression <int>(cmd.Parameter), Dispatcher.Invoke(() => CalculateObjectParameter(cmd)), CalculateExpression <int>(cmd.Parameter) - 1, input.HasValue ? input.Value : 0), false); } else { var path = string.Format(cmd.Action.ActiveStatePath, cmd.InputKey, CalculateExpression <int>(cmd.Parameter), Dispatcher.Invoke(() => CalculateObjectParameter(cmd)), CalculateExpression <int>(cmd.Parameter) - 1, input.HasValue ? input.Value : 0); var value = cmd.Action.StateValue == "Input" ? (object)cmd.InputKey : (cmd.Action.StateValue == "String" ? Dispatcher.Invoke(() => CalculateObjectParameter(cmd)).ToString() : (object)CalculateExpression <int>(cmd.Parameter)); SetValueByPath(state, path, value); int flag = 0; while (GetValueByPath(state, path) != value) { Thread.Sleep(50); if (_stopThread) { return; } if (++flag > 10) { break; } } } _waitBeforeUpdate = Math.Max(_internalState.Transitions[cmd.Action.TransitionNumber].Duration, _waitBeforeUpdate); } } } _conditions.Clear(); ThreadPool.QueueUserWorkItem((x) => { Enabled = true; Thread.Sleep(_waitBeforeUpdate); _waitBeforeUpdate = -1; Dispatcher.Invoke(() => _internalState.UpdateAsync()); }); }