public void Dispose() { AxisPen.Dispose(); AxisFont.Dispose(); AxisBrush.Dispose(); LegendFont.Dispose(); LegendBrush.Dispose(); foreach (Pen pen in SeriesPens) { pen.Dispose(); } }
/// <summary> /// Draw axis with all lines /// </summary> /// <param name="gl"></param> private void DrawAxis(OpenGL gl, double width, double height) { //Get the axis color, secondary lines color and ticks color var axisLineColor = AxisBrush.GetRGBAf(); var axisSecondaryLineColor = SecondaryGridBrush.GetRGBAf(); var ticksColor = TicksBrush.GetRGBAf(); var ticksScaleColor = TicksScaleBrush.GetRGBAf(); // Get length of Tick line double tickWidth = 5; #region Draw YTicks and labels // Ticks line of axis-Y and ticks double gapY = height / (YGapCount + 1); double realValueOfGapY = (MaxY - MinY) / (YGapCount + 1); for (int num = 0; num <= YGapCount + 1; num++) { double posX = tickWidth; double posY = gapY * num; // Draw secondary line if (IsSecondaryLineVisible) { gl.PushAttrib(OpenGL.GL_ENABLE_BIT); if (IsDotDash) { gl.LineStipple(1, 0xAAAA); gl.Enable(OpenGL.GL_LINE_STIPPLE); } else { gl.Disable(OpenGL.GL_LINE_STIPPLE); } gl.Color(axisSecondaryLineColor[0], axisSecondaryLineColor[1], axisSecondaryLineColor[2]);// will be chaged by drawText if without it gl.Begin(OpenGL.GL_LINES); gl.Vertex(0.0d, posY); gl.Vertex(width, posY); gl.End(); gl.PopAttrib(); } // Draw ticks line gl.Color(ticksScaleColor[0], ticksScaleColor[1], ticksScaleColor[2]);// will be chaged by drawText if without it gl.Begin(OpenGL.GL_LINES); gl.Vertex(0.0d, posY); gl.Vertex(tickWidth, posY); gl.End(); // Draw ticks string dispText = (num * realValueOfGapY + MinY).ToString("f2"); double textWidth = 0, textHeight = 0; GetSizeOfText(gl, dispText, ref textWidth, ref textHeight); double textPosX = 2 * tickWidth; double textPosY = num == YGapCount + 1 ? posY - textHeight : (num == 0 ? posY + 2 : posY); DrawString(gl, dispText, (int)textPosX, (int)textPosY, ticksColor); } #endregion #region Draw XTicks and labels // Ticks line of axis-X and ticks double gapX = width / (XGapCount + 1); double realValueOfGapX = (MaxX - MinX).TotalMilliseconds / (XGapCount + 1);// Milliseconds in one gap for (int num = 0; num <= XGapCount + 1; num++) { double posX = num * gapX; // Draw secondary line if (IsSecondaryLineVisible) { gl.PushAttrib(OpenGL.GL_ENABLE_BIT); if (IsDotDash) { gl.LineStipple(1, 0xAAAA); gl.Enable(OpenGL.GL_LINE_STIPPLE); } else { gl.Disable(OpenGL.GL_LINE_STIPPLE); } gl.Color(axisSecondaryLineColor[0], axisSecondaryLineColor[1], axisSecondaryLineColor[2]);// will be chaged by drawText if without it gl.Begin(OpenGL.GL_LINES); gl.Vertex(posX, 0.0d); gl.Vertex(posX, height); gl.End(); gl.PopAttrib(); } // Draw ticks line gl.Color(ticksScaleColor[0], ticksScaleColor[1], ticksScaleColor[2]);// will be chaged by drawText if without it gl.Begin(OpenGL.GL_LINES); gl.Vertex(posX, 0.0d); gl.Vertex(posX, tickWidth); gl.End(); // Draw text string dispText = (MinX + TimeSpan.FromMilliseconds(realValueOfGapX * num)).ToString("HH:mm:ss"); double textWidth = 0, textHeight = 0; GetSizeOfText(gl, dispText, ref textWidth, ref textHeight); double textPosX = num == XGapCount + 1 ? posX - textWidth - 5 : posX - textWidth / 2; double textPosY = tickWidth + textHeight / 2; DrawString(gl, dispText, (int)textPosX, (int)textPosY, ticksColor); } #endregion #region Draw Axis-X and Axis-Y // Left line of axis-Y gl.Color(axisLineColor[0], axisLineColor[1], axisLineColor[2]); gl.Begin(OpenGL.GL_LINES); gl.Vertex(0.0d, 0.0d); gl.Vertex(0.0d, height); gl.End(); // Draw right line when the axis is boxed if (IsBoxed) { gl.Begin(OpenGL.GL_LINES); gl.Vertex(width, 0.0d); gl.Vertex(width, height); gl.End(); } // Left line of axis-Y gl.Color(axisLineColor[0], axisLineColor[1], axisLineColor[2]); gl.Begin(OpenGL.GL_LINES); gl.Vertex(0.0d, 0.0d); gl.Vertex(width, 0.0d); gl.End(); // Draw right line when the axis is boxed if (IsBoxed) { gl.Begin(OpenGL.GL_LINES); gl.Vertex(0.0d, height); gl.Vertex(width, height); gl.End(); } #endregion }