Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
November 24, 2017, 02:29:57 AM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: Getting started with C# & WinForms.  (Read 7900 times)
petertrei
Newbie
*
Posts: 1


View Profile Email
« on: July 19, 2010, 01:28:31 PM »

Hi folks:

I'm quite new to this, coming out of a security/encryption background, but I need to write a WinForms app in C# with .NET 3.5 for WinMobile 6/PocketPC 5. PureMVC seems the way to go; it covers all my target environments. However, I'm new not only to PureMVC, but to Win GUI programming. I hope this question isn't too, too, basic.

The Best Practices guide and the WPF example are extremely helpful. I have the WPF example up and running in Visual Studio, and am trying to get a very simple MVC Winforms app up and running.

My test app consists of 3 Forms, each has 1 button. Form1 goes to Form2, Form2 to Form3, and Form3 back to Form2. This allows startup specific code to be associated with Form1, and Forms 2&3 to have a nice symmetry.

This works fine in pure WinForms; I'm now trying to make it work via MVC. At the moment, my primary concern is 'Where the heck should I be initiating PureMVC?' The WPF app initiates its concrete Facade extension in App's constructor (an extension of Application).

Where would be the equivalent point in a WinForms app? In Main()? or in Form1's constructor? Somewhere else?

I'd love to see a small complete example, using C#, PureMVC, and Winforms, but have been unable to locate one. The best link I've found is
http://www.pathf.com/blogs/2009/07/winforms-development-made-simple-with-puremvc/
but its no where near complete.

thanks in advance,

Peter Trei


Logged
adamczak
Moderator
Jr. Member
*****
Posts: 10


View Profile Email
« Reply #1 on: July 26, 2010, 09:00:52 PM »

Hi Peter,

Sorry for the slow response.  The way I instantiate PureMVC in my WinForms apps is in the following way:

Code:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
Application.SetCompatibleTextRenderingDefault(false);
MainForm mf = new MainForm(args);
ApplicationFacade facade = (ApplicationFacade) ApplicationFacade.Instance;
facade.Startup(mf);
Application.Run(mf);
}
catch (Exception ex)
{
// Log some errors, show message box, etc.
}
}

I hope this helps some, and post any other questions you have.

Andy Adamczak

Logged
Pages: [1]
Print
Jump to: