Exemple #1
0
        /// <summary>
        /// Gets the height and width of a marker for point layer.
        /// </summary>
        private void GetIconWidthAndHeight(IGeometryStyle style, ref int iconWidth, ref int iconHeight)
        {
            var marker = style.Marker;
            var icon   = style.Marker.Icon;

            if (icon != null && marker.Type == MarkerType.Bitmap)
            {
                if (icon.Width * marker.IconScaleX > iconWidth)
                {
                    iconWidth = Convert.ToInt32(icon.Width * marker.IconScaleX + 0.5);
                }

                if (icon.Height * marker.IconScaleY > iconHeight)
                {
                    iconHeight = Convert.ToInt32(icon.Height * marker.IconScaleY + 0.5);
                }
            }

            if (marker.Type == MarkerType.FontCharacter)
            {
                double ratio = marker.FrameVisible ? 1.4 : 1.0;
                if (marker.Size * ratio > iconWidth)
                {
                    iconWidth = Convert.ToInt32(marker.Size * ratio);
                }

                if (marker.Size * ratio > iconHeight)
                {
                    iconHeight = Convert.ToInt32(marker.Size * ratio);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of PolygonForm class
        /// </summary>
        public PolygonForm(IAppContext context, ILegendLayer layer, IGeometryStyle style, bool applyDisabled) : base(context)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }

            InitializeComponent();

            _style    = style;
            _metadata = SymbologyPlugin.GetMetadata(layer.Handle);
            _legend   = context.Legend;
            _layer    = layer;

            _initState = style.Serialize();

            _noEvents = true;

            Initialize();

            btnApply.Visible          = !applyDisabled;
            tabControl1.SelectedIndex = _tabPage;
        }
        /// <summary>
        /// Drawing of images in the style column
        /// </summary>
        private void dgvCategories_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex != CMN_STYLE)
            {
                return;
            }

            if (e.RowIndex >= 0 && e.RowIndex < _shapefile.Categories.Count)
            {
                var img = e.Value as Image;
                if (img == null)
                {
                    return;
                }

                var cat = _shapefile.Categories[e.RowIndex];
                if (cat == null)
                {
                    return;
                }

                IGeometryStyle sdo = cat.Style;

                using (Graphics g = Graphics.FromImage(img))
                {
                    g.Clear(Color.White);
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.SmoothingMode     = SmoothingMode.HighQuality;

                    if (_shapefile.GeometryType == GeometryType.Polygon)
                    {
                        sdo.DrawRectangle(g, 0.0f, 0.0f, img.Width - 1, img.Height - 1, true, img.Width, img.Height,
                                          dgvCategories.BackgroundColor);
                    }
                    else if (_shapefile.GeometryType == GeometryType.Polyline)
                    {
                        sdo.DrawLine(g, 0.0f, 0.0f, img.Width - 1, img.Height - 1, true, img.Width, img.Height,
                                     dgvCategories.BackgroundColor);
                    }
                    else if (_shapefile.PointOrMultiPoint)
                    {
                        sdo.DrawPoint(g, 0.0f, 0.0f, img.Width, img.Height, dgvCategories.BackgroundColor);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a new instance of PointsForm class
        /// </summary>
        public PointsForm(IAppContext context, ILegendLayer layer, IGeometryStyle options, bool applyDisabled) : base(context)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            InitializeComponent();

            _legend = context.Legend;
            _layer  = layer;
            _style  = options;

            // setting values to the controls
            _initState = _style.Serialize();
            _noEvents  = true;

            btnApply.Visible = !applyDisabled;

            pointIconControl1.Initialize(_style.Marker);

            dynamicVisibilityControl1.Initialize(_style, _context.Map.CurrentZoom, _context.Map.CurrentScale);
            dynamicVisibilityControl1.ValueChanged += (s, e) => {
                btnApply.Enabled = true;
                dynamicVisibilityControl1.ApplyChanges();
            };

            InitControls();

            Options2Gui();
            _noEvents = false;

            InitFonts();

            DrawPreview();

            AttachListeners();

            UpdateDefaultColor();

            tabControl1.SelectedIndex = _tabIndex;
        }
Exemple #5
0
        /// <summary>
        /// Creates a new instance of PointsForm class
        /// </summary>
        public PointsForm(IMuteLegend legend, ILegendLayer layer, IGeometryStyle options, bool applyDisabled)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }
            if (legend == null)
            {
                throw new ArgumentNullException("legend");
            }

            InitializeComponent();

            _legend = legend;
            _layer  = layer;
            _style  = options;

            // setting values to the controls
            _initState = _style.Serialize();
            _noEvents  = true;

            btnApply.Visible = !applyDisabled;

            pointIconControl1.Initialize(_style.Marker);

            InitControls();

            Options2Gui();
            _noEvents = false;

            InitFonts();

            DrawPreview();

            AttachListeners();

            UpdateDefaultColor();

            tabControl1.SelectedIndex = _tabIndex;
        }
