i have multiple User Interfaces , and I want to swich between them .
i have written some codes for it .
but i change my mode , it hangs .
My windows form , with a single picture box control only .
Code: Select all
public partial class MainScreen : Form
{
TGraphics3D t3d;
bool to_exit = false;
int last_display_mode = 0;
public MainScreen()
{
InitializeComponent();
}
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainScreen());
}
private void MainScreen_Load(object sender, EventArgs e)
{
this.Show();
t3d = new TGraphics3D(pbMain, this);
t3d.startup_path = Application.StartupPath;
last_display_mode = TGraphics3D.display_mode;
SwitchDisplay(TGraphics3D.display_mode);
while(!to_exit)
Heartbeat();
GC.Collect();
}
private void Heartbeat()
{
if (TGraphics3D.display_mode == 7)
to_exit = true;
else
{
if (last_display_mode != TGraphics3D.display_mode)
{
SwitchDisplay(TGraphics3D.display_mode);
last_display_mode = TGraphics3D.display_mode;
}
}
}
// ---------------
// Display Manager
// ---------------
private void SwitchDisplay(int mode)
{
TGraphics3D.paused = true;
t3d.AddStaticText(new Point(500, 500), new Point(600, 520), 0, false, true, null, TGraphics3D.display_mode.ToString());
switch (mode)
{
case 0:
break;
case 1:
break;
case 2:
t3d.AddGUIButton(new Point(10, 10), new Point(500, 50), 101, "still not working ?");
t3d.AddGUIButton(new Point(60, 60), new Point(100, 100), 102, "to mode 3");
break;
case 3:
t3d.AddGUIButton(new Point(110, 110), new Point(150, 150), 103, "to mode 2");
t3d.AddStaticText(new Point(200, 200), new Point(300, 300), 0, false, false, null, "mode 3");
break;
case 4:
break;
case 5:
break;
case 6:
break;
default: // should not be here
to_exit = true;
break;
}
TGraphics3D.paused = false;
last_display_mode = mode;
t3d.Heartbeat();
}
}