/// <summary> /// Clears the expression in the textbox /// </summary> private void btnClear_Click(object sender, EventArgs e) { if (richTextBox1.Text.ToLower() == "<no expression>") { if (MessageBox.Show("Remove labels?", LegendControl.Legend.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MapWinGIS.Labels lb = m_shapefile.Labels; for (int i = 0; i < lb.Count; i++) { for (int j = 0; j < lb.get_NumParts(i); j++) { lb.get_Label(i, j).Text = ""; } } listBox1.Enabled = true; btnPlus.Enabled = true; btnQuotes.Enabled = true; btnNewLine.Enabled = true; richTextBox1.Enabled = true; richTextBox1.Text = ""; lb.SavingMode = tkSavingMode.modeXMLOverwrite; lb.Synchronized = true; if (!lb.Synchronized) { lb.Clear(); } } } else { richTextBox1.Text = ""; } }
/// <summary> /// Changes the enabled properties of controls /// </summary> private void RefreshControlsState(object sender, EventArgs e) { if (_noEvents) { return; } ShpfileType type = Globals.ShapefileType2D(_shapefile.ShapefileType); // appearance udDefaultSize.Enabled = (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT); clpPointFill.Enabled = (type != ShpfileType.SHP_POLYLINE); clpSelection.Enabled = (type != ShpfileType.SHP_POLYLINE); // provide the options if there are a single line pattern, otherwise extednded options are needed ShapeDrawingOptions options = _shapefile.DefaultDrawingOptions; if (options.UseLinePattern) { if (options.LinePattern.Count <= 1) { panelLineOptions.Visible = true; clpDefaultOutline.Enabled = true; icbLineWidth.Enabled = (options.LinePattern.get_Line(0).LineType == tkLineType.lltSimple); lblMultilinePattern.Visible = false; } else { lblMultilinePattern.Visible = true; panelLineOptions.Visible = false; } } else { clpDefaultOutline.Enabled = true; icbLineWidth.Enabled = true; panelLineOptions.Visible = true; lblMultilinePattern.Visible = false; } // categories udMinSize.Enabled = chkUseVariableSize.Checked; udMaxSize.Enabled = chkUseVariableSize.Checked; udNumCategories.Enabled = !chkUniqueValues.Checked; btnCategoryAppearance.Enabled = (dgvCategories.SelectedCells.Count > 0); btnCategoryRemove.Enabled = (dgvCategories.SelectedCells.Count > 0); btnCategoryClear.Enabled = (dgvCategories.Rows.Count > 0); // labels MapWinGIS.Labels labels = _shapefile.Labels; //btnLabelsAppearance.Enabled = (labels.Count > 0); btnLabelsClear.Enabled = (labels.Count > 0); groupLabelAppearance.Enabled = (labels.Count > 0); groupLabelStyle.Enabled = (labels.Count > 0); chkShowLabels.Enabled = (labels.Count > 0); panelLabels.Enabled = (labels.Count > 0); groupChartAppearance.Enabled = _shapefile.Charts.Count > 0; // charts bool enabled = (_shapefile.Charts.Count > 0); //&& (_shapefile.Charts.NumFields > 0); btnClearCharts.Enabled = (_shapefile.Charts.Count > 0); icbChartColorScheme.Enabled = enabled; groupCharts.Enabled = enabled; optChartBars.Enabled = enabled; optChartsPie.Enabled = enabled; chkChartsVisible.Enabled = enabled; btnChartsEditColorScheme.Enabled = enabled; }
/// <summary> /// Generates labels with specified positions /// </summary> private void btnOk_Click(object sender, EventArgs e) { // callback and wait cursor ICallback cBackOld = m_shapefile.GlobalCallback; Callback cback = new Callback(); m_shapefile.GlobalCallback = cback; this.Enabled = false; this.Cursor = Cursors.WaitCursor; MapWinGIS.Labels lb = m_shapefile.Labels; tkLabelPositioning positioning = get_LabelPositioning(); lb.LineOrientation = (tkLineLabelOrientation)cboLineOrientation.SelectedIndex; try { // generation m_shapefile.GenerateLabels(-1, positioning, !chkLabelEveryPart.Checked); m_shapefile.Labels.SavingMode = tkSavingMode.modeXMLOverwrite; // .lbl file should be updated ShpfileType type = Globals.ShapefileType2D(m_shapefile.ShapefileType); if (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT) { if (optAlignBottomCenter.Checked) { m_alignment = tkLabelAlignment.laBottomCenter; } if (optAlignBottomLeft.Checked) { m_alignment = tkLabelAlignment.laBottomLeft; } if (optAlignBottomRight.Checked) { m_alignment = tkLabelAlignment.laBottomRight; } if (optAlignCenter.Checked) { m_alignment = tkLabelAlignment.laCenter; } if (optAlignCenterLeft.Checked) { m_alignment = tkLabelAlignment.laCenterLeft; } if (optAlignCenterRight.Checked) { m_alignment = tkLabelAlignment.laCenterRight; } if (optAlignTopCenter.Checked) { m_alignment = tkLabelAlignment.laTopCenter; } if (optAlignTopLeft.Checked) { m_alignment = tkLabelAlignment.laTopLeft; } if (optAlignTopRight.Checked) { m_alignment = tkLabelAlignment.laTopRight; } } // updating references to categories if (lb.NumCategories > 0) { for (int i = 0; i < lb.Count; i++) { MapWinGIS.Label label = lb.get_Label(i, 0); label.Category = m_shapefile.get_ShapeCategory(i); } } } finally { this.Enabled = true; this.Cursor = Cursors.Default; cback.Clear(); m_shapefile.GlobalCallback = cBackOld; } }