Example #1
0
 /// <summary>
 /// Constructor for the <see cref="Location"/> class that specifies the
 /// (x, y), (width, height), and the <see cref="CoordType"/>.
 /// </summary>
 /// <remarks>
 /// The (x,y) position
 /// corresponds to the starting position, the (x2, y2) coorresponds to the ending position
 /// (typically used for <see cref="ArrowItem"/>'s).
 /// </remarks>
 /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="width">The width, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="height">The height, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
 /// units for <see paramref="x"/> and <see paramref="y"/></param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public Location(float x, float y, float width, float height,
                 CoordType coordType, AlignH alignH, AlignV alignV) :
     this(x, y, coordType, alignH, alignV)
 {
     this.width  = width;
     this.height = height;
 }
 /// <summary>
 /// Constructor that creates a <see cref="GraphItem"/> with the specified
 /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
 /// Other properties are set to default values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <remarks>
 /// The two coordinates define the location point for the object.
 /// The units of the coordinates are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
 /// </remarks>
 /// <param name="x">The x position of the item.  The item will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public GraphItem(float x, float y, CoordType coordType, AlignH alignH, AlignV alignV)
 {
     this.isVisible = true;
     this.Tag       = null;
     this.zOrder    = ZOrder.A_InFront;
     this.location  = new Location(x, y, coordType, alignH, alignV);
 }
Example #3
0
 /// <summary>
 /// Constructor that creates a <see cref="GraphItem"/> with the specified
 /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
 /// Other properties are set to default values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <remarks>
 /// The four coordinates define the starting point and ending point for
 /// <see cref="ArrowItem"/>'s, or the topleft and bottomright points for
 /// <see cref="ImageItem"/>'s.  For <see cref="GraphItem"/>'s that only require
 /// one point, the <see paramref="x2"/> and <see paramref="y2"/> values
 /// will be ignored.  The units of the coordinates are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
 /// </remarks>
 /// <param name="x">The x position of the item.</param>
 /// <param name="y">The y position of the item.</param>
 /// <param name="x2">The x2 position of the item.</param>
 /// <param name="y2">The x2 position of the item.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public GraphItem(float x, float y, float x2, float y2, CoordType coordType,
                  AlignH alignH, AlignV alignV)
 {
     this.Tag      = null;
     this.zOrder   = ZOrder.A_InFront;
     this.location = new Location(x, y, x2, y2, coordType, alignH, alignV);
 }
 /// <summary>
 /// Constructor for the <see cref="Location"/> class that specifies the
 /// (x, y), (width, height), and the <see cref="CoordType"/>.
 /// </summary>
 /// <remarks>
 /// The (x,y) position
 /// corresponds to the starting position, the (x2, y2) coorresponds to the ending position
 /// (typically used for <see cref="ArrowObj"/>'s).
 /// </remarks>
 /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="width">The width, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="height">The height, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
 /// units for <see paramref="x"/> and <see paramref="y"/></param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public Location(double x, double y, double width, double height,
                 CoordType coordType, AlignH alignH, AlignV alignV) :
     this(x, y, coordType, alignH, alignV)
 {
     _width  = width;
     _height = height;
 }
Example #5
0
 /// <overloads>Constructors for the <see cref="ImageObj"/> object</overloads>
 /// <summary>
 /// A constructor that allows the <see cref="System.Drawing.Image"/> and
 /// <see cref="RectangleF"/> location for the
 /// <see cref="ImageObj"/> to be pre-specified.
 /// </summary>
 /// <param name="image">A <see cref="System.Drawing.Image"/> class that defines
 /// the image</param>
 /// <param name="rect">A <see cref="RectangleF"/> struct that defines the
 /// image location, specifed in units based on the
 /// <see cref="Location.CoordinateFrame"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public ImageObj(Image image, RectangleF rect, CoordType coordType,
                 AlignH alignH, AlignV alignV) :
     base(rect.X, rect.Y, rect.Width, rect.Height, coordType,
          alignH, alignV)
 {
     _image    = image;
     _isScaled = Default.IsScaled;
 }
Example #6
0
 /// <summary>
 /// Constructor that creates a <see cref="GraphItem"/> with the specified
 /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
 /// Other properties are set to default values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <remarks>
 /// The four coordinates define the starting point and ending point for
 /// <see cref="ArrowItem"/>'s, or the topleft and bottomright points for
 /// <see cref="ImageItem"/>'s.  For <see cref="GraphItem"/>'s that only require
 /// one point, the <see paramref="x2"/> and <see paramref="y2"/> values
 /// will be ignored.  The units of the coordinates are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
 /// </remarks>
 /// <param name="x">The x position of the item.</param>
 /// <param name="y">The y position of the item.</param>
 /// <param name="x2">The x2 position of the item.</param>
 /// <param name="y2">The x2 position of the item.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public GraphItem(float x, float y, float x2, float y2, CoordType coordType,
                  AlignH alignH, AlignV alignV)
 {
     this.isVisible           = true;
     this.isClippedToAxisRect = Default.IsClippedToAxisRect;
     this.Tag      = null;
     this.zOrder   = ZOrder.A_InFront;
     this.location = new Location(x, y, x2, y2, coordType, alignH, alignV);
 }
Example #7
0
 /// <summary>
 /// Constructor that creates a <see cref="GraphObj"/> with the specified
 /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
 /// Other properties are set to default values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <remarks>
 /// The two coordinates define the location point for the object.
 /// The units of the coordinates are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
 /// </remarks>
 /// <param name="x">The x position of the item.  The item will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public GraphObj(double x, double y, CoordType coordType, AlignH alignH, AlignV alignV)
 {
     _isVisible            = true;
     _isClippedToChartRect = Default.IsClippedToChartRect;
     this.Tag  = null;
     _zOrder   = ZOrder.A_InFront;
     _location = new Location(x, y, coordType, alignH, alignV);
     _link     = new Link();
 }
Example #8
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="Location"/> object from which to copy</param>
 public Location(Location rhs)
 {
     this.x               = rhs.x;
     this.y               = rhs.y;
     this.width           = rhs.width;
     this.height          = rhs.height;
     this.coordinateFrame = rhs.CoordinateFrame;
     this.alignH          = rhs.AlignH;
     this.alignV          = rhs.AlignV;
 }
 /// <summary>
 /// Constructor for the <see cref="Location"/> class that specifies the
 /// x, y position and the <see cref="CoordType"/>.
 /// </summary>
 /// <remarks>
 /// The (x,y) position corresponds to the top-left corner;
 /// </remarks>
 /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
 /// units for <see paramref="x"/> and <see paramref="y"/></param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public Location(double x, double y, CoordType coordType, AlignH alignH, AlignV alignV)
 {
     _x               = x;
     _y               = y;
     _width           = 0;
     _height          = 0;
     _coordinateFrame = coordType;
     _alignH          = alignH;
     _alignV          = alignV;
 }
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="Location"/> object from which to copy</param>
 public Location(Location rhs)
 {
     _x               = rhs._x;
     _y               = rhs._y;
     _width           = rhs._width;
     _height          = rhs._height;
     _coordinateFrame = rhs.CoordinateFrame;
     _alignH          = rhs.AlignH;
     _alignV          = rhs.AlignV;
 }
Example #11
0
 /// <summary>
 /// Constructor for the <see cref="Location"/> class that specifies the
 /// x, y position and the <see cref="CoordType"/>.
 /// </summary>
 /// <remarks>
 /// The (x,y) position corresponds to the top-left corner;
 /// </remarks>
 /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
 /// units for <see paramref="x"/> and <see paramref="y"/></param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public Location(float x, float y, CoordType coordType, AlignH alignH, AlignV alignV)
 {
     this.x               = x;
     this.y               = y;
     this.width           = 0;
     this.height          = 0;
     this.coordinateFrame = coordType;
     this.alignH          = alignH;
     this.alignV          = alignV;
 }
