// 还原 private void followCogStatusResetDelegateMethod() { // 判断是否达到InvokeRequired if (this.box.InvokeRequired) { // 使用委托 followCogStatusDelegate myDelegate = new followCogStatusDelegate(followCogStatusResetDelegateMethod); //Invoke delegate this.box.Invoke(new Action(() => { this.box.Location = new Point(203, 169); this.box.Size = new Size(91, 91); })); } else { this.box.Location = new Point(203, 169); this.box.Size = new Size(91, 91); } }
// 后 private void followCogStatusPullDelegateMethod() { // 判断是否达到InvokeRequired if (this.cogBarStatus.InvokeRequired) { // 使用委托 followCogStatusDelegate myDelegate = new followCogStatusDelegate(followCogStatusPullDelegateMethod); //Invoke delegate for (int i = 0; i < 10; i++) { int w = this.box.Size.Width; int h = this.box.Size.Height; int x = this.box.Location.X; int y = this.box.Location.Y; if (w > 111) { this.box.Invoke(new Action(() => { this.box.Location = new Point(193, 159); this.box.Size = new Size(111, 111); })); break; } else { this.box.Invoke(new Action(() => { this.box.Location = new Point(x - 1, y - 1); this.box.Size = new Size(w + 2, h + 2); })); Thread.Sleep(100); } } } else { for (int i = 0; i < 10; i++) { int w = this.box.Size.Width; int h = this.box.Size.Height; int x = this.box.Location.X; int y = this.box.Location.Y; if (w > 111) { this.box.Location = new Point(193, 159); this.box.Size = new Size(111, 111); break; } else { this.box.Location = new Point(x - 1, y - 1); this.box.Size = new Size(w + 2, h + 2); Thread.Sleep(100); } } } }
// 空闲 private void freeCogStatusDelegateMethod() { // 判断是否达到InvokeRequired if (this.box.InvokeRequired) { // 使用委托 followCogStatusDelegate myDelegate = new followCogStatusDelegate(freeCogStatusDelegateMethod); //Invoke delegate for (int i = 0; i < 3; i++) { this.box.Invoke(new Action(() => { int x = this.box.Location.X; int y = this.box.Location.Y; this.box.Location = new Point(x, y + 1); })); Thread.Sleep(180); } for (int i = 0; i < 3; i++) { this.box.Invoke(new Action(() => { int x = this.box.Location.X; int y = this.box.Location.Y; this.box.Location = new Point(x, y - 1); })); Thread.Sleep(180); } } else { for (int i = 0; i < 5; i++) { int x = this.box.Location.X; int y = this.box.Location.Y; this.box.Location = new Point(x, y + 1); Thread.Sleep(100); } for (int i = 0; i < 5; i++) { int x = this.box.Location.X; int y = this.box.Location.Y; this.box.Location = new Point(x, y - 1); Thread.Sleep(100); } } }
// 上 private void followCogStatusLiftDelegateMethod() { // 判断是否达到InvokeRequired if (this.cogBarStatus.InvokeRequired) { // 使用委托 followCogStatusDelegate myDelegate = new followCogStatusDelegate(followCogStatusDropDelegateMethod); //Invoke delegate for (int i = 0; i < 10; i++) { int w = this.box.Size.Width; int h = this.box.Size.Height; int x = this.box.Location.X; int y = this.box.Location.Y; if (y < 69) { this.box.Invoke(new Action(() => { this.box.Location = new Point(203, 69); })); break; } else { this.box.Invoke(new Action(() => { this.box.Location = new Point(x, y - 10); })); Thread.Sleep(100); } } } else { for (int i = 0; i < 10; i++) { int w = this.box.Size.Width; int h = this.box.Size.Height; int x = this.box.Location.X; int y = this.box.Location.Y; if (y < 69) { this.box.Location = new Point(203, 69); break; } else { this.box.Location = new Point(x, y - 10); Thread.Sleep(100); } } } }