예제 #1
0
        /// <summary>
        /// Transforms and saves the data.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveButton_Click(object sender, EventArgs e)
        {
            try
            {
                // Get spatial reference
                IFeatureClass benchmarks = (IFeatureClass)_benchmarkName.Open();
                _transform.SetSpatialReference(((IGeoDataset)benchmarks).SpatialReference);

                // Set benchmarks
                for (int i = 1; i < 4; i++)
                {
                    IFeature feature = benchmarks.GetFeature(i);
                    _transform.SetBenchmarkPoint(i, (IPoint)feature.ShapeCopy);
                }

                // Set total station benchmarks
                _transform.SetTSBenchmark(1, benchmark1ComboBox.Text);
                _transform.SetTSBenchmark(2, benchmark2ComboBox.Text);
                _transform.SetTSBenchmark(3, benchmark3ComboBox.Text);

                // Add data to be transformed
                foreach (IDatasetName dsName in EsriUtilities.GetFeatureClassNames(esriGeometryType.esriGeometryAny, _inputDatasetName))
                {
                    _transform.AddData((IFeatureClassName)dsName);
                }

                // Transform data
                IQueryFilter query = new QueryFilterClass();
                query.WhereClause = "\"Chosen\" = 1";
                ITable  table  = (ITable)_transformTableName.Open();
                ICursor cursor = table.Search(query, true);
                IRow    row    = cursor.NextRow();
                int     hinge  = Convert.ToInt32(((string)row.get_Value(table.FindField("Hinge"))).Split(' ')[1]);
                int     toBM   = Convert.ToInt32(((string)row.get_Value(table.FindField("Bearing"))).Split(' ')[2]);
                _transform.SaveData(hinge, toBM);

                // Close dialog
                Init();
                ChampExtension.GetExtension().GetApplyDockableWindow().Show(false);
                ArcMap.Document.ActiveView.Refresh();
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }
        /// <summary>
        /// Adds the feataure classes to be transformed, sets the benchmark attribute IDs,
        /// transforms the data into graphics, and fills the error boxes on the next panel.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonTransform_Click(object sender, EventArgs e)
        {
            try
            {
                IDatasetName controlName = (IDatasetName)comboBoxControlPts.SelectedItem;
                _transform.ClearData();
                foreach (ListViewItem item in listViewData.Items)
                {
                    if (!_nameComparer.Equal((IDatasetName)item.Tag, controlName))
                    {
                        _transform.AddData((IFeatureClassName)item.Tag);
                    }
                }
                _transform.SetTSBenchmark(1, comboBoxBM1Att.SelectedItem.ToString());
                _transform.SetTSBenchmark(2, comboBoxBM2Att.SelectedItem.ToString());
                _transform.SetTSBenchmark(3, comboBoxBM3Att.SelectedItem.ToString());

                string rbName       = FormUtilities.GetCheckedRadioButton(groupBoxBMs).Name;
                int    defaultHinge = int.Parse(rbName.Substring(rbName.Length - 1));
                rbName = FormUtilities.GetCheckedRadioButton(groupBoxRotation).Name;
                int defaultBearing = int.Parse(rbName.Substring(rbName.Length - 1));
                rbName = string.Format("radioButton{0}{1}{2}", rbName.Contains("GPS") ? "GPS" : "Compass",
                                       defaultHinge, defaultBearing);

                IEnvelope extent = new EnvelopeClass();
                foreach (ListViewItem item in listViewData.CheckedItems)
                {
                    extent.Union(_transform.TransformFeatures2Graphics((IFeatureClassName)item.Tag,
                                                                       _graphicsColor));
                }
                ArcMap.Document.ActiveView.Extent = extent;
                ArcMap.Document.FocusMap.MapScale = 10000;
                ArcMap.Document.ActiveView.Refresh();

                ((RadioButton)panelOutput.Controls.Find(rbName, true)[0]).Checked = false; // to force things to update
                ((RadioButton)panelOutput.Controls.Find(rbName, true)[0]).Checked = true;

                string id;
                for (int hingeIndex = 1; hingeIndex <= 3; hingeIndex++)
                {
                    for (int bearingIndex = 1; bearingIndex <= 3; bearingIndex++)
                    {
                        if (bearingIndex != hingeIndex)
                        {
                            for (int benchmarkIndex = 1; benchmarkIndex <= 3; benchmarkIndex++)
                            {
                                if (benchmarkIndex != hingeIndex)
                                {
                                    id = hingeIndex.ToString() + bearingIndex.ToString() +
                                         benchmarkIndex.ToString();
                                    SetError("HGPS" + id);
                                    SetError("ZGPS" + id);
                                    SetError("HCompass" + id);
                                    SetError("ZCompass" + id);
                                }
                            }
                        }
                    }
                }

                panelInput.Visible  = false;
                panelOutput.Visible = true;
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
        }