本文整理汇总了C#中ZedGraph.PaneBase类的典型用法代码示例。如果您正苦于以下问题:C# PaneBase类的具体用法?C# PaneBase怎么用?C# PaneBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PaneBase类属于ZedGraph命名空间,在下文中一共展示了PaneBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPen
public Pen GetPen( PaneBase pane, float scaleFactor, PointPair dataValue )
{
Color color = _color;
if ( _gradientFill.IsGradientValueType )
color = _gradientFill.GetGradientColor( dataValue );
Pen pen = new Pen( color,
pane.ScaledPenWidth( _width, scaleFactor ) );
pen.DashStyle = _style;
if ( _style == DashStyle.Custom )
{
if ( _dashOff > 1e-10 && _dashOn > 1e-10 )
{
pen.DashStyle = DashStyle.Custom;
float[] pattern = new float[2];
pattern[0] = _dashOn;
pattern[1] = _dashOff;
pen.DashPattern = pattern;
}
else
pen.DashStyle = DashStyle.Solid;
}
return pen;
}
示例2: FindPoint
/// <summary>
/// Determine if a mouse point is within the legend, and if so, which legend
/// entry (<see cref="CurveItem"/>) is nearest.
/// </summary>
/// <param name="mousePt">The screen point, in pixel coordinates.</param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <param name="index">The index number of the <see cref="CurveItem"/> legend
/// entry that is under the mouse point. The <see cref="CurveItem"/> object is
/// accessible via <see cref="GraphPane.CurveList">CurveList[index]</see>.
/// </param>
/// <returns>true if the mouse point is within the <see cref="Legend"/> bounding
/// box, false otherwise.</returns>
/// <seealso cref="GraphPane.FindNearestObject"/>
public bool FindPoint( PointF mousePt, PaneBase pane, float scaleFactor, out int index )
{
index = -1;
if ( _rect.Contains( mousePt ) )
{
int j = (int)( ( mousePt.Y - _rect.Top ) / _legendItemHeight );
int i = (int)( ( mousePt.X - _rect.Left - _tmpSize / 2.0f ) / _legendItemWidth );
if ( i < 0 )
i = 0;
if ( i >= _hStack )
i = _hStack - 1;
int pos = i + j * _hStack;
index = 0;
PaneList paneList = GetPaneList( pane );
foreach ( GraphPane tmpPane in paneList )
{
foreach ( CurveItem curve in tmpPane.CurveList )
{
if ( curve._label._isVisible && curve._label._text != string.Empty )
{
if ( pos == 0 )
return true;
pos--;
}
index++;
}
}
return true;
}
else
return false;
}
示例3: CalcRect
/// <summary>
/// Calculate the <see cref="Legend"/> rectangle (<see cref="Rect"/>),
/// taking into account the number of required legend
/// entries, and the legend drawing preferences.
/// </summary>
/// <remarks>Adjust the size of the
/// <see cref="Chart.Rect"/> for the parent <see cref="GraphPane"/> to accomodate the
/// space required by the legend.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <param name="tChartRect">
/// The rectangle that contains the area bounded by the axes, in pixel units.
/// <seealso cref="Chart.Rect" />
/// </param>
public void CalcRect( Graphics g, PaneBase pane, float scaleFactor,
ref RectangleF tChartRect )
{
// Start with an empty rectangle
_rect = Rectangle.Empty;
_hStack = 1;
_legendItemWidth = 1;
_legendItemHeight = 0;
RectangleF clientRect = pane.CalcClientRect( g, scaleFactor );
// If the legend is invisible, don't do anything
if ( !_isVisible )
return;
int nCurve = 0;
PaneList paneList = GetPaneList( pane );
_tmpSize = GetMaxHeight( paneList, g, scaleFactor );
float halfGap = _tmpSize / 2.0F,
maxWidth = 0,
tmpWidth,
gapPix = _gap * _tmpSize;
foreach ( GraphPane tmpPane in paneList )
{
// Loop through each curve in the curve list
// Find the maximum width of the legend labels
//foreach ( CurveItem curve in tmpPane.CurveList )
//foreach ( CurveItem curve in GetIterator( tmpPane.CurveList, _isReverse ) )
int count = tmpPane.CurveList.Count;
for ( int i = 0; i < count; i++ )
{
CurveItem curve = tmpPane.CurveList[_isReverse ? count - i - 1 : i];
if ( curve._label._text != string.Empty && curve._label._isVisible )
{
// Calculate the width of the label save the max width
FontSpec tmpFont = ( curve._label._fontSpec != null ) ?
curve._label._fontSpec : this.FontSpec;
tmpWidth = tmpFont.GetWidth( g, curve._label._text, scaleFactor ) / 2;
if ( tmpWidth > maxWidth )
maxWidth = tmpWidth;
// Save the maximum symbol height for line-type curves
if ( curve is LineItem && ( (LineItem)curve ).Symbol.Size > _legendItemHeight )
_legendItemHeight = ( (LineItem)curve ).Symbol.Size;
nCurve++;
}
}
if ( pane is MasterPane && ( (MasterPane)pane ).IsUniformLegendEntries )
break;
}
float widthAvail;
// Is this legend horizontally stacked?
if ( _isHStack )
{
// Determine the available space for horizontal stacking
switch ( _position )
{
// Never stack if the legend is to the right or left
case LegendPos.Right:
case LegendPos.Left:
widthAvail = 0;
break;
//.........这里部分代码省略.........
示例4: Draw
/// <summary>
/// Render this <see cref="GraphObj"/> object to the specified <see cref="Graphics"/> device.
/// </summary>
/// <remarks>
/// This method is normally only called by the Draw method
/// of the parent <see cref="GraphObjList"/> collection object.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="PaneBase"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public abstract void Draw( Graphics g, PaneBase pane, float scaleFactor );
示例5: PointInBox
/// <summary>
/// Determine if the specified screen point lies inside the bounding box of this
/// <see cref="GraphObj"/>.
/// </summary>
/// <param name="pt">The screen point, in pixels</param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="PaneBase"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <returns>true if the point lies in the bounding box, false otherwise</returns>
public virtual bool PointInBox( PointF pt, PaneBase pane, Graphics g, float scaleFactor )
{
GraphPane gPane = pane as GraphPane;
if ( gPane != null && _isClippedToChartRect && !gPane.Chart.Rect.Contains( pt ) )
return false;
return true;
}
示例6: GetCoords
/// <summary>
/// Determines the shape type and Coords values for this GraphObj
/// </summary>
override public void GetCoords( PaneBase pane, Graphics g, float scaleFactor,
out string shape, out string coords )
{
// transform the x,y location from the user-defined
// coordinate frame to the screen pixel location
RectangleF pixRect = _location.TransformRect( pane );
shape = "rect";
coords = String.Format( "{0:f0},{1:f0},{2:f0},{3:f0}",
pixRect.Left, pixRect.Top, pixRect.Right, pixRect.Bottom );
}
示例7: GetCoords
/// <summary>
/// Determines the shape type and Coords values for this GraphObj
/// </summary>
public override void GetCoords( PaneBase pane, Graphics g, float scaleFactor,
out string shape, out string coords )
{
// transform the x,y location from the user-defined
// coordinate frame to the screen pixel location
PointF pix = _location.Transform( pane );
PointF[] pts = _fontSpec.GetBox( g, _text, pix.X, pix.Y, _location.AlignH,
_location.AlignV, scaleFactor, new SizeF() );
shape = "poly";
coords = String.Format( "{0:f0},{1:f0},{2:f0},{3:f0},{4:f0},{5:f0},{6:f0},{7:f0},",
pts[0].X, pts[0].Y, pts[1].X, pts[1].Y,
pts[2].X, pts[2].Y, pts[3].X, pts[3].Y );
}
示例8: Draw
/// <summary>
/// Render this object to the specified <see cref="Graphics"/> device.
/// </summary>
/// <remarks>
/// This method is normally only called by the Draw method
/// of the parent <see cref="GraphObjList"/> collection object.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
override public void Draw( Graphics g, PaneBase pane, float scaleFactor )
{
if ( _points != null && _points.Length > 1 )
{
using ( GraphicsPath path = MakePath( pane ) )
{
// Fill or draw the symbol as required
if ( _fill.IsVisible )
{
using ( Brush brush = this.Fill.MakeBrush( path.GetBounds() ) )
g.FillPath( brush, path );
}
if ( _border.IsVisible )
{
using ( Pen pen = _border.GetPen( pane, scaleFactor ) )
g.DrawPath( pen, path );
}
}
}
}
示例9: MakePath
internal GraphicsPath MakePath( PaneBase pane )
{
GraphicsPath path = new GraphicsPath();
bool first = true;
PointF lastPt = new PointF();
foreach( PointD pt in _points )
{
// Convert the coordinates from the user coordinate system
// to the screen coordinate system
// Offset the points by the location value
PointF pixPt = Location.Transform( pane, pt.X + _location.X, pt.Y + _location.Y,
_location.CoordinateFrame );
if ( Math.Abs( pixPt.X ) < 100000 &&
Math.Abs( pixPt.Y ) < 100000 )
{
if ( first )
first = false;
else
path.AddLine( lastPt, pixPt );
lastPt = pixPt;
}
}
if ( _isClosedFigure )
path.CloseFigure();
return path;
}
示例10: Draw
/// <summary>
/// Render the specified <paramref name="text"/> to the specifed
/// <see cref="Graphics"/> device. The text, border, and fill options
/// will be rendered as required.
/// </summary>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="text">A string value containing the text to be
/// displayed. This can be multiple lines, separated by newline ('\n')
/// characters</param>
/// <param name="x">The X location to display the text, in screen
/// coordinates, relative to the horizontal (<see cref="AlignH"/>)
/// alignment parameter <paramref name="alignH"/></param>
/// <param name="y">The Y location to display the text, in screen
/// coordinates, relative to the vertical (<see cref="AlignV"/>
/// alignment parameter <paramref name="alignV"/></param>
/// <param name="alignH">A horizontal alignment parameter specified
/// using the <see cref="AlignH"/> enum type</param>
/// <param name="alignV">A vertical alignment parameter specified
/// using the <see cref="AlignV"/> enum type</param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public void Draw( Graphics g, PaneBase pane, string text, float x,
float y, AlignH alignH, AlignV alignV,
float scaleFactor )
{
this.Draw( g, pane, text, x, y, alignH, alignV,
scaleFactor, new SizeF() );
}
示例11: PointInBox
/// <summary>
/// Determine if the specified screen point lies inside the bounding box of this
/// <see cref="LineObj"/>.
/// </summary>
/// <remarks>The bounding box is calculated assuming a distance
/// of <see cref="GraphPane.Default.NearestTol"/> pixels around the arrow segment.
/// </remarks>
/// <param name="pt">The screen point, in pixels</param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <returns>true if the point lies in the bounding box, false otherwise</returns>
public override bool PointInBox(PointF pt, PaneBase pane, Graphics g, float scaleFactor)
{
if (! base.PointInBox(pt, pane, g, scaleFactor))
return false;
// transform the x,y location from the user-defined
// coordinate frame to the screen pixel location
PointF pix = _location.TransformTopLeft(pane);
PointF pix2 = _location.TransformBottomRight(pane);
using (var pen = new Pen(Color.Black, (float) GraphPane.Default.NearestTol*2.0F))
{
using (var path = new GraphicsPath())
{
path.AddLine(pix, pix2);
return path.IsOutlineVisible(pt, pen);
}
}
}
示例12: GetCoords
/// <summary>
/// Determines the shape type and Coords values for this GraphObj
/// </summary>
public override void GetCoords(PaneBase pane, Graphics g, float scaleFactor,
out string shape, out string coords)
{
// transform the x,y location from the user-defined
// coordinate frame to the screen pixel location
RectangleF pixRect = _location.TransformRect(pane);
var matrix = new Matrix();
if (pixRect.Right == 0)
pixRect.Width = 1;
var angle = (float) Math.Atan((pixRect.Top - pixRect.Bottom)/
(pixRect.Left - pixRect.Right));
matrix.Rotate(angle, MatrixOrder.Prepend);
// Move the coordinate system to local coordinates
// of this text object (that is, at the specified
// x,y location)
matrix.Translate(-pixRect.Left, -pixRect.Top, MatrixOrder.Prepend);
var pts = new PointF[4];
pts[0] = new PointF(0, 3);
pts[1] = new PointF(pixRect.Width, 3);
pts[2] = new PointF(pixRect.Width, -3);
pts[3] = new PointF(0, -3);
matrix.TransformPoints(pts);
shape = "poly";
coords = String.Format("{0:f0},{1:f0},{2:f0},{3:f0},{4:f0},{5:f0},{6:f0},{7:f0},",
pts[0].X, pts[0].Y, pts[1].X, pts[1].Y,
pts[2].X, pts[2].Y, pts[3].X, pts[3].Y);
}
示例13: Draw
/// <summary>
/// Render this object to the specified <see cref="Graphics"/> device.
/// </summary>
/// <remarks>
/// This method is normally only called by the Draw method
/// of the parent <see cref="GraphObjList"/> collection object.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
public override void Draw(Graphics g, PaneBase pane, float scaleFactor)
{
// Convert the arrow coordinates from the user coordinate system
// to the screen coordinate system
PointF pix1 = Location.TransformTopLeft(pane);
PointF pix2 = Location.TransformBottomRight(pane);
if (pix1.X > -10000 && pix1.X < 100000 && pix1.Y > -100000 && pix1.Y < 100000 &&
pix2.X > -10000 && pix2.X < 100000 && pix2.Y > -100000 && pix2.Y < 100000)
{
// calculate the length and the angle of the arrow "vector"
double dy = pix2.Y - pix1.Y;
double dx = pix2.X - pix1.X;
float angle = (float) Math.Atan2(dy, dx)*180.0F/(float) Math.PI;
var length = (float) Math.Sqrt(dx*dx + dy*dy);
// Save the old transform matrix
Matrix transform = g.Transform;
// Move the coordinate system so it is located at the starting point
// of this arrow
g.TranslateTransform(pix1.X, pix1.Y);
// Rotate the coordinate system according to the angle of this arrow
// about the starting point
g.RotateTransform(angle);
// get a pen according to this arrow properties
using (var pen = new Pen(_color, pane.ScaledPenWidth(_penWidth, scaleFactor)))
{
pen.DashStyle = _style;
g.DrawLine(pen, 0, 0, length, 0);
}
// Restore the transform matrix back to its original state
g.Transform = transform;
}
}
示例14: Draw
/// <summary>
/// Render this object to the specified <see cref="Graphics"/> device.
/// </summary>
/// <remarks>
/// This method is normally only called by the Draw method
/// of the parent <see cref="GraphObjList"/> collection object.
/// </remarks>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
override public void Draw( Graphics g, PaneBase pane, float scaleFactor )
{
// Convert the arrow coordinates from the user coordinate system
// to the screen coordinate system
RectangleF pixRect = this.Location.TransformRect( pane );
// Clip the rect to just outside the PaneRect so we don't end up with wild coordinates.
RectangleF tmpRect = pane.Rect;
tmpRect.Inflate( 20, 20 );
pixRect.Intersect( tmpRect );
if ( Math.Abs( pixRect.Left ) < 100000 &&
Math.Abs( pixRect.Top ) < 100000 &&
Math.Abs( pixRect.Right ) < 100000 &&
Math.Abs( pixRect.Bottom ) < 100000 )
{
// If the box is to be filled, fill it
_fill.Draw( g, pixRect );
// Draw the border around the box if required
_border.Draw( g, pane, scaleFactor, pixRect );
}
}
示例15: PointInBox
/// <summary>
/// Determine if the specified screen point lies inside the bounding box of this
/// <see cref="PolyObj"/>.
/// </summary>
/// <param name="pt">The screen point, in pixels</param>
/// <param name="pane">
/// A reference to the <see cref="PaneBase"/> object that is the parent or
/// owner of this object.
/// </param>
/// <param name="g">
/// A graphic device object to be drawn into. This is normally e.Graphics from the
/// PaintEventArgs argument to the Paint() method.
/// </param>
/// <param name="scaleFactor">
/// The scaling factor to be used for rendering objects. This is calculated and
/// passed down by the parent <see cref="GraphPane"/> object using the
/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
/// font sizes, etc. according to the actual size of the graph.
/// </param>
/// <returns>true if the point lies in the bounding box, false otherwise</returns>
override public bool PointInBox( PointF pt, PaneBase pane, Graphics g, float scaleFactor )
{
if ( _points != null && _points.Length > 1 )
{
if ( ! base.PointInBox(pt, pane, g, scaleFactor ) )
return false;
using ( GraphicsPath path = MakePath( pane ) )
return path.IsVisible( pt );
}
else
return false;
}