コード例 #1
0
        private void setEditableLayer(IFeature pFeat)
        {
            CSpatialSubs oSubs = new CSpatialSubs();

            IEditLayers   pEditLayers = this.m_editor as IEditLayers;
            IFeatureLayer pFLayer     = oSubs.returnFLayerByName(pFeat.Class.AliasName, true);

            pEditLayers.SetCurrentLayer(pFLayer, 0);
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            CSpatialSubs oSubs = new CSpatialSubs();

            IFeatureLayer pFLayer     = oSubs.returnFLayerByName(lbLayers.SelectedItem.ToString(), true);
            IEditLayers   pEditLayers = this.m_pEditor as IEditLayers;

            pEditLayers.SetCurrentLayer(pFLayer, 0);
            this.Close();
        }
コード例 #3
0
        private void oEditSel_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
        {
            IEditLayers   pEditLayers = this.m_editor as IEditLayers;
            IFeatureLayer pFLayer     = pEditLayers.CurrentLayer as IFeatureLayer;

            if (pFLayer != null)
            {
                //m_editor.StopEditing(true);
                saveEdits(pFLayer);
            }
        }
コード例 #4
0
        void IEditTask.Deactivate()
        {
            //Stop listening for editor events.
            ((IEditEvents_Event)m_editor).OnCurrentLayerChanged -= OnCurrentLayerChanged;

            //Release object references.
            m_editor     = null;
            m_editSketch = null;
            m_editLayer  = null;
            m_mxDoc      = null;
        }
コード例 #5
0
        public ViperPinForm(IEditor3 editor)
        {
            InitializeComponent();

            m_editor     = editor;
            m_edSketch   = m_editor as IEditSketch3;
            m_editLayers = m_editor as IEditLayers;

            lblEditLayer.Text = m_editLayers.CurrentLayer.Name;

            //Load field combo box with field names
            IFields pFields = m_editLayers.CurrentLayer.FeatureClass.Fields;

            for (int i = 0; i < pFields.FieldCount; i++)
            {
                cmbPINField.Items.Add(pFields.get_Field(i).Name);
            }

            //get pinfield from registry
            string      pinField = null;
            RegistryKey pRegKey  = Registry.CurrentUser.OpenSubKey("Software\\ESRI\\ViperPin");

            if (pRegKey != null)
            {
                pinField = pRegKey.GetValue("Pinfield").ToString();
            }

            //set the combo box to the pinfield
            for (int i = 0; i < pFields.FieldCount; i++)
            {
                if (pinField == pFields.get_Field(i).Name)
                {
                    cmbPINField.Text = pinField;
                    break;
                }
                else
                {
                    cmbPINField.Text = "None";
                }
            }

            //cmbPINField.SelectedIndex = 0;
            cmbPINField.Refresh();
            m_lotNum    = 1;
            txtlot.Text = "1";

            //Set center right of form to center right of screen
            this.StartPosition = FormStartPosition.Manual;
            this.Left          = 0;
            this.Top           = (Screen.PrimaryScreen.Bounds.Height / 2) - (this.Height / 2);
        }
コード例 #6
0
        private bool checkSelectedLayer()
        {
            bool bRetVal = false;

            IEditLayers   pEditLayers = this.m_editor as IEditLayers;
            IFeatureLayer pFLayer     = pEditLayers.CurrentLayer as IFeatureLayer;

            if (pFLayer != null)
            {
                bRetVal = true;
            }

            return(bRetVal);
        }
