Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Adam
- {
- public partial class Form1 : Form
- {
- public List<Game> Games = new List<Game>();
- public System.Int32 MaxPerLine = 3;//this is the amount of pic box's you want on each line.
- public Form1()
- {
- InitializeComponent();
- Game Game;
- for (System.Int32 i = 0; i < 7; i++)//this is just a example, use a plugin system
- {
- Game = new Game();
- Game.TitleImgURL = "http://download.xbox.com/content/images/66acd000-77fe-1000-9115-d802425307d1/1033/boxartsm.jpg";
- Game.TitleName = "Oblivion";
- Game.TitleID = 0x425307d1;
- Game.Form = new Form();
- Games.Add(Game);
- Game = new Game();
- Game.TitleImgURL = "http://download.xbox.com/content/images/66acd000-77fe-1000-9115-d80241560898/1033/boxartsm.jpg";
- Game.TitleName = "Call of Duty® ELITE";
- Game.TitleID = 0x41560898;
- Game.Form = new Form();
- Games.Add(Game);
- }
- ////group box with scroll bar,can look nice. math may need tweaking slightly?
- //GroupBox GB = new GroupBox();
- //GB.Dock = DockStyle.Fill;
- //Panel P = new Panel();
- //P.Dock = DockStyle.Fill;
- //P.AutoScroll = true;
- //GB.Controls.Add(P);
- //Controls.Add(GB);
- for (System.Int32 i = 0; i < Games.Count; i++)
- {
- Games[i].Form.Text = Games[i].TitleName;//just caus
- GameIcon Icon = new GameIcon(Games[i]);
- System.Int32 CurLine = (System.Int32)Math.Round((System.Double)(i / MaxPerLine));//you get this or you dont, but its simple math
- System.Int32 LinePos = i - (MaxPerLine * CurLine);//""
- Icon.Location = new System.Drawing.Point(10 + (85 * LinePos), 10 + (CurLine * 120));//10 being default pos(X + Y), 85/120 = pic box size
- Icon.Click += new EventHandler(Icon_Click);//event handlers make the world work, you want to click the pic box?
- Controls.Add(Icon);
- //P.Controls.Add(Icon);//for the gb with a scroll bar
- }
- }
- private void Icon_Click(object sender, EventArgs e)
- {
- //MessageBox.Show(((GameIcon)sender).Game.TitleName);
- if (((GameIcon)sender).Game.Form.Visible == false)
- {
- ((GameIcon)sender).Game.Form.Show();
- }
- else
- {
- ((GameIcon)sender).Game.Form.Hide();
- }
- }
- }
- public class GameIcon : PictureBox
- {
- public Game Game;
- public GameIcon(Game _Game)
- {
- Game = _Game;
- ImageLocation = Game.TitleImgURL;
- Size = new System.Drawing.Size(85, 120);
- }
- }
- public class Game
- {
- public System.String TitleImgURL;
- public System.String TitleName;
- public System.UInt32 TitleID;
- public Form Form;//i recommend using user controls not forms
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment