Also, is there any way to make sure the softkey menus the same across
all forms?
public sealed class Browser {
Browser () {}
static Form current;
static EventHandler exit = new EventHandler(Exit);
static void Exit (object o, EventArgs a) {
Application.Exit();
}
public static void Show (Form f) {
// Assert(f != null, 0);
if (current == null) {
current = f;
current.Closed += exit;
Application.Run(current);
} else {
// Assert(f != current, 0);
f.Closed += exit;
f.Show();
current.Closed -= exit;
current.Hide();
current = f;
}
}
}
// An application with two screens could look like this:
public delegate void Command ();
public sealed class HomeView {
HomeView () {}
static Form f;
public static event Command Edit;
static void OnEdit (object o, EventArgs a) {
if (Edit!= null) { Edit(); }
}
public static void Initialize () {
// Assert(f == null, 0);
f = new Form();
Button b = new Button();
b.Text = "Edit";
b.Click += new EventHandler(OnEdit);
f.Controls.Add(b);
f.Controls.Add(new Label());
}
public static void Activate () {
// Assert(f != null, 0);
Browser.Show(f);
}
}
public sealed class EditView {
EditView () {}
static Form f;
public static event Command Done;
static void OnDone (object o, EventArgs a) {
if (Done!= null) { Done(); }
}
public static void Initialize () {
// Assert(f == null, 0);
f = new Form();
Button b = new Button();
b.Text = "Done";
b.Click += new EventHandler(OnDone);
f.Controls.Add(b);
f.Controls.Add(new Label());
}
public static void Activate () {
// Assert(f != null, 0);
Browser.Show(f);
}
}
sealed class App {
static void Main () {
HomeView.Initialize();
EditView.Initialize();
HomeView.Edit += new Command(EditView.Activate);
EditView.Done += new Command(HomeView.Activate);
HomeView.Activate();
}
}
You can create a main Form with a back panel and add your others forms
to the panel when you need to show you form. Then you can use events
to communicate between the main form and the childs forms.
BR
Fabien Decret
Windows Embedded Consultant
ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/