Example #1
0
        void AddEmptyPlansToList(ICadastralFabric Fabric, IFIDSet EmptyPlansFIDSet, dlgEmptyPlansList EmptyPlansList)
        {
            ITable         pPlansTable = Fabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
            CheckedListBox list        = EmptyPlansList.checkedListBox1;
            IArray         array       = new ArrayClass();

            for (int idx = 0; idx <= (EmptyPlansFIDSet.Count() - 1); idx++)
            {
                // Add the name of the plan to the list
                Int32 i_x;
                Int32 iPlanName;
                iPlanName = pPlansTable.FindField("NAME");
                EmptyPlansFIDSet.Next(out i_x);
                array.Add(i_x);
                string sPlanName = (string)pPlansTable.GetRow(i_x).get_Value(iPlanName);
                list.Items.Add(sPlanName, true);
            }
            // Bind array of plan ids with the list
            list.Tag = (object)array;
            if (list.Items.Count > 0)
            {
                EmptyPlansList.checkedListBox1_SelectedValueChanged(null, null);
            }
        }
        protected override void OnClick()
        {
            IMouseCursor pMouseCursor = new MouseCursorClass();
              pMouseCursor.SetCursor(2);

              //get the plans
              UID pUID = new UIDClass();
              pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
              ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
              ICadastralEditor pCadEd = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

              IEditor pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");
              dlgEmptyPlansList pPlansListDialog = new dlgEmptyPlansList();

              IActiveView pActiveView = ArcMap.Document.ActiveView;
              IMap pMap = pActiveView.FocusMap;
              ICadastralFabric pCadFabric = null;
              clsFabricUtils FabricUTILS = new clsFabricUtils();

              //if we're in an edit session then grab the target fabric
              if (pEd.EditState == esriEditState.esriStateEditing)
              {
            pCadFabric = pCadEd.CadastralFabric;
              }
              if(pCadFabric==null)
              {
              //find the first fabric in the map
            if (!FabricUTILS.GetFabricFromMap(pMap, out pCadFabric))
            {
              MessageBox.Show
            ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
              return;
            }
              }
              ITable pPlansTable =null;
              if (pCadFabric != null)
            pPlansTable = pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
              else
            return;
              IDataset pDS = (IDataset)pPlansTable;
              IWorkspace pWS = pDS.Workspace;

              bool bIsFileBasedGDB;
              bool bIsUnVersioned;
              bool bUseNonVersionedEdit;
              if (!(FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd,
            out bIsFileBasedGDB, out bIsUnVersioned, out bUseNonVersionedEdit)))
            return;

              IFIDSet pEmptyPlans = null;
              if (!FindEmptyPlans(pCadFabric, null, null, out pEmptyPlans))
            return;

              //Fill the list on the dialog
              AddEmptyPlansToList(pCadFabric, pEmptyPlans, pPlansListDialog);

              //Display the dialog
              DialogResult pDialogResult = pPlansListDialog.ShowDialog();
              if (pDialogResult != DialogResult.OK)
            return;
              IArray array = (IArray)pPlansListDialog.checkedListBox1.Tag;

              IFIDSet pPlansToDelete = new FIDSetClass();

              foreach (int checkedItemIndex in pPlansListDialog.checkedListBox1.CheckedIndices)
              {
            Int32 iPlansID = (Int32)array.get_Element(checkedItemIndex);
            if (iPlansID>-1)
              pPlansToDelete.Add(iPlansID);
              }

              if (bUseNonVersionedEdit)
              {
            FabricUTILS.DeleteRowsUnversioned(pWS, pPlansTable, pPlansToDelete, null, null);
              }
              else
              {
            try
            {
              try
              {
            pEd.StartOperation();
              }
              catch
              {
            pEd.AbortOperation();//abort any open edit operations and try again
            pEd.StartOperation();
              }
              FabricUTILS.DeleteRowsByFIDSet(pPlansTable, pPlansToDelete, null, null);
              pEd.StopOperation("Delete Empty Plans");
            }
            catch (COMException ex)
            {
              MessageBox.Show(Convert.ToString(ex.ErrorCode));
              pEd.AbortOperation();
            }
              }
        }
 void AddEmptyPlansToList(ICadastralFabric Fabric, IFIDSet EmptyPlansFIDSet, dlgEmptyPlansList EmptyPlansList)
 {
     ITable pPlansTable = Fabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
       CheckedListBox list = EmptyPlansList.checkedListBox1;
       IArray array = new ArrayClass();
       for (int idx = 0; idx <= (EmptyPlansFIDSet.Count() - 1); idx++)
       {
     // Add the name of the plan to the list
     Int32 i_x;
     Int32 iPlanName;
     iPlanName = pPlansTable.FindField("NAME");
     EmptyPlansFIDSet.Next(out i_x);
     array.Add(i_x);
     string sPlanName = (string)pPlansTable.GetRow(i_x).get_Value(iPlanName);
     list.Items.Add(sPlanName, true);
       }
       // Bind array of plan ids with the list
       list.Tag = (object)array;
       if(list.Items.Count>0)
     EmptyPlansList.checkedListBox1_SelectedValueChanged(null, null);
 }
