private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = this.CreateGraphics(); Obj1.Paint(g); Obj2.Paint(g); }
private void MouseCtrl(object sender, System.Windows.Forms.MouseEventArgs e) { //while (ClientRectangle.Contains(PointToClient(MousePosition))) mouse_x = Control.MousePosition.X - this.Location.X - 8; mouse_y = Control.MousePosition.Y - this.Location.Y - 30; Graphics g = this.CreateGraphics(); int wheel = e.Delta; Task task1 = Task.Run(() => { Obj1.DataCheck(Obj1.isInsideSmth(mouse_x, mouse_y), wheel); Obj2.DataCheck(Obj2.isInsideSmth(mouse_x, mouse_y), wheel); }); Task task2 = Task.Run(() => { Obj1.Paint_MouseHover(Obj1.isInsideSmth(mouse_x, mouse_y), g, k); Obj2.Paint_MouseHover(Obj2.isInsideSmth(mouse_x, mouse_y), g, k); Obj1.Paint(g); Obj2.Paint(g); }); task1.Wait(); task2.Wait(); Thread.Sleep(55); k = 0; }