/// <summary> /// Render the Value onto the control at post-render indicator time /// </summary> /// <param name="sender">KnobControl</param> /// <param name="e">PostRenderEventArgs</param> private void PostRenderKnobIndicator1(object sender, PostRenderEventArgs e) { KnobControl kc = sender as KnobControl; if (kc != null) { // Draw the knob Value (with an offset shadow) // on top of the KnobIndicator using (Font font = new Font("Arial", 30, FontStyle.Regular)) { using (StringFormat strFormat = new StringFormat(StringFormatFlags.NoClip)) { strFormat.Alignment = StringAlignment.Center; string s = kc.Value.ToString(); if (s.EndsWith(".0")) { s = s.Substring(0, s.Length - 2); } RectangleF r = GetTextRect(e.Bounds, font); r.Offset(2, 2); e.Graphics.DrawString(s, font, Brushes.Black, r, strFormat); r.Offset(-2, -2); e.Graphics.DrawString(s, font, Brushes.White, r, strFormat); } } } }
private void DrawNetRegressionLine(ctlChartBase sender, PostRenderEventArgs args) { try { if (mcheckBox_displayRegression.Checked == false) { return; } foreach (Analysis analysis in m_displayCache.Keys) { // Here we only draw the regression line for the selected analysis, unless it's null, which means the user wants to see all of the analysis together. if (analysis == m_selectedAnalysis || m_selectedAnalysis == null) { if (analysis.ProcessedState == ProcessingState.Processed) { // IRegressionAlgorithm regressor = analysis.RegressionResults.Regressor; float xFrom = sender.ViewPort.X; float xFinal = sender.ViewPort.Right; clsColorIterator iterator = new clsColorIterator(); Color color = iterator.GetColor(analysis.Id); color = Color.FromArgb(120, color); using (Pen mpen_line = new Pen(color, 5)) { if (!mcheckBox_useResiduals.Checked) { int numDivisions = 10; float step = (xFinal - xFrom) / numDivisions; for (; xFrom < xFinal; xFrom += step) { // float yFrom = Convert.ToSingle(regressor.GetTransformedNET(Convert.ToInt32(xFrom))); // float xTo = xFrom + step; // float yTo = Convert.ToSingle(regressor.GetTransformedNET(Convert.ToInt32(xTo))); // args.Graphics.DrawLine(mpen_line, sender.GetScreenPixelX(xFrom), sender.GetScreenPixelY(yFrom), // sender.GetScreenPixelX(xTo), sender.GetScreenPixelY(yTo)); } } else { args.Graphics.DrawLine(mpen_line, sender.GetScreenPixelX(xFrom), sender.GetScreenPixelY(0), sender.GetScreenPixelX(xFinal), sender.GetScreenPixelY(0)); } } } } } } catch (Exception) { // who cares! } }
/// <summary> /// Render the control Value at post-render indicator time /// </summary> /// <param name="sender">KnobControl</param> /// <param name="e">PostRenderEventArgs</param> private void PostRenderKnobIndicator2(object sender, PostRenderEventArgs e) { KnobControl kc = sender as KnobControl; if (kc != null) { // Draw the knob Value on top of the KnobIndicator using (Font font = new Font("Arial", 16, FontStyle.Regular)) { using (StringFormat strFormat = new StringFormat(StringFormatFlags.NoClip)) { strFormat.Alignment = StringAlignment.Center; RectangleF r = GetTextRect(e.Bounds, font); e.Graphics.DrawString(kc.Value.ToString(), font, Brushes.Black, r, strFormat); } } } }