VintageRice

[Visual Studio][Working] - Infinite Panel Loop

Aug 26th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  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.Tasks;
  9. using System.Windows.Forms;
  10. using System.Threading;
  11.  
  12. namespace gameCreation
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         int panelCount;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.        
  23.         private void timer1_Tick(object sender, EventArgs e)
  24.         {
  25.             int trueX = Cursor.Position.X - this.Location.X;
  26.             int trueY = Cursor.Position.Y - this.Location.Y;
  27.  
  28.             foreach(Panel P in this.Controls)
  29.             {
  30.                 if(P != null)
  31.                 {
  32.                     if (trueX < this.Width && trueX > (this.Width - 50) && trueY < 112 && trueY > 12)
  33.                     {
  34.                         ((Panel)P).SetBounds(((Panel)P).Location.X - 3, ((Panel)P).Location.Y, 200, 100);
  35.                     }
  36.                 }
  37.  
  38.                 if (((Panel)P).Location.X <= (0 - ((Panel)P).Width))
  39.                 {
  40.                     ((Panel)P).SetBounds(((Panel)P).Location.X + (panelCount * 200) + (panelCount * 6), ((Panel)P).Location.Y, 200, 100);
  41.                 }
  42.             }
  43.         }
  44.  
  45.         private void Form1_Load(object sender, EventArgs e)
  46.         {
  47.             foreach(Panel P in this.Controls)
  48.             {
  49.                 panelCount++;
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment