示例#1
0
        public void Draw(Graphics g, TimeEntry startTime, TimeEntry endTime, bool drawHeader, float?forceWidth = null, bool exportColor = false)
        {
            g.Clear(attrs.BgColor.ToSD(exportColor));

            var path     = getPathData();
            var stations = path.GetRawPath().ToList();

            var margin = CalcMargins(g, defaultMargin, stations, startTime, endTime, drawHeader);
            var width  = forceWidth ?? g.ClipBounds.Width;
            var height = GetHeight(g, startTime, endTime, drawHeader);

            // Zeitaufteilung
            var timeRenderer = new TimeRenderer(attrs);

            timeRenderer.Render(g, margin, startTime, endTime, width, exportColor);

            // Stationenaufteilung
            var headerRenderer = new HeaderRenderer(attrs, path);
            var stationOffsets = headerRenderer.Render(g, margin, width, height, drawHeader, exportColor);

            // Züge
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.SetClip(new RectangleF(0 /*margin.Left*/, margin.Top, width /*- margin.Left - margin.Right*/, height - margin.Bottom - margin.Top));

            var trains        = tt.Trains.Where(t => t.Days.IsIntersecting(attrs.RenderDays));
            var trainRenderer = new TrainRenderer(stations, tt, margin, startTime, stationOffsets, attrs.RenderDays);

            foreach (var train in trains)
            {
                trainRenderer.Render(g, train, exportColor);
            }
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
        }
示例#2
0
文件: Renderer.cs 项目: fadoe/FPLedit
        public void Draw(Graphics g, TimeSpan startTime, TimeSpan endTime, bool drawHeader)
        {
            g.Clear((Color)attrs.BgColor);

            var stations = tt.GetRoute(route).GetOrderedStations();

            if (!margin.Calced)
            {
                margin = CalcMargins(g, margin, stations, startTime, endTime, drawHeader);
            }
            margin.Calced = true;

            if (width == 0)
            {
                width = g.ClipBounds.Width;
            }
            if (height == 0)
            {
                height = GetHeight(startTime, endTime, drawHeader);
            }

            // Zeitaufteilung
            var timeRenderer = new TimeRenderer(attrs, this);

            timeRenderer.Render(g, margin, startTime, endTime, width);

            // Stationenaufteilung
            var headerRenderer = new HeaderRenderer(stations, attrs, route);
            var stationOffsets = headerRenderer.Render(g, margin, width, height, drawHeader);

            // Züge
            g.AntiAlias = true;
            var clip = g.ClipBounds;

            clip.Y      += margin.Top;
            clip.Height -= (margin.Top + margin.Bottom + 1);
            g.SetClip(clip);

            var trains = tt.Trains.Where(t =>
            {
                for (int i = 0; i < 6; i++)
                {
                    if (attrs.RenderDays[i] && t.Days[i])
                    {
                        return(true);
                    }
                }
                return(false);
            });
            var trainRenderer = new TrainRenderer(stations, tt, margin, startTime, stationOffsets);

            foreach (var train in trains)
            {
                trainRenderer.Render(g, train);
            }
            g.AntiAlias = false;
        }