Form2.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.ComponentModel;
  3. using System.Threading;
  4. using System.Windows.Forms;
  5. namespace UAS_AutoPass
  6. {
  7. public partial class Tip : Form
  8. {
  9. int state;
  10. private DoWorkEventArgs e;
  11. public Tip()
  12. {
  13. InitializeComponent();
  14. }
  15. private void Form2_Load(object sender, EventArgs e)
  16. {
  17. this.ShowInTaskbar = false;
  18. this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
  19. this.Top = this.Height;
  20. state = 0;
  21. label1.Text = DateTime.Now.ToString();
  22. }
  23. public void startthread(string filename,string type)
  24. {
  25. label1.Text = filename;
  26. if(type == "OK")
  27. label1.ForeColor = System.Drawing.Color.Green;
  28. if(type == "NG")
  29. label1.ForeColor = System.Drawing.Color.Red;
  30. //thread.Start();
  31. using (BackgroundWorker bw = new BackgroundWorker())
  32. {
  33. bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
  34. bw.DoWork += new DoWorkEventHandler(bw_DoWork);
  35. bw.RunWorkerAsync("Tank");
  36. }
  37. }
  38. private void bw_DoWork(object sender, DoWorkEventArgs e)
  39. {
  40. }
  41. private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  42. {
  43. aa();
  44. Thread.Sleep(2000);
  45. bb();
  46. }
  47. public void aa()
  48. {
  49. if (state == 0)
  50. {
  51. state = 1;
  52. int t = this.Left;
  53. for (int i = t; i >= Screen.PrimaryScreen.WorkingArea.Width - this.Width; i--)
  54. {
  55. this.Left = i;
  56. Application.DoEvents();
  57. }
  58. state = 0;
  59. }
  60. }
  61. public void bb()
  62. {
  63. if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
  64. {
  65. state = 1;
  66. int t = this.Left;
  67. for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i++)
  68. {
  69. this.Left = i;
  70. Application.DoEvents();
  71. }
  72. state = 0;
  73. }
  74. }
  75. private void Form2_MouseEnter(object sender, EventArgs e)
  76. {
  77. if (state == 0)
  78. {
  79. state = 1;
  80. int t = this.Left;
  81. for (int i = t; i >= Screen.PrimaryScreen.WorkingArea.Width - this.Width; i=i-2)
  82. {
  83. this.Left = i;
  84. Application.DoEvents();
  85. }
  86. state = 0;
  87. }
  88. }
  89. private void Form2_MouseLeave(object sender, EventArgs e)
  90. {
  91. if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
  92. {
  93. state = 1;
  94. int t = this.Left;
  95. for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i=i+2)
  96. {
  97. this.Left = i;
  98. Application.DoEvents();
  99. }
  100. state = 0;
  101. }
  102. }
  103. }
  104. }