コード例 #1
0
        private void OnSimulationStart(object sender, System.Windows.RoutedEventArgs e)
        {
            if (FactoryDropdown.SelectedItem != null)
            {
                string errorID = csu.CreateSimulation();
                if (errorID == null)
                {
                    return;
                }
                else if (errorID.Equals(""))
                {
                    ShowPopUp("Simulation konnte nicht erzeugt werden.");
                }
                string[] parts = errorID.Split(new char[] { ':' });

                if (parts.Length == 2)
                {
                    string code = parts[0];
                    string simulationIdString = parts[1];
                    if (code.Equals("ERROR"))
                    {
                        ShowPopUp("Simulation konnte nicht erzeugt werden, weil Maschine " + parts[1] + " nicht richtig positioniert ist.");
                    }

                    else if (code.Equals("ID"))
                    {
                        int    simulationID = int.Parse(simulationIdString);
                        string firstLine    = "Simulation unter der ID " + simulationID + " erstellt.";
                        string secondLine   = "Jetzt anzeigen?";

                        ClearSimulationPulldown();
                        InitSimulationPulldown();

                        object showSimulation = this.Dispatcher.Invoke(new ShowInvitationWindowDelegate(ShowSimulationInvitationWindow), new object[] { simulationID, firstLine, secondLine });
                        if ((bool)showSimulation)
                        {
                            Dictionary <int, string> simulations = csu.GetSimulationFactories();
                            if (simulations != null)
                            {
                                string simulationName = simulations[simulationID];
                                string simulationPulldownItemString = HelperFunctions.ToString(simulationID, simulationName);
                                SimulationFactoryDropdown.SelectedItem = simulationPulldownItemString;
                                LoadSimulation(simulationID);
                            }
                        }
                    }
                }
            }
        }