Example #12
0
 /// <summary>
 /// Constructor that creates a <see cref="Brush"/> fill, using a user-supplied, custom
 /// <see cref="Brush"/>.  This constructor will make the brush unscaled (see <see cref="IsScaled"/>),
 /// but it provides <see paramref="alignH"/> and <see paramref="alignV"/> parameters to control
 /// alignment of the brush with respect to the filled object.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> to use for fancy fills.  Typically, this would
 /// be a <see cref="LinearGradientBrush"/> or a <see cref="TextureBrush"/> class</param>
 /// <param name="alignH">Controls the horizontal alignment of the brush within the filled object
 /// (see <see cref="AlignH"/></param>
 /// <param name="alignV">Controls the vertical alignment of the brush within the filled object
 /// (see <see cref="AlignV"/></param>
 public Fill(Brush brush, AlignH alignH, AlignV alignV)
 {
     Init();
     this.alignH   = alignH;
     this.alignV   = alignV;
     this.isScaled = false;
     this.color    = Color.White;
     this.brush    = (Brush)brush.Clone();
     this.type     = FillType.Brush;
 }
Example #13
0
 /// <summary>
 /// Constructor that creates a <see cref="Brush"/> fill, using a user-supplied, custom
 /// <see cref="Brush"/>.  This constructor will make the brush unscaled (see <see cref="IsScaled"/>),
 /// but it provides <see paramref="alignH"/> and <see paramref="alignV"/> parameters to control
 /// alignment of the brush with respect to the filled object.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> to use for fancy fills.  Typically, this would
 /// be a <see cref="LinearGradientBrush"/> or a <see cref="TextureBrush"/> class</param>
 /// <param name="alignH">Controls the horizontal alignment of the brush within the filled object
 /// (see <see cref="AlignH"/></param>
 /// <param name="alignV">Controls the vertical alignment of the brush within the filled object
 /// (see <see cref="AlignV"/></param>
 public Fill(Brush brush, AlignH alignH, AlignV alignV)
 {
     Init();
     _alignH   = alignH;
     _alignV   = alignV;
     _isScaled = false;
     _color    = Color.White;
     _brush    = (Brush)brush.Clone();
     _type     = FillType.Brush;
 }
Example #14
0
 /// <summary>
 /// Constructor that creates a <see cref="GraphObj"/> with the specified
 /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
 /// Other properties are set to default values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <remarks>
 /// The two coordinates define the location point for the object.
 /// The units of the coordinates are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
 /// </remarks>
 /// <param name="x">The x position of the item.  The item will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 /// <param name="xAxisIndex">Index of the XAxis</param>
 /// <param name="yAxisIndex">Index of the YAxis</param>
 protected GraphObj(double x, double y, CoordType coordType, AlignH alignH, AlignV alignV)
 {
     _isVisible            = true;
     _isClippedToChartRect = Default.IsClippedToChartRect;
     this.Tag   = null;
     _zOrder    = ZOrder.A_InFront;
     _location  = new Location(x, y, coordType, alignH, alignV);
     _link      = new Link();
     IsX2Axis   = false;
     IsY2Axis   = false;
     YAxisIndex = 0;
 }
Example #15
0
 /// <summary>
 /// Generic initializer to default values
 /// </summary>
 private void Init()
 {
     color         = Color.White;
     brush         = null;
     type          = FillType.None;
     this.isScaled = Default.IsScaled;
     this.alignH   = Default.AlignH;
     this.alignV   = Default.AlignV;
     this.rangeMin = 0.0;
     this.rangeMax = 1.0;
     gradientBM    = null;
 }
Example #16
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The Fill object from which to copy</param>
        public Fill(Fill rhs)
        {
            _color = rhs._color;
            _secondaryValueGradientColor = rhs._color;

            if (rhs._brush != null)
            {
                _brush = (Brush)rhs._brush.Clone();
            }
            else
            {
                _brush = null;
            }
            _type         = rhs._type;
            _alignH       = rhs.AlignH;
            _alignV       = rhs.AlignV;
            _isScaled     = rhs.IsScaled;
            _rangeMin     = rhs._rangeMin;
            _rangeMax     = rhs._rangeMax;
            _rangeDefault = rhs._rangeDefault;
            _gradientBM   = null;

            if (rhs._colorList != null)
            {
                _colorList = (Color[])rhs._colorList.Clone();
            }
            else
            {
                _colorList = null;
            }

            if (rhs._positionList != null)
            {
                _positionList = (float[])rhs._positionList.Clone();
            }
            else
            {
                _positionList = null;
            }

            if (rhs._image != null)
            {
                _image = (Image)rhs._image.Clone();
            }
            else
            {
                _image = null;
            }

            _angle    = rhs._angle;
            _wrapMode = rhs._wrapMode;
        }
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Location(SerializationInfo info, StreamingContext context)
        {
            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32("schema");

            _alignV          = (AlignV)info.GetValue("alignV", typeof(AlignV));
            _alignH          = (AlignH)info.GetValue("alignH", typeof(AlignH));
            _x               = info.GetDouble("x");
            _y               = info.GetDouble("y");
            _width           = info.GetDouble("width");
            _height          = info.GetDouble("height");
            _coordinateFrame = (CoordType)info.GetValue("coordinateFrame", typeof(CoordType));
        }
Example #18
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The Fill object from which to copy</param>
        public Fill(Fill rhs)
        {
            color = rhs.color;
            if (rhs.brush != null)
            {
                brush = (Brush)rhs.brush.Clone();
            }
            else
            {
                brush = null;
            }
            type       = rhs.type;
            alignH     = rhs.AlignH;
            alignV     = rhs.AlignV;
            isScaled   = rhs.IsScaled;
            rangeMin   = rhs.RangeMin;
            rangeMax   = rhs.RangeMax;
            gradientBM = null;

            if (rhs.colorList != null)
            {
                colorList = (Color[])rhs.colorList.Clone();
            }
            else
            {
                colorList = null;
            }

            if (rhs.positionList != null)
            {
                positionList = (float[])rhs.positionList.Clone();
            }
            else
            {
                positionList = null;
            }

            if (rhs.image != null)
            {
                image = (Image)rhs.image.Clone();
            }
            else
            {
                image = null;
            }

            angle    = rhs.angle;
            wrapMode = rhs.wrapMode;
        }
Example #19
0
        /// <summary>
        /// Generic initializer to default values
        /// </summary>
        private void Init()
        {
            color         = Color.White;
            brush         = null;
            type          = FillType.None;
            this.isScaled = Default.IsScaled;
            this.alignH   = Default.AlignH;
            this.alignV   = Default.AlignV;
            this.rangeMin = 0.0;
            this.rangeMax = 1.0;
            gradientBM    = null;

            colorList    = null;
            positionList = null;
            angle        = 0;
            image        = null;
            wrapMode     = WrapMode.Tile;
        }
Example #20
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The Fill object from which to copy</param>
 public Fill(Fill rhs)
 {
     color = rhs.color;
     if (rhs.brush != null)
     {
         brush = (Brush)rhs.Brush.Clone();
     }
     else
     {
         brush = null;
     }
     type       = rhs.type;
     alignH     = rhs.AlignH;
     alignV     = rhs.AlignV;
     isScaled   = rhs.IsScaled;
     rangeMin   = rhs.RangeMin;
     rangeMax   = rhs.RangeMax;
     gradientBM = null;
 }