Exemple #6
0
        /// <summary>
        /// Creates a new instance of PolygonsForm class
        /// </summary>
        public LinesForm(IAppContext _context, ILegendLayer layer, IGeometryStyle style, bool applyDisabled) : base(_context)
        {
            if (layer == null)
            {
                throw new ArgumentNullException("layer");
            }
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }

            InitializeComponent();

            _style     = style;
            _legend    = _context.Legend;
            _layer     = layer;
            _initState = style.Serialize();

            btnApply.Visible = !applyDisabled;

            Initialize();
        }
Exemple #7
0
        /// <summary>
        /// Draws layer icon.
        /// </summary>
        /// <returns>Height of icon in screen coordinates.</returns>
        private int DrawLayerIcon(ILegendLayer layer, IGeometryStyle options, Graphics g, float left, float top)
        {
            int width  = _thumbnailWidth;
            int height = _thumbnailHeight;

            var fs = layer.FeatureSet;

            if (fs == null)
            {
                return(height + 3);
            }

            var hdc = g.GetHdc();

            GetIconWidthAndHeight(options, ref width, ref height);

            left = (int)(left + 0.5);
            top  = (int)(top + 0.5);

            if (fs.PointOrMultiPoint)
            {
                options.DrawPoint(hdc, left, top, width, height, _backColor);
            }
            else if (fs.IsPolyline)
            {
                options.DrawLine(hdc, left, top, width, height, false, width, height, _backColor);
            }
            else if (fs.IsPolygon)
            {
                options.DrawRectangle(hdc, left, top, width - 1, height - 1, false, width + 1, height + 1, _backColor);
            }

            g.ReleaseHdc(hdc);

            return(height + 3);
        }
Exemple #8
0
        /// <summary>
        /// Displays symbology form of the appropriate type
        /// </summary>
        public static Form GetSymbologyForm(this IAppContext context, int layerHandle, IGeometryStyle options, bool applyDisabled)
        {
            Form form  = null;
            var  layer = context.Legend.Layers.ItemByHandle(layerHandle);

            var fs = layer.FeatureSet;

            if (fs == null)
            {
                return(null);
            }

            var type = fs.GeometryType;

            if (type == GeometryType.Point || type == GeometryType.MultiPoint)
            {
                form = new PointsForm(context.Legend, layer, options, applyDisabled);
            }
            else if (type == GeometryType.Polyline)
            {
                form = new LinesForm(context.Legend, layer, options, applyDisabled);
            }
            else if (type == GeometryType.Polygon)
            {
                form = new PolygonForm(context.Legend, layer, options, applyDisabled);
            }
            return(form);
        }
 public void CopyStyleFrom(IGeometryStyle style)
 {
     _editor.CopyOptionsFrom(style.GetInternal());
 }
Exemple #10
0
 public static ShapeDrawingOptions GetInternal(this IGeometryStyle style)
 {
     return(style.InternalObject as ShapeDrawingOptions);
 }
Exemple #11
0
        /// <summary>
        /// Generates shapefile categories according to specified options
        /// </summary>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (cboField.SelectedIndex < 0)
            {
                MessageService.Current.Info("No field for generation was selected.");
                DialogResult = DialogResult.None;
                return;
            }

            int count;

            if (!Int32.TryParse(cboCategoriesCount.Text, out count))
            {
                MessageService.Current.Warn("Number of categories isn't a valid interger.");
                return;
            }

            var categories = _shapefile.Categories;
            int index      = ((RealIndexComboItem)cboField.SelectedItem).RealIndex;

            categories.Generate(index, (Classification)cboClassificationType.SelectedIndex, count);

            categories.Caption = "Categories: " + _shapefile.Fields[index].Name;

            if (chkUseVariableSize.Checked)
            {
                if (_shapefile.PointOrMultiPoint)
                {
                    double step = (double)(udMaxSize.Value - udMinSize.Value) / ((double)categories.Count - 1);
                    for (int i = 0; i < categories.Count; i++)
                    {
                        categories[i].Style.Marker.Size = (int)udMinSize.Value + Convert.ToInt32(i * step);
                    }
                }
                else if (_shapefile.GeometryType == GeometryType.Polyline)
                {
                    double step = (double)(udMaxSize.Value + udMinSize.Value) / (double)categories.Count;
                    for (int i = 0; i < categories.Count; i++)
                    {
                        categories[i].Style.Line.Width = (int)udMinSize.Value + Convert.ToInt32(i * step);
                    }
                }
            }

            ColorRamp scheme = null;

            if (icbColorScheme.SelectedIndex >= 0)
            {
                var blend = icbColorScheme.ColorSchemes[icbColorScheme.SelectedIndex];
                scheme = blend.ToColorScheme();
            }

            var type = chkRandomColors.Checked ? SchemeType.Random : SchemeType.Graduated;

            _shapefile.Categories.ApplyColorScheme(type, scheme);

            if (chkSetGradient.Checked)
            {
                for (int i = 0; i < categories.Count; i++)
                {
                    IGeometryStyle options = categories[i].Style;
                    options.Fill.SetGradient(options.Fill.Color, 75);
                    options.Fill.Type = FillType.Gradient;
                }
            }

            _shapefile.Categories.ApplyExpressions();

            SaveSettings();
        }