private void OnButtonCommand_Back(object sender, NumpadCommands cmd) { if (NewDataText.Length > 0) { NewDataText = NewDataText.Substring(0, NewDataText.Length - 1); } }
private void OnButtonCommand_Space(object sender, NumpadCommands cmd) { if (!NewDataText.EndsWith(" ")) { NewDataText += " "; } }
private void OnButtonCommand_Digit(object sender, NumpadCommands cmd) { if (cmd == NumpadCommands.KeyDot) { var data = NewDataText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var last = data.LastOrDefault() ?? string.Empty; if (data.Count() <= 2) { if (!last.Contains('.')) { NewDataText += "."; } } else { if (!last.Contains("..")) { if (last.LastOrDefault() == '.' || !last.Contains(".")) { NewDataText += "."; } } } } else { NewDataText += ((int)cmd).ToString(); } }
public NumpadButton(string text, int x, int y, NumpadCommands cmd, Action <object, NumpadCommands> action) { Text = text; X = x; Y = y; Command = cmd; ExecuteCommand = action; }
private void OnButtonCommand_Enter(object sender, NumpadCommands cmd) { if (NewDataTextEntered != null && NewDataTextEntered(NewDataText)) { NewDataText = string.Empty; } ; }
public void Add(string text, int x, int y, NumpadCommands cmd, Action <object, NumpadCommands> action) { if (x >= 0 && x < X && y >= 0 && y < Y) { if (!_buttons.Where(z => z.X == x && z.Y == y).Any()) { _buttons.Add(new NumpadButton(text, x, y, cmd, action)); return; } } throw new Exception("Duplicate key defintion for numpad"); }
private void OnButtonCommand_Clear(object sender, NumpadCommands cmd) { NewDataText = String.Empty; }