Esempio n. 1
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));
        }
Esempio n. 2
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;
        }
Esempio n. 3
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>
 protected GraphObj(
     double x,
     double y,
     double x2,
     double y2,
     CoordType coordType,
     AlignH alignH,
     AlignV alignV)
 {
     _isVisible            = true;
     _isClippedToChartRect = Default.IsClippedToChartRect;
     Tag       = null;
     _zOrder   = ZOrder.A_InFront;
     _location = new Location(x, y, x2, y2, coordType, alignH, alignV);
     _link     = new Link();
 }
Esempio n. 4
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;
 }
Esempio n. 5
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;
        }
Esempio n. 6
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;
 }
Esempio n. 7
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");
        }
Esempio n. 8
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;
        }
Esempio n. 9
0
        public Scale(Scale rhs, Axis owner)
        {
            _ownerAxis = owner;

            _min       = rhs._min;
            _max       = rhs._max;
            _majorStep = rhs._majorStep;
            _minorStep = rhs._minorStep;
            _exponent  = rhs._exponent;
            _baseTic   = rhs._baseTic;

            _minAuto       = rhs._minAuto;
            _maxAuto       = rhs._maxAuto;
            _majorStepAuto = rhs._majorStepAuto;
            _minorStepAuto = rhs._minorStepAuto;
            _magAuto       = rhs._magAuto;
            _formatAuto    = rhs._formatAuto;

            _isMinLabelVisible = rhs._isMinLabelVisible;
            _isMaxLabelVisible = rhs._isMaxLabelVisible;

            _majorUnit = rhs._majorUnit;
            _minorUnit = rhs._minorUnit;

            _format = rhs._format;

            _align          = rhs._align;
            _alignH         = rhs._alignH;
            _alignHMaxLabel = rhs._alignHMaxLabel;
            _alignHMinLabel = rhs._alignHMinLabel;

            if (rhs._textLabels != null)
            {
                _textLabels = (string[])rhs._textLabels.Clone();
            }
            else
            {
                _textLabels = null;
            }
        }
Esempio n. 10
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;
 }
Esempio n. 11
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;
 }
Esempio n. 12
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;
        }
Esempio n. 13
0
        /// <summary>
        /// Copy Constructor.  Create a new <see cref="Scale" /> object based on the specified
        /// existing one.
        /// </summary>
        /// <param name="rhs">The <see cref="Scale" /> object to be copied.</param>
        /// <param name="owner">The <see cref="Axis" /> object that will own the
        /// new instance of <see cref="Scale" /></param>
        public Scale( Scale rhs, Axis owner )
        {
            _ownerAxis = owner;

            _min = rhs._min;
            _max = rhs._max;
            _majorStep = rhs._majorStep;
            _minorStep = rhs._minorStep;
            _exponent = rhs._exponent;
            _baseTic = rhs._baseTic;

            _minAuto = rhs._minAuto;
            _maxAuto = rhs._maxAuto;
            _majorStepAuto = rhs._majorStepAuto;
            _minorStepAuto = rhs._minorStepAuto;
            _magAuto = rhs._magAuto;
            _formatAuto = rhs._formatAuto;

            _minGrace = rhs._minGrace;
            _maxGrace = rhs._maxGrace;

            _mag = rhs._mag;

            _isUseTenPower = rhs._isUseTenPower;
            _isReverse = rhs._isReverse;
            _isPreventLabelOverlap = rhs._isPreventLabelOverlap;
            _isVisible = rhs._isVisible;
            _isSkipFirstLabel = rhs._isSkipFirstLabel;
            _isSkipLastLabel = rhs._isSkipLastLabel;
            _isSkipCrossLabel = rhs._isSkipCrossLabel;

            _majorUnit = rhs._majorUnit;
            _minorUnit = rhs._minorUnit;

            _format = rhs._format;

            _isLabelsInside = rhs._isLabelsInside;
            _align = rhs._align;
            _alignH = rhs._alignH;

            _fontSpec = (FontSpec) rhs._fontSpec.Clone();

            _labelGap = rhs._labelGap;

            if ( rhs._textLabels != null )
                _textLabels = (string[])rhs._textLabels.Clone();
            else
                _textLabels = null;
        }
Esempio n. 14
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;
        }
Esempio n. 15
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;
        }
Esempio n. 16
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;
        }
Esempio n. 17
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] );
        }
Esempio n. 18
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 );
 }
Esempio n. 19
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;
 }
Esempio n. 20
0
 /// <summary>
 /// Apply style to Zedgraph text object
 /// </summary>
 /// <param name="textObj"></param>
 /// <param name="color"></param>
 /// <param name="size"></param>
 /// <param name="alignH"></param>
 public static TextObj Style(this TextObj textObj, Color color,  int size, AlignH alignH)
 {
     textObj.Style(color, size);
     textObj.Location.AlignH = alignH;
     return textObj;
 }
