Link to home
Start Free TrialLog in
Avatar of gemky
gemky

asked on

How do I correctly navigate a multi form c# .net CF 3.5 app.

Hello,

I have a multiform form .Net CF application which has 4-6 unrelated forms.   I've being using the Show Hide approach in the past with other CF form apps as I need to remember my button states on some of the form, but I've never had this many forms.

What would be the best approach in terms of performance to navigate between say 4 forms quickly.  None of the forms are connected to a database, any data which may be required is gathered from a serial port via a separate thread.

Form Navigation is as follows

Form 1 - has 3 buttons (Show Form 2,Show Form 3, Show Form 4)
Form 2 - has 3 buttons (Show Form 1,Show Form 3, Show Form 4)
Form 3 - has 3 buttons (Show Form 1,Show Form 2, Show Form 4)
Form 4 - only has an exit button and this shows the previously viewed Form)

I attempted the singleton approach so I would only have one instance of each form but when I ran the application there was a 2 second delay between loading forms for some reason so I have left this approach for now.

Another concern of mine is that I am repeating navigation buttons on each form (duplicating)

Some additional information about my app which weighs on Memory usage.  This is a GUI rich application (.net CF 3.5 ). I'm using custom buttons for .net CF which allows the use of images on buttons. I'm using these buttons for navigation instead of tabs because I need to use the images on the buttons and my forms have a background image by

 overriding the On Paint for my form, (the .net CF framework does have an image background feature for forms)

I use the following in my code

Bitmap backgroundImage;  //uses an embedded image which is loaded into the Bitmap when the FormLoads


// Draws the image to fit the ClientRectangle area of the form.
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawImage(backgroundImage, this.ClientRectangle,
              new Rectangle(0, 0, this.backgroundImage.Width, this.backgroundImage.Height), GraphicsUnit.Pixel);
        }


Considering
   (1) I have 4 forms I want to swap between quickly in no particular order.
   (2) Form 4 navigates only to the previously viewed form
   (3) I'm using buttons with images for navigation.  (4 similar buttons on all 3 forms)
   (4) I'm overriding OnPaint of the forms background to have a Rich GUI

Whats the best way for me to navigate?
Should I re look at the singleton approach?
Would something like the following link work for .net CF 3.5 and Visual Studio 2008?
http://msdn.microsoft.com/en-us/library/aa446546.aspx

Perhaps after navigation has been solved I can look at the efficiency of how I'm using images.

Any help with navigation is so appreciated, Thank you

KY


Avatar of hjgode
hjgode
Flag of Germany image

Did you already read the article about multiform framework in CF2?

http://msdn.microsoft.com/en-us/library/aa446546.aspx

and the revised one at http://blog.opennetcf.com/ctacke/2009/11/25/RevisitingTheFormStack.aspx

Avatar of gemky
gemky

ASKER

Yes I have read it. I'm pretty new to programming, I only do a little bit here and there so there lies the problem. I'm finding it very hard to get my head around the multiframe work code in the Opennetfc example.
ASKER CERTIFIED SOLUTION
Avatar of hjgode
hjgode
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gemky

ASKER

Thanks hjgode, this is great and I can follow it too. There are some parts I don't understand still but with some research I should have it figured out.  
Avatar of gemky

ASKER

Hjgode,

I've added a problem do the Multiform solution. Maybe you may know what i'm forgetting.
https://www.experts-exchange.com/questions/26735363/Multiple-Form-Application-Framework-issue-with-mouse-events-and-images-on-custom-buttons.html

Thanks
KY