Example #1
0
        private void DrawEdge(Edge e)
        {
            if (e == null)
            {
                return;
            }

            int   thickness = e.IsDouble ? doubleThickness : normalThickness;
            Brush b         = Brushes.Black;

            if (e.HasRail)
            {
                b         = Brushes.Red;
                thickness = railThickness;
            }

            LineCoordinates coords = CoordsFromEdge(e);

            double x1       = pointSize / 2 + coords.startX + leftShift;
            double x2       = pointSize / 2 + coords.endX + leftShift;
            double y1       = topShift + pointSize / 2 + coords.startY * heightScale;
            double y2       = topShift + pointSize / 2 + coords.endY * heightScale;
            Line   edgeLine = new Line()
            {
                Stroke = b, StrokeThickness = thickness, X1 = x1, X2 = x2, Y1 = y1, Y2 = y2
            };

            edgeLine.Tag         = e;
            edgeLine.MouseEnter += MouseOverEdge;
            edgeLine.MouseLeave += MouseOutEdge;
            edgeLine.MouseUp    += MouseClickEdge;
            gameCanvas.Children.Add(edgeLine);
        }
Example #2
0
        private LineCoordinates CoordsFromEdge(Edge e)
        {
            LineCoordinates coords = new LineCoordinates();

            coords.startX = LeftFromVertex(e.From);
            coords.endX   = LeftFromVertex(e.To);
            coords.startY = TopFromVertex(e.From);
            coords.endY   = TopFromVertex(e.To);

            return(coords);
        }