TextBoxEx3.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using MECF.Framework.UI.Client.CenterViews.Dialogs;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Input;
  10. using TextBox2 = OpenSEMI.Ctrlib.Controls.TextBoxEx;
  11. namespace MECF.Framework.UI.Client.Themes.lightgreen
  12. {
  13. public partial class TextBoxEx3 : ResourceDictionary
  14. {
  15. public void OnClick(object sender, MouseButtonEventArgs e)
  16. {
  17. if (sender is TextBox2)
  18. {
  19. TextBox2 textBox = sender as TextBox2;
  20. string strRet = Show(sender, textBox.Text);
  21. if (string.IsNullOrEmpty(strRet)) return;
  22. textBox.Text = strRet;
  23. }
  24. else if (sender is PasswordBox)
  25. {
  26. PasswordBox passwordBox = sender as PasswordBox;
  27. string strRet = Show(sender, passwordBox.Password);
  28. if (string.IsNullOrEmpty(strRet)) return;
  29. passwordBox.Password = strRet;
  30. }
  31. }
  32. private string Show(object sender, string strDefaultValue)
  33. {
  34. TextBox2 control = sender as TextBox2;
  35. string strRet = string.Empty;
  36. //if (control.Tag != null && control.Tag.ToString().Equals("Number"))
  37. //{
  38. // var point = control.PointFromScreen(new Point(0, 0));
  39. // double x = SystemParameters.WorkArea.Width;
  40. // double y = SystemParameters.WorkArea.Height;
  41. // NumberKeyborardNoMinus numberKeyboard = new NumberKeyborardNoMinus("", strDefaultValue,true,control.MaxValue,control.MinValue);
  42. // if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < y)
  43. // {
  44. // numberKeyboard.Top = -point.Y + control.ActualHeight + 5;
  45. // }
  46. // else
  47. // {
  48. // numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;
  49. // }
  50. // if (-point.X + numberKeyboard.Width < x)
  51. // {
  52. // numberKeyboard.Left = -point.X;
  53. // }
  54. // else
  55. // {
  56. // numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);
  57. // }
  58. // if ((bool)numberKeyboard.ShowDialog()) strRet = numberKeyboard.ValueString;
  59. //}
  60. if (control.Tag != null && control.Tag.ToString().Contains("Number"))
  61. {
  62. NumberKeyboard numberKeyboard = new NumberKeyboard("", strDefaultValue);
  63. var point = control.PointFromScreen(new Point(0, 0));
  64. double x = SystemParameters.WorkArea.Width;
  65. double y = SystemParameters.WorkArea.Height;
  66. if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < y)
  67. {
  68. numberKeyboard.Top = -point.Y + control.ActualHeight + 5;
  69. }
  70. else
  71. {
  72. numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;
  73. }
  74. if (-point.X + numberKeyboard.Width < x)
  75. {
  76. numberKeyboard.Left = -point.X;
  77. }
  78. else
  79. {
  80. numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);
  81. }
  82. if ((bool)numberKeyboard.ShowDialog()) strRet = numberKeyboard.ValueString;
  83. }
  84. else if (control.Tag != null && control.Tag.ToString().Contains("None"))
  85. {
  86. return string.Empty;
  87. }
  88. else
  89. {
  90. FullKeyboard fullKeyboard = new FullKeyboard("", strDefaultValue);
  91. var point = control.PointFromScreen(new Point(0, 0));
  92. double x = SystemParameters.WorkArea.Width;
  93. double y = SystemParameters.WorkArea.Height;
  94. if (-point.Y + control.ActualHeight + 5 + fullKeyboard.Height < y)
  95. {
  96. fullKeyboard.Top = -point.Y + control.ActualHeight + 5;
  97. }
  98. else
  99. {
  100. fullKeyboard.Top = -point.Y - fullKeyboard.Height - 5;
  101. }
  102. if (-point.X + fullKeyboard.Width < x)
  103. {
  104. fullKeyboard.Left = -point.X;
  105. }
  106. else
  107. {
  108. fullKeyboard.Left = -point.X - (fullKeyboard.Width - control.ActualWidth);
  109. }
  110. if ((bool)fullKeyboard.ShowDialog()) strRet = fullKeyboard.ValueString;
  111. }
  112. return strRet;
  113. }
  114. }
  115. }