Example #4
0
        protected override void OnClick()
        {
            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            //get the plans
            UID pUID = new UIDClass();

            pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
            ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
            ICadastralEditor            pCadEd     = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

            IEditor           pEd = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");
            dlgEmptyPlansList pPlansListDialog = new dlgEmptyPlansList();

            IActiveView      pActiveView = ArcMap.Document.ActiveView;
            IMap             pMap        = pActiveView.FocusMap;
            ICadastralFabric pCadFabric  = null;
            clsFabricUtils   FabricUTILS = new clsFabricUtils();

            //if we're in an edit session then grab the target fabric
            if (pEd.EditState == esriEditState.esriStateEditing)
            {
                pCadFabric = pCadEd.CadastralFabric;
            }
            if (pCadFabric == null)
            {
                //find the first fabric in the map
                if (!FabricUTILS.GetFabricFromMap(pMap, out pCadFabric))
                {
                    MessageBox.Show
                        ("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
                    return;
                }
            }
            ITable pPlansTable = null;

            if (pCadFabric != null)
            {
                pPlansTable = pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPlans);
            }
            else
            {
                return;
            }
            IDataset   pDS = (IDataset)pPlansTable;
            IWorkspace pWS = pDS.Workspace;

            bool bIsFileBasedGDB;
            bool bIsUnVersioned;
            bool bUseNonVersionedEdit;

            if (!(FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd,
                                                   out bIsFileBasedGDB, out bIsUnVersioned, out bUseNonVersionedEdit)))
            {
                return;
            }

            IFIDSet pEmptyPlans = null;

            if (!FindEmptyPlans(pCadFabric, null, null, out pEmptyPlans))
            {
                return;
            }

            //Fill the list on the dialog
            AddEmptyPlansToList(pCadFabric, pEmptyPlans, pPlansListDialog);

            //Display the dialog
            DialogResult pDialogResult = pPlansListDialog.ShowDialog();

            if (pDialogResult != DialogResult.OK)
            {
                return;
            }
            IArray array = (IArray)pPlansListDialog.checkedListBox1.Tag;

            IFIDSet pPlansToDelete = new FIDSetClass();

            foreach (int checkedItemIndex in pPlansListDialog.checkedListBox1.CheckedIndices)
            {
                Int32 iPlansID = (Int32)array.get_Element(checkedItemIndex);
                if (iPlansID > -1)
                {
                    pPlansToDelete.Add(iPlansID);
                }
            }

            if (bUseNonVersionedEdit)
            {
                FabricUTILS.DeleteRowsUnversioned(pWS, pPlansTable, pPlansToDelete, null, null);
            }
            else
            {
                try
                {
                    try
                    {
                        pEd.StartOperation();
                    }
                    catch
                    {
                        pEd.AbortOperation();//abort any open edit operations and try again
                        pEd.StartOperation();
                    }
                    FabricUTILS.DeleteRowsByFIDSet(pPlansTable, pPlansToDelete, null, null);
                    pEd.StopOperation("Delete Empty Plans");
                }
                catch (COMException ex)
                {
                    MessageBox.Show(Convert.ToString(ex.ErrorCode));
                    pEd.AbortOperation();
                }
            }
        }