Esempio n. 21
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 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.Tag      = null;
     this.zOrder   = ZOrder.A_InFront;
     this.location = new Location(x, y, coordType, alignH, alignV);
 }
Esempio n. 22
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;
 }
Esempio n. 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);
 }
Esempio n. 24
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;
 }
Esempio n. 25
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() );
        }
Esempio n. 26
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);
 }
Esempio n. 27
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;
        }
Esempio n. 28
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" );
        }
Esempio n. 29
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() );
        }
Esempio n. 30
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;
 }
Esempio n. 31
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;
        }
Esempio n. 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;
        }
Esempio n. 33
0
        /// <summary>
        /// Basic constructor -- requires that the <see cref="Scale" /> object be intialized with
        /// a pre-existing owner <see cref="Axis" />.
        /// </summary>
        /// <param name="ownerAxis">The <see cref="Axis" /> object that is the owner of this
        /// <see cref="Scale" /> instance.</param>
        public Scale( Axis ownerAxis )
        {
            _ownerAxis = ownerAxis;

            _min = 0.0;
            _max = 1.0;
            _majorStep = 0.1;
            _minorStep = 0.1;
            _exponent = 1.0;
            _mag = 0;
            _baseTic = PointPair.Missing;

            _minGrace = Default.MinGrace;
            _maxGrace = Default.MaxGrace;

            _minAuto = true;
            _maxAuto = true;
            _majorStepAuto = true;
            _minorStepAuto = true;
            _magAuto = true;
            _formatAuto = true;

            _isReverse = Default.IsReverse;
            _isUseTenPower = true;
            _isPreventLabelOverlap = true;
            _isVisible = true;
            _isSkipFirstLabel = false;
            _isSkipLastLabel = false;
            _isSkipCrossLabel = false;

            _majorUnit = DateUnit.Day;
            _minorUnit = DateUnit.Day;

            _format = null;
            _textLabels = null;

            _isLabelsInside = Default.IsLabelsInside;
            _align = Default.Align;
            _alignH = Default.AlignH;

            _fontSpec = new FontSpec(
                Default.FontFamily, Default.FontSize,
                Default.FontColor, Default.FontBold,
                Default.FontUnderline, Default.FontItalic,
                Default.FillColor, Default.FillBrush,
                Default.FillType );

            _fontSpec.Border.IsVisible = false;
            _labelGap = Default.LabelGap;
        }
Esempio n. 34
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]));
        }
Esempio n. 35
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 Scale( 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" );

            _min = info.GetDouble( "min" );
            _max = info.GetDouble( "max" );
            _majorStep = info.GetDouble( "majorStep" );
            _minorStep = info.GetDouble( "minorStep" );
            _exponent = info.GetDouble( "exponent" );
            _baseTic = info.GetDouble( "baseTic" );

            _minAuto = info.GetBoolean( "minAuto" );
            _maxAuto = info.GetBoolean( "maxAuto" );
            _majorStepAuto = info.GetBoolean( "majorStepAuto" );
            _minorStepAuto = info.GetBoolean( "minorStepAuto" );
            _magAuto = info.GetBoolean( "magAuto" );
            _formatAuto = info.GetBoolean( "formatAuto" );

            _minGrace = info.GetDouble( "minGrace" );
            _maxGrace = info.GetDouble( "maxGrace" );

            _mag = info.GetInt32( "mag" );

            _isReverse = info.GetBoolean( "isReverse" );
            _isPreventLabelOverlap = info.GetBoolean( "isPreventLabelOverlap" );
            _isUseTenPower = info.GetBoolean( "isUseTenPower" );

            _isVisible = true;
            _isVisible = info.GetBoolean( "isVisible" );

            _isSkipFirstLabel = info.GetBoolean( "isSkipFirstLabel" );
            _isSkipLastLabel = info.GetBoolean( "isSkipLastLabel" );
            _isSkipCrossLabel = info.GetBoolean( "isSkipCrossLabel" );

            _textLabels = (string[]) info.GetValue( "textLabels", typeof(string[]) );
            _format = info.GetString( "format" );

            _majorUnit = (DateUnit) info.GetValue( "majorUnit", typeof(DateUnit) );
            _minorUnit = (DateUnit) info.GetValue( "minorUnit", typeof(DateUnit) );

            _isLabelsInside = info.GetBoolean( "isLabelsInside" );
            _align = (AlignP)info.GetValue( "align", typeof( AlignP ) );
            if ( schema >= 11 )
                _alignH = (AlignH)info.GetValue( "alignH", typeof( AlignH ) );

            _fontSpec = (FontSpec)info.GetValue( "fontSpec", typeof( FontSpec ) );
            _labelGap = info.GetSingle( "labelGap" );
        }
Esempio n. 36
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));
		}
Esempio n. 37
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;
        }
Esempio n. 38
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;
 }
Esempio n. 39
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;
        }
Esempio n. 40
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;
		}
Esempio n. 41
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 );
 }
Esempio n. 42
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;
		}
Esempio n. 43
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();
        }
Esempio n. 44
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;
		}