/// <summary>
        /// Handling the clicking on the category preview
        /// </summary>
        void m_legend_LayerCategoryClicked(int Handle, int Category)
        {
            if (m_legend == null || m_legend.m_Map == null)
            {
                return;
            }

            MapWinGIS.Shapefile sf = m_legend.m_Map.get_Shapefile(Handle);
            if (sf != null)
            {
                MapWinGIS.ShapefileCategory cat = sf.Categories.get_Item(Category);
                if (cat != null)
                {
                    Form form = FormHelper.GetSymbologyForm(m_legend, Handle, sf.ShapefileType, cat.DrawingOptions, false);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        // do something
                    }
                    form.Dispose();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 填充分级渲染属性到grid中
        /// </summary>
        private void RefreshCategoriesList()
        {
            dgvCategories.SuspendLayout();
            dgvCategories.Rows.Clear();

            int numCategories = _shapefile.Categories.Count;

            if (numCategories == 0)
            {
                dgvCategories.ColumnHeadersVisible = false;
                dgvCategories.ResumeLayout();
                RefreshControlsState(null, null);
                return;
            }
            else
            {
                dgvCategories.ColumnHeadersVisible = true;
            }

            dgvCategories.Rows.Add(numCategories);

            bool noEventsState = _noEvents;

            _noEvents = true;

            // 计算每个目录的数量
            Dictionary <int, int> values = new Dictionary <int, int>();  // 键为目录的id,值为数量
            int category;

            for (int i = 0; i < _shapefile.NumShapes; i++)
            {
                category = _shapefile.get_ShapeCategory(i);
                if (values.ContainsKey(category))
                {
                    values[category] += 1;
                }
                else
                {
                    values.Add(category, 1);
                }
            }

            for (int i = 0; i < numCategories; i++)
            {
                MapWinGIS.ShapefileCategory cat = _shapefile.Categories.get_Item(i);
                dgvCategories[CMN_CATEGORYID, i].Value = i;
                dgvCategories[CMN_VISIBLE, i].Value    = cat.DrawingOptions.Visible;
                Bitmap bitmap = new Bitmap(dgvCategories.Columns[CMN_STYLE].Width - 20, dgvCategories.Rows[i].Height - 8);
                //Graphics g = Graphics.FromImage(bitmap);
                //bitmap = _legend.Snapshot();
                //pictureBox.Image = bitmap;
                dgvCategories[CMN_STYLE, i].Value = bitmap;
                //dgvCategories[CMN_STYLE, i].Value = new Bitmap(@"D:\MyDownloads\Download\earth.png");
                dgvCategories[CMN_NAME, i].Value       = cat.Name;
                dgvCategories[CMN_EXPRESSION, i].Value = cat.Expression;

                if (values.ContainsKey(i))
                {
                    dgvCategories[CMN_COUNT, i].Value = values[i];
                }
                else
                {
                    dgvCategories[CMN_COUNT, i].Value = 0;
                }
            }
            dgvCategories.ResumeLayout();


            for (int i = 1; i < dgvCategories.Columns.Count; i++)
            {
                if (i != CMN_STYLE && i != CMN_COUNT)
                {
                    dgvCategories.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.AllCells);
                    dgvCategories.Columns[i].Width += 10;
                }
            }
            RefreshControlsState(null, null);
            _noEvents = noEventsState;
        }
Esempio n. 3
0
        /// <summary>
        /// Fills the data grid view with information about label categories
        /// </summary>
        private void RefreshCategoriesList()
        {
            dgvCategories.SuspendLayout();
            dgvCategories.Rows.Clear();

            int numCategories = _shapefile.Categories.Count;

            if (numCategories == 0)
            {
                dgvCategories.ColumnHeadersVisible = false;
                dgvCategories.ResumeLayout();
                RefreshControlsState(null, null);
                return;
            }
            else
            {
                dgvCategories.ColumnHeadersVisible = true;
            }

            dgvCategories.Rows.Add(numCategories);

            bool noEventsState = _noEvents;

            _noEvents = true;

            // calculating the number of shapes per category
            Dictionary <int, int> values = new Dictionary <int, int>();  // id of category, count
            int category;

            for (int i = 0; i < _shapefile.NumShapes; i++)
            {
                category = _shapefile.get_ShapeCategory(i);
                if (values.ContainsKey(category))
                {
                    values[category] += 1;
                }
                else
                {
                    values.Add(category, 1);
                }
            }

            for (int i = 0; i < numCategories; i++)
            {
                MapWinGIS.ShapefileCategory cat = _shapefile.Categories.get_Item(i);
                dgvCategories[CMN_CATEGORYID, i].Value = i;
                dgvCategories[CMN_VISIBLE, i].Value    = cat.DrawingOptions.Visible;
                dgvCategories[CMN_STYLE, i].Value      = new Bitmap(dgvCategories.Columns[CMN_STYLE].Width - 20, dgvCategories.Rows[i].Height - 8);
                dgvCategories[CMN_NAME, i].Value       = cat.Name;
                dgvCategories[CMN_EXPRESSION, i].Value = cat.Expression;

                if (values.ContainsKey(i))
                {
                    dgvCategories[CMN_COUNT, i].Value = values[i];
                }
                else
                {
                    dgvCategories[CMN_COUNT, i].Value = 0;
                }
            }
            dgvCategories.ResumeLayout();

            // autosizing columns
            for (int i = 1; i < dgvCategories.Columns.Count; i++)
            {
                if (i != CMN_STYLE && i != CMN_COUNT)
                {
                    dgvCategories.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.AllCells);
                    dgvCategories.Columns[i].Width += 10;
                }
            }
            RefreshControlsState(null, null);
            _noEvents = noEventsState;
        }