/// <summary>Verifica se o botão estava pressionada e foi liberada.</summary> /// <param name="key">A tecla a ser verificada.</param> public bool IsReleased(Buttons button) { bool result = false; if (State.IsConnected) { if (OldState.IsButtonDown(button) && State.IsButtonUp(button)) { result = true; } } else if (KeyboardMap != null) { var k = KeyboardMap[button]; if (k != null) { if (lastKeyboardState.IsKeyDown(k.Value) && keyboardState.IsKeyUp(k.Value)) { result = true; } } } return(result); }
public List <IState> GeneratePossibleStates(IVertex dst) { var result = new List <IState>(); var unknownEdges = dst.Connectors.OfType <MaybeBlockedEdge>().ToList(); var length = Math.Pow(2, unknownEdges.Count); for (var i = 0; i < length; i++) { var possibleState = OldState.Clone(); possibleState.Source = this; var blockedEdges = Convert.ToString(i, 2).PadLeft(unknownEdges.Count, '0').Select(c => c != '0').ToArray(); var stateProbability = 1.0; for (var j = 0; j < unknownEdges.Count; j++) { if (blockedEdges[j]) { stateProbability *= unknownEdges[j].BlockageProbability; possibleState.Graph.Block(unknownEdges[j]); } else { stateProbability *= 1 - unknownEdges[j].BlockageProbability; possibleState.Graph.Free(unknownEdges[j]); } } possibleState.Probability = stateProbability; result.Add(possibleState); } result.ForEach(r => UpdateState(r, dst)); return(result); }
internal void LoadParameters(bool loadFromFile, string visualElementsManifestPath, string mediumImageResizeMetadataPath, string smallImageResizeMetadataPath, string targetFolderPath) { if (loadFromFile) { var xmlDoc = XDocument.Load(visualElementsManifestPath); try { ShortcutItemImage mediumImage = null; ShortcutItemImage smallImage = null; if (File.Exists(mediumImageResizeMetadataPath)) { mediumImage = ShortcutItemImage.Load(mediumImageResizeMetadataPath); } if (File.Exists(smallImageResizeMetadataPath)) { smallImage = ShortcutItemImage.Load(smallImageResizeMetadataPath); } var parameters = from b in xmlDoc.Descendants("VisualElements") select new ShortcutItemState { BackgroundColor = b.Attribute("BackgroundColor")?.Value, ForegroundText = b.Attribute("ForegroundText")?.Value, ShowNameOnSquare150X150Logo = b.Attribute("ShowNameOnSquare150x150Logo")?.Value == "on", MediumImage = mediumImage ?? new ShortcutItemImage(ShortcutConstantsAndEnums.MediumShortcutOutputSize) { Bytes = ImageUtils.LoadFileToByteArray(targetFolderPath + b.Attribute("Square150x150Logo")?.Value), X = 0, Y = 0 }, SmallImage = smallImage ?? new ShortcutItemImage(ShortcutConstantsAndEnums.SmallShortcutOutputSize) { Bytes = ImageUtils.LoadFileToByteArray(targetFolderPath + b.Attribute("Square70x70Logo")?.Value), X = 0, Y = 0 } }; OldState = parameters.Single(); CurrentState = OldState.Clone(); } catch { ResetParameters(); } } else { ResetParameters(); } }
public override int GetHashCode() { return(InputChar.GetHashCode() ^ StackHead.GetHashCode() ^ StackReplace.GetHashCode() ^ NewState.GetHashCode() ^ OldState.GetHashCode()); }
public bool OldKeyUpEvent(object key) { if (!OldState.ContainsKey((SDL2.SDL.SDL_Keycode)key)) { return(true); } return(!OldState[(SDL2.SDL.SDL_Keycode)key]); }
public bool OldButtonUpEvent(object key) { if (!OldState.ContainsKey((uint)key)) { return(true); } return(!OldState[(uint)key]); }
public bool OldKeyDownEvent(object key) { if (!OldState.ContainsKey((SDL2.SDL.SDL_Keycode)key)) { return(false); } return(OldState[(SDL2.SDL.SDL_Keycode)key]); }
public bool OldButtonDownEvent(object key) { if (!OldState.ContainsKey((uint)key)) { return(false); } return(OldState[(uint)key]); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is OrderFulfillmentUpdatedUpdate other && ((FulfillmentUid == null && other.FulfillmentUid == null) || (FulfillmentUid?.Equals(other.FulfillmentUid) == true)) && ((OldState == null && other.OldState == null) || (OldState?.Equals(other.OldState) == true)) && ((NewState == null && other.NewState == null) || (NewState?.Equals(other.NewState) == true))); }
public override void Update() { GamePadState state = listener.State.CurrentState; OldState = CurrentState; CurrentState = new List <Buttons>(); foreach (var rawBind in listener.RawBinds) { Buttons btn = (Buttons)rawBind; if (state.IsButtonDown(btn)) { CurrentState.Add(btn); } } ReleasedMappings = ResolveMaps(OldState.Except(CurrentState)); // released PressedMappings = ResolveMaps(CurrentState.Except(OldState)); // pressed DownMappings = ResolveMaps(OldState.Intersect(CurrentState)); // down }
public override int GetHashCode() { int hashCode = 1020384167; if (FulfillmentUid != null) { hashCode += FulfillmentUid.GetHashCode(); } if (OldState != null) { hashCode += OldState.GetHashCode(); } if (NewState != null) { hashCode += NewState.GetHashCode(); } return(hashCode); }
public UiState(MemoryPosition?memoryPosition = null) { this.memoryPosition = null; if (memoryPosition != null && memoryPosition?.knownValues != null) { this.memoryPosition = memoryPosition?.knownValues.Where(entry => { return(entry.offset != null && Array.IndexOf(SUPPORTED_ENCODINGS, entry.type) != -1); }).ToArray(); } oldState = new OldState { videoRam = new byte[16][], dmdShadedBuffer = new byte[] { }, lampState = new byte[] { }, solenoidState = new byte[] { }, inputState = new byte[] { } }; videoRam = new byte[16][]; }
public string LogString() { return($"({Update.ToString()}): [{OldState.LogString()}] -> [{NewState.LogString()}]"); }
protected void ToString(List <string> toStringOutput) { toStringOutput.Add($"FulfillmentUid = {(FulfillmentUid == null ? "null" : FulfillmentUid == string.Empty ? "" : FulfillmentUid)}"); toStringOutput.Add($"OldState = {(OldState == null ? "null" : OldState.ToString())}"); toStringOutput.Add($"NewState = {(NewState == null ? "null" : NewState.ToString())}"); }
/// <summary> /// Tarkistaa painetaanko näppäintä /// </summary> /// <param name="button">Näppäin.</param> /// <returns>True jos painetaan</returns> public bool IsButtonDown(Buttons button) { return(CurrentState.IsButtonDown(button) && OldState.IsButtonDown(button)); }
public void Add(OperationInvoker doChange, OperationInvoker undoChange) { OldState.Add(undoChange); NewState.Add(doChange); }
public string LogString() { return(string.Format("({0}): [{1}] -> [{2}]", Update.ToString(), OldState.LogString(), NewState.LogString())); }
public void UndoChanges() { CurrentState = OldState.Clone(); }