Exemplo n.º 1
0
        /// <summary>
        /// 勾选框事件处理,可见性处理
        /// </summary>
        private void dgvCategories_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1 || e.ColumnIndex == -1)
            {
                return;
            }

            if (_noEvents)
            {
                return;
            }

            if (e.ColumnIndex == CMN_VISIBLE)
            {
                int index = (int)dgvCategories[CMN_CATEGORYID, e.RowIndex].Value;
                _shapefile.Categories.get_Item(index).DrawingOptions.Visible = (bool)dgvCategories[e.ColumnIndex, e.RowIndex].Value;

                // toggle labels in case they are present
                MapWinGIS.LabelCategory cat = _shapefile.Labels.get_Category(index);
                if (cat != null && cat.Enabled)
                {
                    cat.Visible = (bool)dgvCategories[e.ColumnIndex, e.RowIndex].Value;
                }
                RedrawMap();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for editing single category
        /// </summary>
        /// <param name="lb"></param>
        public LabelStyleForm(MapWinGIS.Shapefile sf, MapWinGIS.LabelCategory lb)
        {
            m_categoryEdited = true;
            m_shapefile      = sf;

            InitializeComponent();
            this.Initialize(lb);

            tabControl1.SelectedIndex = tabNumber;

            // expression isn't available for the categories
            if (m_categoryEdited)
            {
                tabControl1.TabPages.Remove(tabControl1.TabPages[4]);   // visibility
                tabControl1.TabPages.Remove(tabControl1.TabPages[3]);   // position
                tabControl1.TabPages.Remove(tabControl1.TabPages[0]);   // expression
            }
            lblResult.Visible = false;
            btnApply.Visible  = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes controls of the form
        /// </summary>
        private void Initialize(LabelCategory lb)
        {
            m_category = lb;

            m_NoEvents = true;
            cboFontName.Items.Clear();
            foreach (FontFamily family in FontFamily.Families)
            {
                cboFontName.Items.Add(family.Name);
            }

            cboDecimalPlaces.Items.Add("Auto");
            for (int i = 1; i <= 6; i++)
            {
                cboDecimalPlaces.Items.Add(i.ToString());
            }
            cboDecimalPlaces.SelectedIndex = 0;

            icbLineType.ComboStyle  = ImageComboStyle.LineStyle;
            icbLineWidth.ComboStyle = ImageComboStyle.LineWidth;

            icbFrameType.Color1        = Color.Transparent;
            icbFrameType.ComboStyle    = ImageComboStyle.FrameType;
            icbFrameType.SelectedIndex = 0;

            if (!m_categoryEdited)
            {
                for (int i = 0; i < m_shapefile.NumFields; i++)
                {
                    string name = m_shapefile.Field[i].Name;
                    if (name.ToLower() != "mwshapeid")
                    {
                        listBox1.Items.Add(name);
                    }
                }
            }

            string[] scales = { "1",      "10",     "100",     "1000", "5000", "10000", "25000", "50000", "100000",
                                "250000", "500000", "1000000", "10000000" };
            cboMinScale.Items.Clear();
            cboMaxScale.Items.Clear();
            cboBasicScale.Items.Clear();
            foreach (string t in scales)
            {
                cboMinScale.Items.Add(t);
                cboMaxScale.Items.Add(t);
                cboBasicScale.Items.Add(t);
            }

            // displaying options in the GUI
            LabelStyle2Gui(m_category);

            btnTest_Click(null, null);

            txtLabelExpression.Text = m_shapefile.Labels.VisibilityExpression;

            // serialization
            if (m_categoryEdited)
            {
                m_initState = m_category.Serialize();
            }
            else
            {
                tkSavingMode mode = m_shapefile.Labels.SavingMode;
                m_shapefile.Labels.SavingMode = tkSavingMode.modeNone;
                m_initState = m_shapefile.Labels.Serialize();
                m_shapefile.Labels.SavingMode = mode;
            }

            cboLabelsVerticalPosition.Items.Clear();
            cboLabelsVerticalPosition.Items.Add("Above layer");
            cboLabelsVerticalPosition.Items.Add("Above all layers");

            var labels = m_shapefile.Labels;

            cboLabelsVerticalPosition.SelectedIndex = (int)labels.VerticalPosition;
            chkLabelsRemoveDuplicates.Checked       = labels.RemoveDuplicates;
            chkAviodCollisions.Checked = labels.AvoidCollisions;
            chkScaleLabels.Checked     = labels.ScaleLabels;
            cboBasicScale.Text         = labels.BasicScale.ToString();

            udLabelOffsetX.SetValue(labels.OffsetX);
            udLabelOffsetY.SetValue(labels.OffsetY);
            udLabelsBuffer.SetValue(labels.CollisionBuffer);

            // alignment
            optAlignBottomCenter.Checked = (labels.Alignment == tkLabelAlignment.laBottomCenter);
            optAlignBottomLeft.Checked   = (labels.Alignment == tkLabelAlignment.laBottomLeft);
            optAlignBottomRight.Checked  = (labels.Alignment == tkLabelAlignment.laBottomRight);
            optAlignCenter.Checked       = (labels.Alignment == tkLabelAlignment.laCenter);
            optAlignCenterLeft.Checked   = (labels.Alignment == tkLabelAlignment.laCenterLeft);
            optAlignCenterRight.Checked  = (labels.Alignment == tkLabelAlignment.laCenterRight);
            optAlignTopCenter.Checked    = (labels.Alignment == tkLabelAlignment.laTopCenter);
            optAlignTopLeft.Checked      = (labels.Alignment == tkLabelAlignment.laTopLeft);
            optAlignTopRight.Checked     = (labels.Alignment == tkLabelAlignment.laTopRight);

            ShpfileType shpType = Globals.ShapefileType2D(m_shapefile.ShapefileType);

            optAlignCenter.Enabled = (shpType != ShpfileType.SHP_POINT && shpType != ShpfileType.SHP_MULTIPOINT);

            btnApply.Enabled = (m_shapefile.Labels.Expression != "" && m_shapefile.Labels.Count == 0);
            string[] list = new string[] {
                "Default",
                "SingleBitPerPixelGridFit",
                "SingleBitPerPixel",
                "AntiAliasGridFit",
                "HintAntiAlias",
                "ClearType"
            };
            cboTextRenderingHint.DataSource = list;
            SetSelectedIndex(cboTextRenderingHint, (int)m_shapefile.Labels.TextRenderingHint);
            cboTextRenderingHint.SelectedIndexChanged += Gui2LabelStyle;

            m_NoEvents = false;

            // initial drawing
            this.DrawPreview(null, null);
        }