Example #1
0
 private void OnButtonCommand_Back(object sender, NumpadCommands cmd)
 {
     if (NewDataText.Length > 0)
     {
         NewDataText = NewDataText.Substring(0, NewDataText.Length - 1);
     }
 }
Example #2
0
 private void OnButtonCommand_Space(object sender, NumpadCommands cmd)
 {
     if (!NewDataText.EndsWith(" "))
     {
         NewDataText += " ";
     }
 }
Example #3
0
 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();
     }
 }
Example #4
0
 public NumpadButton(string text, int x, int y, NumpadCommands cmd, Action <object, NumpadCommands> action)
 {
     Text           = text;
     X              = x;
     Y              = y;
     Command        = cmd;
     ExecuteCommand = action;
 }
Example #5
0
 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");
 }
Example #7
0
 private void OnButtonCommand_Clear(object sender, NumpadCommands cmd)
 {
     NewDataText = String.Empty;
 }