Example #21
0
        // schema changed to 2 with addition of rangeDefault
        // schema changed to 10 with version 5 refactor -- not backwards compatible

        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Fill(SerializationInfo info, StreamingContext context)
        {
            Init();

            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32("schema");

            _color = (Color)info.GetValue("color", typeof(Color));
            _secondaryValueGradientColor = (Color)info.GetValue("secondaryValueGradientColor", typeof(Color));
            //brush = (Brush) info.GetValue( "brush", typeof(Brush) );
            //brushHolder = (BrushHolder) info.GetValue( "brushHolder", typeof(BrushHolder) );
            _type     = (FillType)info.GetValue("type", typeof(FillType));
            _isScaled = info.GetBoolean("isScaled");
            _alignH   = (AlignH)info.GetValue("alignH", typeof(AlignH));
            _alignV   = (AlignV)info.GetValue("alignV", typeof(AlignV));
            _rangeMin = info.GetDouble("rangeMin");
            _rangeMax = info.GetDouble("rangeMax");

            //BrushHolder brushHolder = (BrushHolder) info.GetValue( "brushHolder", typeof( BrushHolder ) );
            //brush = brush;

            _colorList    = (Color[])info.GetValue("colorList", typeof(Color[]));
            _positionList = (float[])info.GetValue("positionList", typeof(float[]));
            _angle        = info.GetSingle("angle");
            _image        = (Image)info.GetValue("image", typeof(Image));
            _wrapMode     = (WrapMode)info.GetValue("wrapMode", typeof(WrapMode));

            if (_colorList != null && _positionList != null)
            {
                ColorBlend blend = new ColorBlend();
                blend.Colors    = _colorList;
                blend.Positions = _positionList;
                CreateBrushFromBlend(blend, _angle);
            }
            else if (_image != null)
            {
                _brush = new TextureBrush(_image, _wrapMode);
            }

            _rangeDefault = info.GetDouble("rangeDefault");
        }
Example #22
0
        /// <summary>
        /// Generic initializer to default values
        /// </summary>
        private void Init()
        {
            _color = Color.White;
            _secondaryValueGradientColor = Color.White;
            _brush        = null;
            _type         = FillType.None;
            _isScaled     = Default.IsScaled;
            _alignH       = Default.AlignH;
            _alignV       = Default.AlignV;
            _rangeMin     = 0.0;
            _rangeMax     = 1.0;
            _rangeDefault = double.MaxValue;
            _gradientBM   = null;

            _colorList    = null;
            _positionList = null;
            _angle        = 0;
            _image        = null;
            _wrapMode     = WrapMode.Tile;
        }
Example #23
0
 /// <summary>
 /// Constructor that sets all <see cref="TextObj"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="x">The x position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public TextObj( string text, double x, double y, CoordType coordType, AlignH alignH, AlignV alignV )
     : base(x, y, coordType, alignH, alignV)
 {
     Init( text );
 }
Example #24
0
        /// <summary>
        /// Generic initializer to default values
        /// </summary>
        private void Init()
        {
            _color = Color.White;
            _secondaryValueGradientColor = Color.White;
            _brush = null;
            _type = FillType.None;
            _isScaled = Default.IsScaled;
            _alignH = Default.AlignH;
            _alignV = Default.AlignV;
            _rangeMin = 0.0;
            _rangeMax = 1.0;
            _rangeDefault = double.MaxValue;
            _gradientBM = null;

            _colorList = null;
            _positionList = null;
            _angle = 0;
            _image = null;
            _wrapMode = WrapMode.Tile;
        }
Example #25
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The Fill object from which to copy</param>
        public Fill( Fill rhs )
        {
            _color = rhs._color;
            _secondaryValueGradientColor = rhs._color;

            if ( rhs._brush != null )
                _brush = (Brush) rhs._brush.Clone();
            else
                _brush = null;
            _type = rhs._type;
            _alignH = rhs.AlignH;
            _alignV = rhs.AlignV;
            _isScaled = rhs.IsScaled;
            _rangeMin = rhs._rangeMin;
            _rangeMax = rhs._rangeMax;
            _rangeDefault = rhs._rangeDefault;
            _gradientBM = null;

            if ( rhs._colorList != null )
                _colorList = (Color[]) rhs._colorList.Clone();
            else
                _colorList = null;

            if ( rhs._positionList != null )
            {
                _positionList = (float[]) rhs._positionList.Clone();
            }
            else
                _positionList = null;

            if ( rhs._image != null )
                _image = (Image) rhs._image.Clone();
            else
                _image = null;

            _angle = rhs._angle;
            _wrapMode = rhs._wrapMode;
        }
Example #26
0
        /// <summary>
        /// Constructor that creates a <see cref="GraphItem"/> with the specified
        /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
        /// Other properties are set to default values as defined in the <see cref="Default"/> class.
        /// </summary>
        /// <remarks>
        /// The four coordinates define the starting point and ending point for
        /// <see cref="ArrowItem"/>'s, or the topleft and bottomright points for
        /// <see cref="ImageItem"/>'s.  For <see cref="GraphItem"/>'s that only require
        /// one point, the <see paramref="x2"/> and <see paramref="y2"/> values
        /// will be ignored.  The units of the coordinates are specified by the
        /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
        /// </remarks>
        /// <param name="x">The x position of the item.</param>
        /// <param name="y">The y position of the item.</param>
        /// <param name="x2">The x2 position of the item.</param>
        /// <param name="y2">The x2 position of the item.</param>
        /// <param name="coordType">The <see cref="CoordType"/> enum value that
        /// indicates what type of coordinate system the x and y parameters are
        /// referenced to.</param>
        /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
        /// the horizontal alignment of the object with respect to the (x,y) location</param>
        /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
        /// the vertical alignment of the object with respect to the (x,y) location</param>
        public GraphItem( float x, float y, float x2, float y2, CoordType coordType,
					AlignH alignH, AlignV alignV )
        {
            this.Tag = null;
            this.zOrder = ZOrder.A_InFront;
            this.location = new Location( x, y, x2, y2, coordType, alignH, alignV );
        }
Example #27
0
        /// <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.  This special case method will show the
        /// specified text as a power of 10, using the <see cref="Default.SuperSize"/>
        /// and <see cref="Default.SuperShift"/>.
        /// </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="ZedGraph.GraphPane"/> 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 DrawTenPower( Graphics g, GraphPane pane, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			float scaleFactor )
        {
            SmoothingMode sModeSave = g.SmoothingMode;
            TextRenderingHint sHintSave = g.TextRenderingHint;
            if ( _isAntiAlias )
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            }

            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref _scaledSize, ref _font );
            float scaledSuperSize = _scaledSize * Default.SuperSize;
            Remake( scaleFactor, this.Size * Default.SuperSize, ref scaledSuperSize,
                ref _superScriptFont );

            // Get the width and height of the text
            SizeF size10 = g.MeasureString( "10", _font );
            SizeF sizeText = g.MeasureString( text, _superScriptFont );
            SizeF totSize = new SizeF( size10.Width + sizeText.Width,
                                    size10.Height + sizeText.Height * Default.SuperShift );
            float charWidth = g.MeasureString( "x", _superScriptFont ).Width;

            // Save the old transform matrix for later restoration
            Matrix saveMatrix = g.Transform;

            g.Transform = SetupMatrix( g.Transform, x, y, totSize, alignH, alignV, _angle );

            // make a center justified StringFormat alignment
            // for drawing the text
            StringFormat strFormat = new StringFormat();
            strFormat.Alignment = _stringAlignment;

            // Create a rectangle representing the border around the
            // text.  Note that, while the text is drawn based on the
            // TopCenter position, the rectangle is drawn based on
            // the TopLeft position.  Therefore, move the rectangle
            // width/2 to the left to align it properly
            RectangleF rectF = new RectangleF( -totSize.Width / 2.0F, 0.0F,
                totSize.Width, totSize.Height );

            // If the background is to be filled, fill it
            _fill.Draw( g, rectF );

            // Draw the border around the text if required
            _border.Draw( g, pane, scaleFactor, rectF );

            // make a solid brush for rendering the font itself
            using ( SolidBrush brush = new SolidBrush( _fontColor ) )
            {
                // Draw the actual text.  Note that the coordinate system
                // is set up such that 0,0 is at the location where the
                // CenterTop of the text needs to be.
                g.DrawString( "10", _font, brush,
                                ( -totSize.Width + size10.Width ) / 2.0F,
                                sizeText.Height * Default.SuperShift, strFormat );
                g.DrawString( text, _superScriptFont, brush,
                                ( totSize.Width - sizeText.Width - charWidth ) / 2.0F,
                                0.0F,
                                strFormat );
            }

            // Restore the transform matrix back to original
            g.Transform = saveMatrix;

            g.SmoothingMode = sModeSave;
            g.TextRenderingHint = sHintSave;
        }
