private void notifyPadEvent(int playerIndex, PadEvent.PadButtonCommand padCode, IvyEvent.PadButtonAction state) { bool newState; if (state == IvyEvent.PadButtonAction.DOWN_STATE) { newState = true; } else if (state == IvyEvent.PadButtonAction.UP_STATE) { newState = false; } else { newState = isDownForPlayer[playerIndex][(int)padCode]; } isDownForPlayer[playerIndex][(int)padCode] = newState; PadEvent pe = new PadEvent(playerIndex, padCode, state); Thread t = new Thread(new ThreadStart(delegate() { onPadEvent(pe); })); t.Start(); //TODO : lancer le thread qui va appeler la fonction event }
private void Button_Click(object sender, RoutedEventArgs e) { var but = sender as Button; switch (but.Name) { case "NEXT": case "PREV": if (DataItem != null) { StrVal = Value; } PadEvent?.Invoke(this, new PadEventArgs { Name = but.Name, DataItem = DataItem });; break; case "BKSP": if (Value.Length > 0) { var len = Value.Length; if (len == 2 && Value[0] == '-') { Value = Value.Substring(0, len - 2); } else { Value = Value.Substring(0, len - 1); } } break; case "CLR": Value = string.Empty; break; case "RST": Value = StrVal; break; case "PM": if (Value.Length > 0) { if (Value[0] == '-') { Value = Value.Substring(1); } else { Value = $"-{Value}"; } } break; case "DOT": if (!Value.Contains('.') && Value != "" && char.IsDigit(Value.Last())) { Value = Value + '.'; } break; case "FEET": if (!Value.Contains("'") && DataItem.IsPosition && int.TryParse(Value, out _)) { Value = Value + "'"; } break; default: if (but.Name.StartsWith("NUM")) { if (isNew && ValueTextBox.SelectionLength > 0) { Value = (string)but.Content; } else { Value += but.Content; } } break; } if (but.Name != "NEXT" && but.Name != "PREV") { isNew = false; } }
public abstract bool onPadEvent(PadEvent pe);