Click here to Skip to main content
Click here to Skip to main content
Go to top

Fireball.XmlGui

, 29 Jul 2005
Rate this:
Please Sign up or sign in to vote.
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 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:

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 Wink | ;) . 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 Wink | ;)

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

Share

About the Author

dotnetfireball
Web Developer
Italy Italy
No Biography provided

Comments and Discussions

 
GeneralMyXaml PinprotectorMarc Clifton29-Jul-05 5:36 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 29 Jul 2005
Article Copyright 2005 by dotnetfireball
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid