|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.CustomResource.UserControls
- {
- /// <summary>
- /// UserKeyBoard.xaml 的交互逻辑
- /// </summary>
- public partial class UserKeyBoard : UserControl
- {
- public Action<object> MyKeyDown;
-
- public UserKeyBoard()
- {
- InitializeComponent();
- }
-
- //通过判断按钮的content属性来做对应处理
- private void ButtonGrid_Click(object sender, RoutedEventArgs e)
- {
- Button clickedButton = (Button)e.OriginalSource; //获取click事件触发源,即按了的按钮
- switch((String)clickedButton.Content)
- {
- case "DEL":
- MyKeyDown(EKeyitem.DEL);
- break;
- case "AC":
- MyKeyDown(EKeyitem.AC);
- break;
- case "确认":
- MyKeyDown(EKeyitem.OK);
- break;
- case "A/a":
- UIElementCollection grd = ButtonGrid.Children;
- int count = grd.Count;
- for (int i = 0; i < count; i++)
- {
- Button buttonTemp = grd[i] as Button;
- String contentTemp = buttonTemp.Content as String;
- if (contentTemp == "AC" || contentTemp == "A/a" || contentTemp == "确认" || contentTemp == "DEL")
- continue;
- buttonTemp.Content = contentTemp[0] > 90 ? contentTemp.ToUpper() : contentTemp.ToLower();
- }
- break;
- default:
- MyKeyDown((String)clickedButton.Content);
- break;
- }
- }
-
-
- public enum EKeyitem
- {
- DEL,
- AC,
- Shift,
- OK,
- A
-
- }
- }
- }
|