Beispiel #1
0
        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 void Draw(Graphics g, System.Drawing.Drawing2D.Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog)
 {
     this.Draw(g, this.Pen, matrixValueToScreen, graphRectangle, isLog);
 }
        protected override void PaintTmpGraph(Graphics aGraphic)
        {
            using (MethodLogger ml = new MethodLogger(this))
             {
            #region Draw vertical lines
            if (this.ShowGrid)
            {
               DrawVerticalGridLines(aGraphic, false, 0, dateSerie.Length - 1);
            }
            #endregion

            int i = 0;
            Rectangle2D rect2D = new Rectangle2D(GraphRectangle);
            PointF[] points = null;
            foreach (GraphCurveType currentCurveType in CurveList)
            {
               if (currentCurveType.IsVisible)
               {
                  points = GetScreenPoints(0, dateSerie.Length - 1, currentCurveType.DataSerie);
                  if (points != null && points.Count() > 1)
                  {
                     aGraphic.DrawLines(currentCurveType.CurvePen, points);
                  }
               }
               i++;
            }

            this.DrawSliders(aGraphic);

            aGraphic.DrawRectangle(framePen, GraphRectangle.X, GraphRectangle.Y, GraphRectangle.Width, GraphRectangle.Height);
             }
        }
Beispiel #5
0
 public abstract Segment2D Trim(Rectangle2D rect);
Beispiel #6
0
 public abstract PointF[] Intersection(Rectangle2D rect);
Beispiel #7
0
        public override void Draw(Graphics g, Pen pen, System.Drawing.Drawing2D.Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog)
        {
            // Calculate intersection with bounding rectangle
            Line2D newLine = (Line2D)this.Transform(matrixValueToScreen, isLog);
            Segment2D trimmedSegment = newLine.Trim(graphRectangle);

            if (trimmedSegment.Point1 != PointF.Empty && trimmedSegment.Point2 != PointF.Empty)
            {
                g.DrawLine(pen, trimmedSegment.Point1, trimmedSegment.Point2);
            }
            else
            {
                StockLog.Write("Invalid line to be drawn");
            }
        }
Beispiel #8
0
 public override Segment2D Trim(Rectangle2D rect)
 {
     PointF[] points = this.Intersection(rect);
     if (points.Length < 2)
     {
         return new Segment2D();
     }
     return new Segment2D(points[0], points[1]);
 }
Beispiel #9
0
        public override PointF[] Intersection(Rectangle2D rect)
        {
            Segment2D[] segmentArray = rect.GetSegments();

            PointF[] pointArray = new PointF[] { PointF.Empty, PointF.Empty };
            int nbPoints = 0;

            PointF intersectionPoint = PointF.Empty;
            foreach (Segment2D segment in segmentArray)
            {
                intersectionPoint = segment.Intersection(this);
                if (intersectionPoint != PointF.Empty && !pointArray.Contains(intersectionPoint))
                {
                    pointArray[nbPoints++] = intersectionPoint;
                }
            }
            return pointArray.Take(nbPoints).ToArray();
        }
 public override void Draw(Graphics g, System.Drawing.Drawing2D.Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog)
 {
     throw new NotImplementedException();
 }
Beispiel #11
0
 public abstract void Draw(Graphics g, Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog);
Beispiel #12
0
 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;
 }
 protected void DrawTmpSegment(Graphics graph, Pen pen, PointF point1, PointF point2, bool useTransform, bool temporary)
 {
     // Calculate intersection with bounding rectangle
      Rectangle2D rect2D = new Rectangle2D(GraphRectangle);
      Segment2D newLine = new Segment2D(point1, point2);
      if (useTransform)
      {
     newLine.Draw(graph, pen, this.matrixValueToScreen, rect2D, this.IsLogScale);
      }
      else
      {
     newLine.Draw(graph, pen, GraphControl.matrixIdentity, rect2D, false);
      }
 }
 protected void DrawTmpItem(Graphics graph, Pen pen, DrawingItem item, bool useTransform, bool temporary)
 {
     // Calculate intersection with bounding rectangle
      Rectangle2D rect2D = new Rectangle2D(GraphRectangle);
      if (useTransform)
      {
     item.Draw(graph, pen, this.matrixValueToScreen, rect2D, this.IsLogScale);
      }
      else
      {
     item.Draw(graph, pen, GraphControl.matrixIdentity, rect2D, this.IsLogScale);
      }
 }
Beispiel #15
0
        public override void Draw(Graphics g, Pen pen, Matrix matrixValueToScreen, Rectangle2D graphRectangle, bool isLog)
        {
            // Calculate intersection with bounding rectangle
            Segment2D newSegment = (Segment2D)this.Transform(matrixValueToScreen, isLog);
            Segment2D trimmedSegment = newSegment.Trim(graphRectangle);

            if (trimmedSegment.Point1 != PointF.Empty && trimmedSegment.Point2 != PointF.Empty)
            {
                g.DrawLine(this.Pen, trimmedSegment.Point1, trimmedSegment.Point2);
            }
        }
        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();
            }
        }