/// <summary> /// Applies options, generates charts if needed /// </summary> bool ApplyOptions() { if (_charts.NumFields == 0) { if (_charts.Count == 0) { //MessageBox.Show("No fields were chosen. No charts will be displayed.", _plugin.Globals.AppName, MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; } else { if (MessageBox.Show("No fields were chosen. Do you want to remove all charts?", LegendControl.Legend.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _charts.Clear(); } else { return(false); } } } else if (_shapefile.Charts.Count == 0) { // there is no charts, start generation ShpfileType type = Globals.ShapefileType2D(_shapefile.ShapefileType); if (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_MULTIPOINT) { // start generation, no need to prompt the user for position ICallback cBackOld = _shapefile.GlobalCallback; Callback cback = new Callback(); _shapefile.GlobalCallback = cback; this.Enabled = false; this.Cursor = Cursors.WaitCursor; try { _shapefile.Charts.Generate(tkLabelPositioning.lpCentroid); } finally { this.Enabled = true; this.Cursor = Cursors.Default; cback.Clear(); _shapefile.GlobalCallback = cBackOld; } } else { // prompting user for charts position AddChartsForm form = new AddChartsForm(_shapefile); if (form.ShowDialog() != DialogResult.OK) { return(false); } form.Dispose(); } } return(true); }
/// <summary> /// Calculates chart positions /// </summary> private void btnOk_Click(object sender, EventArgs e) { ICallback cBackOld = m_shapefile.GlobalCallback; Callback cback = new Callback(); m_shapefile.GlobalCallback = cback; this.Enabled = false; this.Cursor = Cursors.WaitCursor; try { tkLabelPositioning positioning = tkLabelPositioning.lpCentroid; if (optPosition4.Checked) { positioning = (tkLabelPositioning)optPosition4.Tag; } if (optPosition3.Checked) { positioning = (tkLabelPositioning)optPosition3.Tag; } if (optPosition2.Checked) { positioning = (tkLabelPositioning)optPosition2.Tag; } if (optPosition1.Checked) { positioning = (tkLabelPositioning)optPosition1.Tag; } m_shapefile.Charts.Generate(positioning); m_shapefile.Charts.SavingMode = tkSavingMode.modeXMLOverwrite; } finally { this.Enabled = true; this.Cursor = Cursors.Default; cback.Clear(); m_shapefile.GlobalCallback = cBackOld; } }
/// <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; } }