Results 1 to 5 of 5

Thread: Question About Designing Skinnable Front End In .NET.

  1. #1
    FLAC
    Join Date
    May 2006
    Location
    Calgary, Alberta
    Posts
    1,718

    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. #2
    North of the land of Hey Huns
    Auto Apps:loading...

    Join Date
    Jun 2004
    Location
    Westminster, MD
    Posts
    2,144
    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

  3. #3
    North of the land of Hey Huns
    Auto Apps:loading...

    Join Date
    Jun 2004
    Location
    Westminster, MD
    Posts
    2,144
    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

  4. #4
    FLAC
    Join Date
    May 2006
    Location
    Calgary, Alberta
    Posts
    1,718
    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

  5. #5
    North of the land of Hey Huns
    Auto Apps:loading...

    Join Date
    Jun 2004
    Location
    Westminster, MD
    Posts
    2,144
    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

Similar Threads

  1. New front end
    By alienmanfc6 in forum Other Cool Front Ends
    Replies: 3
    Last Post: 03-30-2008, 08:57 PM
  2. New Skinnable C# .NET Front End
    By Hessian in forum Software & Software Development
    Replies: 11
    Last Post: 12-06-2007, 11:34 AM
  3. Now a front end question?
    By nixneon in forum Newbie
    Replies: 3
    Last Post: 06-09-2005, 04:38 PM
  4. front end question
    By johnnywu005 in forum Newbie
    Replies: 5
    Last Post: 06-03-2005, 05:13 PM
  5. Question About a Front End for Mac OS X?
    By bns2000 in forum MacCar
    Replies: 12
    Last Post: 11-24-2004, 11:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •