123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Threading;
- using System.Windows.Forms;
- namespace UAS_AutoPass
- {
- public partial class Tip : Form
- {
- int state;
- public Tip()
- {
- InitializeComponent();
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- this.ShowInTaskbar = false;
- this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width;
- this.Top = this.Height;
- state = 0;
- label1.Text = DateTime.Now.ToString();
- }
- public void startthread(string filename,string type)
- {
- label1.Text = filename;
- if(type == "OK")
- label1.ForeColor = System.Drawing.Color.Green;
- if(type == "NG")
- label1.ForeColor = System.Drawing.Color.Red;
-
- //thread.Start();
- using (BackgroundWorker bw = new BackgroundWorker())
- {
- bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
- bw.DoWork += new DoWorkEventHandler(bw_DoWork);
- bw.RunWorkerAsync("Tank");
- }
- }
- private void bw_DoWork(object sender, DoWorkEventArgs e)
- {
- }
- private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- if (checkBox1.Checked)
- {
- aa();
- Thread.Sleep(2000);
- bb();
- }
- }
- public void aa()
- {
- if (state == 0)
- {
- state = 1;
- int t = this.Left;
- for (int i = t; i >= Screen.PrimaryScreen.WorkingArea.Width - this.Width; i--)
- {
- this.Left = i;
- Application.DoEvents();
- }
- state = 0;
- }
- }
- public void bb()
- {
- if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
- {
- state = 1;
- int t = this.Left;
- for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i++)
- {
- this.Left = i;
- Application.DoEvents();
- }
- state = 0;
- }
- }
- private void Form2_MouseEnter(object sender, EventArgs e)
- {
- if (state == 0)
- {
- state = 1;
- int t = this.Left;
- for (int i = t; i >= Screen.PrimaryScreen.WorkingArea.Width - this.Width; i=i-2)
- {
- this.Left = i;
- Application.DoEvents();
- }
- state = 0;
- }
- }
- private void Form2_MouseLeave(object sender, EventArgs e)
- {
- if (checkBox1.Checked)
- {
- Panel p = sender as Panel;
- //如果Mouse Leave,则清除背景图,否则不处理
- Point mousePoint = p.PointToClient(Control.MousePosition);
- if (!p.ClientRectangle.Contains(mousePoint))
- {
- if (this.Left <= Screen.PrimaryScreen.WorkingArea.Width - 10 && state == 0)
- {
- state = 1;
- int t = this.Left;
- for (int i = t; i < Screen.PrimaryScreen.WorkingArea.Width - 10; i = i + 2)
- {
- this.Left = i;
- Application.DoEvents();
- }
- state = 0;
- }
- }
- }
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- }
- private void checkBox1_CheckedChanged(object sender, EventArgs e)
- {
- if (!checkBox1.Checked)
- aa();
- }
- }
- }
|