Example #28
0
        /// <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() );
        }
Example #29
0
        private Matrix GetMatrix( float x, float y, SizeF sizeF, AlignH alignH, AlignV alignV,
							float angle )
        {
            // Build a transform matrix that inverts that drawing transform
            // in this manner, the point is brought back to the box, rather
            // than vice-versa.  This allows the container check to be a simple
            // RectangleF.Contains, since the rectangle won't be rotated.
            Matrix matrix = new Matrix();

            // In this case, the bounding box is anchored to the
            // top-left of the text box.  Handle the alignment
            // as needed.
            float xa, ya;
            if ( alignH == AlignH.Left )
                xa = sizeF.Width / 2.0F;
            else if ( alignH == AlignH.Right )
                xa = -sizeF.Width / 2.0F;
            else
                xa = 0.0F;

            if ( alignV == AlignV.Center )
                ya = -sizeF.Height / 2.0F;
            else if ( alignV == AlignV.Bottom )
                ya = -sizeF.Height;
            else
                ya = 0.0F;

            // Shift the coordinates to accomodate the alignment
            // parameters
            matrix.Translate( -xa, -ya, MatrixOrder.Prepend );

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if ( angle != 0.0F )
                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( -x, -y, MatrixOrder.Prepend );

            return matrix;
        }
Example #30
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The Fill object from which to copy</param>
 public Fill( Fill rhs )
 {
     color = rhs.color;
     if ( rhs.brush != null )
         brush = (Brush) rhs.Brush.Clone();
     else
         brush = null;
     type = rhs.type;
     alignH = rhs.AlignH;
     alignV = rhs.AlignV;
     isScaled = rhs.IsScaled;
     rangeMin = rhs.RangeMin;
     rangeMax = rhs.RangeMax;
     gradientBM = null;
 }
Example #31
0
 /// <summary>
 /// Generic initializer to default values
 /// </summary>
 private void Init()
 {
     color = Color.White;
     brush = null;
     type = FillType.None;
     this.isScaled = Default.IsScaled;
     this.alignH = Default.AlignH;
     this.alignV = Default.AlignV;
     this.rangeMin = 0.0;
     this.rangeMax = 1.0;
     gradientBM = null;
 }
Example #32
0
        /// <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.  This special case method will show the
        /// specified text as a power of 10, using the <see cref="Default.SuperSize"/>
        /// and <see cref="Default.SuperShift"/>.
        /// </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="ZedGraph.GraphPane"/> 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="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void DrawTenPower( Graphics g, GraphPane pane, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			double scaleFactor )
        {
            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref this.scaledSize, ref this.font );
            float scaledSuperSize = this.scaledSize * Default.SuperSize;
            Remake( scaleFactor, this.Size * Default.SuperSize, ref scaledSuperSize,
                ref this.superScriptFont );

            // Get the width and height of the text
            SizeF size10 = g.MeasureString( "10", this.font );
            SizeF sizeText = g.MeasureString( text, this.superScriptFont );
            SizeF totSize = new SizeF( size10.Width + sizeText.Width,
                                    size10.Height + sizeText.Height * Default.SuperShift );
            float charWidth = g.MeasureString( "x", this.superScriptFont ).Width;

            // Save the old transform matrix for later restoration
            Matrix matrix = g.Transform;

            // Move the coordinate system to local coordinates
            // of this text object (that is, at the specified
            // x,y location)
            g.TranslateTransform( x, y, MatrixOrder.Prepend );

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if ( angle != 0.0F )
                g.RotateTransform( -angle, MatrixOrder.Prepend );

            // Since the text will be drawn by g.DrawString()
            // assuming the location is the TopCenter
            // (the Font is aligned using StringFormat to the
            // center so multi-line text is center justified),
            // shift the coordinate system so that we are
            // actually aligned per the caller specified position
            float xa, ya;
            if ( alignH == AlignH.Left )
                xa = totSize.Width / 2.0F;
            else if ( alignH == AlignH.Right )
                xa = -totSize.Width / 2.0F;
            else
                xa = 0.0F;

            if ( alignV == AlignV.Center )
                ya = -totSize.Height / 2.0F;
            else if ( alignV == AlignV.Bottom )
                ya = -totSize.Height;
            else
                ya = 0.0F;

            // Shift the coordinates to accomodate the alignment
            // parameters
            g.TranslateTransform( xa, ya, MatrixOrder.Prepend );

            // make a solid brush for rendering the font itself
            SolidBrush brush = new SolidBrush( this.fontColor );

            // make a center justified StringFormat alignment
            // for drawing the text
            StringFormat strFormat = new StringFormat();
            strFormat.Alignment = this.stringAlignment;

            // Create a rectangle representing the border around the
            // text.  Note that, while the text is drawn based on the
            // TopCenter position, the rectangle is drawn based on
            // the TopLeft position.  Therefore, move the rectangle
            // width/2 to the left to align it properly
            RectangleF rectF = new RectangleF( -totSize.Width / 2.0F, 0.0F,
                totSize.Width, totSize.Height );

            // If the background is to be filled, fill it
            this.fill.Draw( g, rectF );

            // Draw the border around the text if required
            this.border.Draw( g, pane, scaleFactor, rectF );

            // Draw the actual text.  Note that the coordinate system
            // is set up such that 0,0 is at the location where the
            // CenterTop of the text needs to be.
            g.DrawString( "10", this.font, brush,
                            ( -totSize.Width + size10.Width ) / 2.0F,
                            sizeText.Height * Default.SuperShift, strFormat );
            g.DrawString( text, this.superScriptFont, brush,
                            ( totSize.Width - sizeText.Width - charWidth ) / 2.0F,
                            0.0F,
                            strFormat );

            // Restore the transform matrix back to original
            g.Transform = matrix;
        }
Example #33
0
 /// <summary>
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">The <see cref="Location"/> object from which to copy</param>
 public Location( Location rhs )
 {
     this.x = rhs.x;
     this.y = rhs.y;
     this.width = rhs.width;
     this.height = rhs.height;
     this.coordinateFrame = rhs.CoordinateFrame;
     this.alignH = rhs.AlignH;
     this.alignV = rhs.AlignV;
 }
