private void ShowSwitches(System.Drawing.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.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); } } }
private void ShowSignals(System.Drawing.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.SignalNormal()) { 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); } } } }