godzcheater

4 Adam

Dec 26th, 2011
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.36 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.Windows.Forms;
  9.  
  10. namespace Adam
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public List<Game> Games = new List<Game>();
  15.         public System.Int32 MaxPerLine = 3;//this is the amount of pic box's you want on each line.
  16.  
  17.         public Form1()
  18.         {
  19.             InitializeComponent();
  20.             Game Game;
  21.             for (System.Int32 i = 0; i < 7; i++)//this is just a example, use a plugin system
  22.             {
  23.                 Game = new Game();
  24.                 Game.TitleImgURL = "http://download.xbox.com/content/images/66acd000-77fe-1000-9115-d802425307d1/1033/boxartsm.jpg";
  25.                 Game.TitleName = "Oblivion";
  26.                 Game.TitleID = 0x425307d1;
  27.                 Game.Form = new Form();
  28.                 Games.Add(Game);
  29.                 Game = new Game();
  30.                 Game.TitleImgURL = "http://download.xbox.com/content/images/66acd000-77fe-1000-9115-d80241560898/1033/boxartsm.jpg";
  31.                 Game.TitleName = "Call of Duty® ELITE";
  32.                 Game.TitleID = 0x41560898;
  33.                 Game.Form = new Form();
  34.                 Games.Add(Game);
  35.             }
  36.  
  37.             ////group box with scroll bar,can look nice. math may need tweaking slightly?
  38.             //GroupBox GB = new GroupBox();
  39.             //GB.Dock = DockStyle.Fill;
  40.             //Panel P = new Panel();
  41.             //P.Dock = DockStyle.Fill;
  42.             //P.AutoScroll = true;
  43.             //GB.Controls.Add(P);
  44.             //Controls.Add(GB);
  45.  
  46.             for (System.Int32 i = 0; i < Games.Count; i++)
  47.             {
  48.                 Games[i].Form.Text = Games[i].TitleName;//just caus
  49.  
  50.                 GameIcon Icon = new GameIcon(Games[i]);
  51.  
  52.                 System.Int32 CurLine = (System.Int32)Math.Round((System.Double)(i / MaxPerLine));//you get this or you dont, but its simple math
  53.                 System.Int32 LinePos = i - (MaxPerLine * CurLine);//""
  54.                 Icon.Location = new System.Drawing.Point(10 + (85 * LinePos), 10 + (CurLine * 120));//10 being default pos(X + Y), 85/120 = pic box size
  55.  
  56.                 Icon.Click += new EventHandler(Icon_Click);//event handlers make the world work, you want to click the pic box?
  57.  
  58.                 Controls.Add(Icon);
  59.                 //P.Controls.Add(Icon);//for the gb with a scroll bar
  60.             }
  61.         }
  62.  
  63.         private void Icon_Click(object sender, EventArgs e)
  64.         {
  65.             //MessageBox.Show(((GameIcon)sender).Game.TitleName);
  66.             if (((GameIcon)sender).Game.Form.Visible == false)
  67.             {
  68.                 ((GameIcon)sender).Game.Form.Show();
  69.             }
  70.             else
  71.             {
  72.                 ((GameIcon)sender).Game.Form.Hide();
  73.             }
  74.         }
  75.  
  76.     }
  77.     public class GameIcon : PictureBox
  78.     {
  79.         public Game Game;
  80.  
  81.         public GameIcon(Game _Game)
  82.         {
  83.             Game = _Game;
  84.             ImageLocation = Game.TitleImgURL;
  85.             Size = new System.Drawing.Size(85, 120);
  86.         }
  87.     }
  88.     public class Game
  89.     {
  90.         public System.String TitleImgURL;
  91.         public System.String TitleName;
  92.         public System.UInt32 TitleID;
  93.         public Form Form;//i recommend using user controls not forms
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment