Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of Symbol
 /// </summary>
 public Symbol()
 {
     _size = new Size2D(4,4);
     _offset = new Position2D(0,0);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Only copies the shared placement aspects (Size, Offset, Angle) from the specified symbol.
 /// </summary>
 /// <param name="symbol">The symbol to copy values from.</param>
 public void CopyPlacement(ISymbol symbol)
 {
     if (_innerSymbol != null)
     {
         _innerSymbol.CopyPlacement(symbol);
         return;
     }
     _size = symbol.Size.Copy();
     _offset = symbol.Offset.Copy();
     _angle = symbol.Angle;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculates a size that would be necessary to contain the entire symbol, taking rotation and
        /// offset into account.
        /// </summary>
        /// <returns></returns>
        public Size2D GetBoundingSize()
        {
            if (_innerSymbol != null)
            {
                return _innerSymbol.GetBoundingSize();
            }

            // x and y represent the magnitude of the separation from the center
            double x = 0;
            double y =0;
     

            double dx = _size.Width / 2;
            double dy = _size.Height /2;
            Position2D[] corners = new Position2D[4];
            corners[TOP_LEFT] = new Position2D(-dx, dy);
            corners[TOP_RIGHT] = new Position2D(dx, dy);
            corners[BOTTOM_LEFT] = new Position2D(-dx, -dy);
            corners[BOTTOM_RIGHT] = new Position2D(dx, -dy);
            
            double radians = _angle * Math.PI / 180;

            for(int i = 0; i < 4; i++)
            {
                Position2D corner = corners[i];
                Position2D rotated = new Position2D();
                rotated.X = corner.X * Math.Cos(radians) - corner.Y * Math.Sin(radians);
                rotated.Y = corner.X * Math.Sin(radians) + corner.Y * Math.Cos(radians);

                Position2D shifted = new Position2D();
                shifted.X = rotated.X + _offset.X;
                shifted.Y = rotated.Y + _offset.Y;

                if (Math.Abs(shifted.X) > x) x = Math.Abs(shifted.X);
                if (Math.Abs(shifted.Y) > y) y = Math.Abs(shifted.Y);
              
            }

            // Since x and y represent a "distance" from (0,0), the size has to be twice that.
            return new Size2D(2*x, 2*y);
           
           
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of PicturePattern
 /// </summary>
 public PicturePattern()
 {
     _scale = new Position2D(1, 1);
     _wrapMode = WrapMode.Tile;
     _dialogFilter = "Image Files|*.bmp;*.gif;*.jpg;*.png;*.tif;*.ico";
 }