Form2.cs 3.2 KB

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