示例#1
0
        /// <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);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Draws preview based on the chosen options
        /// </summary>
        private void DrawPreview()
        {
            if (_noEvents)
            {
                return;
            }

            if (pctPreview.Image != null)
            {
                pctPreview.Image.Dispose();
            }

            var rect = pctPreview.ClientRectangle;
            var bmp  = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);

            using (var g = Graphics.FromImage(bmp))
            {
                _style.DrawRectangle(g, 40.0f, 40.0f, rect.Width - 80, rect.Height - 80, true, rect.Width, rect.Height, BackColor);
            }

            pctPreview.Image = bmp;
        }
示例#3
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);
        }