public void Draw(CoordinateTransformer coordinateSystem, BrushProvider brushProvider, Graphics graphicsObj) { var bounds = new Rectangle(); bounds.X = (int)coordinateSystem.ValidTimeToX(validFrom); bounds.Y = (int)coordinateSystem.RecordTimeToY(recordTo); bounds.Width = (int)coordinateSystem.ValidTimeToX(validTo) - bounds.X; bounds.Height = (int)coordinateSystem.RecordTimeToY(recordFrom) - bounds.Y; if (bounds.Width == 0 || bounds.Height == 0) return; var brush = brushProvider.GetBrush(transactionId, transactionId, recordFrom, recordTo, validFrom, validTo, new Rectangle(bounds.Y, bounds.X, bounds.Height, bounds.Width)); var pen = new Pen(Color.Black, 1); graphicsObj.FillRectangle(brush, bounds); graphicsObj.DrawRectangle(pen, bounds); var text = String.Format("T:{0} / R:{1}", transactionId, String.Join(", ", revIds)); var font = new Font("Lucida Console", 10f); var textBrush = new SolidBrush(Color.Black); var height = graphicsObj.MeasureString(text, font).Height; if (validFrom == DateTime.MinValue) { bounds.X += 10; } if(coordinateSystem.fontVisible) graphicsObj.DrawString(text, font, textBrush, bounds.X, bounds.Bottom - height); brush.Dispose(); }
public void Draw(CoordinateTransformer coordinateSystem, BrushProvider brushProvider, Graphics graphicsObj) { foreach (var version in transactions.Values) { version.Draw(coordinateSystem, brushProvider, graphicsObj); } }
public Form1() { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); checkpoint = new Checkpoint(); var mins = checkpoint.MinCorner(); CoordinateTransformer.start = mins.Item1.recordFrom; var tran = new CoordinateTransformer(zoom, offsetX, offsetY); if (mins.Item2.validFrom == DateTime.MinValue) { offsetX = -tran.ValidTimeToX(DateTime.Now); } else offsetX = -tran.ValidTimeToX(mins.Item2.validFrom) + 50; offsetY = tran.RecordTimeToY(mins.Item1.recordFrom) - 500; }
private void Form1_Paint(object sender, PaintEventArgs e) { long tranId = hoverVersion == null ? 0L : hoverVersion.transactionId; var coords = new CoordinateTransformer(zoom, offsetX, offsetY); checkpoint.Draw(coords, new BrushProvider(tranId), e.Graphics); e.Graphics.FillRectangle(new SolidBrush(Color.White), 680, 0, 400, 900 ); e.Graphics.DrawString(hoverText, new Font("Lucida Console", 10), new SolidBrush(Color.Black), 685, 10); var pen = new Pen(new SolidBrush(Color.DarkGray)); e.Graphics.DrawLine(pen, mouseX, 0, mouseX, 1000); e.Graphics.DrawLine(pen, 0, mouseY, 1000, mouseY); var now = (int)coords.RecordTimeToY(DateTime.Now); e.Graphics.DrawLine(pen, 0, now, 1000, now); }
public Version FindVersion(CoordinateTransformer coords, int x, int y) { var validTime = coords.XToValidTime(x); var recordTime = coords.YToRecordTime(y); return transactions.SingleOrDefault(kvp => kvp.Value.recordFrom <= recordTime && kvp.Value.recordTo >= recordTime && kvp.Value.validFrom <= validTime && kvp.Value.validTo >= validTime).Value; }