Example #34
0
        /// <summary>
        /// Constructor that creates a <see cref="GraphObj"/> with the specified
        /// position, <see cref="CoordType"/>, <see cref="AlignH"/>, and <see cref="AlignV"/>.
        /// Other properties are set to default values as defined in the <see cref="Default"/> class.
        /// </summary>
        /// <remarks>
        /// The four coordinates define the starting point and ending point for
        /// <see cref="ArrowObj"/>'s, or the topleft and bottomright points for
        /// <see cref="ImageObj"/>'s.  For <see cref="GraphObj"/>'s that only require
        /// one point, the <see paramref="x2"/> and <see paramref="y2"/> values
        /// will be ignored.  The units of the coordinates are specified by the
        /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.
        /// </remarks>
        /// <param name="x">The x position of the item.</param>
        /// <param name="y">The y position of the item.</param>
        /// <param name="x2">The x2 position of the item.</param>
        /// <param name="y2">The x2 position of the item.</param>
        /// <param name="coordType">The <see cref="CoordType"/> enum value that
        /// indicates what type of coordinate system the x and y parameters are
        /// referenced to.</param>
        /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
        /// the horizontal alignment of the object with respect to the (x,y) location</param>
        /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
        /// the vertical alignment of the object with respect to the (x,y) location</param>
        public GraphObj( double x, double y, double x2, double y2, CoordType coordType,
					AlignH alignH, AlignV alignV )
        {
            _isVisible = true;
            _isClippedToChartRect = Default.IsClippedToChartRect;
            this.Tag = null;
            _zOrder = ZOrder.A_InFront;
            _location = new Location( x, y, x2, y2, coordType, alignH, alignV );
            _link = new Link();
        }
Example #35
0
        /// <summary>
        /// Determines if the specified screen point lies within the bounding box of
        /// the text, taking into account alignment and rotation parameters.
        /// </summary>
        /// <param name="pt">The screen point, in pixel units</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="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="GraphPane.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 within the bounding box, false otherwise</returns>
        public bool PointInBox(PointF pt, Graphics g, string text, float x,
                               float y, AlignH alignH, AlignV alignV,
                               double scaleFactor)
        {
            // make sure the font size is properly scaled
            Remake(scaleFactor, this.Size, ref this.scaledSize, ref this.font);

            // Get the width and height of the text
            SizeF sizeF = g.MeasureString(text, this.font);

            // Create a bounding box rectangle for the text
            RectangleF rect = new RectangleF(new PointF(-sizeF.Width / 2.0F, 0.0F), sizeF);

            // Build a transform matrix that inverts that drawing transform
            // in this manner, the point is brought back to the box, rather
            // than vice-versa.  This allows the container check to be a simple
            // RectangleF.Contains, since the rectangle won't be rotated.
            Matrix matrix = new Matrix();

            // In this case, the bounding box is anchored to the
            // top-left of the text box.  Handle the alignment
            // as needed.
            float xa, ya;

            if (alignH == AlignH.Left)
            {
                xa = sizeF.Width / 2.0F;
            }
            else if (alignH == AlignH.Right)
            {
                xa = -sizeF.Width / 2.0F;
            }
            else
            {
                xa = 0.0F;
            }

            if (alignV == AlignV.Center)
            {
                ya = -sizeF.Height / 2.0F;
            }
            else if (alignV == AlignV.Bottom)
            {
                ya = -sizeF.Height;
            }
            else
            {
                ya = 0.0F;
            }

            // Shift the coordinates to accomodate the alignment
            // parameters
            matrix.Translate(-xa, -ya, MatrixOrder.Prepend);

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if (angle != 0.0F)
            {
                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(-x, -y, MatrixOrder.Prepend);

            PointF[] pts = new PointF[1];
            pts[0] = pt;
            matrix.TransformPoints(pts);

            return(rect.Contains(pts[0]));
        }
Example #36
0
        /// <summary>
        /// Constructor for the <see cref="Location"/> class that specifies the
        /// (x, y), (width, height), and the <see cref="CoordType"/>.
        /// </summary>
        /// <remarks>
        /// The (x,y) position
        /// corresponds to the starting position, the (x2, y2) coorresponds to the ending position
        /// (typically used for <see cref="ArrowItem"/>'s).
        /// </remarks>
        /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
        /// </param>
        /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
        /// </param>
        /// <param name="width">The width, specified in units of <see paramref="coordType"/>.
        /// </param>
        /// <param name="height">The height, specified in units of <see paramref="coordType"/>.
        /// </param>
        /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
        /// units for <see paramref="x"/> and <see paramref="y"/></param>
        /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
        /// the horizontal alignment of the object with respect to the (x,y) location</param>
        /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
        /// the vertical alignment of the object with respect to the (x,y) location</param>
        public Location( float x, float y, float width, float height,
			CoordType coordType, AlignH alignH, AlignV alignV )
            : this(x, y, coordType, alignH, alignV)
        {
            this.width = width;
            this.height = height;
        }
Example #37
0
 /// <summary>
 /// Constructor that creates a <see cref="Brush"/> fill, using a user-supplied, custom
 /// <see cref="Brush"/>.  This constructor will make the brush unscaled (see <see cref="IsScaled"/>),
 /// but it provides <see paramref="alignH"/> and <see paramref="alignV"/> parameters to control
 /// alignment of the brush with respect to the filled object.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> to use for fancy fills.  Typically, this would
 /// be a <see cref="LinearGradientBrush"/> or a <see cref="TextureBrush"/> class</param>
 /// <param name="alignH">Controls the horizontal alignment of the brush within the filled object
 /// (see <see cref="AlignH"/></param>
 /// <param name="alignV">Controls the vertical alignment of the brush within the filled object
 /// (see <see cref="AlignV"/></param>
 public Fill( Brush brush, AlignH alignH, AlignV alignV )
 {
     Init();
     this.alignH = alignH;
     this.alignV = alignV;
     this.isScaled = false;
     this.color = Color.White;
     this.brush = (Brush) brush.Clone();
     this.type = FillType.Brush;
 }
Example #38
0
        private Matrix SetupMatrix( Matrix matrix, float x, float y, SizeF sizeF, AlignH alignH,
				AlignV alignV, float angle )
        {
            // Move the coordinate system to local coordinates
            // of this text object (that is, at the specified
            // x,y location)
            matrix.Translate( x, y, MatrixOrder.Prepend );

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if ( _angle != 0.0F )
                matrix.Rotate( -angle, MatrixOrder.Prepend );

            // Since the text will be drawn by g.DrawString()
            // assuming the location is the TopCenter
            // (the Font is aligned using StringFormat to the
            // center so multi-line text is center justified),
            // shift the coordinate system so that we are
            // actually aligned per the caller specified position
            float xa, ya;
            if ( alignH == AlignH.Left )
                xa = sizeF.Width / 2.0F;
            else if ( alignH == AlignH.Right )
                xa = -sizeF.Width / 2.0F;
            else
                xa = 0.0F;

            if ( alignV == AlignV.Center )
                ya = -sizeF.Height / 2.0F;
            else if ( alignV == AlignV.Bottom )
                ya = -sizeF.Height;
            else
                ya = 0.0F;

            // Shift the coordinates to accomodate the alignment
            // parameters
            matrix.Translate( xa, ya, MatrixOrder.Prepend );

            return matrix;
        }
Example #39
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Location"/> class. 
 /// The Copy Constructor
 /// </summary>
 /// <param name="rhs">
 /// The <see cref="Location"/> object from which to copy
 /// </param>
 public Location(Location rhs)
 {
     this._x = rhs._x;
     this._y = rhs._y;
     this._width = rhs._width;
     this._height = rhs._height;
     this._coordinateFrame = rhs.CoordinateFrame;
     this._alignH = rhs.AlignH;
     this._alignV = rhs.AlignV;
 }
Example #40
0
        /// <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>
        /// <param name="layoutArea">The limiting area (<see cref="SizeF"/>) into which the text
        /// must fit.  The actual rectangle may be smaller than this, but the text will be wrapped
        /// to accomodate the area.</param>
        public void Draw( Graphics g, PaneBase pane, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			float scaleFactor, SizeF layoutArea )
        {
            // make sure the font size is properly scaled
            //Remake( scaleFactor, this.Size, ref this.scaledSize, ref this.font );

            SmoothingMode sModeSave = g.SmoothingMode;
            TextRenderingHint sHintSave = g.TextRenderingHint;
            if ( _isAntiAlias )
            {
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.TextRenderingHint = TextRenderingHint.AntiAlias;
            }

            SizeF sizeF;
            if ( layoutArea.IsEmpty )
                sizeF = MeasureString( g, text, scaleFactor );
            else
                sizeF = MeasureString( g, text, scaleFactor, layoutArea );

            // Save the old transform matrix for later restoration
            Matrix saveMatrix = g.Transform;
            g.Transform = SetupMatrix( g.Transform, x, y, sizeF, alignH, alignV, _angle );

            // Create a rectangle representing the border around the
            // text.  Note that, while the text is drawn based on the
            // TopCenter position, the rectangle is drawn based on
            // the TopLeft position.  Therefore, move the rectangle
            // width/2 to the left to align it properly
            RectangleF rectF = new RectangleF( -sizeF.Width / 2.0F, 0.0F,
                                sizeF.Width, sizeF.Height );

            // If the background is to be filled, fill it
            _fill.Draw( g, rectF );

            // Draw the border around the text if required
            _border.Draw( g, pane, scaleFactor, rectF );

            // make a center justified StringFormat alignment
            // for drawing the text
            StringFormat strFormat = new StringFormat();
            strFormat.Alignment = _stringAlignment;
            //			if ( this.stringAlignment == StringAlignment.Far )
            //				g.TranslateTransform( sizeF.Width / 2.0F, 0F, MatrixOrder.Prepend );
            //			else if ( this.stringAlignment == StringAlignment.Near )
            //				g.TranslateTransform( -sizeF.Width / 2.0F, 0F, MatrixOrder.Prepend );

            // Draw the drop shadow text.  Note that the coordinate system
            // is set up such that 0,0 is at the location where the
            // CenterTop of the text needs to be.
            if ( _isDropShadow )
            {
                float xShift = (float)( Math.Cos( _dropShadowAngle ) *
                            _dropShadowOffset * _font.Height );
                float yShift = (float)( Math.Sin( _dropShadowAngle ) *
                            _dropShadowOffset * _font.Height );
                RectangleF rectD = rectF;
                rectD.Offset( xShift, yShift );
                // make a solid brush for rendering the font itself
                using ( SolidBrush brushD = new SolidBrush( _dropShadowColor ) )
                    g.DrawString( text, _font, brushD, rectD, strFormat );
            }

            // make a solid brush for rendering the font itself
            using ( SolidBrush brush = new SolidBrush( _fontColor ) )
            {
                // Draw the actual text.  Note that the coordinate system
                // is set up such that 0,0 is at the location where the
                // CenterTop of the text needs to be.
                //RectangleF layoutArea = new RectangleF( 0.0F, 0.0F, sizeF.Width, sizeF.Height );
                g.DrawString( text, _font, brush, rectF, strFormat );

                //System.Diagnostics.Trace.WriteLine(string.Format("draw {0} font size {1}",
                //    text, _font.Size));
            }

            // Restore the transform matrix back to original
            g.Transform = saveMatrix;

            g.SmoothingMode = sModeSave;
            g.TextRenderingHint = sHintSave;
        }
Example #41
0
 /// <summary>
 /// Constructor that sets all <see cref="TextItem"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="x">The x position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public TextItem( string text, float x, float y, CoordType coordType, AlignH alignH, AlignV alignV )
     : base(x, y, coordType, alignH, alignV)
 {
     Init( text );
 }
Example #42
0
        /// <summary>
        /// Returns a polygon that defines the bounding box of
        /// the text, taking into account alignment and rotation parameters.
        /// </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="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>
        /// <param name="layoutArea">The limiting area (<see cref="SizeF"/>) into which the text
        /// must fit.  The actual rectangle may be smaller than this, but the text will be wrapped
        /// to accomodate the area.</param>
        /// <returns>A polygon of 4 points defining the area of this text</returns>
        public PointF[] GetBox( Graphics g, string text, float x,
				float y, AlignH alignH, AlignV alignV,
				float scaleFactor, SizeF layoutArea )
        {
            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref _scaledSize, ref _font );

            // Get the width and height of the text
            SizeF sizeF;
            if ( layoutArea.IsEmpty )
                sizeF = g.MeasureString( text, _font );
            else
                sizeF = g.MeasureString( text, _font, layoutArea );

            // Create a bounding box rectangle for the text
            RectangleF rect = new RectangleF( new PointF( -sizeF.Width / 2.0F, 0.0F ), sizeF );

            Matrix matrix = new Matrix();
            SetupMatrix( matrix, x, y, sizeF, alignH, alignV, _angle );

            PointF[] pts = new PointF[4];
            pts[0] = new PointF( rect.Left, rect.Top );
            pts[1] = new PointF( rect.Right, rect.Top );
            pts[2] = new PointF( rect.Right, rect.Bottom );
            pts[3] = new PointF( rect.Left, rect.Bottom );
            matrix.TransformPoints( pts );

            return pts;
        }
