I got bored:
Skin file:
Code:
button,100,100,100,35,"Test Button",CMD_PLAY
button,200,100,100,35,"Test Button",CMD_PAUSE
button,300,100,100,35,"Test Button",CMD_STOP
Form1.cs:
Code:
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;
using System.IO;
namespace SkinTest
{
public partial class Form1 : Form
{
public Form1()
{
this.Load += new System.EventHandler(this.Form1_Load);
this.ClientSize = new System.Drawing.Size(598, 394);
}
List<Control> controlList;
private void Form1_Load(object sender, EventArgs e)
{
controlList = new List<Control>();
String[] array = File.ReadAllLines("test.skin");
for (int i = 0; i < array.Length; i++)
{
Control tmpControl;// = new Control();
String[] split = array[i].Split(',');
if (split[0] == "button")
{
tmpControl = new Button();
tmpControl.Parent = this;
this.Controls.Add(tmpControl);
tmpControl.Location = new Point(int.Parse(split[1]),int.Parse(split[2]));
tmpControl.Size = new Size(int.Parse(split[3]),int.Parse(split[4]));
tmpControl.Text = split[5];
tmpControl.Name = split[6];
tmpControl.Click += new EventHandler(ButtonClick);
controlList.Add(tmpControl);
}
}
}
private void ButtonClick(object sender, EventArgs e)
{
MessageBox.Show("Button Clicked: " + ((Button)sender).Name);
}
}
}
Bookmarks