Click here to Skip to main content
15,880,967 members
Articles / Desktop Programming / Windows Forms
Article

Fireball.XmlGui

Rate me:
Please Sign up or sign in to vote.
2.10/5 (7 votes)
29 Jul 20052 min read 33.8K   517   23   1
A library for creating plug-ins with User Interface created from an XML file.

Xml_gui_sample_23_07_05.PNG

Introduction

In this article, I can illustrate what is Fireball.XmlGui and give a brief introduction to it. The library is under development and any suggestions and bug feedback are very much appreciated. If you find a bug please register here and send us the issues. Fireball.XmlGui is licensed under LGPL and this is very useful for programmers who need to use the library for commercial applications because LGPL doesn't force you to distribute your source code, you only need to distribute or link to my site for Fireball.XmlGui source code. For news about this library, go to my home page and get the latest binary from there.

Background

Fireball.XmlGui was developed for adding to plug-in based applications the support for creating dynamic plug-ins with a simple XML file. The syntax is very like XAML and it is also possible to use the code-behind! You only need to specify on the root of the document the attribute CodeBehind with the filename of the C# source file. The library is not limited to System.Windows.Forms GUI creation. You can also use it for dynamically creating any other type of classes, for adding classes as subnodes on the XML, like the Controls tag on this example. You need only the collection and inherit from the System.Collections.IList.

Using the code

See the next XML sample code:

XML
<?xml version="1.0" encoding="utf-8" ?>

<XFGDocument Name="Sample XmlGui" 
             NameSpaces="System.Drawing,System.Windows.Forms,
                    customNamespace,Fireball.XmlGui.Graphics" 
    CodeBehind="formsample.fxg.cs">
    
  <References>
      <Assembly Name="System.dll" />
      <Assembly Name="System.Drawing.dll" />
      <Assembly Name="System.Windows.Forms.dll" />
  </References>
  <MyForm Name="Prova"  Height="300" Width="400" Text="Hello World!">
    <Controls>
 
      <ToolStrip Name="ToolStrip1">
    
      </ToolStrip>
      <MenuStrip Name="MenuStrip1">
            <Items>
                <ToolStripMenuItem Text="File" >
                    <DropDownItems>
                        <ToolStripMenuItem Text="New" Click="MyForm.OpenClick"/>
                        <ToolStripMenuItem Text="Open" Click="MyForm.OpenClick"/>
                    </DropDownItems>
                </ToolStripMenuItem>
            </Items>
      </MenuStrip>
      <Panel Dock="Fill" BackColor="Color.Red">
          <Controls>
              <WebBrowser Name="browser1" Dock="Fill" />
          </Controls>
      </Panel>
      <StatusStrip />
    </Controls>
  </MyForm>
</XFGDocument>

The root element is XFGDocument. On this tag you need to set its name and the NameSpaces attribute to all namespaces you need to use from XML each separated by a , (comma). You can also specify the code-behind file with the attribute CodeBehind. In this example, the first child tag of the document needs to be a form. In this example, I use the class declared on the code-behind file. MyForm is a class that inherits from System.Windows.Forms.Form. Next, the source code of the code-behind file:

C#
using System;
using System.Drawing;
using System.Windows.Forms;
 
namespace customNamespace
{    
    public class MyForm : Form
    {
        static MyForm MyFormIstance;
        
        public MyForm()
        {
            MyFormIstance = this;
        }
        
        public static void OpenClick(object sender,EventArgs e)
        {
            WebBrowser br = 
              (WebBrowser)MyFormIstance.Controls.Find("browser1", true)[0];
            
            br.Navigate("http://www.dotnetfireball.org");
        }
    }
}

The source code is very short and simple, and you don't need to be a guru for creating a GUI with this library ;). On the XML code, if you need to set a property, you can do it as an attribute. For the moment, that is all. If you have any questions about the library, don't hesitate to contact me. I plan to write more about this library in future. At the moment, my time is dedicated to the development of the library, and other works ;)

Note: for running the sample, go on the sample bin/debug directory and execute the run.bat file.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMyXaml Pin
Marc Clifton29-Jul-05 5:36
mvaMarc Clifton29-Jul-05 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.