public TFRProfileWindow([NotNull] ArcticFoxConfiguration.TFRTable tfrTable) { if (tfrTable == null) { throw new ArgumentNullException("tfrTable"); } m_tfrTable = tfrTable; InitializeComponent(); InitializeChart(); InitializeControls(); InitializeWorkspace(); }
internal static Bitmap CreateTFRCurvePreview(ArcticFoxConfiguration.TFRTable tfrTable, Size size) { const float percentMaxValue = 4; var actualMinTemperature = tfrTable.Points.Min(x => x.Temperature); var actualMaxTemperature = tfrTable.Points.Max(x => x.Temperature) - actualMinTemperature; var actualWidth = size.Width - 1; var actualHeight = size.Height - 1; var bitmap = new Bitmap(size.Width, size.Height); using (var gfx = Graphics.FromImage(bitmap)) { gfx.Clear(Color.White); var chartPoints = new PointF[tfrTable.Points.Length]; for (var i = 0; i < tfrTable.Points.Length; i++) { var powerPoint = tfrTable.Points[i]; var xRaw = powerPoint.Temperature - actualMinTemperature; var yRaw = powerPoint.Factor / 10000f; // 4 is a sum of 2 pixel paddings from left and right. var x = xRaw * (actualWidth - 4) / actualMaxTemperature; var y = actualHeight - yRaw * actualHeight / percentMaxValue; // Realize padding from left by 2 pixels. chartPoints[i] = new PointF(x + 2, y); } DrawGrid(gfx, 10, 5, actualWidth, actualHeight); gfx.DrawLines(new Pen(Color.YellowGreen, 1), chartPoints); gfx.DrawRectangle(Pens.LightGray, 0, 0, actualWidth, actualHeight); } return(bitmap); }