Example #43
0
 /// <summary>
 /// Constructor that sets all <see cref="TextItem"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="x">The x position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public TextItem(string text, float x, float y, CoordType coordType, AlignH alignH, AlignV alignV) :
     base(x, y, coordType, alignH, alignV)
 {
     Init(text);
 }
Example #44
0
 /// <summary>
 /// Constructor that creates a <see cref="Brush"/> fill, using a user-supplied, custom
 /// <see cref="Brush"/>.  This constructor will make the brush unscaled (see <see cref="IsScaled"/>),
 /// but it provides <see paramref="alignH"/> and <see paramref="alignV"/> parameters to control
 /// alignment of the brush with respect to the filled object.
 /// </summary>
 /// <param name="brush">The <see cref="Brush"/> to use for fancy fills.  Typically, this would
 /// be a <see cref="LinearGradientBrush"/> or a <see cref="TextureBrush"/> class</param>
 /// <param name="alignH">Controls the horizontal alignment of the brush within the filled object
 /// (see <see cref="AlignH"/></param>
 /// <param name="alignV">Controls the vertical alignment of the brush within the filled object
 /// (see <see cref="AlignV"/></param>
 public Fill( Brush brush, AlignH alignH, AlignV alignV )
 {
     Init();
     _alignH = alignH;
     _alignV = alignV;
     _isScaled = false;
     _color = Color.White;
     _brush = (Brush) brush.Clone();
     _type = FillType.Brush;
 }
Example #45
0
		/// <summary>
		/// Constructor for deserializing objects
		/// </summary>
		/// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
		/// </param>
		/// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
		/// </param>
		protected Location(SerializationInfo info, StreamingContext context)
		{
			// The schema value is just a file version parameter.  You can use it to make future versions
			// backwards compatible as new member variables are added to classes
			int sch = info.GetInt32("schema");

			_alignV = (AlignV) info.GetValue("alignV", typeof (AlignV));
			_alignH = (AlignH) info.GetValue("alignH", typeof (AlignH));
			_x = info.GetDouble("x");
			_y = info.GetDouble("y");
			_width = info.GetDouble("width");
			_height = info.GetDouble("height");
			_coordinateFrame = (CoordType) info.GetValue("coordinateFrame", typeof (CoordType));
		}
