/// <summary> /// Draws the partition. /// </summary> /// <param name="painter">The graphics object with which to draw.</param> /// <param name="centerPoint">Center point of the partition.</param> protected override void DrawPartition(Graphics painter, GraphPoint centerPoint, int partitionNumber) { GraphPoint beginning = centerPoint, end = centerPoint; //Calculates the ends of the partition-line beginning.RealY -= 4; end.RealY += 4; StringFormat format = new StringFormat(); format.FormatFlags = StringFormatFlags.DirectionVertical; string numberToDraw = partitionNumber.ToString(); if (partitionNumber > 999 && partitionNumber < 10000000) { numberToDraw = numberToDraw.Remove(numberToDraw.Length - 3); numberToDraw = string.Concat(numberToDraw, "k"); } else if (partitionNumber > 9999999) { numberToDraw = numberToDraw.Remove(numberToDraw.Length - 7); numberToDraw = string.Concat(numberToDraw, "m"); } DrawLine(beginning, end, painter, Color.Black); end.RealY += Constants.partitionOffset; DrawNumber(painter, end, numberToDraw, format); }
/// <summary> /// Draws the number. /// </summary> /// <param name="painter">Painter.</param> /// <param name="centerPoint">Center point.</param> /// <param name="toDraw">To draw.</param> /// <param name="format">Format.</param> protected void DrawNumber(Graphics painter, GraphPoint centerPoint, string toDraw, StringFormat format) { Rectangle Rec = new Rectangle((int)centerPoint.RealX, (int)centerPoint.RealY + 12, 50, 50); Rec.X -= (Rec.Width / 2); Rec.Y -= (Rec.Height / 2); painter.DrawString(toDraw, toUse, Brushes.Black, Rec, format); }
/// <summary> /// Draw the axis with a specified Graphics object. /// </summary> /// <param name="painter">A graphics object to draw with.</param> public void Draw (Graphics painter) { GraphPoint GP = _beginsAt; DrawLine (_beginsAt, _endsAt, painter, Color.Black); DrawArrowEnds (painter); int dist = CalculateDistanceBetweenPartitions (); //Calculates the next partition and draws untill the last partition has been drawn for (int i = 0; i < _maxRange; i++) { GP = CalcNextPartition (GP); if (i % dist == 0) { DrawPartition (painter, GP, i + 1); } } }
/// <summary> /// Initializes a new instance of the <see cref="P2Graph.AbstractAxis"/> class. /// </summary> /// <param name="axisName">Axis name.</param> /// <param name="gPanel">The panel on which to draw the axis.</param> protected AbstractAxis(string axisName, MasterGraphPanel gPanel) { this._name = axisName; this._minRange = 0; this._maxRange = 1; this._MGP = gPanel; this._beginsAt = new GraphPoint(0, 0, _MGP); this._endsAt = new GraphPoint(0, 0, _MGP); CalculateAxisEnds(); while (34 < TextRenderer.MeasureText("9999", new Font(toUse.FontFamily, toUse.Size, toUse.Style)).Width) { toUse = new Font(toUse.FontFamily, toUse.Size - 0.1f, toUse.Style); } }
/// <summary> /// Draws the partition. /// </summary> /// <param name="painter">Graphics component.</param> /// <param name="centerPoint">Center point.</param> /// <param name="partitionNumber">Partition number.</param> protected abstract void DrawPartition(Graphics painter, GraphPoint centerPoint, int partitionNumber);
/// <summary> /// Draws a line between two points. /// </summary> /// <param name="P1">The starting <see cref="P2Graph.GraphPoint"/> of the line.</param> /// <param name="P2">The ending <see cref="P2Graph.GraphPoint"/> of the line.</param> /// <param name="painter">The graphics object with which to draw.</param> /// <param name="col">Color of the graph</param> protected virtual void DrawLine(GraphPoint P1, GraphPoint P2, Graphics painter, Color col) { painter.DrawLine(new Pen(col, 2), P1, P2); }
/// <summary> /// Draws a number to the panel. /// </summary> /// <param name="painter">Painter.</param> /// <param name="centerPoint">Center point of the string.</param> /// <param name="toDraw">The strinsg being drawn.</param> protected void DrawNumber(Graphics painter, GraphPoint centerPoint, string toDraw) { this.DrawNumber(painter, centerPoint, toDraw, StringFormat.GenericDefault); }
/// <summary> /// Calculates the next partition. /// </summary> /// <returns>The next partition.</returns> /// <param name="currentPoint">Current point.</param> protected abstract GraphPoint CalcNextPartition(GraphPoint currentPoint);
/// <summary> /// Calculates the next partition. /// </summary> /// <returns>The next partition.</returns> /// <param name="currentPoint">Current point.</param> protected override GraphPoint CalcNextPartition (GraphPoint currentPoint) { currentPoint.RealY -= _MGP.yPixelScale; return currentPoint; }
/// <summary> /// Calculates the next partition. /// </summary> /// <returns>The next partition.</returns> /// <param name="currentPoint">Current point.</param> protected override GraphPoint CalcNextPartition(GraphPoint currentPoint) { currentPoint.RealX += _MGP.xPixelScale; return(currentPoint); }