5,445,109 members and growing! (15,517 online)
Email Password   helpLost your password?
Languages » C# » Windows Forms     Intermediate

Tiny WinForms Application Framework - Juju

By Väinölä Harri

Tiny WinForms Application Framework - Juju
C#, Windows, .NET 1.1, .NETVisual Studio, VS.NET2003, Dev

Posted: 23 Dec 2003
Updated: 23 Dec 2003
Views: 30,568
Bookmarked: 15 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
4 votes for this Article.
Popularity: 1.94 Rating: 3.21 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
2 votes, 50.0%
3
2 votes, 50.0%
4
0 votes, 0.0%
5

Introduction

Many times customer says 'we need Windows application which works like browser’. This article describes how to make WinForms Application which mimics a Browser. Because Tiny WinForms Application Framework is so long a name, I have called it JUJU.

What does the code do?

  • JUJU mimics MS Explorer - you can browse WinForms forward and backward
  • old Form sends arguments to the new Form
  • new Form inherits size and location properties
  • Forms are linked together with double linked list
  • Events are handled in separated class
  • easy to maintain

How to start

When you start to build a new Windows Application and it’s layout looks like Browser, include these files to our project and start to create the new Forms. You can jump from any form to another and the framework remembers how to go backwards or forwards. There is one main class that handles the behaviour of Browser. It is called AppManager (Application Manager). Every time when you create a new Form, and you want to create it to the same stack as previous form, you must create the new form via AppManager, example.

AppManager.Show (new Form1, “”)  //new stack, no arguments 

AppManager.Show (new Forms, this, arguments)  //same stack, with arguments   

Every Form has it’s own FormManager class, where you can hide all public events which are common to all Forms. FormManager takes care of usual Form events and it discuss with AppManager.

Main ideas, Juju

Main function is Start and it is the place where you initialize AppManager. AppManager glues all windows together with a Double Linked List, see code.

public class Start   
{
  public Start() {}
  [STAThread]
    static void Main() { 
      AppManager.Show(new Home(), "");
      Application.Run();
  }
}

Expand your Form with your own common interface IForm.

public class Form1 : System.Windows.Forms.Form, IForm{..}  

Add FormManager class to every Form which must have Browser like behaviour. FormManager class takes care of usual tasks which the Form must to do. It initialize Toolbars, Event Handler etc. After that you can concentrate real work, designing WinForms. Every common event is circulated via this class.

publicForm1() { 
     InitializeComponent();                                
     FormManager frmManager = new FormManager( this);       
}                                                                 

Remember also to Implement all IForm functions.

When you want to create new window just call AppManager.Show(...). Every new form inherits properties from previous form (= location, layout). Old Form also send arguments to the new one so that it knows how to initialize data.

AppManager.Show( new Form1(), this, argsOUT);

If the new Form is in the middle of stack when you call function AppManager.Show(..) it removes all the Forms from the right and after that it adds new Form to the end of stack. Previous form is hidden and new form is shown.

publicstatic void Show(Form newForm, Form oldForm, string args) { 
  Node current = Activate(oldForm); 
  if (current.Right != null) Remove(current.Right.Value, true); 
    Node node = new Node(newForm, current, null); 
  current.Right = node; 
  nodes.Add(node); 
  InitForm(newForm, oldForm, args); 
  ShowHide(newForm, oldForm); 
  current = null; 
}                                                                 

Bugs and comments

If you have any ideas how to develop this idea don’t hesitate to contact me, dathava@jippii.fi. I would be pleased if someone can give me me ideas how to develop this idea further. Maybe there are better ways how to handle events. So if you invent any new features, let me know. Juju means a trick in Finnish.

What is needed?

Common Keyboard and Menu handlers.

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

About the Author

Väinölä Harri



Location: Finland Finland

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 6 of 6 (Total in Forum: 6) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralGeneratormemberakorolev1023:10 5 Jul '05  
GeneralNew Frames in Stack are going bigger and biggermemberDrFlow5:04 28 Apr '04  
GeneralRe: New Frames in Stack are going bigger and biggermemberhuuhaa8:10 9 May '04  
GeneralRe: New Frames in Stack are going bigger and biggermemberDrFlow21:37 9 May '04  
GeneralRe: New Frames in Stack are going bigger and biggermemberhuuhaa3:35 10 May '04  
GeneralThanks, it's interestingmemberAldamo0:29 28 Jan '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 23 Dec 2003
Editor: Nishant Sivakumar
Copyright 2003 by Väinölä Harri
Everything else Copyright © CodeProject, 1999-2008
Web15 | Advertise on the Code Project