Example #46
0
        // schema changed to 2 with addition of rangeDefault
        // schema changed to 10 with version 5 refactor -- not backwards compatible
        /// <summary>
        /// Constructor for deserializing objects
        /// </summary>
        /// <param name="info">A <see cref="SerializationInfo"/> instance that defines the serialized data
        /// </param>
        /// <param name="context">A <see cref="StreamingContext"/> instance that contains the serialized data
        /// </param>
        protected Fill( SerializationInfo info, StreamingContext context )
        {
            Init();

            // The schema value is just a file version parameter.  You can use it to make future versions
            // backwards compatible as new member variables are added to classes
            int sch = info.GetInt32( "schema" );

            _color = (Color) info.GetValue( "color", typeof(Color) );
            _secondaryValueGradientColor = (Color) info.GetValue( "secondaryValueGradientColor", typeof( Color ) );
            //brush = (Brush) info.GetValue( "brush", typeof(Brush) );
            //brushHolder = (BrushHolder) info.GetValue( "brushHolder", typeof(BrushHolder) );
            _type = (FillType) info.GetValue( "type", typeof(FillType) );
            _isScaled = info.GetBoolean( "isScaled" );
            _alignH = (AlignH) info.GetValue( "alignH", typeof(AlignH) );
            _alignV = (AlignV) info.GetValue( "alignV", typeof(AlignV) );
            _rangeMin = info.GetDouble( "rangeMin" );
            _rangeMax = info.GetDouble( "rangeMax" );

            //BrushHolder brushHolder = (BrushHolder) info.GetValue( "brushHolder", typeof( BrushHolder ) );
            //brush = brush;

            _colorList = (Color[]) info.GetValue( "colorList", typeof(Color[]) );
            _positionList = (float[]) info.GetValue( "positionList", typeof(float[]) );
            _angle = info.GetSingle( "angle" );
            _image = (Image) info.GetValue( "image", typeof(Image) );
            _wrapMode = (WrapMode) info.GetValue( "wrapMode", typeof(WrapMode) );

            if ( _colorList != null && _positionList != null )
            {
                ColorBlend blend = new ColorBlend();
                blend.Colors = _colorList;
                blend.Positions = _positionList;
                CreateBrushFromBlend( blend, _angle );
            }
            else if ( _image != null )
            {
                _brush = new TextureBrush( _image, _wrapMode );
            }

            _rangeDefault = info.GetDouble( "rangeDefault" );
        }
Example #47
0
 /// <summary>
 /// Constructor that sets all <see cref="TextObj"/> properties to default
 /// values as defined in the <see cref="Default"/> class.
 /// </summary>
 /// <param name="text">The text to be displayed.</param>
 /// <param name="x">The x position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the <see cref="AlignH"/>
 /// property.</param>
 /// <param name="y">The y position of the text.  The units
 /// of this position are specified by the
 /// <see cref="ZedGraph.Location.CoordinateFrame"/> property.  The text will be
 /// aligned to this position based on the
 /// <see cref="AlignV"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public TextObj(string text, double x, double y, CoordType coordType, AlignH alignH, AlignV alignV)
     : base(x, y, coordType, alignH, alignV)
 {
     Init(text);
 }
Example #48
0
 /// <overloads>Constructors for the <see cref="ImageObj"/> object</overloads>
 /// <summary>
 /// A constructor that allows the <see cref="System.Drawing.Image"/> and
 /// <see cref="RectangleF"/> location for the
 /// <see cref="ImageObj"/> to be pre-specified.
 /// </summary>
 /// <param name="image">A <see cref="System.Drawing.Image"/> class that defines
 /// the image</param>
 /// <param name="rect">A <see cref="RectangleF"/> struct that defines the
 /// image location, specifed in units based on the
 /// <see cref="Location.CoordinateFrame"/> property.</param>
 /// <param name="coordType">The <see cref="CoordType"/> enum value that
 /// indicates what type of coordinate system the x and y parameters are
 /// referenced to.</param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public ImageObj(Image image, RectangleF rect, CoordType coordType,
                 AlignH alignH, AlignV alignV)
     : base(rect.X, rect.Y, rect.Width, rect.Height, coordType,
                          alignH, alignV)
 {
     _image = image;
     _isScaled = Default.IsScaled;
 }
Example #49
0
        /// <summary>
        /// Determines if the specified screen point lies within the bounding box of
        /// the text, taking into account alignment and rotation parameters.
        /// </summary>
        /// <param name="pt">The screen point, in pixel units</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="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>
        /// <returns>true if the point lies within the bounding box, false otherwise</returns>
        public bool PointInBox( PointF pt, Graphics g, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			float scaleFactor )
        {
            return PointInBox( pt, g, text, x, y, alignH, alignV, scaleFactor, new SizeF() );
        }
        public static TextObj CreateGraphLabel(string text, float x, float y, AlignH hAlign, AlignV vAlign, Color color)
        {
            TextObj comment = new TextObj(text, x, y, CoordType.ChartFraction, hAlign, vAlign);

            comment.FontSpec.Border.IsVisible = false;
            comment.FontSpec.Fill.IsVisible   = false;
            comment.FontSpec.Family           = "Verdana";
            comment.FontSpec.Size             = 7;
            comment.FontSpec.FontColor        = color;
            return(comment);
        }
Example #51
0
        /// <summary>
        /// Determines if the specified screen point lies within the bounding box of
        /// the text, taking into account alignment and rotation parameters.
        /// </summary>
        /// <param name="pt">The screen point, in pixel units</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="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>
        /// <param name="layoutArea">The limiting area (<see cref="SizeF"/>) into which the text
        /// must fit.  The actual rectangle may be smaller than this, but the text will be wrapped
        /// to accomodate the area.</param>
        /// <returns>true if the point lies within the bounding box, false otherwise</returns>
        public bool PointInBox( PointF pt, Graphics g, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			float scaleFactor, SizeF layoutArea )
        {
            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref _scaledSize, ref _font );

            // Get the width and height of the text
            SizeF sizeF;
            if ( layoutArea.IsEmpty )
                sizeF = g.MeasureString( text, _font );
            else
                sizeF = g.MeasureString( text, _font, layoutArea );

            // Create a bounding box rectangle for the text
            RectangleF rect = new RectangleF( new PointF( -sizeF.Width / 2.0F, 0.0F ), sizeF );

            // Build a transform matrix that inverts that drawing transform
            // in this manner, the point is brought back to the box, rather
            // than vice-versa.  This allows the container check to be a simple
            // RectangleF.Contains, since the rectangle won't be rotated.
            Matrix matrix = GetMatrix( x, y, sizeF, alignH, alignV, _angle );

            PointF[] pts = new PointF[1];
            pts[0] = pt;
            matrix.TransformPoints( pts );

            return rect.Contains( pts[0] );
        }
Example #52
0
		/// <summary>
		/// Constructor for the <see cref="Location"/> class that specifies the
		/// x, y position and the <see cref="CoordType"/>.
		/// </summary>
		/// <remarks>
		/// The (x,y) position corresponds to the top-left corner;
		/// </remarks>
		/// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
		/// units for <see paramref="x"/> and <see paramref="y"/></param>
		/// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
		/// the horizontal alignment of the object with respect to the (x,y) location</param>
		/// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
		/// the vertical alignment of the object with respect to the (x,y) location</param>
		public Location(double x, double y, CoordType coordType, AlignH alignH, AlignV alignV)
		{
			_x = x;
			_y = y;
			_width = 0;
			_height = 0;
			_coordinateFrame = coordType;
			_alignH = alignH;
			_alignV = alignV;
		}
Example #53
0
 /// <summary>
 /// Constructor for the <see cref="Location"/> class that specifies the
 /// x, y position and the <see cref="CoordType"/>.
 /// </summary>
 /// <remarks>
 /// The (x,y) position corresponds to the top-left corner;
 /// </remarks>
 /// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
 /// </param>
 /// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
 /// units for <see paramref="x"/> and <see paramref="y"/></param>
 /// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
 /// the horizontal alignment of the object with respect to the (x,y) location</param>
 /// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
 /// the vertical alignment of the object with respect to the (x,y) location</param>
 public Location( float x, float y, CoordType coordType, AlignH alignH, AlignV alignV )
 {
     this.x = x;
     this.y = y;
     this.width = 0;
     this.height = 0;
     this.coordinateFrame = coordType;
     this.alignH = alignH;
     this.alignV = alignV;
 }