コード例 #7
0
    public ViperPinForm(IEditor3 editor)
    {
      InitializeComponent();

      m_editor = editor;
      m_edSketch = m_editor as IEditSketch3;
      m_editLayers = m_editor as IEditLayers;

      lblEditLayer.Text = m_editLayers.CurrentLayer.Name;

      //Load field combo box with field names
      IFields pFields = m_editLayers.CurrentLayer.FeatureClass.Fields;
		  for (int i=0; i < pFields.FieldCount; i++)
      {
        cmbPINField.Items.Add(pFields.get_Field(i).Name);
      }

      //get pinfield from registry
      string pinField = null;
      RegistryKey pRegKey = Registry.CurrentUser.OpenSubKey("Software\\ESRI\\ViperPin");
      if (pRegKey != null)
      {
        pinField = pRegKey.GetValue("Pinfield").ToString();
      }

      //set the combo box to the pinfield
      for (int i = 0; i < pFields.FieldCount; i++)
      {
        if (pinField == pFields.get_Field(i).Name)
        {
          cmbPINField.Text = pinField;
          break;
        }
        else
        {
          cmbPINField.Text = "None";
        }
      }

      //cmbPINField.SelectedIndex = 0;
      cmbPINField.Refresh();
      m_lotNum = 1;
      txtlot.Text = "1";

      //Set center right of form to center right of screen
      this.StartPosition = FormStartPosition.Manual;
      this.Left = 0;
      this.Top = (Screen.PrimaryScreen.Bounds.Height / 2) - (this.Height / 2);
    }
コード例 #8
0
        void IEditTask.Activate(IEditor Editor, IEditTask oldTask)
        {
            if (Editor == null)
            {
                return;
            }

            //Initialize class member variables.
            m_editor     = Editor;
            m_editSketch = Editor as IEditSketch;
            m_editSketch.GeometryType = esriGeometryType.esriGeometryPolyline;
            m_editLayer = Editor as IEditLayers;
            m_mxDoc     = Editor.Parent.Document as IMxDocument;

            //Wire editor events.
            ((IEditEvents_Event)m_editor).OnCurrentLayerChanged +=
                new IEditEvents_OnCurrentLayerChangedEventHandler(OnCurrentLayerChanged);
        }
コード例 #9
0
        //Invoked at the end of an editor session (Editor->Stop Editing).
        private void Events_OnStopEditing(bool Save)
        {
            CSpatialSubs oSubs = new CSpatialSubs();

            IEditLayers   pEditLayers = this.m_editor as IEditLayers;
            IFeatureLayer pFLayer     = pEditLayers.CurrentLayer as IFeatureLayer;

            if (pFLayer == null)
            {
                //System.Windows.Forms.MessageBox.Show("Please ensure that you have selected the edited feature class in the editor window.\r\n", "City of Medford GIS Tools: Update Data", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                //returnEditLayer();
                //return;
            }
            else
            {
                if (Save)
                {
                    saveEdits(pFLayer);
                }
            }
        }
