public Schalter(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { string[] glAnschl = elem[2].Split(' '); Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); if (elem.Length > 4) { KoppelungsString = elem[4]; } if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); if (gl.GleisElementAnschluss(this)) { AnschlussGleis = gl; Ausgang = AnschlussGleis.Ausgang; Parent.SchalterElemente.Hinzufügen(this); _graphicsPath = new GraphicsPath(); this.Berechnung(); } } }
/// <summary> /// Konstruktor zum laden aus der .anl-Datei /// </summary> /// <param name="parent"></param> /// <param name="zoom"></param> /// <param name="anzeigeTyp"></param> /// <param name="elem"></param> public InfoFenster(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { string[] glAnschl = elem[2].Split(' '); Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); Gleisposition = Convert.ToInt32(glAnschl[1]); if (elem[3] == "0") { _lage = false; } else { _lage = Convert.ToBoolean(elem[3]); } if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); AnschlussGleis = gl; Parent.InfoElemente.Hinzufügen(this); this.Text = ""; //InfoString; this.Berechnung(); } }
/// <summary> /// zum Laden aus der Text-Datei /// </summary> /// <param name="parent">AnlagenElemente</param> /// <param name="zoom"></param> /// <param name="anzeigeTyp"></param> /// <param name="elem">Zeile aus der Text-Datei</param> public EingangsSchalter(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { KurzBezeichnung = "Eing"; string[] glAnschl = elem[2].Split(' '); Ausgang.SpeicherString = elem[3]; Bezeichnung = elem[4]; Stecker = elem[5]; Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); Gleisposition = Convert.ToInt32(glAnschl[1]); if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); { AnschlussGleis = gl; Parent.EingSchalterElemente.Hinzufügen(this); _graphicsPath = new GraphicsPath(); _graphicsPathKreis = new GraphicsPath(); this.Berechnung(); } } }
public bool AttachTrack(Gleis track) { int angle = track.GetDirection(this); switch (_attachedTracks) { case 0: _gleise[0] = track; _attachedTracks++; return(true); case 4: break; default: bool success = false; for (int i = 0; i < 4; i++) { if (_gleise[i] != null) { int diff = Math.Abs((_gleise[i].GetDirection(this) - angle)); if (diff == 1 || diff == 7) { if (i == 0 || i == 2) { success = AttachTrack(track, i + 1); } else { success = AttachTrack(track, i - 1); } } else if (diff > 2 && diff < 6) { if (i > 1) { i = 0; } else { i = 2; } success = AttachTrack(track, i); if (!success) { success = AttachTrack(track, i + 1); } } } if (success) { return(true); } } break; } return(false); }
private Signal GegenSignalSuchen() { bool richtung = this.InZeichenRichtung; Gleis gl = this.AnschlussGleis; if (richtung) { if (gl.Signale[1] != null) { return(gl.Signale[1]); } } else { if (gl.Signale[0] != null) { return(gl.Signale[0]); } } Knoten kn = (richtung ? gl.StartKn : gl.EndKn); while (kn.Weichen[0] == null && kn.Weichen[1] == null) { bool stumpfGleis = true; foreach (Gleis g in kn.Gleise) { if (g != null && g != gl) { gl = g; stumpfGleis = false; break; } } if (stumpfGleis) { break; } richtung = (gl.StartKn == kn); if (richtung) { if (gl.Signale[0] != null) { return(gl.Signale[0]); } } else { if (gl.Signale[1] != null) { return(gl.Signale[1]); } } kn = (richtung ? gl.EndKn : gl.StartKn); } return(null); }
public int GetGleisAnschlussNr(Gleis gleis) { for (int i = 0; i < 4; i++) { if (gleis == _gleise[i]) { return(i); } } return(-1); }
/// <summary> /// zum Laden aus der Text-Datei /// </summary> /// <param name="parent">AnlagenElemente</param> /// <param name="zoom"></param> /// <param name="anzeigeTyp"></param> /// <param name="elem">Zeile aus der Text-Datei</param> public FSS(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { KurzBezeichnung = "Fss"; string[] glAnschl = elem[2].Split(' '); _reglerNrQuelle[0] = Convert.ToInt32(elem[3]); _reglerNrQuelle[1] = Convert.ToInt32(elem[4]); _reglerNr[0] = Convert.ToInt32(elem[3]); _reglerNr[1] = Convert.ToInt32(elem[4]); _fss[0] = null; _regler[0] = null; if (_reglerNr[0] > 0) { _regler[0] = Parent.ReglerElemente.Element(_reglerNr[0]); } _fss[1] = null; _regler[1] = null; if (_reglerNr[1] > 0) { _regler[1] = Parent.ReglerElemente.Element(_reglerNr[1]); } Ausgang.SpeicherString = elem[5]; if (elem.Length > 7) { Bezeichnung = elem[6]; Stecker = elem[7]; } if (elem.Length > 8) { KoppelungsString = elem[8]; } if (elem.Length > 9) { sichtbarkeit = Convert.ToBoolean(elem[9]); } Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); Gleisposition = Convert.ToInt32(glAnschl[1]); if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); { AnschlussGleis = gl; Parent.FssElemente.Hinzufügen(this); _graphicsPath = new GraphicsPath(); _graphicsPathKreis = new GraphicsPath(); this.Berechnung(); } } }
public Weiche(AnlagenElemente parent, Int32 iD, Int32 zoom, AnzeigeTyp anzeigeTyp, Knoten node, Gleis gleis1, Gleis gleis2) : base(parent, iD, zoom, anzeigeTyp) { Ausgang = new Adresse(parent); KurzBezeichnung = "We"; _gleise[0] = gleis1; _gleise[1] = gleis2; _knoten = node; Parent.WeicheElemente.Hinzufügen(this); this.stringFormat = new StringFormat(); this.stringFormat.Alignment = StringAlignment.Far; this.stringFormat.LineAlignment = StringAlignment.Far; this.farbeFillEllipse = Color.Red; this.farbeLinien = Color.Black; this.Berechnung(); }
/// <summary> /// fügt ein Gleis an einer bestimmten Position ein (beim Gleis neu erstellen) und /// erzeugt neue Weichen falls nötig /// </summary> /// <param name="track"></param> /// <param name="position"></param> /// <returns></returns> public bool AttachTrack(Gleis track, int position) { if (_gleise[position] == null) { _gleise[position] = track; _attachedTracks++; if (_gleise[0] != null && _gleise[1] != null && Weichen[0] == null) { Weichen[0] = new Weiche(Parent, 10 * ID + 0, Zoom, AnzeigenTyp, this, _gleise[0], _gleise[1]); } if (_gleise[2] != null && _gleise[3] != null && Weichen[1] == null) { Weichen[1] = new Weiche(Parent, 10 * ID + 1, Zoom, AnzeigenTyp, this, _gleise[2], _gleise[3]); } return(true); } return(false); }
/// <summary> /// Zum laden aus der Anlagen-Datei /// </summary> /// <param name="parent"></param> /// <param name="zoom"></param> /// <param name="anzeigeTyp"></param> /// <param name="elem"></param> public Entkuppler(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { Ausgang = new Adresse(parent); KurzBezeichnung = "Ek"; string[] glAnschl = elem[2].Split(' '); Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); if (gl.GleisElementAnschluss(this)) { AnschlussGleis = gl; Parent.EntkupplerElemente.Hinzufügen(this); Ausgang.SpeicherString = elem[3]; Bezeichnung = elem[4]; this.Berechnung(); } } }
public Signal(AnlagenElemente parent, Int32 zoom, AnzeigeTyp anzeigeTyp, string[] elem) : base(parent, Convert.ToInt32(elem[1]), zoom, anzeigeTyp) { string[] glAnschl = elem[2].Split(' '); KurzBezeichnung = "Sn"; Bezeichnung = elem[6]; if (elem.Length > 7) { Stecker = elem[7]; } Ausgang = new Adresse(parent); if (elem.Length > 8) { _autoStart = Convert.ToBoolean(elem[8]); } if (elem.Length > 9) { _zugLaengeMax = Convert.ToInt32(elem[9]); } if (elem.Length > 10) { ZugTypString = elem[10]; } if (elem.Length > 11) { KoppelungsString = elem[11]; } if (elem.Length > 12) { ZielGleisNr = Convert.ToInt16(elem[12]); } Gleis gl = Parent.GleisElemente.Element(Convert.ToInt32(glAnschl[0])); if (gl != null) { PositionRaster = gl.GetRasterPosition(this, Convert.ToInt32(glAnschl[1])); Position = new Point(PositionRaster.X * Zoom, PositionRaster.Y * Zoom); InZeichenRichtung = Convert.ToBoolean(elem[3]); if (gl.GleisElementAnschluss(this)) { Ausgang.SpeicherString = elem[5]; AnschlussGleis = gl; Parent.SignalElemente.Hinzufügen(this); this._stringFormat = new StringFormat(); this._stringFormat.Alignment = StringAlignment.Center; this._stringFormat.LineAlignment = StringAlignment.Center; this._graphicsPathHintergrund = new GraphicsPath(); this._graphicsPathKreis = new GraphicsPath(); this._graphicsPathLinien = new GraphicsPath(); this._graphicsPathText = new GraphicsPath(); this._farbe = Color.Red; this.Berechnung(); } Signal gegenSig = GegenSignalSuchen(); if (gegenSig != null) { GegenSignal = gegenSig; gegenSig.GegenSignal = this; } } infoFensterLaden(Convert.ToInt16(elem[4])); }