Exemplo n.º 1
0
            /// <summary>
            /// Constructor: Creates the necessary GUI elements for the given NetworkLayer
            /// </summary>
            /// <param name="ns">Reference to the NodeSteuerung controlling the network layers</param>
            /// <param name="nl">Reference to base NetworkLayer to create GUI elements for</param>
            public NetworkLayerGUI(NodeSteuerung ns, NetworkLayer nl)
            {
                _nodeController = ns;
                _networkLayer = nl;
                _editTitle = new System.Windows.Forms.TextBox();
                _btnRemove = new System.Windows.Forms.Button();
                _cbVisible = new System.Windows.Forms.CheckBox();

                _editTitle.Text = nl.title;
                _editTitle.Dock = DockStyle.Fill;
                _editTitle.Leave += new EventHandler(_editTitle_Leave);

                _btnRemove.Text = "Remove";
                _btnRemove.Click += new EventHandler(_btnRemove_Click);

                _cbVisible.Text = "Visible";
                _cbVisible.Checked = nl.visible;
                _cbVisible.CheckedChanged += new EventHandler(_cbVisible_CheckedChanged);
            }
Exemplo n.º 2
0
        void nodeSteuerung_NetworkLayersChanged(object sender, NodeSteuerung.NetworkLayersChangedEventArgs e)
        {
            switch (e._invalidationLevel)
                {
                case NodeSteuerung.NetworkLayersChangedEventArgs.InvalidationLevel.ONLY_VISIBILITY_CHANGED:
                    Invalidate(InvalidationLevel.ONLY_MAIN_CANVAS);
                    break;
                default:
                    // fist: update NetworkLayer combo box for LineNode setup
                    cbNetworkLayer.Items.Clear();
                    foreach (NetworkLayer nl in nodeSteuerung._networkLayers)
                        {
                        cbNetworkLayer.Items.Add(nl);
                        }

                    selectedLineNodes = selectedLineNodes;

                    // then: update NetworkLayerGUI elements
                    _networkLayerGUI.Clear();

                    tlpLayers.SuspendLayout();
                    tlpLayers.Controls.Clear();
                    tlpLayers.RowStyles.Clear();

                    tlpLayers.RowCount = nodeSteuerung._networkLayers.Count + 1;
                    tlpLayers.Height = (tlpLayers.RowCount + 1) * 28;
                    int i = 0;
                    foreach (NetworkLayer nl in nodeSteuerung._networkLayers)
                        {
                        NetworkLayerGUI nlg = new NetworkLayerGUI(nodeSteuerung, nl);
                        nlg.AddToPanel(tlpLayers, i);
                        _networkLayerGUI.Add(nlg);
                        ++i;
                        }

                    tlpLayers.RowStyles.Add(new RowStyle(SizeType.AutoSize, 28));
                    tlpLayers.ResumeLayout(true);
                    break;
                }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Speichert den aktuellen Zustand der nodeSteuerung und timelineSteuerung in die XML-Datei filename
        /// </summary>
        /// <param name="filename">Dateiname der zu speichernden Datei</param>
        /// <param name="nodeSteuerung">NodeSteuerung</param>
        /// <param name="timelineSteuerung">TimelineSteuerung</param>
        /// <param name="trafficVolumeSteuerung">VerkehrSteuerung</param>
        /// <param name="ps">ProgramSettings</param>
        public static void SaveToFile(string filename, NodeSteuerung nodeSteuerung, TimelineSteuerung timelineSteuerung, Verkehr.VerkehrSteuerung trafficVolumeSteuerung, ProgramSettings ps)
        {
            try
                {
                // erstma nen XMLWriter machen
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.Indent = true;
                xws.NewLineHandling = NewLineHandling.Entitize;

                XmlWriter xw = XmlWriter.Create(filename, xws);

                // leeren XmlSerializerNamespaces Namespace erstellen
                XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
                xsn.Add("", "");

                xw.WriteStartElement("CityTrafficSimulator");

                    // write saveVersion
                    xw.WriteStartAttribute("saveVersion");
                    xw.WriteString("8");
                    xw.WriteEndAttribute();

                    // serialize program settings
                    XmlSerializer xsPS = new XmlSerializer(typeof(ProgramSettings));
                    xsPS.Serialize(xw, ps, xsn);

                    nodeSteuerung.SaveToFile(xw, xsn);
                    timelineSteuerung.SaveToFile(xw, xsn);
                    trafficVolumeSteuerung.SaveToFile(xw, xsn);

                xw.WriteEndElement();

                xw.Close();

                }
            catch (IOException e)
                {
                MessageBox.Show(e.Message);
                throw;
                }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Läd eine XML Datei und versucht daraus den gespeicherten Zustand wiederherzustellen
        /// </summary>
        /// <param name="filename">Dateiname der zu ladenden Datei</param>
        /// <param name="nodeSteuerung">NodeSteuerung in das Layout eingelesen werden soll</param>
        /// <param name="timelineSteuerung">TimelineSteuerung in die die LSA eingelesen werden soll</param>
        /// <param name="trafficVolumeSteuerung">VerkehrSteurung to load into</param>
        public static ProgramSettings LoadFromFile(String filename, NodeSteuerung nodeSteuerung, TimelineSteuerung timelineSteuerung, Verkehr.VerkehrSteuerung trafficVolumeSteuerung)
        {
            LoadingForm.LoadingForm lf = new LoadingForm.LoadingForm();
            lf.Text = "Loading file '" + filename + "'...";
            lf.Show();

            lf.SetupUpperProgress("Loading Document...", 8);

            // Dokument laden
            XmlDocument xd = new XmlDocument();
            xd.Load(filename);

            // parse save file version
            int saveVersion = 0;
            XmlNode mainNode = xd.SelectSingleNode("//CityTrafficSimulator");
            XmlNode saveVersionNode = mainNode.Attributes.GetNamedItem("saveVersion");
            if (saveVersionNode != null)
                saveVersion = Int32.Parse(saveVersionNode.Value);
            else
                saveVersion = 0;

            ProgramSettings ps;
            if (saveVersion >= 8)
                {
                XmlNode xnlLineNode = xd.SelectSingleNode("//CityTrafficSimulator/ProgramSettings");
                TextReader tr = new StringReader(xnlLineNode.OuterXml);
                XmlSerializer xsPS = new XmlSerializer(typeof(ProgramSettings));
                ps = (ProgramSettings)xsPS.Deserialize(tr);
                }
            else
                {
                // set some okay default settings
                ps = new ProgramSettings();

                ps._simSpeed = 1;
                ps._simSteps = 15;
                ps._simDuration = 300;
                ps._simRandomSeed = 42;

                ps._zoomLevel = 7;
                ps._renderQuality = 0;

                ps._renderStatistics = false;
                ps._renderVelocityMapping = false;
                ps._showFPS = false;

                ps._renderOptions = new NodeSteuerung.RenderOptions();
                ps._renderOptions.renderLineNodes = true;
                ps._renderOptions.renderNodeConnections = true;
                ps._renderOptions.renderVehicles = true;
                ps._renderOptions.performClipping = true;
                ps._renderOptions.clippingRect = new Rectangle(0, 0, 10000, 10000);
                ps._renderOptions.renderIntersections = false;
                ps._renderOptions.renderLineChangePoints = false;
                ps._renderOptions.renderLineNodeDebugData = false;
                ps._renderOptions.renderNodeConnectionDebugData = false;
                ps._renderOptions.renderVehicleDebugData = false;

                List<Color> tmp = new List<Color>();
                tmp.Add(Color.DarkRed);
                tmp.Add(Color.Yellow);
                tmp.Add(Color.DarkGreen);
                ps._velocityMappingColorMap = new Tools.ColorMap(tmp);
                }

            lf.StepUpperProgress("Parsing Network Layout...");
            List<Auftrag> toReturn = nodeSteuerung.LoadFromFile(xd, lf);

            lf.StepUpperProgress("Parsing Singnals...");
            timelineSteuerung.LoadFromFile(xd, nodeSteuerung.nodes, lf);

            lf.StepUpperProgress("Parsing Traffic Volume...");
            trafficVolumeSteuerung.LoadFromFile(xd, nodeSteuerung.nodes, lf);
            if (saveVersion < 5)
                {
                trafficVolumeSteuerung.ImportOldTrafficVolumeData(toReturn);
                }

            lf.StepUpperProgress("Done");
            lf.ShowLog();

            lf.Close();
            lf = null;

            return ps;
        }
Exemplo n.º 5
0
 public void RenderOuterVehicleNetwork(Graphics g, NodeSteuerung.RenderOptions options)
 {
     foreach (IVehicle v in VehicleDrivedOut)
     {
         Point pt = new Point((int)v.state.positionAbs.X, (int)v.state.positionAbs.Y);
         if (options.renderVehicles && (!options.performClipping || options.clippingRect.Contains(pt)))
     {
         v.Draw(g, options.vehicleVelocityMapping);
     }
     }
 }