public override void Draw(System.Drawing.Graphics g, System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog) { using (Brush brush = new SolidBrush(pen.Color)) { PointF[] points = new PointF[] { this.Center }; this.Transform(matrixValueToScreen, isLog, points); if (graphRectangle.Contains(points[0])) { g.FillEllipse(brush, points[0].X - this.Size, points[0].Y - this.Size, this.Size * 2, this.Size * 2); } } }
public override void Draw(Graphics g, Pen pen, System.Drawing.Drawing2D.Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog) { using (Brush brush = new SolidBrush(pen.Color)) { PointF[] points = new PointF[] { this.TopLeft, this.TopRight, this.BottomRight, this.BottomLeft, this.TopLeft }; this.Transform(matrixValueToScreen, isLog, points); if (graphRectangle.Contains(points[0])) { g.DrawLines(pen, points); } } }
public override Segment2D Trim(Rectangle2D rect) { Segment2D segment = new Segment2D(); if (rect.Contains(this.Point1)) { segment.Point1 = this.Point1; PointF[] points = this.Intersection(rect); if (points.Length == 1) { segment.Point2 = points[0]; } else { StockLog.Write("Exception"); } } else { return new Line2D(this.Point1, this.Point2).Trim(rect); } return segment; }
public override void GraphControl_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (!this.Focused) this.Focus(); if (!this.IsInitialized || this.curveList == null) { return; } // Notify listeners if (this.lastMouseIndex != -1 && this.PointPick != null) { PointPick(lastMouseIndex, this.dateSerie[lastMouseIndex]); } PointF mousePoint = new PointF(e.X, e.Y); // Allow clicking in the margin for usability purpose if (((e.X - this.GraphRectangle.Right) > 0.0f) && ((e.X - this.GraphRectangle.Right) < 20.0f)) { mousePoint.X = this.GraphRectangle.Right - 1; } Rectangle2D rect2D = new Rectangle2D(this.GraphRectangle); if (rect2D.Contains(mousePoint)) { PointF mouseValuePoint; if (this.Magnetism) { mouseValuePoint = FindClosestExtremum(GetValuePointFromScreenPoint(mousePoint)); } else { mouseValuePoint = GetValuePointFromScreenPoint(mousePoint); } if (this.DrawingMode == GraphDrawMode.Normal) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { // Create horizontal line is CTRL key is pressed if ((Control.ModifierKeys & Keys.Control) != 0) { if ((Control.ModifierKeys & Keys.Shift) != 0) { // Draw vertical line mouseValuePoint = GetValuePointFromScreenPoint(mousePoint); Line2D newLine = (Line2D) new Line2D(mouseValuePoint, 0.0f, 1.0f, this.DrawingPen); drawingItems.Add(newLine); AddToUndoBuffer(GraphActionType.AddItem, newLine); this.DrawingStep = GraphDrawingStep.SelectItem; this.BackgroundDirty = true; // The new line becomes a part of the background selectedLineIndex = -1; } else { // Draw horizontal line Line2D newLine = (Line2D) new Line2D(mouseValuePoint, 1.0f, 0.0f, this.DrawingPen); drawingItems.Add(newLine); AddToUndoBuffer(GraphActionType.AddItem, newLine); this.DrawingStep = GraphDrawingStep.SelectItem; this.BackgroundDirty = true; // The new line becomes a part of the background selectedLineIndex = -1; } } else // Show daily values box { if (!forceNoValueBoxDisplay) { this.PaintDailyBox(mousePoint); } } } else { this.contextMenu.Show(this, e.Location); } } else { MouseClickDrawing(e, ref mousePoint, ref mouseValuePoint); } this.PaintForeground(); } }