终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

75 rindas
2.2 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace BPASmartClient.CustomResource.UserControls
  16. {
  17. /// <summary>
  18. /// UserKeyBoard.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class UserKeyBoard : UserControl
  21. {
  22. public Action<object> MyKeyDown;
  23. public UserKeyBoard()
  24. {
  25. InitializeComponent();
  26. }
  27. //通过判断按钮的content属性来做对应处理
  28. private void ButtonGrid_Click(object sender, RoutedEventArgs e)
  29. {
  30. Button clickedButton = (Button)e.OriginalSource; //获取click事件触发源,即按了的按钮
  31. switch((String)clickedButton.Content)
  32. {
  33. case "DEL":
  34. MyKeyDown(EKeyitem.DEL);
  35. break;
  36. case "AC":
  37. MyKeyDown(EKeyitem.AC);
  38. break;
  39. case "确认":
  40. MyKeyDown(EKeyitem.OK);
  41. break;
  42. case "A/a":
  43. UIElementCollection grd = ButtonGrid.Children;
  44. int count = grd.Count;
  45. for (int i = 0; i < count; i++)
  46. {
  47. Button buttonTemp = grd[i] as Button;
  48. String contentTemp = buttonTemp.Content as String;
  49. if (contentTemp == "AC" || contentTemp == "A/a" || contentTemp == "确认" || contentTemp == "DEL")
  50. continue;
  51. buttonTemp.Content = contentTemp[0] > 90 ? contentTemp.ToUpper() : contentTemp.ToLower();
  52. }
  53. break;
  54. default:
  55. MyKeyDown((String)clickedButton.Content);
  56. break;
  57. }
  58. }
  59. public enum EKeyitem
  60. {
  61. DEL,
  62. AC,
  63. Shift,
  64. OK,
  65. A
  66. }
  67. }
  68. }