void FlipHandler(Tuple <SwitchMode, TaskCompletionSource <bool> > t) { var flipToMode = t.Item1; var completion = t.Item2; var succeed = false; if (flipToMode != _mode) { if (_mode == SwitchMode.Close) { if (IsAvailable(_valve.In)) { Push(_valve.Out, Grab(_valve.In)); } else if (IsAvailable(_valve.Out) && !HasBeenPulled(_valve.In)) { Pull(_valve.In); } _mode = SwitchMode.Open; } else { _mode = SwitchMode.Close; } succeed = true; } completion.SetResult(succeed); }
private void OnDestroy() { GetComponent <VRTK_ControllerEvents>().GripPressed -= DoGrabPressed; GetComponent <VRTK_ControllerEvents>().GripReleased -= DoGrabReleased; GetComponent <VRTK_ControllerEvents>().ButtonTwoPressed -= DoButtonTwoPressed; _instance = null; }
public void ReadXml(XmlReader reader) { reader.MoveToContent(); Source = VariableFactory.CreateScriptedVariable <long>(reader.GetAttribute("Source")); string modeString = reader.GetAttribute("Mode"); if (modeString != null) { Mode = (SwitchMode)Enum.Parse(typeof(SwitchMode), modeString); } bool hasElements = !reader.IsEmptyElement; reader.ReadStartElement(); if (hasElements) { while (reader.IsStartElement()) { reader.MoveToContent(); if (reader.Name == "Default" && Default == null) { Default = ReadCase(reader); } else { var c = ReadCase(reader); Cases.Add(c); } } reader.ReadEndElement(); } }
public Task <bool> Flip(SwitchMode flipToMode) { var completion = new TaskCompletionSource <bool>(); _flipCallback(Tuple.Create(flipToMode, completion)); return(completion.Task); }
/// <summary> /// Tuät d Animazion startä. /// </summary> /// /// <param name="mode">Dr Modus i welem d Animazion laift (chunnt uifs Mappind druif ah)</param> /// <param name="render">Ä Funktion wo tuät s Buid uisgäh</param> /// <param name="completed">Wird uisgfiärt wenn fertig</param> public void Start(SwitchMode mode, Action <byte[][]> render, Action completed = null) { IsRunning = true; SwitchMode = mode; _frameIndex = 0; FoundFollowMatch = true; // Always render the first frame in a follow sequence. switch (SwitchMode) { case SwitchMode.ColorMask: case SwitchMode.Follow: case SwitchMode.MaskedReplace: StartEnhance(render); break; case SwitchMode.Replace: case SwitchMode.FollowReplace: StartReplace(render, completed); break; case SwitchMode.LayeredColorMask: StartLCM(render); break; } }
public static IActivityBuilder Switch( this IBuilder builder, Func <SwitchCaseBuilder, ValueTask> cases, SwitchMode mode = SwitchMode.MatchFirst, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) { var switchCaseBuilder = new SwitchCaseBuilder(); var activityBuilder = builder.Then <Switch>(async setup => { await cases(switchCaseBuilder); setup .WithCases(async context => { var evaluatedCases = switchCaseBuilder.Cases.Select(async x => new SwitchCase(x.Name, await x.Condition(context))).ToList(); return(await Task.WhenAll(evaluatedCases)); }) .WithMode(mode); }, null, lineNumber, sourceFile); foreach (var caseDescriptor in switchCaseBuilder.Cases) { caseDescriptor.OutcomeBuilder(activityBuilder); } return(activityBuilder); }
public bool SetMode(SwitchMode mode, InputPort inputPort) { if (!_rs232Device.Enabled) { return(false); } string result = string.Empty; switch (mode) { case SwitchMode.Default: result = _rs232Device.WriteWithResponse("swmode default", $"^swmode default {_respSuccess}$"); break; case SwitchMode.Next: result = _rs232Device.WriteWithResponse("swmode next", $"^swmode next {_respSuccess}$"); break; case SwitchMode.Auto: result = _rs232Device.WriteWithResponse($"swmode i{inputPort:00} auto", $"^swmode i{inputPort:00} auto {_respSuccess}$"); break; default: Debug.Assert(false, "Unkown SwitchMode"); return(false); } return(result != null); }
private void OnDestroy() { SwitchMode.DisablePointer(); _headset.GetComponent <VRTK_Pointer>().PointerStateValid -= DoPointerEnter; _headset.GetComponent <VRTK_Pointer>().PointerStateValid -= DoPointerExit; GetComponent <VRTK_Pointer>().PointerStateValid -= DoPointerEnter; GetComponent <VRTK_Pointer>().PointerStateValid -= DoPointerExit; }
private void CbMode_Click(object sender, RoutedEventArgs e) { bool value = !cbMode.IsChecked.Value; settings.IsLight = value; _settingsRepository.Save(settings); SwitchMode?.Invoke(sender, e); }
/// <summary> /// Creates <see cref="Valve{T}"/> with inital <paramref name="mode"/> /// </summary> /// <param name="mode">state of the valve at the startup of the flow</param> public Valve(SwitchMode mode) { _mode = mode; In = new Inlet <T>("valve.in"); Out = new Outlet <T>("valve.out"); Shape = new FlowShape <T, T>(In, Out); }
public AltSupportingBgm(IBgm regular, IBgm alternate, SwitchMode switchMode) { Regular = regular; Alt = alternate; SwitchMode = switchMode; current = Regular; }
public AltSupportingBgm(IBgm regular, IBgm alternate, SwitchMode switchMode) { Regular = regular; Alt = alternate; SwitchMode = switchMode; current = Regular; }
public void SetSwitchValue(bool value, BiomeSwitchMode biomeSwitchMode, string biomeName, Color previewColor) { this.value = value; this.mode = SwitchMode.Bool; this.biomeSwitchMode = biomeSwitchMode; this.biomeName = biomeName; this.previewColor = previewColor; this.biome = null; }
public void Toggle() { if (_cart != null) return; _mode = (_mode == SwitchMode.Up ? SwitchMode.Down : SwitchMode.Up); }
public void SetSwitchValue(float min, float max, BiomeSwitchMode biomeSwitchMode, string biomeName, Color previewColor) { this.min = min; this.max = max; this.mode = SwitchMode.Float; this.biomeSwitchMode = biomeSwitchMode; this.biomeName = biomeName; this.previewColor = previewColor; this.biome = null; }
/// <summary> /// Set the switch mode /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnSwitchModeChanged(object sender, RoutedEventArgs e) { MenuItem item = sender as MenuItem; OnMenuItemClick(item); SwitchMode mode = ( SwitchMode )Enum.Parse(typeof(SwitchMode), ( string )item.Header); DockingManager.SwitchMode = mode; }
public AltSupportingBgm(IBgm regular, IBgm alternate, SwitchMode switchMode) { #pragma warning disable RECS0021 Regular = regular; Alt = alternate; SwitchMode = switchMode; current = Regular; #pragma warning restore RECS0021 }
public AltSupportingBgm(IBgm regular, IBgm alternate, SwitchMode switchMode) { #pragma warning disable RECS0021 Regular = regular; Alt = alternate; SwitchMode = switchMode; current = Regular; #pragma warning restore RECS0021 }
public static IActivityBuilder Switch( this IBuilder builder, Action <SwitchCaseBuilder> cases, SwitchMode mode = SwitchMode.MatchFirst, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) { return(builder.Switch(caseBuilder => { cases(caseBuilder); return new ValueTask(); }, mode, lineNumber, sourceFile)); }
public Switch() { this.Mode = SwitchMode.Click; this.Brush = Brushes.Black; this.OffBrush = Brushes.Black; this.Width = 28; this.Height = 50; this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.UserPaint, true); this.Value = 0.0; this.Cursor = Cursors.Hand; }
public Switch() { this.Mode = SwitchMode.Click; this.Brush = Brushes.Black; this.OffBrush = Brushes.Black; this.Width = 28; this.Height = 50; this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.UserPaint, true); this.Value = 0.0; this.Cursor = Cursors.Hand; }
public SwitchStatementNode( Token nodeToken, string label, ParseTreeNode expression, ParseTreeNode[] clauses, SwitchMode mode) { this.NodeToken = nodeToken; this._label = label == null ? "" : label; this._expression = expression; this._clauses = clauses; this._mode = mode; }
public ValveGraphStageLogic(Valve <T> valve, TaskCompletionSource <IValveSwitch> completion) : base(valve.Shape) { _valve = valve; _completion = completion; _mode = valve._mode; var flipCallback = GetAsyncCallback <(SwitchMode, TaskCompletionSource <bool>)>(FlipHandler); var getModeCallback = GetAsyncCallback <TaskCompletionSource <SwitchMode> >(t => t.SetResult(_mode)); _switch = new ValveSwitch(flipCallback, getModeCallback); SetHandler(_valve.In, this); SetHandler(_valve.Out, this); }
/// <summary> /// Tuät d Animazion startä. /// </summary> /// /// <param name="mode">Dr Modus i welem d Animazion laift (chunnt uifs Mappind druif ah)</param> /// <param name="render">Ä Funktion wo tuät s Buid uisgäh</param> /// <param name="completed">Wird uisgfiärt wenn fertig</param> public void Start(SwitchMode mode, Action <byte[][]> render, Action completed = null) { IsRunning = true; SwitchMode = mode; _frameIndex = 0; if (AddPlanes) { StartEnhance(render); } else { StartReplace(render, completed); } }
void Start() { //Make sure controllerevents component exists if (GetComponent <VRTK_ControllerEvents>() == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same")); return; } Blackboard.OnGridsizeChanged += DoGridsizeChanged; previewCube = Instantiate(Resources.Load("Cube"), transform.position + new Vector3(0, 0, 3), Quaternion.identity) as GameObject; previewCube.transform.localScale = new Vector3(GridController.GridSize, GridController.GridSize, GridController.GridSize); //previewCube.transform.SetParent(transform); SwitchMode.EnableColorPicker(); }
private void DoButtonTwoPressed(object sender, ControllerInteractionEventArgs e) { _showOptions = !_showOptions; if (_showOptions) { SwitchMode.OptionLock = true; _originalPointerState = GameObject.Find("RightController").GetComponent <VRTK_Pointer>().enabled; GameObject.Find("RightController").GetComponent <VRTK_UIPointer>().enabled = true; SwitchMode.Instance.ReleaseCurrentTool(); _originalPointerOrigin = SwitchMode.IsHeadsetPointer(); if (SwitchMode.IsHeadsetPointer()) { SwitchMode.Instance.TogglePointerOrigin(); } SwitchMode.EnablePointer(); _originalColorpickerState = SwitchMode.IsColorPickerActive(); SwitchMode.DisableColorPicker(); } else { GameObject.Find("RightController").GetComponent <VRTK_UIPointer>().enabled = false; if (!_originalPointerState) { SwitchMode.DisablePointer(); } SwitchMode.Instance.RestoreLastTool(); SwitchMode.OptionLock = false; if (_originalPointerOrigin) { SwitchMode.Instance.TogglePointerOrigin(); } if (_originalColorpickerState) { SwitchMode.EnableColorPicker(); } } transform.GetChild(0).gameObject.SetActive(_showOptions); }
void Start() { SwitchMode.EnablePointer(); _headset = GameObject.Find("Headset"); if (GetComponent <VRTK_ControllerEvents>() == null) { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_ControllerEvents_ListenerExample", "VRTK_ControllerEvents", "the same")); return; } _headset.GetComponent <VRTK_Pointer>().PointerStateValid += DoPointerEnter; _headset.GetComponent <VRTK_Pointer>().PointerStateInvalid += DoPointerExit; GetComponent <VRTK_Pointer>().PointerStateValid += DoPointerEnter; GetComponent <VRTK_Pointer>().PointerStateInvalid += DoPointerExit; }
public Mapping(BinaryReader reader) { Checksum = reader.ReadUInt32BE(); //Logger.Trace(" [{1}] [palette] Read checksum as {0}", Checksum, reader.BaseStream.Position); Mode = (SwitchMode)reader.ReadByte(); //Logger.Trace(" [{1}] [palette] Read mode as {0}", Mode, reader.BaseStream.Position); PaletteIndex = reader.ReadUInt16BE(); //Logger.Trace(" [{1}] [palette] Read index as {0}", PaletteIndex, reader.BaseStream.Position); if (Mode == SwitchMode.Palette) { Duration = reader.ReadUInt32BE(); //Logger.Trace(" [{1}] [palette] Read duration as {0}", Duration, reader.BaseStream.Position); } else { Offset = reader.ReadUInt32BE(); //Logger.Trace(" [{1}] [palette] Read offset as {0}", Offset, reader.BaseStream.Position); } }
public XmlElement GenerateXmlElement(XmlDocument doc) { var node = doc.CreateElement("Viewport"); node.SetAttribute("Index", ScreenIndex.ToString()); node.SetAttribute("Name", Name); if (!IsVisible) { node.SetAttribute("IsVisible", IsVisible.ToString()); } node.SetAttribute("TimeLength", TimeLength.ToString()); node.SetAttribute("SwitchMode", SwitchMode.ToString()); node.SetAttribute("SwitchHotKey", SwitchHotKey.ToString()); if (ElementsCaptionColor != System.Drawing.Color.White) { node.SetAttribute("ElementsCaptionColor", ElementsCaptionColor.ToArgb().ToString()); } if (ElementsCaptionScale != 1) { node.SetAttribute("ElementsCaptionScale", ElementsCaptionScale.ToString()); } foreach (var elm in Elements) { if (elm == null) { continue; } if (elm.Resource != null && elm.Resource.FullFilePath == ResourceInfo_BackgroundImage.DefaultBackgroundImageFile) { continue; } var enode = elm.GenerateXmlElement(doc); node.AppendChild(enode); } var gnode = ElemGroupCollector.GenerateXmlElement(doc); if (gnode != null) { node.AppendChild(gnode); } return(node); }
/// <summary> /// Tuät d Animazion startä. /// </summary> /// /// <param name="mode">Dr Modus i welem d Animazion laift (chunnt uifs Mappind druif ah)</param> /// <param name="render">Ä Funktion wo tuät s Buid uisgäh</param> /// <param name="completed">Wird uisgfiärt wenn fertig</param> public void Start(SwitchMode mode, Action <byte[][]> render, Action completed = null) { IsRunning = true; SwitchMode = mode; _frameIndex = 0; switch (SwitchMode) { case SwitchMode.ColorMask: case SwitchMode.Follow: StartEnhance(render); break; case SwitchMode.Replace: case SwitchMode.FollowReplace: StartReplace(render, completed); break; case SwitchMode.LayeredColorMask: case SwitchMode.MaskedReplace: StartLCM(render); break; } }
private void GenerateSwitch(DfaState dfa, int errorState, SwitchMode mode) { _main.WriteLine("switch(state)"); _main.WriteLine("{"); dfa.ForEachNR((state) => { _main.WriteLine("case State{0}:", state.Index); if (mode == SwitchMode.ActionJump || mode == SwitchMode.ActionOnly) { foreach (var nfa1 in state.AllMarks) { if (nfa1.Mark == Marks.ResetRange) { var name = GetVarname(nfa1.Name, ""); // #1 Do NOT use SetDefaultValue, it clears bytes too -> wrong! // #1 Should to create special method for this // #2 Ok for IndexArray optimimized _main.WriteLine("{0}." + GetSetDefauleValueCall() + ";", name); } if (nfa1.Mark == Marks.ResetRangeIfInvalid) { var name = GetVarname(nfa1.Name, ""); _main.WriteLine("if({0}.End <0) {0}.Begin = int.MinValue;", name); } if (nfa1.Mark == Marks.Custom) { var name = GetVarname(nfa1.Name, ""); _main.WriteLine(nfa1.Value.Replace("Var", name)); } } foreach (var nfa1 in state.AllMarks)//.NfaStates) { if (nfa1.Mark == Marks.Count) _main.WriteLine("{0}++;", GetVarname(nfa1.Name, "Count.")); } foreach (var mark in state.AllMarks) { if (mark.Mark == Marks.ContinueRange) { var ifv = GetCountComparation(RemoveExtraInfo(mark.Name)); if (ifv != "") ifv += " && "; _main.WriteLine("if({1}{0}.End == i-1) {0}.End = i;", GetVarname(mark.Name, ""), ifv); } } foreach (var nfa1 in state.AllMarks)//.NfaStates) { switch (nfa1.Mark) { case Marks.BeginRange: case Marks.EndRange: case Marks.EndRangeIfInvalid: var varName = GetVarname(nfa1.Name, "") + ((nfa1.Mark == Marks.BeginRange) ? ".Begin" : ".End"); var condition = GetCountComparation(RemoveExtraInfo(nfa1.Name)); if (nfa1.Mark != Marks.EndRange) { if (condition != "") condition += " && "; condition = varName + " < 0"; } if (condition != "") _main.Write("if({0})", condition); _main.Write("{0} = i", varName); if (nfa1.Offset != 0) _main.Write("{0} {1}", (nfa1.Offset > 0) ? "+" : "-", Math.Abs(nfa1.Offset)); _main.WriteLine(";"); break; case Marks.BoolEx: _main.WriteLine("boolExPosition = i;"); goto case Marks.Bool; case Marks.Bool: _main.WriteLine("{0} = true;", GetVarname(nfa1.Name, "")); break; case Marks.BoolExNot: _main.WriteLine("if(boolExPosition == i-1) {0} = false;", GetVarname(nfa1.Name, "")); break; case Marks.Final: _main.WriteLine("Final = true;"); break; } } //if (mode == SwitchMode.ActionJump || mode == SwitchMode.ActionOnly) //{ if (state.HasMarks) { foreach (var decimal1 in state.Decimals) _main.WriteLine("{0} = ({0} << 1) * 5 + bytes[i - 1] - 48;", GetVarname(decimal1.Name, "")); foreach (var hex1 in state.Hexes) _main.WriteLine("{0} = ({0} << 4) + AsciiCodeToHex[bytes[i - 1]];", GetVarname(hex1.Name, "")); } //} if (state.Consts.Count > 0) { foreach (var pair in state.ConstNameValues) { var ifv = GetCountComparation(RemoveExtraInfo(pair.Key)); if (ifv != "") _main.Write("if(" + ifv + ") "); _main.WriteLine("{0} = {1}s.{2};", AddCountPrefix(RemoveExtraInfo(pair.Key)), RemoveBrackets(VariableInfo.GetShortName(pair.Key)), pair.Value); } } } if (state.IsFinal) { if (mode == SwitchMode.JumpOnly) { _main.WriteLine("state = table{0}[bytes[i]];", state.Index); _main.WriteLine("break;"); } else { _main.WriteLine("goto exit1;"); } } else { if (mode == SwitchMode.ActionJump || mode == SwitchMode.JumpOnly) _main.WriteLine("state = table{0}[bytes[i]];", state.Index); _main.WriteLine("break;"); } }); // ForEach state _main.WriteLine("case State{0}:", errorState); if (mode == SwitchMode.ActionJump || mode == SwitchMode.ActionOnly) _main.WriteLine("i--;"); _main.WriteLine("Error = true;"); _main.WriteLine("goto exit1;"); _main.WriteLine("}"); }
public static bool Valid(this SwitchMode switchMode) { return(Enum.IsDefined(typeof(SwitchMode), switchMode)); }
public SwitchTrack(Vector position, Direction direction, ConsoleKey key) : base(position, direction) { _key = key; _mode = SwitchMode.Down; }
public override int GetHashCode() { return((Code + SwitchMode.ToString("G")).GetHashCode()); }
public static ISetupActivity <Switch> WithMode(this ISetupActivity <Switch> activity, SwitchMode value) => activity.Set(x => x.Mode, value);
private void OnDestroy() { Destroy(previewCube); SwitchMode.DisableColorPicker(); Blackboard.OnGridsizeChanged -= DoGridsizeChanged; }