예제 #1
0
        /// <summary>
        /// Draws shapefile preview in shapefile drawing column
        /// </summary>
        private void DataGridViewMW_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.ColumnIndex != _shapeDrawingColumn)
            {
                return;
            }

            if (!CheckSynchronization())
            {
                return;
            }

            var img = e.Value as Image;

            if (img == null)
            {
                return;
            }

            GeometryRowStyle val = _shapeOptions[e.RowIndex];

            if (val == null || val.Style == null)
            {
                return;
            }

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

                if (val.Type == GeometryType.Polygon)
                {
                    val.Style.DrawRectangle(g, 0, 0, img.Width - 1, img.Height - 1, true, img.Width, img.Height,
                                            BackgroundColor);
                }
                else if (val.Type == GeometryType.Polyline)
                {
                    val.Style.DrawLine(g, 0, 0, img.Width - 1, img.Height - 1, true, img.Width, img.Height,
                                       BackgroundColor);
                }
                else if (val.Type == GeometryType.Point)
                {
                    val.Style.DrawPoint(g, 0.0f, 0.0f, img.Width, img.Height, BackgroundColor);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Sets drawing options for particular row in data grid view
        /// </summary>
        /// <param name="rowIndex">Row index to set options for</param>
        /// <param name="options">Set of options</param>
        public bool set_ShapefileDrawingOptions(int rowIndex, GeometryRowStyle options)
        {
            if (!CheckSynchronization())
            {
                return(false);
            }

            if (rowIndex >= 0 && rowIndex < _shapeOptions.Count)
            {
                if (options.Style != null)    // to avoid additional checks later
                {
                    _shapeOptions[rowIndex] = options;
                    return(true);
                }
            }

            return(false);
        }