public RectangleF GetLabelBounds(TextObj textObj, GraphPane graphPane, Graphics graphics)
        {
            SizeF size;
            lock (_textBoxSizes)
            {
                var label = new Label {Text = textObj.Text, FontSize = textObj.FontSpec.Size};
                if (!_textBoxSizes.TryGetValue(label, out size))
                {
                    const float scaleFactor = 1.0f;

                    // This is a really expensive call, so we're caching its result across threads.
                    var coords = textObj.FontSpec.GetBox(
                        graphics, textObj.Text, 0, 0,
                        textObj.Location.AlignH, textObj.Location.AlignV, scaleFactor, new SizeF());

                    // Turn four points into a size.
                    var min = coords[0];
                    var max = min;
                    for (int i = 1; i < coords.Length; i++)
                    {
                        var point = coords[i];
                        if (min.X > point.X)
                            min.X = point.X;
                        if (min.Y > point.Y)
                            min.Y = point.Y;
                        if (max.X < point.X)
                            max.X = point.X;
                        if (max.Y < point.Y)
                            max.Y = point.Y;
                    }
                    size = new SizeF(max.X - min.X, max.Y - min.Y);

                    // Cache the result.
                    _textBoxSizes[label] = size;
                }
            }

            PointF pix = textObj.Location.Transform(graphPane);
            return new RectangleF(pix, size);
        }
 private bool Equals(Label other)
 {
     return string.Equals(Text, other.Text) && FontSize.Equals(other.FontSize);
 }
示例#3
0
文件: Label.cs 项目: stewmc/vixen
		/// <summary>
		/// Copy constructor
		/// </summary>
		/// <param name="rhs">the <see cref="Label" /> instance to be copied.</param>
		public Label(Label rhs)
		{
			if (rhs._text != null)
				_text = (string) rhs._text.Clone();
			else
				_text = string.Empty;

			_isVisible = rhs._isVisible;
			if (rhs._fontSpec != null)
				_fontSpec = rhs._fontSpec.Clone();
			else
				_fontSpec = null;
		}
示例#4
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 CurveItem( 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" );

            _label = (Label) info.GetValue( "label", typeof(Label) );
            _isY2Axis = info.GetBoolean( "isY2Axis" );
            if ( sch >= 11 )
                _isX2Axis = info.GetBoolean( "isX2Axis" );
            else
                _isX2Axis = false;

            _isVisible = info.GetBoolean( "isVisible" );

            _isOverrideOrdinal = info.GetBoolean( "isOverrideOrdinal" );

            // Data Points are always stored as a PointPairList, regardless of the
            // actual original type (which could be anything that supports IPointList).
            _points = (PointPairList) info.GetValue( "points", typeof(PointPairList) );

            Tag = info.GetValue( "Tag", typeof(object) );

            _yAxisIndex = info.GetInt32( "yAxisIndex" );

            _link = (Link) info.GetValue( "link", typeof(Link) );
        }
示例#5
0
        /// <summary>
        /// The Copy Constructor
        /// </summary>
        /// <param name="rhs">The CurveItem object from which to copy</param>
        public CurveItem( CurveItem rhs )
        {
            _label = rhs._label.Clone();
            _isY2Axis = rhs.IsY2Axis;
            _isX2Axis = rhs.IsX2Axis;
            _isVisible = rhs.IsVisible;
            _isOverrideOrdinal = rhs._isOverrideOrdinal;
            _yAxisIndex = rhs._yAxisIndex;

            if ( rhs.Tag is ICloneable )
                this.Tag = ((ICloneable) rhs.Tag).Clone();
            else
                this.Tag = rhs.Tag;

            _points = (IPointList) rhs.Points.Clone();

            _link = rhs._link.Clone();
        }
示例#6
0
 /// <summary>
 /// Internal initialization routine thats sets some initial values to defaults.
 /// </summary>
 /// <param name="label">A string label (legend entry) for this curve</param>
 private void Init( string label )
 {
     _label = new Label( label, null );
     _isY2Axis = false;
     _isX2Axis = false;
     _isVisible = true;
     _isOverrideOrdinal = false;
     this.Tag = null;
     _yAxisIndex = 0;
     _link = new Link();
 }
示例#7
0
 /// <summary>
 /// Local dispose method
 /// </summary>
 /// <param name="bDisposing">if disposing is required</param>
 protected virtual void Dispose(bool bDisposing)
 {
     if (!m_bDisposed)
     {
         if (bDisposing)
         {
             if (_label != null)
             {
                 _label.Dispose();
                 _label = null;
             }
         }
         m_bDisposed = true;
     }
 }