コード例 #10
0
        public void RunManualRules()
        {
            ICursor cursor = null; IFeatureCursor fCursor = null;
            bool    ran = false;

            try
            {
                //Get list of editable layers
                IEditor     editor  = _editor;
                IEditLayers eLayers = (IEditLayers)editor;
                long        lastOID = -1;
                string      lastLay = "";

                if (_editor.EditState != esriEditState.esriStateEditing)
                {
                    return;
                }

                IMap        map        = editor.Map;
                IActiveView activeView = map as IActiveView;


                IStandaloneTable stTable;

                ITableSelection tableSel;

                IStandaloneTableCollection stTableColl = (IStandaloneTableCollection)map;

                long rowCount    = stTableColl.StandaloneTableCount;
                long rowSelCount = 0;
                for (int i = 0; i < stTableColl.StandaloneTableCount; i++)
                {
                    stTable  = stTableColl.get_StandaloneTable(i);
                    tableSel = (ITableSelection)stTable;
                    if (tableSel.SelectionSet != null)
                    {
                        rowSelCount = rowSelCount + tableSel.SelectionSet.Count;
                    }
                }
                long featCount  = map.SelectionCount;
                int  totalCount = (Convert.ToInt32(rowSelCount) + Convert.ToInt32(featCount));


                if (totalCount >= 1)
                {
                    editor.StartOperation();

                    if (MessageBox.Show("Are you sure you wish to apply attribute assistant manual rules for the selected " + totalCount + " rows and features?",
                                        "Confirm", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        ran = true;


                        //bool test = false;

                        //Get list of feature layers
                        UID geoFeatureLayerID = new UIDClass();
                        geoFeatureLayerID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
                        IEnumLayer        enumLayer = map.get_Layers(((ESRI.ArcGIS.esriSystem.UID)geoFeatureLayerID), true);
                        IFeatureLayer     fLayer;
                        IFeatureSelection fSel;
                        ILayer            layer;
                        // Step through each geofeature layer in the map
                        enumLayer.Reset();
                        // Create an edit operation enabling undo/redo
                        try
                        {
                            while ((layer = enumLayer.Next()) != null)
                            {
                                // Verify that this is a valid, visible layer and that this layer is editable
                                fLayer = (IFeatureLayer)layer;
                                if (fLayer.Valid && eLayers.IsEditable(fLayer))//fLayer.Visible &&
                                {
                                    // Verify that this layer has selected features
                                    IFeatureClass fc = fLayer.FeatureClass;
                                    fSel = (IFeatureSelection)fLayer;

                                    if ((fc != null) && (fSel.SelectionSet.Count > 0))
                                    {
                                        // test = true;

                                        fSel.SelectionSet.Search(null, false, out cursor);
                                        fCursor = cursor as IFeatureCursor;
                                        IFeature feat;
                                        while ((feat = (IFeature)fCursor.NextFeature()) != null)
                                        {
                                            lastLay = fLayer.Name;


                                            lastOID = feat.OID;
                                            IObject pObj = feat as IObject;

                                            AAState.FeatureManual(pObj);
                                            feat.Store();
                                        }
                                        if (feat != null)
                                        {
                                            Marshal.ReleaseComObject(feat);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            editor.AbortOperation();
                            ran = false;
                            MessageBox.Show("RunManualRules\n" + ex.Message + " \n" + lastLay + ": " + lastOID, ex.Source);
                            return;
                        }
                        finally
                        {
                            //try
                            //{
                            //    // Stop the edit operation
                            //    editor.StopOperation("Run Manual Rules - Features");
                            //}
                            //catch (Exception ex)
                            //{ }
                        }



                        try
                        {
                            for (int i = 0; i < stTableColl.StandaloneTableCount; i++)
                            {
                                stTable  = stTableColl.get_StandaloneTable(i);
                                tableSel = (ITableSelection)stTable;
                                if (tableSel.SelectionSet != null)
                                {
                                    if (tableSel.SelectionSet.Count > 0)
                                    {
                                        tableSel.SelectionSet.Search(null, false, out cursor);
                                        IRow pRow;
                                        while ((pRow = (IRow)cursor.NextRow()) != null)
                                        {
                                            lastOID = pRow.OID;
                                            lastLay = stTable.Name;
                                            IObject pObj = pRow as IObject;
                                            AAState.FeatureManual(pObj);
                                            pRow.Store();
                                        }
                                        if (pRow != null)
                                        {
                                            Marshal.ReleaseComObject(pRow);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            editor.AbortOperation();
                            MessageBox.Show("RunManualRules\n" + ex.Message + " \n" + lastLay + ": " + lastOID, ex.Source);
                            ran = false;

                            return;
                        }
                        finally
                        {
                            //try
                            //{
                            //     Stop the edit operation
                            //    editor.StopOperation("Run Manual Rules - Features");
                            //}
                            //catch (Exception ex)
                            //{ }
                        }
                        try
                        {
                            editor.StopOperation("Run Manual Rules - Features");
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select some features or rows to run this process.");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " \n" + "RunManualRules", ex.Source);
                ran = false;

                return;
            }
            finally
            {
                if (ran)
                {
                    MessageBox.Show("Process has completed successfully");
                }

                if (cursor != null)
                {
                    Marshal.ReleaseComObject(cursor);
                }
                if (fCursor != null)
                {
                    Marshal.ReleaseComObject(fCursor);
                }
            }
        }