예제 #1
0
        /// <summary>
        /// Calculates the bounding size for this entire symbol.
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static Size2D GetBoundingSize(this IList<ISymbol> self)
        {
            Size2D size = new Size2D();

            foreach (ISymbol symbol in self)
            {
                Size2D bsize = symbol.GetBoundingSize();
                size.Width = Math.Max(size.Width, bsize.Width);
                size.Height = Math.Max(size.Width, bsize.Height);
            }
            return size;
        }
예제 #2
0
 /// <summary>
 /// Creates a SimpleSymbol with the specified color, shape and size.  The size is used for 
 /// both the horizontal and vertical directions.
 /// </summary>
 /// <param name="color">The color of the symbol</param>
 /// <param name="shape">The shape of the symbol</param>
 /// <param name="size">The size of the symbol</param>
 public SimpleSymbol(Color color, PointShapes shape, double size)
 {
     Configure();
     _color = color;
     _pointShape = shape;
     Size = new Size2D(size, size);
 }
예제 #3
0
 /// <summary>
 /// This replaces the constant size calculation with a size
 /// calculation that is appropriate for features.
 /// </summary>
 /// <param name="count">The integer count of the number of sizes to create.</param>
 /// <returns>A list of double valued sizes.</returns>
 protected override List<double> GetSizeSet(int count)
 {
     List<double> result = new List<double>();
     if (EditorSettings.UseSizeRange)
     {
         double start = EditorSettings.StartSize;
         double dr = (EditorSettings.EndSize - start);
         double dx = dr / count;
         if (!EditorSettings.RampColors)
         {
             Random rnd = new Random(DateTime.Now.Millisecond);
             for (int i = 0; i < count; i++)
             {
                 result.Add(start + rnd.NextDouble() * dr);
             }
         }
         else
         {
             for (int i = 0; i < count; i++)
             {
                 result.Add(start + i * dx);
             }
         }
     }
     else
     {
         Size2D sizes = new Size2D(2, 2);
         IPointSymbolizer ps = EditorSettings.TemplateSymbolizer as IPointSymbolizer;
         if (ps != null) sizes = ps.GetSize();
         double size = Math.Max(sizes.Width, sizes.Height);
         for (int i = 0; i < count; i++)
         {
             result.Add(size);
         }
     }
     return result;
 }
예제 #4
0
 /// <summary>
 /// Creates a Size2DDialog with a specific symbol to edit when "Apply Changes" is clicked
 /// </summary>
 /// <param name="symbol"></param>
 public Size2DDialog(ISymbol symbol)
 {
     _original = symbol;
     _editValue = _original.Size.Copy();
     dbxHeight.Value = _editValue.Height;
     dbxWidth.Value = _editValue.Width;
 }
예제 #5
0
 /// <summary>
 /// Creates a new instance of CharacterSymbol
 /// </summary>
 /// <param name="character">The character to use for the symbol</param>
 /// <param name="fontFamily">The font family for the character</param>
 /// <param name="color">The color for the character</param>
 /// <param name="size">The size for the symbol</param>
 public CharacterSymbol(char character, string fontFamily, Color color, double size)
 {
     _character = character;
     _fontFamilyName = fontFamily;
     _color = color;
     _style = FontStyle.Regular;
     Size = new Size2D(size, size);
     base.SymbolType = SymbolTypes.Character;
 }
예제 #6
0
 /// <summary>
 /// This assumes that you wish to simply scale the various sizes.
 /// It will adjust all of the sizes so that the maximum size is 
 /// the same as the specified size.
 /// </summary>
 /// <param name="value">The Size2D of the new maximum size</param>
 public void SetSize(Size2D value)
 {
     Size2D oldSize = _symbols.GetBoundingSize();
     double dX = value.Width/oldSize.Width;
     double dY = value.Height/oldSize.Height;
     foreach (ISymbol symbol in _symbols)
     {
         Size2D os = symbol.Size;
         symbol.Size = new Size2D(os.Width*dX, os.Height*dY);
     }
     
 }
 private void Configure()
 {
    
     _boxes = new List<SizeBox>();
     _numBoxes = 4;
     _minSize = new Size2D(4, 4);
     _maxSize = new Size2D(30, 30);
     _selectedSize = _minSize.Copy();
     _boxSize = new Size(36, 36);
     _boxBackColor = SystemColors.Control;
     _boxSelectionColor = SystemColors.Highlight;
     _symbol = new SimpleSymbol();
     _orientation = Orientation.Horizontal;
     _roundingRadius = 6;
     RefreshBoxes();
 }
예제 #8
0
 /// <summary>
 /// Tests for equality against another size.  
 /// </summary>
 /// <param name="size">the size to compare this size to</param>
 /// <returns>boolean, true if the height and width are the same in each case.</returns>
 public bool Equals(Size2D size)
 {
     if (((object)size) == null) return false;
     return (size.Width == Width && size.Height == Height);
 }
 // Updates this control to show the recently submitted size of a new symbol
 private void UpdateControl()
 {
     _selectedSize = _symbol.Size;
 }
 /// <summary>
 /// Handles the mouse up situation
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     bool changed = false;
     foreach (SizeBox sb in _boxes)
     {
         if (sb.Bounds.Contains(e.Location))
         {
             if (sb.IsSelected == false)
             {
                 sb.IsSelected = true;
                 _selectedSize = sb.Size.Copy();
                 _symbol.Size.Height = sb.Size.Height;
                 _symbol.Size.Width = sb.Size.Width;
                 changed = true;
             }
         }
         else
         {
             if (sb.IsSelected)
             {
                 sb.IsSelected =false;
             }
         }
     }
     Invalidate();
     if(changed)OnSelectedSizeChanged();
     base.OnMouseUp(e);
 }
예제 #11
0
 /// <summary>
 /// Creates a new instance of Symbol
 /// </summary>
 public Symbol()
 {
     _size = new Size2D(4,4);
     _offset = new Position2D(0,0);
 }
예제 #12
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;
 }
예제 #13
0
        /// <summary>
        /// Converts a string into a Size2D
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value is string)
            {
                try
                {
                    string s = (string)value;
                    string[] converterParts = s.Split(',');
                    double x = 0;
                    double y = 0;
                    if (converterParts.Length > 1)
                    {
                        x = double.Parse(converterParts[0].Trim());
                        y = double.Parse(converterParts[1].Trim());
                    }
                    else if (converterParts.Length == 1)
                    {
                        x = double.Parse(converterParts[0].Trim());
                        y = 0;
                    }
                    else
                    {
                        x = 0;
                        y = 0;
                    }
                    Size2D result = new Size2D(x, y);
                    return result;
                }
                catch 
                {
                    throw new ArgumentException("Cannot convert [" + value.ToString() + "] to Size2D");
                }
            }
            if (value is Size2D)
            {
                return value;
            }
            return base.ConvertFrom(context, culture, value);
          

        }