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; }
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; }
public void DrawHeader(Graphics g, int width) { g.Clear((Color)attrs.BgColor); var stations = tt.GetRoute(route).Stations; var margin = CalcMargins(g, deafultHeaderMargin, stations, attrs.StartTime, attrs.EndTime, true); var height = GetHeight(g, TimeEntry.Zero, TimeEntry.Zero, true); // Draw empty timespan. // Stationenaufteilung var headerRenderer = new HeaderRenderer(stations, attrs, route); headerRenderer.Render(g, margin, width, height, true); }
public void DrawHeader(Graphics g, int width, bool exportColor) { g.Clear(attrs.BgColor.ToSD(exportColor)); var path = getPathData(); var stations = path.GetRawPath().ToList(); var margin = CalcMargins(g, deafultHeaderMargin, stations, attrs.StartTime, GetEndTime(attrs.StartTime, attrs.EndTime), true); var height = GetHeight(g, TimeEntry.Zero, TimeEntry.Zero, true); // Draw empty timespan. // Stationenaufteilung var headerRenderer = new HeaderRenderer(attrs, path); headerRenderer.Render(g, margin, width, height, true, exportColor); }
private Margins CalcMargins(Graphics g, Margins orig, IEnumerable <Station> stations, TimeEntry startTime, TimeEntry endTime, bool drawHeader) { const int additionalMargin = 5; var result = new Margins(orig.Left + additionalMargin, orig.Top + additionalMargin, orig.Right + additionalMargin, orig.Bottom + additionalMargin); // MarginTop berechnen var hr = new HeaderRenderer(stations, attrs, route); result.Top = drawHeader ? ( attrs.DrawHeader ? hr.GetMarginTop(g) + result.Top : result.Top) : 5; // MarginLeft berechnen var tr = new TimeRenderer(attrs); result.Left += tr.GetMarginLeftOffset(g, startTime, endTime); return(result); }