示例#1
0
        public override bool CopyFrom(object obj)
        {
            bool isCopied = base.CopyFrom(obj);

            if (isCopied && !object.ReferenceEquals(this, obj))
            {
                var from = obj as FloatingScale;
                if (null != from)
                {
                    _cachedPath = null;

                    _scaleSpanValue   = from._scaleSpanValue;
                    _scaleSpanType    = from._scaleSpanType;
                    _scaleNumber      = from._scaleNumber;
                    _scaleSegmentType = from._scaleSegmentType;

                    CopyHelper.Copy(ref _tickSpacing, from._tickSpacing);
                    CopyHelper.Copy(ref _axisStyle, from._axisStyle);

                    _backgroundPadding = from._backgroundPadding;
                    CopyHelper.Copy(ref _background, from._background);
                }
            }
            return(isCopied);
        }
示例#2
0
        /// <summary>
        /// Try to copy from another object. Should try to copy even if the object to copy from is not of
        /// the same type, but a base type. In this case only the base properties should be copied.
        /// </summary>
        /// <param name="obj">Object to copy from.</param>
        /// <returns>
        /// True if at least parts of the object could be copied, false if the object to copy from is incompatible.
        /// </returns>
        public bool CopyFrom(object obj)
        {
            if (object.ReferenceEquals(this, obj))
            {
                return(true);
            }
            var from = obj as RectangularBackground;

            if (null != from)
            {
                _material        = from._material;
                _customDistance  = from._customDistance;
                _customThickness = from._customThickness;
                _padding         = from._padding;
                return(true);
            }
            return(false);
        }
示例#3
0
        protected void MeasureBackground(IGraphicsContext3D g, double itemSizeX, double itemSizeY, double itemSizeZ)
        {
            var fontInfo = FontManager3D.Instance.GetFontInformation(_font);

            double widthOfOne_n   = Glyph.MeasureString("n", _font).X;
            double widthOfThree_M = Glyph.MeasureString("MMM", _font).X;

            if (_background != null)
            {
                _cachedTextPadding = new Margin2D(
                    0.25 * widthOfOne_n,
                    fontInfo.cyDescent,
                    0.25 * widthOfOne_n,
                    fontInfo.cyDescent
                    );
            }
            else
            {
                _cachedTextPadding = new Margin2D(0, 0, 0, 0);
            }

            var paddedTextSize = new VectorD3D((itemSizeX + _cachedTextPadding.Left + _cachedTextPadding.Right), (itemSizeY + _cachedTextPadding.Bottom + _cachedTextPadding.Top), itemSizeZ);
            var textRectangle  = new RectangleD3D(PointD3D.Empty, paddedTextSize); // the origin of the padded text rectangle is always 0

            if (_background != null)
            {
                var backgroundRect = _background.Measure(textRectangle);
                _cachedExtendedTextBounds = backgroundRect.WithRectangleIncluded(textRectangle); //  _cachedExtendedTextBounds.WithOffset(textRectangle.X - backgroundRect.X, textRectangle.Y - backgroundRect.Y, 0);

                ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(_cachedExtendedTextBounds.Size, false);
                _cachedTextOffset = new PointD3D(textRectangle.X - backgroundRect.X + _cachedTextPadding.Left, textRectangle.Y - backgroundRect.Y + _cachedTextPadding.Bottom, 0);
            }
            else
            {
                ((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(paddedTextSize, false);
                _cachedExtendedTextBounds = textRectangle;
                _cachedTextOffset         = PointD3D.Empty;
            }
        }
示例#4
0
		/// <summary>Expands the rectangle by the specified margin.</summary>
		/// <param name="margin">The margin.</param>
		public void Expand(Margin2D margin)
		{
			_x -= margin.Left;
			_w += (margin.Left + margin.Right);
			_y -= margin.Top;
			_h += (margin.Top + margin.Bottom);
		}
示例#5
0
		protected void MeasureBackground(IGraphicsContext3D g, double itemSizeX, double itemSizeY, double itemSizeZ)
		{
			var fontInfo = FontManager3D.Instance.GetFontInformation(_font);

			double widthOfOne_n = Glyph.MeasureString("n", _font).X;
			double widthOfThree_M = Glyph.MeasureString("MMM", _font).X;

			if (this._background != null)
			{
				_cachedTextPadding = new Margin2D(
					0.25 * widthOfOne_n,
					fontInfo.cyDescent,
					0.25 * widthOfOne_n,
					fontInfo.cyDescent
					);
			}
			else
			{
				_cachedTextPadding = new Margin2D(0, 0, 0, 0);
			}

			var paddedTextSize = new VectorD3D((itemSizeX + _cachedTextPadding.Left + _cachedTextPadding.Right), (itemSizeY + _cachedTextPadding.Bottom + _cachedTextPadding.Top), itemSizeZ);
			var textRectangle = new RectangleD3D(PointD3D.Empty, paddedTextSize); // the origin of the padded text rectangle is always 0

			if (this._background != null)
			{
				var backgroundRect = this._background.Measure(textRectangle);
				_cachedExtendedTextBounds = backgroundRect.WithRectangleIncluded(textRectangle); //  _cachedExtendedTextBounds.WithOffset(textRectangle.X - backgroundRect.X, textRectangle.Y - backgroundRect.Y, 0);

				((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(_cachedExtendedTextBounds.Size, false);
				this._cachedTextOffset = new PointD3D(textRectangle.X - backgroundRect.X + _cachedTextPadding.Left, textRectangle.Y - backgroundRect.Y + _cachedTextPadding.Bottom, 0);
			}
			else
			{
				((ItemLocationDirectAutoSize)_location).SetSizeInAutoSizeMode(paddedTextSize, false);
				_cachedExtendedTextBounds = textRectangle;
				_cachedTextOffset = PointD3D.Empty;
			}
		}
示例#6
0
		public override bool CopyFrom(object obj)
		{
			bool isCopied = base.CopyFrom(obj);
			if (isCopied && !object.ReferenceEquals(this, obj))
			{
				var from = obj as FloatingScale;
				if (null != from)
				{
					_cachedPath = null;

					_scaleSpanValue = from._scaleSpanValue;
					_scaleSpanType = from._scaleSpanType;
					_scaleNumber = from._scaleNumber;
					_scaleSegmentType = from._scaleSegmentType;

					CopyHelper.Copy(ref _tickSpacing, from._tickSpacing);
					CopyHelper.Copy(ref _axisStyle, from._axisStyle);

					_backgroundPadding = from._backgroundPadding;
					CopyHelper.Copy(ref _background, from._background);
				}
			}
			return isCopied;
		}
示例#7
0
		/// <summary>
		/// Try to copy from another object. Should try to copy even if the object to copy from is not of
		/// the same type, but a base type. In this case only the base properties should be copied.
		/// </summary>
		/// <param name="obj">Object to copy from.</param>
		/// <returns>
		/// True if at least parts of the object could be copied, false if the object to copy from is incompatible.
		/// </returns>
		public bool CopyFrom(object obj)
		{
			if (object.ReferenceEquals(this, obj))
				return true;
			var from = obj as RectangularBackground;
			if (null != from)
			{
				this._material = from._material;
				this._customDistance = from._customDistance;
				this._customThickness = from._customThickness;
				this._padding = from._padding;
				return true;
			}
			return false;
		}