|
 |
07-24-2009, 03:09 PM
|
#1
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 1,542
|
Question About Designing Skinnable Front End In .NET.
If I were to open Visual Studio and use the designer to place a bunch of buttons on the screen and end up with an application that works like Road Runner, how do I make that skinnable? It seems as simple as going in and changing the location() parameters to point to variables instead of integers and then load those variables from the skin .ini files but this designer code is generated on the fly from the design form by Visual Studio. So if you load them as variables, you'll no longer be able to view the designer because the variables won't be available at design time (or will they?). And even if they are, the second you make a change it'll overwrite all that code you changed. Is there a secret I don't know about?
__________________
Ampie Case
2.5" Hard Drive 80GB Samsung 5400RPM
256 MB DDR2 PC5400
Xenarc 700TSV - VGA Monitor
Intel D945GCLF Motherboard
M2-ATX-HV
2005 Honda Civic
|
|
|
|
|
|
Advertisement
|
Sponsored links
|
07-24-2009, 03:55 PM
|
#2
|
|
North of the land of Hey Huns
Join Date: Jun 2004
Location: Westminster, MD
Posts: 1,039
|
Maherino: No, there is no secret. You cannot use designer to design your skins.
Instead of placing controls, just start with a blank form. Then make a function, for which all the buttons will trigger. You read from the ini file to get the position and name of all the buttons you want, and create an array to hold the buttons. Create new buttons as per the ini file and place them in this array, at the same time setting their click method to the function. In the click method, check the name of the button (set in the ini file) against a list of common commands.
This is a very simple way, if you want I can push out some simple c# code to do just this.
__________________
RevFE - Try it, you just might like it.
Carbon - Next Generation Touchscreen Browser
Come join us on IRC: irc.efnet.net #mp3car
Audiophiles make me chuckle as they pad my wallet.
|
|
|
07-24-2009, 04:03 PM
|
#3
|
|
North of the land of Hey Huns
Join Date: Jun 2004
Location: Westminster, MD
Posts: 1,039
|
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);
}
}
}
__________________
RevFE - Try it, you just might like it.
Carbon - Next Generation Touchscreen Browser
Come join us on IRC: irc.efnet.net #mp3car
Audiophiles make me chuckle as they pad my wallet.
|
|
|
07-24-2009, 04:03 PM
|
#4
|
|
FLAC
Join Date: May 2006
Location: Calgary, Alberta
Posts: 1,542
|
I'd really like some sample code. I get what you're saying but not why I should do it that way.
__________________
Ampie Case
2.5" Hard Drive 80GB Samsung 5400RPM
256 MB DDR2 PC5400
Xenarc 700TSV - VGA Monitor
Intel D945GCLF Motherboard
M2-ATX-HV
2005 Honda Civic
|
|
|
07-24-2009, 04:15 PM
|
#5
|
|
North of the land of Hey Huns
Join Date: Jun 2004
Location: Westminster, MD
Posts: 1,039
|
I must have posted 30 seconds before you. try out the above code see if that explains how to do it a bit better.
__________________
RevFE - Try it, you just might like it.
Carbon - Next Generation Touchscreen Browser
Come join us on IRC: irc.efnet.net #mp3car
Audiophiles make me chuckle as they pad my wallet.
|
|
|
|
Sponsored links
|
|
Advertisement
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:38 PM.
| |