Example #54
0
		/// <summary>
		/// Constructor for the <see cref="Location"/> class that specifies the
		/// (x, y), (width, height), and the <see cref="CoordType"/>.
		/// </summary>
		/// <remarks>
		/// The (x,y) position
		/// corresponds to the starting position, the (x2, y2) coorresponds to the ending position
		/// (typically used for <see cref="ArrowObj"/>'s).
		/// </remarks>
		/// <param name="x">The x position, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="y">The y position, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="width">The width, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="height">The height, specified in units of <see paramref="coordType"/>.
		/// </param>
		/// <param name="coordType">The <see cref="CoordType"/> enum that specifies the
		/// units for <see paramref="x"/> and <see paramref="y"/></param>
		/// <param name="alignH">The <see cref="ZedGraph.AlignH"/> enum that specifies
		/// the horizontal alignment of the object with respect to the (x,y) location</param>
		/// <param name="alignV">The <see cref="ZedGraph.AlignV"/> enum that specifies
		/// the vertical alignment of the object with respect to the (x,y) location</param>
		public Location(double x, double y, double width, double height,
		                CoordType coordType, AlignH alignH, AlignV alignV) :
		                	this(x, y, coordType, alignH, alignV)
		{
			_width = width;
			_height = height;
		}
Example #55
0
		/// <summary>
		/// The Copy Constructor
		/// </summary>
		/// <param name="rhs">The <see cref="Location"/> object from which to copy</param>
		public Location(Location rhs)
		{
			_x = rhs._x;
			_y = rhs._y;
			_width = rhs._width;
			_height = rhs._height;
			_coordinateFrame = rhs.CoordinateFrame;
			_alignH = rhs.AlignH;
			_alignV = rhs.AlignV;
		}
Example #56
0
        /// <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.  This special case method will show the
        /// specified text as a power of 10, using the <see cref="Default.SuperSize"/>
        /// and <see cref="Default.SuperShift"/>.
        /// </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="ZedGraph.GraphPane"/> 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="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public void DrawTenPower(Graphics g, GraphPane pane, string text, float x,
                                 float y, AlignH alignH, AlignV alignV,
                                 double scaleFactor)
        {
            // make sure the font size is properly scaled
            Remake(scaleFactor, this.Size, ref this.scaledSize, ref this.font);
            float scaledSuperSize = this.scaledSize * Default.SuperSize;

            Remake(scaleFactor, this.Size * Default.SuperSize, ref scaledSuperSize,
                   ref this.superScriptFont);

            // Get the width and height of the text
            SizeF size10   = g.MeasureString("10", this.font);
            SizeF sizeText = g.MeasureString(text, this.superScriptFont);
            SizeF totSize  = new SizeF(size10.Width + sizeText.Width,
                                       size10.Height + sizeText.Height * Default.SuperShift);
            float charWidth = g.MeasureString("x", this.superScriptFont).Width;

            // Save the old transform matrix for later restoration
            Matrix matrix = g.Transform;

            // Move the coordinate system to local coordinates
            // of this text object (that is, at the specified
            // x,y location)
            g.TranslateTransform(x, y, MatrixOrder.Prepend);

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if (angle != 0.0F)
            {
                g.RotateTransform(-angle, MatrixOrder.Prepend);
            }

            // Since the text will be drawn by g.DrawString()
            // assuming the location is the TopCenter
            // (the Font is aligned using StringFormat to the
            // center so multi-line text is center justified),
            // shift the coordinate system so that we are
            // actually aligned per the caller specified position
            float xa, ya;

            if (alignH == AlignH.Left)
            {
                xa = totSize.Width / 2.0F;
            }
            else if (alignH == AlignH.Right)
            {
                xa = -totSize.Width / 2.0F;
            }
            else
            {
                xa = 0.0F;
            }

            if (alignV == AlignV.Center)
            {
                ya = -totSize.Height / 2.0F;
            }
            else if (alignV == AlignV.Bottom)
            {
                ya = -totSize.Height;
            }
            else
            {
                ya = 0.0F;
            }

            // Shift the coordinates to accomodate the alignment
            // parameters
            g.TranslateTransform(xa, ya, MatrixOrder.Prepend);

            // make a solid brush for rendering the font itself
            SolidBrush brush = new SolidBrush(this.fontColor);

            // make a center justified StringFormat alignment
            // for drawing the text
            StringFormat strFormat = new StringFormat();

            strFormat.Alignment = this.stringAlignment;

            // Create a rectangle representing the border around the
            // text.  Note that, while the text is drawn based on the
            // TopCenter position, the rectangle is drawn based on
            // the TopLeft position.  Therefore, move the rectangle
            // width/2 to the left to align it properly
            RectangleF rectF = new RectangleF(-totSize.Width / 2.0F, 0.0F,
                                              totSize.Width, totSize.Height);

            // If the background is to be filled, fill it
            this.fill.Draw(g, rectF);

            // Draw the border around the text if required
            this.border.Draw(g, pane, scaleFactor, rectF);

            // Draw the actual text.  Note that the coordinate system
            // is set up such that 0,0 is at the location where the
            // CenterTop of the text needs to be.
            g.DrawString("10", this.font, brush,
                         (-totSize.Width + size10.Width) / 2.0F,
                         sizeText.Height * Default.SuperShift, strFormat);
            g.DrawString(text, this.superScriptFont, brush,
                         (totSize.Width - sizeText.Width - charWidth) / 2.0F,
                         0.0F,
                         strFormat);

            // Restore the transform matrix back to original
            g.Transform = matrix;
        }
Example #57
0
        /// <summary>
        /// Determines if the specified screen point lies within the bounding box of
        /// the text, taking into account alignment and rotation parameters.
        /// </summary>
        /// <param name="pt">The screen point, in pixel units</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="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="GraphPane.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 within the bounding box, false otherwise</returns>
        public bool PointInBox( PointF pt, Graphics g, string text, float x,
			float y, AlignH alignH, AlignV alignV,
			double scaleFactor )
        {
            // make sure the font size is properly scaled
            Remake( scaleFactor, this.Size, ref this.scaledSize, ref this.font );

            // Get the width and height of the text
            SizeF sizeF = g.MeasureString( text, this.font );

            // Create a bounding box rectangle for the text
            RectangleF rect = new RectangleF( new PointF( -sizeF.Width / 2.0F, 0.0F), sizeF );

            // Build a transform matrix that inverts that drawing transform
            // in this manner, the point is brought back to the box, rather
            // than vice-versa.  This allows the container check to be a simple
            // RectangleF.Contains, since the rectangle won't be rotated.
            Matrix matrix = new Matrix();

            // In this case, the bounding box is anchored to the
            // top-left of the text box.  Handle the alignment
            // as needed.
            float	xa, ya;
            if ( alignH == AlignH.Left )
                xa = sizeF.Width / 2.0F;
            else if ( alignH == AlignH.Right )
                xa = -sizeF.Width / 2.0F;
            else
                xa = 0.0F;

            if ( alignV == AlignV.Center )
                ya = -sizeF.Height / 2.0F;
            else if ( alignV == AlignV.Bottom )
                ya = -sizeF.Height;
            else
                ya = 0.0F;

            // Shift the coordinates to accomodate the alignment
            // parameters
            matrix.Translate( -xa, -ya, MatrixOrder.Prepend );

            // Rotate the coordinate system according to the
            // specified angle of the FontSpec
            if ( angle != 0.0F )
                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( -x, -y, MatrixOrder.Prepend );

            PointF[] pts = new PointF[1];
            pts[0] = pt;
            matrix.TransformPoints( pts );

            return rect.Contains( pts[0] );
        }