/// <summary> /// The actual method for drawing the arrow. /// </summary> /// <param name="StreamGeometryContext">Describes a geometry using drawing commands.</param> protected override void DrawArrowGeometry(StreamGeometryContext StreamGeometryContext) { var theta = Math.Atan2(Y1 - Y2, X1 - X2); var sint = Math.Sin(theta); var cost = Math.Cos(theta); var ArrowOrigin = new Point(X1, this.Y1); var ArrowTarget = new Point(X2, this.Y2); var pt3 = new Point(X2 + (HeadWidth * cost - HeadHeight * sint), Y2 + (HeadWidth * sint + HeadHeight * cost)); var pt4 = new Point(X2 + (HeadWidth * cost + HeadHeight * sint), Y2 - (HeadHeight * cost - HeadWidth * sint)); StreamGeometryContext.BeginFigure(ArrowOrigin, isFilled: true, isClosed: false); StreamGeometryContext.LineTo (ArrowTarget, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (pt3, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (pt4, isStroked: true, isSmoothJoin: true); StreamGeometryContext.LineTo (ArrowTarget, isStroked: true, isSmoothJoin: true); StreamGeometryContext.Close(); }
public void displayRecord() { //Find maximum and minimum for this graphlet, in case needed for scaling double max = double.NegativeInfinity; double min = double.PositiveInfinity; foreach (int channel in channels) { Multigraph.displayChannel dc = mg.displayedChannels.Where(n => n.channel == channel).First(); max = Math.Max(dc.max, max); min = Math.Min(dc.min, min); } //Check to see if new Y-axis and grid needed if(mg.individual) if (mg.useAllYMax) drawYGrid(Math.Max(mg.allChanMax, -mg.allChanMin)); else if (!mg.fixedYMax) //then must be per graphlet max drawYGrid(Math.Max(max,-min)); if (mg.individual) // make sure this is the only one { foreach (Plot pl in plots) gCanvas.Children.Remove(pl.path); plots.Clear(); graphletMax = double.MinValue; graphletMin = double.MaxValue; } foreach (int channel in channels) { Multigraph.displayChannel dc = mg.displayedChannels.Where(n => n.channel == channel).First(); points = new StreamGeometry(); ctx = points.Open(); ctx.BeginFigure(new Point(0, offset - mg.gp.halfMargin - dc.buffer[0] * graphletYScale), false, false); double maxY = 10D * MainWindow.graphletSize; for (int x = 1; x < dc.buffer.GetLength(0); x++) { double y = offset - mg.gp.halfMargin - dc.buffer[x] * graphletYScale; if (y > maxY) y = maxY; //limit size of displayed point else if (y < -maxY) y = -maxY; ctx.LineTo(new Point((double)x * graphletXScale, y), true, true); } ctx.Close(); points.Freeze(); Path p = new Path(); p.Stroke = channel == mg.highlightedChannel ? Brushes.Red : Brushes.Black; p.StrokeThickness = channel == mg.highlightedChannel ? strokeThickness * 2D : strokeThickness; p.StrokeLineJoin = PenLineJoin.Round; p.SnapsToDevicePixels = false; //use anti-aliasing p.Data = points; gCanvas.Children.Add(p); //draw the plot onto graphlet Plot pl = new Plot(); pl.path = p; pl.channel = channel; pl.recNumber = mg.RecSet; pl.max = max; graphletMax = Math.Max(graphletMax, max); //for superimposed records pl.min = min; graphletMin = Math.Min(graphletMin, min); pl.gvList = mg.gvList; plots.Add(pl); } }
/// <summary> /// Draws the pie chart /// </summary> /// <param name="context"></param> private void DrawGeometry(StreamGeometryContext context) { Point startPoint = new Point(CentreX, CentreY); Point outerArcStartPoint = ComputeCartesianCoordinate(Rotation, Radius); outerArcStartPoint.Offset(CentreX, CentreY); Point outerArcEndPoint = ComputeCartesianCoordinate(Rotation + Angle, Radius); outerArcEndPoint.Offset(CentreX, CentreY); bool largeArc = Angle > 180.0; Size outerArcSize = new Size(Radius, Radius); context.BeginFigure(startPoint, true, true); context.LineTo(outerArcStartPoint, true, true); context.ArcTo(outerArcEndPoint, outerArcSize, 0, largeArc, SweepDirection.Clockwise, true, true); context.Close(); }