Example #1
0
        private void ShowSwitches(Graphics g, float width)
        {
            if (F.cbShowSwitches.Checked)
            {
                for (var i = 0; i < F.switches.Count; i++)
                {
                    SwitchWidget sw = F.switches[i];

                    var x = (sw.Location.X - F.subX) * F.xScale;
                    var y = F.pbCanvas.Height - (sw.Location.Y - F.subY) * F.yScale;
                    if (x < 0 || y < 0)
                    {
                        continue;
                    }

                    var scaledItem = new PointF()
                    {
                        X = x, Y = y
                    };

                    if (sw.Item.TrJunctionNode.SelectedRoute == sw.main)
                    {
                        g.FillEllipse(Brushes.Black, DispatchViewer.GetRect(scaledItem, width));
                    }
                    else
                    {
                        g.FillEllipse(Brushes.Gray, DispatchViewer.GetRect(scaledItem, width));
                    }

                    sw.Location2D.X = scaledItem.X; sw.Location2D.Y = scaledItem.Y;
                    F.switchItemsDrawn.Add(sw);
                }
            }
        }
Example #2
0
        private void ShowSignals(Graphics g, PointF scaledB, float width)
        {
            if (F.cbShowSignals.Checked)
            {
                foreach (var s in F.signals)
                {
                    if (float.IsNaN(s.Location.X) || float.IsNaN(s.Location.Y))
                    {
                        continue;
                    }
                    var x = (s.Location.X - F.subX) * F.xScale;
                    var y = F.pbCanvas.Height - (s.Location.Y - F.subY) * F.yScale;
                    if (x < 0 || y < 0)
                    {
                        continue;
                    }

                    var scaledItem = new PointF()
                    {
                        X = x, Y = y
                    };
                    s.Location2D.X = scaledItem.X; s.Location2D.Y = scaledItem.Y;
                    if (s.Signal.isSignalNormal())
                    {
                        var color = Brushes.Lime; // bright colour for readability
                        var pen   = F.greenPen;
                        if (s.IsProceed == 0)
                        {
                        }
                        else if (s.IsProceed == 1)
                        {
                            color = Brushes.Yellow; // bright colour for readbility
                            pen   = F.orangePen;
                        }
                        else
                        {
                            color = Brushes.Red;
                            pen   = F.redPen;
                        }
                        g.FillEllipse(color, DispatchViewer.GetRect(scaledItem, width));
                        F.signalItemsDrawn.Add(s);
                        if (s.hasDir)
                        {
                            scaledB.X = (s.Dir.X - F.subX) * F.xScale; scaledB.Y = F.pbCanvas.Height - (s.Dir.Y - F.subY) * F.yScale;
                            g.DrawLine(pen, scaledItem, scaledB);
                        }
                        ShowSignalState(g, scaledItem, s);
                    }
                }
            }
        }
Example #3
0
        }                                     // Shortest possible abbreviation so code is easier to read.

        public TimetableWindow(DispatchViewer form)
        {
            F = form;
        }