版博士V2.0程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

NewStepShow.cs 10 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. using CCWin.SkinControl;
  2. using MaiMuAOI.Properties;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace MaiMuAOI.SysUI.ProcessStep.Ctrl
  14. {
  15. public partial class NewStepShow : UserControl
  16. {
  17. public NewStepShow()
  18. {
  19. InitializeComponent();
  20. RoundRadius = 10;
  21. StepName = "步骤名称";
  22. stepIndex = 0;
  23. stepData = 0.000;
  24. stepMax = 0.000;
  25. stepMin = 0.000;
  26. stepString = "";
  27. stepStatus = StepStsEnum.Error;
  28. tlimit = "";
  29. }
  30. #region Properties
  31. private int roundRadius;
  32. [Description("圆角半径(0为不要圆角)")]
  33. [Category("自定义外观")]
  34. public int RoundRadius
  35. {
  36. get { return roundRadius; }
  37. set
  38. {
  39. if (value < 0)
  40. {
  41. roundRadius = 0;
  42. }
  43. else
  44. {
  45. roundRadius = value;
  46. }
  47. base.Refresh();
  48. }
  49. }
  50. private string stepName;
  51. [Description("步骤名称")]
  52. [Category("自定义外观")]
  53. public string StepName
  54. {
  55. get { return stepName; }
  56. set
  57. {
  58. stepName = value;
  59. this.NameLabel.Text = stepName;
  60. base.Refresh();
  61. }
  62. }
  63. private int stepIndex;
  64. [Description("步骤序号")]
  65. [Category("自定义外观")]
  66. public int StepIndex
  67. {
  68. get { return stepIndex; }
  69. set
  70. {
  71. stepIndex = value;
  72. this.IndexLabel.Text = stepIndex.ToString();
  73. base.Refresh();
  74. }
  75. }
  76. private double stepData;
  77. [Description("步骤数据")]
  78. [Category("自定义外观")]
  79. public double StepData
  80. {
  81. get { return stepData; }
  82. set
  83. {
  84. stepData = value;
  85. this.RelData.Text = stepData.ToString("0.000");
  86. base.Refresh();
  87. }
  88. }
  89. private double stepMax;
  90. [Description("步骤数据Max")]
  91. [Category("自定义外观")]
  92. public double StepMax
  93. {
  94. get { return stepMax; }
  95. set
  96. {
  97. stepMax = value;
  98. this.MaxValue.Text = stepMax.ToString("0.000");
  99. base.Refresh();
  100. }
  101. }
  102. private double stepMin;
  103. [Description("步骤数据Min")]
  104. [Category("自定义外观")]
  105. public double StepMin
  106. {
  107. get { return stepMin; }
  108. set
  109. {
  110. stepMin = value;
  111. this.MinValue.Text = stepMin.ToString("0.000");
  112. base.Refresh();
  113. }
  114. }
  115. private string tlimit;
  116. [Description("步骤数据limit")]
  117. [Category("自定义外观")]
  118. public string TLimit
  119. {
  120. get { return tlimit; }
  121. set
  122. {
  123. tlimit = value;
  124. this.Limit.Text = tlimit;
  125. base.Refresh();
  126. }
  127. }
  128. private string stepString;
  129. [Description("数据详细")]
  130. [Category("自定义外观")]
  131. public string StepString
  132. {
  133. get { return stepString; }
  134. set
  135. {
  136. stepString = value;
  137. //this.AllDataTextBox.Text = stepString;
  138. this.AllDataTextBox.AppendText(stepString + "\r\n");
  139. //this.AllDataTextBox.AppendText(stepString);
  140. base.Refresh();
  141. }
  142. }
  143. public void ClearText()
  144. {
  145. this.AllDataTextBox.Clear();
  146. }
  147. private bool enabel;
  148. public bool Enabel
  149. {
  150. get { return enabel; }
  151. set
  152. {
  153. enabel = value;
  154. if (enabel)
  155. this.pictureBox1.Image = Resources.使用中;
  156. else
  157. this.pictureBox1.Image = Resources.停用_底;
  158. base.Refresh();
  159. }
  160. }
  161. private bool showenabel = true;
  162. public bool ShowEnabel
  163. {
  164. get { return showenabel; }
  165. set
  166. {
  167. showenabel = value;
  168. this.pictureBox1.Visible = showenabel;
  169. base.Refresh();
  170. }
  171. }
  172. public Action<int, bool> EnabelChangeEvent;
  173. public enum StepStsEnum
  174. {
  175. Skip,
  176. Wait,
  177. Testing,
  178. OK,
  179. NG,
  180. Error
  181. }
  182. private StepStsEnum stepStatus;
  183. [Description("步骤状态")]
  184. [Category("自定义外观")]
  185. public StepStsEnum StepStatus
  186. {
  187. get { return stepStatus; }
  188. set
  189. {
  190. stepStatus = value;
  191. switch(stepStatus)
  192. {
  193. case StepStsEnum.Wait:
  194. this.StsLabel.Text = "等待";
  195. this.StsLabel.ForeColor = Color.Black;
  196. break;
  197. case StepStsEnum.Testing:
  198. this.StsLabel.Text = "测试中...";
  199. this.StsLabel.ForeColor = SystemColors.MenuHighlight;
  200. break;
  201. case StepStsEnum.OK:
  202. this.StsLabel.Text = "OK";
  203. this.StsLabel.ForeColor = Color.LimeGreen;
  204. break;
  205. case StepStsEnum.NG:
  206. this.StsLabel.Text = "NG";
  207. this.StsLabel.ForeColor = Color.Red;
  208. break;
  209. case StepStsEnum.Error:
  210. this.StsLabel.Text = "错误";
  211. this.StsLabel.ForeColor = Color.DarkRed;
  212. break;
  213. case StepStsEnum.Skip:
  214. this.StsLabel.Text = "未启用";
  215. this.StsLabel.ForeColor = Color.Black;
  216. break;
  217. }
  218. base.Refresh();
  219. }
  220. }
  221. private ArrayList getIndexArray(String inputStr, String findStr)//找出对应目下标
  222. {
  223. ArrayList list = new ArrayList();
  224. int start = 0;
  225. while (start < inputStr.Length)
  226. {
  227. int index = inputStr.IndexOf(findStr, start);
  228. if (index >= 0)
  229. {
  230. list.Add(index);
  231. start = index + findStr.Length;
  232. }
  233. else
  234. {
  235. break;
  236. }
  237. }
  238. return list;
  239. }
  240. public void SetRedString(string redString)
  241. {
  242. //this.AllDataTextBox.SelectedText = redString;//选择当前行数追加内容
  243. string strt = redString;
  244. ArrayList list = getIndexArray(this.AllDataTextBox.Text, strt);
  245. for (int i = 0; i < list.Count; i++)
  246. {
  247. int index = (int)list[i];
  248. AllDataTextBox.Select(index, strt.Length);//设置当前文本对象
  249. AllDataTextBox.SelectionColor = Color.Red;//设置文本对象颜色
  250. base.Refresh();
  251. }
  252. }
  253. #endregion
  254. #region Override Methods
  255. /// <summary>
  256. /// 在控件尺寸变化时刷新
  257. /// </summary>
  258. /// <param name="e"></param>
  259. protected override void OnResize(EventArgs e)
  260. {
  261. base.OnResize(e);
  262. base.Refresh();
  263. }
  264. /// <summary>
  265. /// 将控件边框修改成圆角
  266. /// </summary>
  267. /// <param name="e"></param>
  268. protected override void OnPaint(PaintEventArgs e)
  269. {
  270. base.OnPaint(e);
  271. Round(this.Region, RoundRadius);
  272. }
  273. #endregion
  274. #region UI Methods
  275. /// <summary>
  276. /// 绘制控件的圆角
  277. /// </summary>
  278. /// <param name="region"></param>
  279. /// <param name="radius"></param>
  280. public void Round(System.Drawing.Region region, int radius)
  281. {
  282. System.Drawing.Drawing2D.GraphicsPath oPath = new System.Drawing.Drawing2D.GraphicsPath();
  283. int x = 0;
  284. int y = 0;
  285. int thisWidth = this.Width;
  286. int thisHeight = this.Height;
  287. int angle = radius;
  288. // 半径非0为圆角矩形
  289. if (angle > 0)
  290. {
  291. System.Drawing.Graphics g = CreateGraphics();
  292. oPath.AddArc(x, y, angle, angle, 180, 90); // 左上角
  293. oPath.AddArc(thisWidth - angle, y, angle, angle, 270, 90); // 右上角
  294. oPath.AddArc(thisWidth - angle, thisHeight - angle, angle, angle, 0, 90); // 右下角
  295. oPath.AddArc(x, thisHeight - angle, angle, angle, 90, 90); // 左下角
  296. oPath.CloseAllFigures();
  297. Region = new System.Drawing.Region(oPath);
  298. }
  299. //半径为0时为矩形
  300. else
  301. {
  302. angle = 0;
  303. oPath.AddLine(x + angle, y, thisWidth - angle, y); // 顶端
  304. oPath.AddLine(thisWidth, y + angle, thisWidth, thisHeight - angle); // 右边
  305. oPath.AddLine(thisWidth - angle, thisHeight, x + angle, thisHeight); // 底边
  306. oPath.AddLine(x, y + angle, x, thisHeight - angle); // 左边
  307. oPath.CloseAllFigures();
  308. Region = new System.Drawing.Region(oPath);
  309. }
  310. }
  311. #endregion
  312. private void pictureBox1_Click(object sender, EventArgs e)
  313. {
  314. this.Enabel = !enabel;
  315. EnabelChangeEvent?.Invoke(stepIndex - 1, enabel);
  316. }
  317. }
  318. }