示例#1
0
        private void SwitchMode(GameModeScreen screen)
        {
            // Stop runnung Clients
            if (CurrentClient != null)
            {
                // Stop Simulation
                CurrentClient.StopSimulation();

                // Dispose Viewer
                mainPanel.Controls.Remove(Renderer);
                Renderer.Dispose();
                Renderer = null;

                // Dispose Client
                CurrentClient.Dispose();
                CurrentClient = null;
            }

            // Close open Modes
            if (CurrentMode != null)
            {
                // Dispose Mode
                mainPanel.Controls.Remove(CurrentMode);
                CurrentMode.Dispose();
                CurrentMode = null;
            }

            // Create new Mode
            CurrentMode = screen;
            mainPanel.Controls.Add(CurrentMode);
            CurrentMode.Dock = DockStyle.Fill;
        }
示例#2
0
        private void startToolButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Create Client
                CurrentClient                      = CurrentMode.StartSimulation();
                CurrentClient.OnError             += CurrentClient_OnError;
                CurrentClient.OnSimulationChanged += CurrentClient_OnSimulationChanged;

                // Dispose Mode
                mainPanel.Controls.Remove(CurrentMode);
                CurrentMode.Dispose();
                CurrentMode = null;

                // Start Simulation
                Renderer = new RenderControl();
                mainPanel.Controls.Add(Renderer);
                Renderer.Dock = DockStyle.Fill;
                Renderer.SetSimulation(CurrentClient);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }