public void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { // draw a circle for each point for (int i = 0; i < m_Points.Count; i++) { MousePoint site = m_Points[i]; Point p = site.Location; float sz = site.Size; if (sz > 0) { NStrokeStyle strokeStyle = null; if ((site.MouseButtons & MouseButtons.Left) != 0) { strokeStyle = m_StrokeCrimson; } else { strokeStyle = m_StrokeMediumSeaGreen; } if ((site.MouseButtons & MouseButtons.Right) != 0) { sz *= 4; } eventArgs.Graphics.PaintEllipse(null, strokeStyle, new NRectangleF(p.X - sz / 2, p.Y - sz / 2, sz, sz)); } } }
/// <summary> /// Occurs before the panel is painted. /// </summary> /// <param name="panel"></param> /// <param name="eventArgs"></param> public override void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs) { NChart chart = (NChart)panel; double dAxisMin = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange.Begin; double dAxisMax = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange.End; m_UserControl.labelMinValue.Text = dAxisMin.ToString(); m_UserControl.labelMaxValue.Text = dAxisMax.ToString(); }
public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { if (m_Parent.m_bUpdateWatermark == false) { return; } // intercepts the on chart after paint event and converts // point or XYZ coordniates to chart viewport coordinates // used to position the custom watermark NChartControl chartControl = m_Parent.nChartControl1; NWatermark watermark = chartControl.Watermarks[0]; NChart chart = m_Parent.nChartControl1.Charts[0]; NPointF viewPoint = new NPointF(); NVector3DF vecModelPoint = new NVector3DF(); NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(chartControl.View.Context, chart.Projection); switch (m_Parent.WatermarkPositionComboBox.SelectedIndex) { case 0: vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, (double)m_Parent.XPositionNumericUpDown.Value); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, (double)m_Parent.YPositionNumericUpDown.Value); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, (double)m_Parent.ZPositionNumericUpDown.Value); break; case 1: NVector3DF vecPoint = new NVector3DF(); int nIndex = (int)m_Parent.DataPointNumericUpDown.Value; vecPoint.X = (float)(double)(m_Parent.m_Point.XValues[nIndex]); vecPoint.Y = (float)(double)(m_Parent.m_Point.Values[nIndex]); vecPoint.Z = (float)(double)(m_Parent.m_Point.ZValues[nIndex]); vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, vecPoint.X); vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, vecPoint.Y); vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, vecPoint.Z); break; } model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint); // convert the view point to parent pixel coordinates watermark.TransformViewPointToParent(ref viewPoint); watermark.Location = new NPointL( new NLength(viewPoint.X, NGraphicsUnit.Pixel), new NLength(viewPoint.Y, NGraphicsUnit.Pixel)); m_Parent.nChartControl1.RecalcLayout(); }
public override void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs) { NChart chart = panel as NChart; NRange1DD rulerRange = chart.Axis(StandardAxis.PrimaryY).Scale.RulerRange; NLabel label = new NLabel(); label.Location = new NPointL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(0, NRelativeUnit.ParentPercentage)); label.ContentAlignment = ContentAlignment.BottomLeft; label.TextStyle.FontStyle.EmSize = new NLength(10); label.Text = " Min[" + rulerRange.Begin + "] Max[" + rulerRange.End + "]"; chart.ChildPanels.Add(label); chart.RecalcLayout(eventArgs.Context); }
public override void Create() { m_Random = new Random(); nChartControl1.Panels.Clear(); NDigitalClockPanel digitalClock = new NDigitalClockPanel(); digitalClock.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(digitalClock); m_Indicator1 = new NRangeIndicator(30); m_Indicator2 = new NRangeIndicator(40); m_Indicator3 = new NRangeIndicator(50); NPanel meter1 = CreateStatusMeterPanel("Battery Meter 1", new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)), m_Indicator1); NPanel meter2 = CreateStatusMeterPanel("Battery Meter 2", new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(45, NRelativeUnit.ParentPercentage)), m_Indicator2); NPanel meter3 = CreateStatusMeterPanel("Battery Meter 3", new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)), m_Indicator3); nChartControl1.Panels.Add(meter1); nChartControl1.Panels.Add(meter2); nChartControl1.Panels.Add(meter3); m_Timer = new Timer(); m_Timer.Interval = 1000; m_Timer.Elapsed += m_Timer_Elapsed; //+= m_Timer_Tick; m_Timer.Start(); }
public void ShowPanel(NPanel panel) { switch (panel) { case NPanel.Start: StartPanel.SetActive(true); ReloadPanel.SetActive(false); EndPanel.SetActive(false); break; case NPanel.Reload: StartPanel.SetActive(false); ReloadPanel.SetActive(true); EndPanel.SetActive(false); break; case NPanel.End: StartPanel.SetActive(false); ReloadPanel.SetActive(false); EndPanel.SetActive(true); break; } }
public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { NGraphics graphics = eventArgs.Graphics; double dPreviousValue, dCurrentValue; int nBarCount = 10; NChart chart = panel as NChart; NBarSeries bar = (NBarSeries)chart.Series[0]; NAxis horzAxis = chart.Axis(StandardAxis.PrimaryX); NAxis vertAxis = chart.Axis(StandardAxis.PrimaryY); NVector3DF vecClientPoint = new NVector3DF(); NVector3DF vecModelPoint = new NVector3DF(); int nBarSize = (int)(chart.ContentArea.Width * (int)bar.WidthPercent) / (nBarCount * 200); // init pens and brushes NStrokeStyle rectStrokeStyle = new NStrokeStyle(1, Color.DarkBlue); NFillStyle rectFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.LightBlue), Color.FromArgb(125, Color.DarkBlue)); NLightingImageFilter lightingFilter = new NLightingImageFilter(); NStrokeStyle positiveArrowStrokeStyle = new NStrokeStyle(1, Color.DarkGreen); NFillStyle positiveArrowFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Green, Color.DarkGreen); positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter); NStrokeStyle equalSignStrokeStyle = new NStrokeStyle(1, Color.DarkGray); NFillStyle equalSignFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Gray, Color.DarkGray); positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter); NStrokeStyle negativeArrowStrokeStyle = new NStrokeStyle(1, Color.DarkRed); NFillStyle negativeArrowFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Red, Color.DarkRed); positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter); for (int i = 1; i < bar.Values.Count; i++) { dPreviousValue = (double)bar.Values[i - 1]; dCurrentValue = (double)bar.Values[i]; vecModelPoint.X = horzAxis.TransformScaleToModel(false, i); vecModelPoint.Y = vertAxis.TransformScaleToModel(false, (float)(double)bar.Values[i]); vecModelPoint.Z = 0; if (!chart.TransformModelToClient(vecModelPoint, ref vecClientPoint)) { continue; } RectangleF rcArrowRect = new RectangleF(vecClientPoint.X - nBarSize, vecClientPoint.Y - nBarSize, 2 * nBarSize, 2 * nBarSize); if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0) { continue; } if (!DisplayMark(dCurrentValue, dPreviousValue)) { continue; } // draw arrow background GraphicsPath path = GetRoundRectanglePath(rcArrowRect); graphics.PaintPath(rectFillStyle, rectStrokeStyle, path); path.Dispose(); rcArrowRect.Inflate(-5, -5); // draw the arrow itself if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0) { continue; } if (dCurrentValue < dPreviousValue) { // draw negative arrow path = GetArrowPath(rcArrowRect, false); graphics.PaintPath(negativeArrowFillStyle, negativeArrowStrokeStyle, path); path.Dispose(); } else if (dCurrentValue > dPreviousValue) { // draw positive arrow path = GetArrowPath(rcArrowRect, true); graphics.PaintPath(positiveArrowFillStyle, positiveArrowStrokeStyle, path); path.Dispose(); } else { // draw equal sign NRectangleF rect = new NRectangleF(rcArrowRect.Left, rcArrowRect.Top, rcArrowRect.Width, rcArrowRect.Height / 3.0f); graphics.PaintRectangle(equalSignFillStyle, equalSignStrokeStyle, rect); rect = new NRectangleF(rcArrowRect.Left, rcArrowRect.Bottom - rect.Height, rcArrowRect.Width, rect.Height); graphics.PaintRectangle(equalSignFillStyle, equalSignStrokeStyle, rect); } } }
public void OnBeforePaint(NPanel panel, NPanelPaintEventArgs eventArgs) { }
public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { Graphics graphics = eventArgs.Graphics.DeviceGraphics; double dPreviousValue, dCurrentValue; int nBarCount = 10; NChart chart = panel as NChart; NBarSeries bar = (NBarSeries)chart.Series[0]; NAxis horzAxis = chart.Axis(StandardAxis.PrimaryX); NAxis vertAxis = chart.Axis(StandardAxis.PrimaryY); NVector3DF vecClientPoint = new NVector3DF(); NVector3DF vecModelPoint = new NVector3DF(); int nBarSize = (int)(chart.ContentArea.Width * (int)bar.WidthPercent) / (nBarCount * 200); // init pens and brushes Pen penRectBorder = new Pen(Color.DarkBlue); SolidBrush brushRectFill = new SolidBrush(Color.FromArgb(125, Color.LightBlue)); Pen penPositiveArrowBorder = new Pen(Color.DarkGreen); SolidBrush brushPositiveArrowFill = new SolidBrush(Color.Green); Pen penEqualSignBorder = new Pen(Color.DarkGray); SolidBrush brushEqualSignFill = new SolidBrush(Color.Gray); Pen penNegativeArrowBorder = new Pen(Color.DarkRed); SolidBrush brushNegativeArrowFill = new SolidBrush(Color.Red); for (int i = 1; i < bar.Values.Count; i++) { dPreviousValue = (double)bar.Values[i - 1]; dCurrentValue = (double)bar.Values[i]; vecModelPoint.X = horzAxis.TransformScaleToModel(false, i); vecModelPoint.Y = vertAxis.TransformScaleToModel(false, (float)(double)bar.Values[i]); vecModelPoint.Z = 0; if (!chart.TransformModelToClient(vecModelPoint, ref vecClientPoint)) { continue; } RectangleF rcArrowRect = new RectangleF(vecClientPoint.X - nBarSize, vecClientPoint.Y - nBarSize, 2 * nBarSize, 2 * nBarSize); if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0) { continue; } if (!DisplayMark(dCurrentValue, dPreviousValue)) { continue; } // draw arrow background GraphicsPath path = GetRoundRectanglePath(rcArrowRect); graphics.FillPath(brushRectFill, path); graphics.DrawPath(penRectBorder, path); path.Dispose(); rcArrowRect.Inflate(-5, -5); // draw the arrow itself if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0) { continue; } if (dCurrentValue < dPreviousValue) { // draw negative arrow path = GetArrowPath(rcArrowRect, false); graphics.FillPath(brushNegativeArrowFill, path); graphics.DrawPath(penNegativeArrowBorder, path); path.Dispose(); } else if (dCurrentValue > dPreviousValue) { // draw positive arrow path = GetArrowPath(rcArrowRect, true); graphics.FillPath(brushPositiveArrowFill, path); graphics.DrawPath(penPositiveArrowBorder, path); path.Dispose(); } else { // draw equal sign RectangleF rect = new RectangleF(rcArrowRect.Left, rcArrowRect.Top, rcArrowRect.Width, rcArrowRect.Height / 3.0f); graphics.FillRectangle(brushEqualSignFill, rect.Left, rect.Top, rect.Width, rect.Height); graphics.DrawRectangle(penEqualSignBorder, rect.Left, rect.Top, rect.Width, rect.Height); rect = new RectangleF(rcArrowRect.Left, rcArrowRect.Bottom - rect.Height, rcArrowRect.Width, rect.Height); graphics.FillRectangle(brushEqualSignFill, rect.Left, rect.Top, rect.Width, rect.Height); graphics.DrawRectangle(penEqualSignBorder, rect.Left, rect.Top, rect.Width, rect.Height); } } // dispose pens and brushes penPositiveArrowBorder.Dispose(); brushPositiveArrowFill.Dispose(); penNegativeArrowBorder.Dispose(); brushNegativeArrowFill.Dispose(); brushRectFill.Dispose(); penRectBorder.Dispose(); }
/// <summary> /// Occurs after the panel is painted. /// </summary> /// <param name="panel"></param> /// <param name="eventArgs"></param> public virtual void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs) { }