InternalTestProcedure.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. namespace AwInitilizer.Procedure.InternalTestProcedure
  9. {
  10. internal class InternalTestProcedure : ProcedureBase
  11. {
  12. private HintDialog hintDialog;
  13. internal override async Task<bool> Run()
  14. {
  15. string btn, btnLang, imgUrl;
  16. for (int btnInt = 0; btnInt < 4; btnInt++)
  17. {
  18. (btn, btnLang, imgUrl) = GetBtnParam(btnInt);
  19. if (btnInt == 3)
  20. {
  21. ShowEmergencyBtnPressRequestDialog(imgUrl);
  22. }
  23. else
  24. {
  25. ShowBtnPressRequestDialog(btnLang, imgUrl);
  26. }
  27. await Task.Delay(5_000);
  28. hintDialog?.Close();
  29. }
  30. return true;
  31. }
  32. private void ShowEmergencyBtnPressRequestDialog(string imgUrl)
  33. {
  34. ShowDialog(
  35. string.Format(Resx.AppResources.EmergencyBtnPressPressHint),
  36. Resx.AppResources.BtnPressHintTitle,
  37. "", imgUrl, cancelAble: false);
  38. }
  39. private void ShowBtnPressRequestDialog(string btnLang, string imgUrl)
  40. {
  41. ShowDialog(
  42. string.Format(Resx.AppResources.BtnPressPressHint, btnLang),
  43. Resx.AppResources.BtnPressHintTitle,
  44. "", imgUrl, cancelAble: false);
  45. }
  46. private void ShowDialog(string msg, string title, string btnText, string imgUrl, bool cancelAble)
  47. {
  48. hintDialog = new HintDialog();
  49. hintDialog.Owner = Application.Current.MainWindow;
  50. hintDialog.Message = msg;
  51. hintDialog.Title = title;
  52. hintDialog.IsCancelAble = cancelAble;
  53. hintDialog.BtnText = btnText;
  54. hintDialog.ImgPath = imgUrl;
  55. if (cancelAble)
  56. {
  57. hintDialog.ShowDialog();
  58. }
  59. else
  60. {
  61. hintDialog.Show();
  62. }
  63. }
  64. private (string btn, string btnLang, string imgUrl) GetBtnParam(int btnInt)
  65. {
  66. string btn, btnLang, imgUrl;
  67. switch (btnInt)
  68. {
  69. case 0:
  70. btn = "Blue Button";
  71. btnLang = Resx.AppResources.BtnPressBlueBtn;
  72. imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Blue.png";
  73. break;
  74. case 1:
  75. btn = "Green Button";
  76. btnLang = Resx.AppResources.BtnPressGreenBtn;
  77. imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Green.png";
  78. break;
  79. case 2:
  80. btn = "Third Button";
  81. btnLang = Resx.AppResources.BtnPressThirdBtn;
  82. imgUrl = "";
  83. break;
  84. case 3:
  85. btn = "EmergencyButton";
  86. btnLang = Resx.AppResources.BtnPressEmergencyBtn;
  87. imgUrl = "pack://application:,,,/AwInitilizer;component/Image/Emergency.png";
  88. break;
  89. default:
  90. btn = "";
  91. btnLang = "";
  92. imgUrl = null;
  93. break;
  94. };
  95. return (btn, btnLang, imgUrl);
  96. }
  97. }
  98. }