Announcement

Collapse
No announcement yet.

Question About Designing Skinnable Front End In .NET.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.
    "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
    RevFE
    My Shop

    Comment


    • #3
      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);
              }
          }
      }
      "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
      RevFE
      My Shop

      Comment


      • #4
        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

        Comment


        • #5
          I must have posted 30 seconds before you. try out the above code see if that explains how to do it a bit better.
          "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
          RevFE
          My Shop

          Comment

          Working...
          X