Ejemplo n.º 1
0
        public static bool SaveEdits(IApplication app, TransactionManager tm)
        {
            bool result = false;
            try
            {
                if (HasEdits(app, tm))
                {
                    UID pUID = new UIDClass();
                    pUID.Value = "esriEditor.Editor";
                    IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection;
                    IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID);

                    editor2.StopEditing(true);
                    editor2.StartEditing((IWorkspace)workspace);
                    workspace.StopEditing(true);
                    workspace.StartEditing(false);
                }

                result = true;
            }
            catch (Exception e)
            {
                Logger.Write("Error saving edits to PGDB", Logger.LogLevel.Debug);
                MessageBox.Show("An error occured while attempting to save current edits.");
                result = false;
            }
            return result;
        }
        /// <summary>Apply the OSM Class Extension to the given table</summary>
        /// <remarks>Obtains an exclusive schema lock if possible otherwise throws an exception</remarks>
        public static void ApplyOSMClassExtension(this ITable table)
        {
            if ((table == null) || (table.Extension is IOSMClassExtension))
                return;

            IClassSchemaEdit3 schemaEdit = table as IClassSchemaEdit3;
            if (schemaEdit == null)
                return;

            int osmIDIndex = table.Fields.FindField("OSMID");

            using (SchemaLockManager lockMgr = new SchemaLockManager(table))
            {
                UID osmClassExtensionUID = new UIDClass() { Value = _OSM_CLASS_EXT_GUID };

                IPropertySet extensionPropertSet = null;
                if (osmIDIndex > -1)
                {
                    // at release 2.1 we changed the OSMID field type to string, hence only when we find the string we are assuming version 2
                    if (table.Fields.get_Field(osmIDIndex).Type == esriFieldType.esriFieldTypeString)
                    {
                        extensionPropertSet = new PropertySetClass();
                        extensionPropertSet.SetProperty("VERSION", _OSM_EXTENSION_VERSION);
                    }
                }

                schemaEdit.AlterClassExtensionCLSID(osmClassExtensionUID, extensionPropertSet);
                schemaEdit.AlterClassExtensionProperties(extensionPropertSet);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 图例
 /// </summary>
 /// <returns></returns>
 public bool AddLegend()
 {
     IGraphicsContainer pGraphicsContainer;
     pGraphicsContainer = mainPage.PageLayout as IGraphicsContainer;
     IMapFrame pFocusMapFrame;
     pFocusMapFrame = pGraphicsContainer.FindFrame(mainPage.ActiveView.FocusMap) as IMapFrame;
     UID u = new UIDClass();
     u.Value = "esriCarto.Legend";
     IMapSurroundFrame pLegendFrame;
     pLegendFrame = pFocusMapFrame.CreateSurroundFrame(u, null);
     IEnvelope pEnvelope;
     pEnvelope = new EnvelopeClass();
     pEnvelope.PutCoords(3, 3, 6, 8);
     IElement pElement;
     pElement = pLegendFrame as IElement;
     pElement.Geometry = pEnvelope;
     ILegendWizard pLegendWizard;
     pLegendWizard = new LegendWizard();
     pLegendWizard.PageLayout = mainPage.PageLayout;
     pLegendWizard.InitialLegendFrame = pLegendFrame;
     bool bOk = pLegendWizard.DoModal(mainPage.hWnd);
     if (bOk == true)
     {
         IElement ele = pLegendWizard.LegendFrame as IElement;
         pGraphicsContainer.AddElement(ele, 0);
         mainPage.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
     return true;
 }
Ejemplo n.º 4
0
        public static bool HasEdits(IApplication app, TransactionManager tm)
        {
            try
            {
                IWorkspaceEdit workspace = (IWorkspaceEdit)tm.Current().PGDBConnection;

                bool processQA = false;
                bool hasEdits = false;
                workspace.HasEdits(ref hasEdits);

                UID pUID = new UIDClass();
                pUID.Value = "esriEditor.Editor";
                IEditor editor = (IEditor)app.FindExtensionByCLSID(pUID);
                IEditTask task = editor.CurrentTask;
                IEditTask resetTask = editor.get_Task(0);
                editor.CurrentTask = resetTask;
                editor.CurrentTask = task;

                IEditor2 editor2 = (IEditor2)app.FindExtensionByCLSID(pUID);
                bool hasCachedEdits = editor2.HasEdits();

                return hasCachedEdits || hasEdits;
            }
            catch (Exception e)
            {
                Logger.Write("Error testing if transaction has edits: " + e.Message + " : " + e.StackTrace, Logger.LogLevel.Debug);
                throw new Exception("Error", e);
            }
        }
Ejemplo n.º 5
0
 public IDockableWindow GetDockableWindow(IApplication app, string winName)
 {
     IDockableWindowManager dWinManager = app as IDockableWindowManager;
     UID winID = new UIDClass();
     winID.Value = winName;
     return dWinManager.GetDockableWindow(winID);
 }
Ejemplo n.º 6
0
        protected override void OnActivate()
        {
            try
            {
                UID dockWinID = new UIDClass();
                dockWinID.Value = ThisAddIn.IDs.EditForm;
                IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                if (!dockWindow.IsVisible())
                {
                    dockWindow.Show(true);
                }

                if (Editor.ActiveLayer == null)
                {
                    return;
                }

                IRasterLayer rasterLayer = (IRasterLayer)Editor.ActiveLayer;
                IRasterProps rasterProp = (IRasterProps)rasterLayer.Raster;
                maxIndex = new Position(rasterProp.Width - 1, rasterProp.Height - 1);

                EditForm editForm = AddIn.FromID<EditForm.AddinImpl>(ThisAddIn.IDs.EditForm).UI;
                editForm.SetLayer(Editor.ActiveLayer.Name);
                System.Array noDataValue = (System.Array)rasterProp.NoDataValue;
                editForm.RasterGridView.NoDataValue = Convert.ToDouble(noDataValue.GetValue(0));
                editForm.SetNoDataValue(editForm.RasterGridView.NoDataValue);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }

            base.OnActivate();
        }
Ejemplo n.º 7
0
        public frmBuffer(IMap _pMap)
        {
            InitializeComponent();
            //load all the feature layers in the map to the layers combo
            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            pMap = _pMap;
            layers = pMap.get_Layers(uid, true);
            layers.Reset();
            ILayer layer = null;
            while ((layer = layers.Next()) != null)
            {
                cboLayers.Items.Add(layer.Name);
            }
            //select the first layer
            if (cboLayers.Items.Count > 0)
                cboLayers.SelectedIndex = 0;

            string tempDir = System.IO.Path.GetTempPath();
            txtOutputPath.Text = System.IO.Path.Combine(tempDir, ((string)cboLayers.SelectedItem + "_buffer.shp"));

            //set the default units of the buffer
            int units = Convert.ToInt32(pMap.MapUnits);
            cboUnits.SelectedIndex = units;
        }
        private static ITable CreateTable(IWorkspace2 workspace, string tableName, IFields fields)
        {
            UID uid = new UIDClass {Value = "esriGeoDatabase.Object"};

            if (workspace == null) return null;

            IFeatureWorkspace featWorkspace = (IFeatureWorkspace) workspace;

            if (workspace.NameExists[esriDatasetType.esriDTTable, tableName])
            {
                using (ComReleaser releaser = new ComReleaser())
                {
                    ITable table = featWorkspace.OpenTable(tableName);
                    releaser.ManageLifetime(table);
                    ((IDataset) table).Delete();
                }
            }


            IFieldChecker fieldChecker = new FieldCheckerClass();
            IEnumFieldError enumFieldError = null;
            IFields validatedFields = null;
            fieldChecker.ValidateWorkspace = workspace as IWorkspace;
            fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

            return featWorkspace.CreateTable(tableName, validatedFields, uid, null, string.Empty);
        }
        public EditorEventsDialog(object hook)
        {
            InitializeComponent();
            this.Hook = hook;
            e_dockWinForm = this;
            //get a reference to the editor
            UID uid = new UIDClass();
            uid.Value = "esriEditor.Editor";
            m_editor = ArcMap.Application.FindExtensionByCLSID(uid) as ESRI.ArcGIS.Editor.IEditor;

            m_TabControl = e_dockWinForm.tabControl1;
            System.Collections.IEnumerator e = m_TabControl.TabPages.GetEnumerator();
            e.MoveNext();
            m_listenTab = e.Current as TabPage;
            e.MoveNext();
            m_selectTab = e.Current as TabPage;

            CheckedListBox editEventList = m_selectTab.GetNextControl(m_selectTab, true) as CheckedListBox;
            editEventList.ItemCheck += new ItemCheckEventHandler(editEventList_ItemCheck);

            ListBox listEvent = m_listenTab.GetNextControl(m_listenTab, true) as ListBox;
            listEvent.MouseDown += new MouseEventHandler(listEvent_MouseDown);

            eventListener = new EventListener(m_editor);

            eventListener.Changed += new ChangedEventHandler(eventListener_Changed);

            //populate the editor events
            editEventList.Items.AddRange(Enum.GetNames(typeof(EventListener.EditorEvent)));
        }
Ejemplo n.º 10
0
        internal static void Invoke(string tool)
        {
            UID uniqueId = new UIDClass();
            uniqueId.Value = "esriGeoprocessingUI.ArcToolboxExtension";

            var arcToolboxExtension = ArcMap.Application.FindExtensionByCLSID(uniqueId) as IArcToolboxExtension;
            if (arcToolboxExtension == null)
                return;

            IGPTool gpTool = null;
            try
            {
                gpTool = arcToolboxExtension.ArcToolbox.GetToolbyNameString(tool);
            }
            catch (COMException)
            {
                MessageBox.Show(@"Unable to find tool: " + tool + Environment.NewLine + @"in the system toolbox.",
                                @"Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (gpTool == null)
                return;

            IGPToolCommandHelper gpCommandHelper = new GPToolCommandHelper();
            gpCommandHelper.SetTool(gpTool);
            gpCommandHelper.Invoke(null);
        }
    //Initialize the Tracking Environment, you only need to do this once
    private void setupTrackingEnv()
    {
      if (!m_bInitialized && ArcMap.Application != null)
      {
        IExtensionManager extentionManager = new ExtensionManagerClass();

        UID uid = new UIDClass();
        uid.Value = "esriTrackingAnalyst.TrackingEngineUtil";
        object mapRef = ArcMap.Application;

        ((IExtensionManagerAdmin)extentionManager).AddExtension(uid, ref mapRef);

        ITrackingEnvironment3 trackingEnv = new TrackingEnvironmentClass();
        try
        {
          trackingEnv.Initialize(ref mapRef);
        }
        catch (Exception ex)
        {
        }
        trackingEnv.EnableTemporalDisplayManagement = true;
     
        m_bInitialized = true;
      }
    }
Ejemplo n.º 12
0
        protected override void OnActivate()
        {
            base.OnActivate();

            try
            {
                if (Painter.ActiveLayer == null)
                {
                    return;
                }

                UID dockWinID = new UIDClass();
                dockWinID.Value = ThisAddIn.IDs.ValueSymbolForm;
                IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
                if (!dockWindow.IsVisible())
                {
                    dockWindow.Show(true);
                }

                IRasterLayer rasterLayer = (IRasterLayer)Painter.ActiveLayer;
                IRasterProps rasterProp = (IRasterProps)rasterLayer.Raster;
                layerExetent = new Envelope(0, rasterProp.Height - 1, 0, rasterProp.Width - 1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error");
            }
        }
 public EditorEventsDialogCommand()
 { 
    // SetupDockableWindow();
     UID windowID = new UIDClass();
     windowID.Value = @"ESRI_Employee_Events_EditorEventsDialog";
     m_dockableWindow = ArcMap.DockableWindowManager.GetDockableWindow(windowID);
 }
 protected override void OnClick()
 {
     UID theUid = new UIDClass();
     theUid.Value = ThisAddIn.IDs.Gbdx_Answer_Factory_AnswerFactoryDockableWindow;
     var window = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
     window.Show(!window.IsVisible());
 }
        /// <summary>
        /// The on click.
        /// </summary>
        protected override void OnClick()
        {
            //            if (ArcMap.Application.CurrentTool.Name != ThisAddIn.IDs.Gbdx_Aggregations_AggregationSelector)
            //            {
            //                UID theUid = new UIDClass();
            //                theUid.Value = ThisAddIn.IDs.Gbdx_Aggregations_AggregationWindow;
            //                var window = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
            //                window.Show(!window.IsVisible());
            //            }

            try
            {
                if (ArcMap.Application.CurrentTool.Name != ThisAddIn.IDs.Gbdx_Aggregations_AggregationSelector)
                {
                    UID theUid = new UIDClass();
                    theUid.Value = ThisAddIn.IDs.Gbdx_Aggregations_Aggregations;
                    var window = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
                    window.Show(!window.IsVisible());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        /// <summary>
        /// The on click method for the button are the arcmap toolbar.
        /// </summary>
        protected override void OnClick()
        {
            UID theUid = new UIDClass();
            theUid.Value = ThisAddIn.IDs.Gbdx_Vector_Index_Forms_VectorIndexDockable;

            IDockableWindow vectorIndexDockableWindow = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
            vectorIndexDockableWindow.Show(!vectorIndexDockableWindow.IsVisible());
        }
        protected override void OnClick()
        {
            UID theUid = new UIDClass();
            theUid.Value = ThisAddIn.IDs.dwnMapUnitLegendEditor;

            IDockableWindow mapUnitForm = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
            if (mapUnitForm.IsVisible() == false) { mapUnitForm.Show(true); }
        }
Ejemplo n.º 18
0
        private IEnumLayer GetLayers()
        {
            UID uid = new UIDClass();
            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            IEnumLayer layers = _hookHelper.FocusMap.get_Layers(uid, true);

            return layers;
        }
Ejemplo n.º 19
0
 protected override void OnClick()
 {
     this.Enabled = true;
     UID dockWinID = new UIDClass();
     dockWinID.Value = @"DataManager_addin_frm_DataManager";
     ESRI.ArcGIS.Framework.IDockableWindow s_dockWindow = ArcCatalog.DockableWindowManager.GetDockableWindow(dockWinID);
     s_dockWindow.Show(!s_dockWindow.IsVisible());
 }
 public CurveByInferenceExtension()
 {            
     //update the dockable window so that it has the correct version
     UID dockWinID = new UIDClass();
     dockWinID.Value = ThisAddIn.IDs.CurveByInferenceWindow;
     s_CurveByInfrenceWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
     s_CurveByInfrenceWindow.Caption = String.Format("{0} ({1})", s_CurveByInfrenceWindow.Caption, ThisAddIn.Version);
 }
        public SetFlowByDigitizedDirectionCSharp()
        {
            UID uidUtilNet = new UIDClass();
            uidUtilNet.Value = "esriEditorExt.UtilityNetworkAnalysisExt";
            m_utilNetExt = ArcMap.Application.FindExtensionByCLSID(uidUtilNet) as IUtilityNetworkAnalysisExt;

            UID uidEditor = new UIDClass();
            uidEditor.Value = "esriEditor.Editor";
            m_editorExt = ArcMap.Application.FindExtensionByCLSID(uidEditor) as IEditor;        
        }
        protected override void OnClick()
        {
            ArcMap.Application.CurrentTool = null;

            UID dockWinID = new UIDClass();
            dockWinID.Value = ThisAddIn.IDs.DockableWindowDistanceAndDirection;

            IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
            dockWindow.Show(true);
        }
Ejemplo n.º 23
0
        public LayerInfo(IMapDocument mapDoc)
        {
            /* Diese Eigenschaften sind für jeden Layer identisch */
            mxd = mapDoc;
            mxdname = mxd.DocumentFilename;

            UID pID = new UIDClass();
            pID.Value = "{EDAD6644-1810-11D1-86AE-0000F8751720}";
            groupLayerList = getLayerList(pID);
        }
Ejemplo n.º 24
0
        private IRepresentationWorkspaceExtension GetRepWSExtFromFeatureClass(IFeatureClass theFeatureClass)
        {
            IDataset theDS = theFeatureClass as IDataset;
            IWorkspace theWorkspace = theDS.Workspace;
            IWorkspaceExtensionManager theExtManager = theWorkspace as IWorkspaceExtensionManager;

            UID theUID = new UIDClass();
            theUID.Value = "{FD05270A-8E0B-4823-9DEE-F149347C32B6}";
            return theExtManager.FindExtension(theUID) as IRepresentationWorkspaceExtension;
        }
 internal static IExtension GetExtension()
 {
     if (s_extension == null)
     {
         UID extID = new UIDClass();
         extID.Value = ThisAddIn.IDs.CurveByInferenceExtension;
         s_extension = ArcMap.Application.FindExtensionByCLSID(extID);
     }
     return s_extension;
 }
Ejemplo n.º 26
0
 protected override void OnClick()
 {
     // Get Dockable window
     UID dockWinID = new UIDClass();
     dockWinID.Value = @"esri_ArcMapAddin_DockWindowTest_DockableWindow1_Class";
     IDockableWindow s_dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
     if (s_dockWindow.IsVisible()) // This true by default if you use the Dockable Window Add-In template to create the dockable window
         s_dockWindow.Show(false);
     else
         s_dockWindow.Show(true);
 }
Ejemplo n.º 27
0
        protected override void OnClick()
        {
            //
            //  TODO: Sample code showing how to access button host
            //
            UID dockWinID = new UIDClass();
            dockWinID.Value = ThisAddIn.IDs.AGOLWindow;

            // Use GetDockableWindow directly as we want the client IDockableWindow not the internal class
            IDockableWindow dockWindow = ArcMap.DockableWindowManager.GetDockableWindow(dockWinID);
            dockWindow.Show(true);
        }
Ejemplo n.º 28
0
        public void AddCommandToApplicationMenu(IApplication TheApplication, string AddThisCommandGUID,
  string ToThisMenuGUID, bool StartGroup, string PositionAfterThisCommandGUID, bool EndGroup)
        {
            if (AddThisCommandGUID.Trim() == "")
            return;

              if (ToThisMenuGUID.Trim() == "")
            return;

              //Then add items to the command bar:
              UID pCommandUID = new UIDClass(); // this references an ICommand
              pCommandUID.Value = AddThisCommandGUID; // the ICommand to add

              //Assign the UID for the menu we want to add the custom button to
              UID MenuUID = new UIDClass();
              MenuUID.Value = ToThisMenuGUID;
              //Get the target menu as a ICommandBar
              ICommandBar pCmdBar = TheApplication.Document.CommandBars.Find(MenuUID) as ICommandBar;

              int iPos = pCmdBar.Count;

              //for the position string, if it's an empty string then default to end of menu.
              if (PositionAfterThisCommandGUID.Trim() != "")
              {
            UID pPositionCommandUID = new UIDClass();
            pPositionCommandUID.Value = PositionAfterThisCommandGUID;
            iPos = pCmdBar.Find(pPositionCommandUID).Index + 1;
            if (pPositionCommandUID != null)
              Marshal.ReleaseComObject(pPositionCommandUID);
              }

              ICommandItem pCmdItem = pCmdBar.Find(pCommandUID);

              //Check if it is already present on the context menu...
              if (pCmdItem == null)
              {
            pCmdItem = pCmdBar.Add(pCommandUID, iPos);
            pCmdItem.Group = StartGroup;
            pCmdItem.Refresh();
              }

              //if (EndGroup)
              //{
              //  if (pCmdBar.Count > iPos)
              //  { pCmdItem=pCmdBar.Find("")}
              //}

              if (pCommandUID != null)
            Marshal.ReleaseComObject(pCommandUID);
              if (MenuUID != null)
            Marshal.ReleaseComObject(MenuUID);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// The on click.
        /// </summary>
        protected override void OnClick()
        {
            if (ArcMap.Application.CurrentTool.Name == ThisAddIn.IDs.Gbdx_Gbd_Selector)
            {
                return;
            }

            UID theUid = new UIDClass();
            theUid.Value = ThisAddIn.IDs.Gbdx_Gbd_GbdDockableWindow;

            var window = ArcMap.DockableWindowManager.GetDockableWindow(theUid);
            window.Show(!window.IsVisible());
        }
Ejemplo n.º 30
0
        //not finished
        public static void BurstFindValves()
        {
            // run a FindPath between 2 flags, create a polyline from the results
            //��Ҫdesktop������

            /*
                        INetworkAnalysisExt pNetAnalysisExt;
                        INetworkAnalysisExtFlags pNetAnalysisExtFlags;
                        INetworkAnalysisExtBarriers pNetAnalysisExtBarriers;
                        INetworkAnalysisExtResults pNetAnalysisExtResults;
                        */

            string valvelayername = "Water Fixtures";
            string waterlinelayername = "Water Lines";
            string waternetworkname = "Water_Network";

            INetworkCollection pNetworkCollection;
            IFeatureDataset pFeatureDataSet;

            IWorkspaceFactory pWSF=new SdeWorkspaceFactoryClass();
            IPropertySet pPropset=new PropertySetClass();

            IFeatureWorkspace pFeatureWorkspace=pWSF.Open(pPropset,0) as IFeatureWorkspace;

            INetwork pNetwork;

            IGeometricNetwork pGeometricNetwork;

            pFeatureDataSet = pFeatureWorkspace.OpenFeatureDataset("datasetName");

            pNetworkCollection=pFeatureDataSet as INetworkCollection;

            pGeometricNetwork=pNetworkCollection.get_GeometricNetworkByName("networkname");

            pNetwork=pGeometricNetwork.Network;

            IEdgeFlagDisplay pEdgeFlagDisplay;
            IFlagDisplay pFlagDisplay;
            IEdgeFlag pEdgeFlag;
            INetFlag pNetFlag;

            //����һ��flag
            pEdgeFlag=new EdgeFlagClass();

            pNetFlag=pEdgeFlag as INetFlag;

            IFeatureLayer pFeatLayerValves;
            IFeatureLayer pFeatLayerWaterLines;

            UID pID=new UIDClass();
        }
        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);
                }
            }
        }
        protected override void OnClick()
        {
            ICadastralEditor            pCadEd         = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            ICadastralFabric            pCadFabric     = pCadEd.CadastralFabric;
            ICadastralExtensionManager2 pCadExtMan     = (ICadastralExtensionManager2)pCadEd;
            IParcelEditManager          pParcEditorMan = (IParcelEditManager)pCadEd;
            IParcelConstruction         pTrav          = pParcEditorMan.ParcelConstruction;

            //Test for the visibility of the parcel details window
            IDockableWindowManager pDocWinMgr = (IDockableWindowManager)ArcMap.Application;
            UID pUID = new UIDClass();

            pUID.Value = "{28531B78-7C42-4785-805D-2A7EC8879EA1}";//ArcID.ParcelDetails
            IDockableWindow pParcelDet = pDocWinMgr.GetDockableWindow(pUID);

            if (!pParcelDet.IsVisible())
            {
                MessageBox.Show("The Parcel Details window is not visible. \r\nThere is no data to save.");
                return;
            }

            //Make sure the lines grid is selected
            Utilities UTILS = new Utilities();

            UTILS.SelectCadastralPropertyPage((ICadastralExtensionManager)pCadExtMan, "lines");

            //test to make sure there is data there to be saved
            IParcelConstruction3 pConstr = (IParcelConstruction3)pTrav;
            IGSParcel            pParcel = null;

            //
            try
            {
                pParcel = pTrav.Parcel;
            }
            catch (COMException err)
            {
                MessageBox.Show(err.Message + Environment.NewLine + "ERROR: Select a parcel or add lines to the grid. \r\nThere is no data to save. ");
                return;
            }
            //define the file that needs to be saved
            // Display .Net dialog for File saving.
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            // Set File Filter
            saveFileDialog.Filter           = "Comma-delimited(*.csv)|*.csv|All Files|*.*";
            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;
            // Warn on overwrite
            saveFileDialog.OverwritePrompt = true;
            // Don't need to Show Help
            saveFileDialog.ShowHelp = false;
            // Set Dialog Title
            saveFileDialog.Title = "Save file";

            // Display Open File Dialog
            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                saveFileDialog = null;
                return;
            }
            TextWriter tw = null;

            try
            {
                tw = new StreamWriter(saveFileDialog.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            try
            {
                IGSPlan pPlan = pTrav.Parcel.Plan;
                int     iDF   = (int)pPlan.DirectionFormat;
                switch (iDF)
                {
                case (int)esriDirectionType.esriDTNorthAzimuth:
                    tw.WriteLine("DT,NA");
                    break;

                case (int)esriDirectionType.esriDTPolar:
                    tw.WriteLine("DT,P");
                    break;

                case (int)esriDirectionType.esriDTQuadrantBearing:
                    tw.WriteLine("DT,QB");
                    break;

                case (int)esriDirectionType.esriDTSouthAzimuth:
                    tw.WriteLine("DT,SA");
                    break;

                default:
                    tw.WriteLine("DT,NA");
                    break;
                }

                int iAU = (int)pPlan.AngleUnits;
                switch (iAU)
                {
                case (int)esriDirectionUnits.esriDUDecimalDegrees:
                    tw.WriteLine("DU,DD");
                    break;

                case (int)esriDirectionUnits.esriDUDegreesMinutesSeconds:
                    tw.WriteLine("DU,DMS");
                    break;

                case (int)esriDirectionUnits.esriDUGons:
                case (int)esriDirectionUnits.esriDUGradians:
                    tw.WriteLine("DU,G");
                    break;

                case (int)esriDirectionUnits.esriDURadians:
                    tw.WriteLine("DU,R");
                    break;

                default:
                    tw.WriteLine("DU,R");
                    break;
                }

                ICadastralUnitConversion pUnitConv = new CadastralUnitConversionClass();
                double dMetricConversion           = pUnitConv.ConvertDouble(1, pPlan.DistanceUnits, esriCadastralDistanceUnits.esriCDUMeter);
                string sLU = Convert.ToString(dMetricConversion);

                tw.WriteLine("ToMetricFactor," + sLU);

                IEnumGSLines pGSLines = pTrav.GetLines();
                pGSLines.Reset();
                IGSLine   pGSLine   = null;
                IGSParcel pGSParcel = null;
                pGSLines.Next(ref pGSParcel, ref pGSLine);
                while (pGSLine != null)
                {
                    int iFromPt  = pGSLine.FromPoint;     //from point
                    int iToPt    = pGSLine.ToPoint;       //to point
                    int iLineCat = (int)pGSLine.Category; //line category
                    if (iLineCat == 4)
                    {
                        pGSLines.Next(ref pGSParcel, ref pGSLine);
                        continue;                            //ignore radial lines
                    }
                    int    iLineUserType = pGSLine.LineType; //line user type
                    int    iAccCat       = pGSLine.Accuracy; //accuracy
                    double dDistance     = pGSLine.Distance; //distance
                    double dChord        = pGSLine.Distance; //chord
                    double dRadius       = pGSLine.Radius;   //radius

                    string sLineCat      = Convert.ToString(iLineCat);
                    string sLineUserType = Convert.ToString(iLineUserType);

                    if (iLineUserType > 2140000000)
                    {
                        sLineUserType = "";
                    }

                    string sAccCat = Convert.ToString(iAccCat);
                    string sFromPt = Convert.ToString(iFromPt);//from point

                    //following need conversion
                    string sDirection = NorthAzRadians_2_DirectionString(pGSLine.Bearing, pPlan.DirectionFormat, pPlan.AngleUnits); //direction
                    string sDistance  = Convert.ToString(dDistance / dMetricConversion);                                            //distance
                    string sRadius    = "";
                    string sChord     = "";

                    if (dRadius != 123456789)
                    {                                                                //circular curve
                        sRadius   = Convert.ToString(dRadius / dMetricConversion);   //radius
                        sChord    = Convert.ToString(dDistance / dMetricConversion); //chord
                        sDistance = "";                                              //distance is replaced with the chord distance
                    }

                    string sToPt = Convert.ToString(iToPt);//to point
                    //write the line
                    tw.WriteLine(sFromPt + "," + sDirection + "," + sDistance + "," + sRadius + "," + sChord + "," + sToPt + ","
                                 + sLineCat + "," + sLineUserType + "," + sAccCat);

                    pGSLines.Next(ref pGSParcel, ref pGSLine);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                tw.Close();
                saveFileDialog = null;
            }
        }
Ejemplo n.º 33
0
        public static IElement CreateElement(IPageLayout ipageLayout_0)
        {
            int         num;
            double      num1;
            double      num2;
            ITextSymbol symbol;
            esriTextHorizontalAlignment horizontalAlignment;
            esriTextVerticalAlignment   verticalAlignment;
            IScaleText  scaleTextClass;
            UID         uIDClass;
            IMapFrame   mapFrame;
            IEnvelope   envelopeClass;
            IEnvelope   envelope;
            ILegend     legendClass2;
            IScaleBar   hollowScaleBarClass;
            double      num3;
            double      num4;
            INorthArrow markerNorthArrowClass;
            IPoint      position         = ElementWizardHelp.GetPosition(ipageLayout_0, out num, out num1, out num2);
            IElement    textElementClass = null;

            switch (ElementWizardHelp.m_ElementType)
            {
            case ElementType.ConstantText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = ElementWizardHelp.m_Text;
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.SingleText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = string.Concat("=", ElementWizardHelp.m_Text);
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.MultiText:
            {
                textElementClass = new TextElementClass();
                (textElementClass as IElementProperties).Name = ElementWizardHelp.m_Text;
                (textElementClass as ITextElement).Text       = string.Concat("M=", ElementWizardHelp.m_Text);
                if (ElementWizardHelp.m_pStyle != null)
                {
                    ElementWizardHelp.SetTextSymblAlign(ElementWizardHelp.m_pStyle as ITextSymbol, num);
                    (textElementClass as ITextElement).Symbol = ElementWizardHelp.m_pStyle as ITextSymbol;
                }
                textElementClass.Geometry = position;
                if (!ElementWizardHelp.m_IsVerticalText)
                {
                    (textElementClass as IElementProperties).Type = "";
                    symbol = (textElementClass as ITextElement).Symbol;
                    if (symbol.Angle != 270)
                    {
                        return(textElementClass);
                    }
                    (symbol as ICharacterOrientation).CJKCharactersRotation = false;
                    symbol.Angle        = 0;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
                else
                {
                    (textElementClass as IElementProperties).Type = "竖向";
                    symbol = (textElementClass as ITextElement).Symbol;
                    (symbol as ICharacterOrientation).CJKCharactersRotation = true;
                    symbol.Angle        = 270;
                    horizontalAlignment = symbol.HorizontalAlignment;
                    verticalAlignment   = symbol.VerticalAlignment;
                    if (horizontalAlignment == esriTextHorizontalAlignment.esriTHALeft)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHAFull)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHARight)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
                    }
                    else if (horizontalAlignment == esriTextHorizontalAlignment.esriTHACenter)
                    {
                        symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
                    }
                    if (verticalAlignment == esriTextVerticalAlignment.esriTVATop)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABottom)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVACenter)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter;
                    }
                    else if (verticalAlignment == esriTextVerticalAlignment.esriTVABaseline)
                    {
                        symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight;
                    }
                    (textElementClass as ITextElement).Symbol = symbol;
                    return(textElementClass);
                }
            }

            case ElementType.JoinTable:
            {
                textElementClass = (new JionTab()).CreateJionTab(ipageLayout_0 as IActiveView, position);
                return(textElementClass);
            }

            case ElementType.ScaleText:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    scaleTextClass = new ScaleTextClass();
                }
                else
                {
                    scaleTextClass = ElementWizardHelp.m_pStyle as IScaleText;
                }
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.ScaleText"
                };
                mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                scaleTextClass.MapUnits  = mapFrame.Map.DistanceUnits;
                scaleTextClass.PageUnits = ipageLayout_0.Page.Units;
                scaleTextClass.Style     = esriScaleTextStyleEnum.esriScaleTextAbsolute;
                INumberFormat numberFormat = scaleTextClass.NumberFormat;
                if (numberFormat is INumericFormat)
                {
                    (numberFormat as INumericFormat).RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfDecimals;
                    (numberFormat as INumericFormat).UseSeparator   = false;
                    (numberFormat as INumericFormat).RoundingValue  = 0;
                    scaleTextClass.NumberFormat = numberFormat;
                }
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, scaleTextClass) as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                scaleTextClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.CustomLegend:
            {
                CustomLegend customLegend = new CustomLegend()
                {
                    LegendInfo = ElementWizardHelp.m_pLegendInfo
                };
                customLegend.Init(ipageLayout_0 as IActiveView, position);
                textElementClass = customLegend;
                return(textElementClass);
            }

            case ElementType.Legend:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    legendClass2 = new LegendClass_2();
                }
                else
                {
                    legendClass2 = ElementWizardHelp.m_pStyle as ILegend;
                }
                legendClass2.AutoAdd        = true;
                legendClass2.AutoReorder    = true;
                legendClass2.AutoVisibility = true;
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.Legend"
                };
                mapFrame         = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, legendClass2) as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                legendClass2.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.Picture:
            {
                string lower = System.IO.Path.GetExtension(ElementWizardHelp.m_PictureFileName).ToLower();
                textElementClass = null;
                string str = lower;
                if (string.IsNullOrEmpty(str))
                {
                    textElementClass = new PngPictureElementClass();
                    (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                    (textElementClass as IPictureElement).MaintainAspectRatio = true;
                    num3 = 0;
                    num4 = 0;
                    (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                    num3 = num3 * 0.0353;
                    num4 = num4 * 0.0353;
                    (textElementClass as IElementProperties2).AutoTransform = true;
                    envelopeClass = new EnvelopeClass();
                    envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                    textElementClass.Geometry = envelopeClass;
                    return(textElementClass);
                }
                else if (str == ".bmp")
                {
                    textElementClass = new BmpPictureElementClass();
                }
                else if (str == ".jpg")
                {
                    textElementClass = new JpgPictureElementClass();
                }
                else if (str == ".gif")
                {
                    textElementClass = new GifPictureElementClass();
                }
                else if (str == ".tif")
                {
                    textElementClass = new TifPictureElementClass();
                }
                else
                {
                    if (str != ".emf")
                    {
                        textElementClass = new PngPictureElementClass();
                        (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                        (textElementClass as IPictureElement).MaintainAspectRatio = true;
                        num3 = 0;
                        num4 = 0;
                        (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                        num3 = num3 * 0.0353;
                        num4 = num4 * 0.0353;
                        (textElementClass as IElementProperties2).AutoTransform = true;
                        envelopeClass = new EnvelopeClass();
                        envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                        textElementClass.Geometry = envelopeClass;
                        return(textElementClass);
                    }
                    textElementClass = new EmfPictureElementClass();
                }
                (textElementClass as IPictureElement).ImportPictureFromFile(ElementWizardHelp.m_PictureFileName);
                (textElementClass as IPictureElement).MaintainAspectRatio = true;
                num3 = 0;
                num4 = 0;
                (textElementClass as IPictureElement2).QueryIntrinsicSize(ref num3, ref num4);
                num3 = num3 * 0.0353;
                num4 = num4 * 0.0353;
                (textElementClass as IElementProperties2).AutoTransform = true;
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + num3, position.Y + num4);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.OLE:
            {
                int screenDisplay = (ipageLayout_0 as IActiveView).ScreenDisplay.hWnd;
                Common.ExtendClass.IOleFrame oleFrame = new OleFrame();
                if (!oleFrame.CreateOleClientItem((ipageLayout_0 as IActiveView).ScreenDisplay, screenDisplay))
                {
                    return(textElementClass);
                }
                textElementClass = oleFrame as IElement;
                envelopeClass    = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                textElementClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.ScaleBar:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    hollowScaleBarClass = new HollowScaleBarClass();
                }
                else
                {
                    hollowScaleBarClass = ElementWizardHelp.m_pStyle as IScaleBar;
                }
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.ScaleBar"
                };
                mapFrame = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                hollowScaleBarClass.Units = mapFrame.Map.DistanceUnits;
                textElementClass          = mapFrame.CreateSurroundFrame(uIDClass, hollowScaleBarClass) as IElement;
                envelopeClass             = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 4, position.Y + 8);
                envelope = new EnvelopeClass();
                hollowScaleBarClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.North:
            {
                if (ElementWizardHelp.m_pStyle == null)
                {
                    markerNorthArrowClass = new MarkerNorthArrowClass();
                }
                else
                {
                    markerNorthArrowClass = ElementWizardHelp.m_pStyle as INorthArrow;
                }
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 3, position.Y + 3);
                uIDClass = new UIDClass()
                {
                    Value = "esriCarto.MarkerNorthArrow"
                };
                mapFrame         = (ipageLayout_0 as IGraphicsContainer).FindFrame((ipageLayout_0 as IActiveView).FocusMap) as IMapFrame;
                textElementClass = mapFrame.CreateSurroundFrame(uIDClass, markerNorthArrowClass) as IElement;
                envelope         = new EnvelopeClass();
                markerNorthArrowClass.QueryBounds((ipageLayout_0 as IActiveView).ScreenDisplay, envelopeClass, envelope);
                envelopeClass.PutCoords(position.X, position.Y, position.X + envelope.Width, position.Y + envelope.Height);
                textElementClass.Geometry = envelopeClass;
                return(textElementClass);
            }

            case ElementType.GraphicElement:
            {
                return(textElementClass);
            }

            case ElementType.DataGraphicElement:
            {
                envelopeClass = new EnvelopeClass();
                envelopeClass.PutCoords(position.X, position.Y, position.X + 8, position.Y + 8);
                textElementClass = new DataGraphicsElement()
                {
                    Geometry = envelopeClass
                };
                return(textElementClass);
            }

            default:
            {
                return(textElementClass);
            }
            }
        }
        protected override void OnClick()
        {
            bool            bShowProgressor = false;
            IStepProgressor pStepProgressor = null;
            //Create a CancelTracker.
            ITrackCancel           pTrackCancel = null;
            IProgressDialogFactory pProgressorDialogFact;

            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            //first get the selected parcel features
            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);

            //check if there is a Manual Mode "modify" job active ===========
            ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;

            if (pCadPacMan.PacketOpen)
            {
                MessageBox.Show("The Delete linepoint command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
                                "Delete Selected LinePoints");
                return;
            }

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

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

            //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;
                }
            }

            IArray CFLinePointLayers = new ArrayClass();

            if (!(FabricUTILS.GetLinePointLayersFromFabric(pMap, pCadFabric, out CFLinePointLayers)))
            {
                return; //no fabric sublayers available for the targeted fabric
            }
            bool       bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
            IWorkspace pWS             = null;
            ITable     pLinePointTable = null;

            try
            {
                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    try
                    {
                        pEd.StartOperation();
                    }
                    catch
                    {
                        pEd.AbortOperation();//abort any open edit operations and try again
                        pEd.StartOperation();
                    }
                }

                IFeatureLayer pFL = (IFeatureLayer)CFLinePointLayers.get_Element(0);
                IDataset      pDS = (IDataset)pFL.FeatureClass;
                pWS = pDS.Workspace;

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

                //loop through each linepoint layer and
                //Get the selection of linepoints
                int iCnt = 0;
                int iTotalSelectionCount = 0;
                for (; iCnt < CFLinePointLayers.Count; iCnt++)
                {
                    pFL = (IFeatureLayer)CFLinePointLayers.get_Element(iCnt);
                    IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
                    ISelectionSet2    pSelSet  = (ISelectionSet2)pFeatSel.SelectionSet;
                    iTotalSelectionCount += pSelSet.Count;
                }

                if (iTotalSelectionCount == 0)
                {
                    MessageBox.Show("Please select some line points and try again.", "No Selection",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (bUseNonVersionedDelete)
                    {
                        pCadEd.CadastralFabricLayer = null;
                        CFLinePointLayers           = null;
                    }
                    return;
                }

                bShowProgressor = (iTotalSelectionCount > 10);

                if (bShowProgressor)
                {
                    pProgressorDialogFact       = new ProgressDialogFactoryClass();
                    pTrackCancel                = new CancelTrackerClass();
                    pStepProgressor             = pProgressorDialogFact.Create(pTrackCancel, ArcMap.Application.hWnd);
                    pProgressorDialog           = (IProgressDialog2)pStepProgressor;
                    pStepProgressor.MinRange    = 1;
                    pStepProgressor.MaxRange    = iTotalSelectionCount;
                    pStepProgressor.StepValue   = 1;
                    pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
                }

                //loop through each linepoint layer and
                //delete from its selection
                m_pQF = new QueryFilterClass();
                iCnt  = 0;
                for (; iCnt < CFLinePointLayers.Count; iCnt++)
                {
                    pFL = (IFeatureLayer)CFLinePointLayers.get_Element(iCnt);
                    IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
                    ISelectionSet2    pSelSet  = (ISelectionSet2)pFeatSel.SelectionSet;

                    ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
                    string     sPref      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                    string     sSuff      = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

                    if (bShowProgressor)
                    {
                        pProgressorDialog.ShowDialog();
                        pStepProgressor.Message = "Collecting line point data...";
                    }

                    //Add the OIDs of all the selected linepoints into a new feature IDSet
                    bool bCont = true;
                    m_pFIDSetLinePoints = new FIDSetClass();

                    ICursor pCursor = null;
                    pSelSet.Search(null, false, out pCursor);//code deletes all selected line points
                    IFeatureCursor pLinePointFeatCurs = (IFeatureCursor)pCursor;
                    IFeature       pLinePointFeat     = pLinePointFeatCurs.NextFeature();

                    while (pLinePointFeat != null)
                    {
                        //Check if the cancel button was pressed. If so, stop process
                        if (bShowProgressor)
                        {
                            bCont = pTrackCancel.Continue();
                            if (!bCont)
                            {
                                break;
                            }
                        }
                        bool bExists = false;
                        m_pFIDSetLinePoints.Find(pLinePointFeat.OID, out bExists);
                        if (!bExists)
                        {
                            m_pFIDSetLinePoints.Add(pLinePointFeat.OID);
                        }

                        Marshal.ReleaseComObject(pLinePointFeat); //garbage collection
                        pLinePointFeat = pLinePointFeatCurs.NextFeature();

                        if (bShowProgressor)
                        {
                            if (pStepProgressor.Position < pStepProgressor.MaxRange)
                            {
                                pStepProgressor.Step();
                            }
                        }
                    }
                    Marshal.ReleaseComObject(pCursor); //garbage collection

                    if (!bCont)
                    {
                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }

                    if (bUseNonVersionedDelete)
                    {
                        if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
                        {
                            if (bUseNonVersionedDelete)
                            {
                                pCadEd.CadastralFabricLayer = null;
                            }
                            return;
                        }
                    }

                    //delete all the line point records
                    if (bShowProgressor)
                    {
                        pStepProgressor.Message = "Deleting selected line points...";
                    }

                    bool bSuccess = true;
                    pLinePointTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLinePoints);

                    if (!bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsByFIDSet(pLinePointTable, m_pFIDSetLinePoints, pStepProgressor, pTrackCancel);
                    }
                    if (bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pLinePointTable,
                                                                     m_pFIDSetLinePoints, pStepProgressor, pTrackCancel);
                    }
                    if (!bSuccess)
                    {
                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }
                }

                if (bUseNonVersionedDelete)
                {
                    FabricUTILS.StopEditing(pWS);
                }

                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    pEd.StopOperation("Delete Line Points");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                RefreshMap(pActiveView, CFLinePointLayers);

                //update the TOC
                IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document);
                for (int i = 0; i < mxDocument.ContentsViewCount; i++)
                {
                    IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i);
                    pCV.Refresh(null);
                }

                if (pProgressorDialog != null)
                {
                    pProgressorDialog.HideDialog();
                }

                if (bUseNonVersionedDelete)
                {
                    pCadEd.CadastralFabricLayer = null;
                    CFLinePointLayers           = null;
                }

                if (pMouseCursor != null)
                {
                    pMouseCursor.SetCursor(0);
                }
            }
        }
Ejemplo n.º 35
0
        protected override void OnClick()
        {
            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            //first get the selected parcel features
            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);

            //check if there is a Manual Mode "modify" job active ===========
            ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;

            if (pCadPacMan.PacketOpen)
            {
                MessageBox.Show("The Delete Parcels command cannot be used when there is an open job.\r\nPlease finish or discard the open job, and try again.",
                                "Delete Selected Parcels");
                return;
            }

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

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

            //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;
                }
            }

            IArray CFParcelLayers = new ArrayClass();

            if (!(FabricUTILS.GetFabricSubLayersFromFabric(pMap, pCadFabric, out CFPointLayer, out CFLineLayer,
                                                           out CFParcelLayers, out CFControlLayer, out CFLinePointLayer)))
            {
                return; //no fabric sublayers available for the targeted fabric
            }

            bool                  bIsFileBasedGDB = false; bool bIsUnVersioned = false; bool bUseNonVersionedDelete = false;
            IWorkspace            pWS           = null;
            ICadastralFabricLayer pCFLayer      = null;
            ITable                pParcelsTable = null;
            ITable                pLinesTable   = null;
            ITable                pLinePtsTable = null;
            ITable                pPointsTable  = null;
            ITable                pControlTable = null;

            try
            {
                //Get the selection of parcels
                IFeatureLayer pFL = (IFeatureLayer)CFParcelLayers.get_Element(0);

                IDataset pDS = (IDataset)pFL.FeatureClass;
                pWS = pDS.Workspace;

                if (!FabricUTILS.SetupEditEnvironment(pWS, pCadFabric, pEd, out bIsFileBasedGDB,
                                                      out bIsUnVersioned, out bUseNonVersionedDelete))
                {
                    return;
                }
                if (bUseNonVersionedDelete)
                {
                    pCFLayer = new CadastralFabricLayerClass();
                    pCFLayer.CadastralFabric    = pCadFabric;
                    pCadEd.CadastralFabricLayer = pCFLayer;//NOTE: Need to set this back to NULL when done.
                }

                ICadastralSelection pCadaSel = (ICadastralSelection)pCadEd;

                IEnumGSParcels pEnumGSParcels = pCadaSel.SelectedParcels;// need to get the parcels before trying to get the parcel count: BUG workaround

                IFeatureSelection pFeatSel = (IFeatureSelection)pFL;
                ISelectionSet2    pSelSet  = (ISelectionSet2)pFeatSel.SelectionSet;

                bMoreThan995UnjoinedParcels = (pSelSet.Count > pCadaSel.SelectedParcelCount); //used for bug workaround

                if (pCadaSel.SelectedParcelCount == 0 && pSelSet.Count == 0)
                {
                    MessageBox.Show("Please select some fabric parcels and try again.", "No Selection",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    pMouseCursor.SetCursor(0);
                    if (bUseNonVersionedDelete)
                    {
                        pCadEd.CadastralFabricLayer = null;
                        CFParcelLayers   = null;
                        CFPointLayer     = null;
                        CFLineLayer      = null;
                        CFControlLayer   = null;
                        CFLinePointLayer = null;
                    }
                    return;
                }

                if (bMoreThan995UnjoinedParcels)
                {
                    m_bShowProgressor = (pSelSet.Count > 10);
                }
                else
                {
                    m_bShowProgressor = (pCadaSel.SelectedParcelCount > 10);
                }

                if (m_bShowProgressor)
                {
                    m_pProgressorDialogFact    = new ProgressDialogFactoryClass();
                    m_pTrackCancel             = new CancelTrackerClass();
                    m_pStepProgressor          = m_pProgressorDialogFact.Create(m_pTrackCancel, ArcMap.Application.hWnd);
                    pProgressorDialog          = (IProgressDialog2)m_pStepProgressor;
                    m_pStepProgressor.MinRange = 1;
                    if (bMoreThan995UnjoinedParcels)
                    {
                        m_pStepProgressor.MaxRange = pSelSet.Count * 18; //(estimate 7 lines per parcel, 4 pts per parcel, 3 line points per parcel, and there is a second loop on parcel list)
                    }
                    else
                    {
                        m_pStepProgressor.MaxRange = pCadaSel.SelectedParcelCount * 18; //(estimate 7 lines per parcel, 4 pts per parcel, 3 line points per parcel, and there is a second loop on parcel list)
                    }
                    m_pStepProgressor.StepValue = 1;
                    pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
                }

                m_pQF = new QueryFilterClass();
                string sPref; string sSuff;

                ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
                sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

                //====== need to do this for all the parcel sublayers in the map that are part of the target fabric

                if (m_bShowProgressor)
                {
                    pProgressorDialog.ShowDialog();
                    m_pStepProgressor.Message = "Collecting parcel data...";
                }

                //Add the OIDs of all the selected parcels into a new feature IDSet
                string[] sOIDList   = { "(" };
                int      tokenLimit = 995;
                bool     bCont      = true;
                int      j          = 0;
                int      iCounter   = 0;

                m_pFIDSetParcels = new FIDSetClass();

                //===================== start bug workaraound for 10.0 client ===================
                if (bMoreThan995UnjoinedParcels)
                {
                    ICursor pCursor = null;
                    pSelSet.Search(null, false, out pCursor);//code deletes all selected parcels
                    IFeatureCursor pParcelFeatCurs = (IFeatureCursor)pCursor;
                    IFeature       pParcFeat       = pParcelFeatCurs.NextFeature();

                    while (pParcFeat != null)
                    {
                        //Check if the cancel button was pressed. If so, stop process
                        if (m_bShowProgressor)
                        {
                            bCont = m_pTrackCancel.Continue();
                            if (!bCont)
                            {
                                break;
                            }
                        }
                        bool bExists = false;
                        m_pFIDSetParcels.Find(pParcFeat.OID, out bExists);
                        if (!bExists)
                        {
                            m_pFIDSetParcels.Add(pParcFeat.OID);

                            if (iCounter <= tokenLimit)
                            {
                                sOIDList[j] = sOIDList[j] + Convert.ToString(pParcFeat.OID) + ",";
                                iCounter++;
                            }
                            else
                            {//maximum tokens reached
                                sOIDList[j] = sOIDList[j].Trim();
                                iCounter    = 0;
                                //set up the next OIDList
                                j++;
                                FabricUTILS.RedimPreserveString(ref sOIDList, 1);
                                sOIDList[j] = "(";
                                sOIDList[j] = sOIDList[j] + Convert.ToString(pParcFeat.OID) + ",";
                            }
                        }
                        Marshal.ReleaseComObject(pParcFeat); //garbage collection
                        pParcFeat = pParcelFeatCurs.NextFeature();

                        if (m_bShowProgressor)
                        {
                            if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange)
                            {
                                m_pStepProgressor.Step();
                            }
                        }
                    }
                    Marshal.ReleaseComObject(pCursor); //garbage collection
                    //===================== end bug workaraound for 10.0 client ===================
                }
                else //===the following code path is preferred======
                {
                    pEnumGSParcels.Reset();
                    IGSParcel pGSParcel = pEnumGSParcels.Next();
                    while (pGSParcel != null)
                    {
                        //Check if the cancel button was pressed. If so, stop process
                        if (m_bShowProgressor)
                        {
                            bCont = m_pTrackCancel.Continue();
                            if (!bCont)
                            {
                                break;
                            }
                        }
                        m_pFIDSetParcels.Add(pGSParcel.DatabaseId);
                        if (iCounter <= tokenLimit)
                        {
                            sOIDList[j] = sOIDList[j] + Convert.ToString(pGSParcel.DatabaseId) + ",";
                            iCounter++;
                        }
                        else
                        {//maximum tokens reached
                            sOIDList[j] = sOIDList[j].Trim();
                            iCounter    = 0;
                            //set up the next OIDList
                            j++;
                            FabricUTILS.RedimPreserveString(ref sOIDList, 1);
                            sOIDList[j] = "(";
                            sOIDList[j] = sOIDList[j] + Convert.ToString(pGSParcel.DatabaseId) + ",";
                        }
                        Marshal.ReleaseComObject(pGSParcel); //garbage collection
                        pGSParcel = pEnumGSParcels.Next();
                        if (m_bShowProgressor)
                        {
                            if (m_pStepProgressor.Position < m_pStepProgressor.MaxRange)
                            {
                                m_pStepProgressor.Step();
                            }
                        }
                    }
                    Marshal.ReleaseComObject(pEnumGSParcels); //garbage collection
                }

                if (!bCont)
                {
                    AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                    return;
                }

                string sTime = "";
                if (!bIsUnVersioned && !bIsFileBasedGDB)
                {
                    //see if parcel locks can be obtained on the selected parcels. First create a job.
                    DateTime localNow = DateTime.Now;
                    sTime = Convert.ToString(localNow);
                    ICadastralJob pJob = new CadastralJobClass();
                    pJob.Name        = sTime;
                    pJob.Owner       = System.Windows.Forms.SystemInformation.UserName;
                    pJob.Description = "Delete selected parcels";
                    try
                    {
                        Int32 jobId = pCadFabric.CreateJob(pJob);
                    }
                    catch (COMException ex)
                    {
                        if (ex.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_ALREADY_EXISTS)
                        {
                            MessageBox.Show("Job named: '" + pJob.Name + "', already exists");
                        }
                        else
                        {
                            MessageBox.Show(ex.Message);
                        }
                        return;
                    }
                }

                //if we're in an enterprise then test for edit locks
                ICadastralFabricLocks pFabLocks = (ICadastralFabricLocks)pCadFabric;
                if (!bIsUnVersioned && !bIsFileBasedGDB)
                {
                    pFabLocks.LockingJob = sTime;
                    ILongArray pLocksInConflict    = null;
                    ILongArray pSoftLcksInConflict = null;

                    ILongArray pParcelsToLock = new LongArrayClass();

                    FabricUTILS.FIDsetToLongArray(m_pFIDSetParcels, ref pParcelsToLock, m_pStepProgressor);
                    if (m_bShowProgressor && !bIsFileBasedGDB)
                    {
                        m_pStepProgressor.Message = "Testing for edit locks on parcels...";
                    }

                    try
                    {
                        pFabLocks.AcquireLocks(pParcelsToLock, true, ref pLocksInConflict, ref pSoftLcksInConflict);
                    }
                    catch (COMException pCOMEx)
                    {
                        if (pCOMEx.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_LOCK_ALREADY_EXISTS ||
                            pCOMEx.ErrorCode == (int)fdoError.FDO_E_CADASTRAL_FABRIC_JOB_CURRENTLY_EDITED)
                        {
                            MessageBox.Show("Edit Locks could not be acquired on all selected parcels.");
                            // since the operation is being aborted, release any locks that were acquired
                            pFabLocks.UndoLastAcquiredLocks();
                        }
                        else
                        {
                            MessageBox.Show(pCOMEx.Message + Environment.NewLine + Convert.ToString(pCOMEx.ErrorCode));
                        }

                        return;
                    }
                }

                //Build an IDSet of lines for the parcel to be deleted, and build an IDSet of the points for those lines
                m_pFIDSetLines  = new FIDSetClass();
                m_pFIDSetPoints = new FIDSetClass();
                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    try
                    {
                        pEd.StartOperation();
                    }
                    catch
                    {
                        pEd.AbortOperation();//abort any open edit operations and try again
                        pEd.StartOperation();
                    }
                }
                if (bUseNonVersionedDelete)
                {
                    if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
                    {
                        return;
                    }
                }

                //first delete all the parcel records
                if (m_bShowProgressor)
                {
                    m_pStepProgressor.Message = "Deleting parcels...";
                }

                bool bSuccess = true;
                pParcelsTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
                pLinesTable   = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLines);
                pLinePtsTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLinePoints);
                pPointsTable  = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
                pControlTable = (ITable)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);

                if (!bUseNonVersionedDelete)
                {
                    bSuccess = FabricUTILS.DeleteRowsByFIDSet(pParcelsTable, m_pFIDSetParcels, m_pStepProgressor, m_pTrackCancel);
                }
                if (bUseNonVersionedDelete)
                {
                    bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pParcelsTable,
                                                                 m_pFIDSetParcels, m_pStepProgressor, m_pTrackCancel);
                }

                if (!bSuccess)
                {
                    if (!bIsUnVersioned)
                    {
                        pFabLocks.UndoLastAcquiredLocks();
                    }

                    AbortEdits(bUseNonVersionedDelete, pEd, pWS);

                    if (!bIsUnVersioned)
                    {
                        //check version and if the Cancel button was not clicked and we're higher than
                        //version 10.0, then re-try the delete with the core delete command
                        string sVersion = Application.ProductVersion;
                        int    iErrCode = FabricUTILS.LastErrorCode;
                        if (!sVersion.StartsWith("10.0") && iErrCode == -2147217400)
                        {
                            FabricUTILS.ExecuteCommand("{B0A62C1C-7FAE-457A-AB25-A966B7254EF6}");
                        }
                    }
                    return;
                }

                //next need to use an in clause for lines, so ...
                string[] sPointOIDList = { "" };
                int      iCnt          = 0;
                int      iTokenCnt     = 0;
                int      iStepCnt      = 1;
                //...for each item in the sOIDList array
                foreach (string inClause in sOIDList)
                {
                    ICursor pLineCurs = FabricUTILS.GetCursorFromCommaSeparatedOIDList(pLinesTable, inClause, "PARCELID");
                    IRow    pRow      = pLineCurs.NextRow();
                    Int32   iFromPt   = pLinesTable.Fields.FindField("FROMPOINTID");
                    Int32   iToPt     = pLinesTable.Fields.FindField("TOPOINTID");

                    while (pRow != null)
                    {
                        if (iTokenCnt >= tokenLimit)
                        {
                            FabricUTILS.RedimPreserveString(ref sPointOIDList, 1);
                            iTokenCnt = 0;
                            iCnt++;
                        }

                        m_pFIDSetLines.Add(pRow.OID);
                        Int32 i = (Int32)pRow.get_Value(iFromPt);
                        if (i > -1)
                        {
                            bool bExists = false;
                            m_pFIDSetPoints.Find(i, out bExists);
                            if (!bExists)
                            {
                                m_pFIDSetPoints.Add(i);
                                sPointOIDList[iCnt] = sPointOIDList[iCnt] + Convert.ToString(i) + ",";
                                iTokenCnt++;
                            }
                        }
                        i = (Int32)pRow.get_Value(iToPt);
                        if (i > -1)
                        {
                            bool bExists = false;
                            m_pFIDSetPoints.Find(i, out bExists);
                            if (!bExists)
                            {
                                m_pFIDSetPoints.Add(i);
                                sPointOIDList[iCnt] = sPointOIDList[iCnt] + Convert.ToString(i) + ",";
                                iTokenCnt++;
                            }
                        }
                        Marshal.ReleaseComObject(pRow); //garbage collection
                        pRow = pLineCurs.NextRow();
                    }
                    Marshal.ReleaseComObject(pLineCurs); //garbage collection

                    //delete line records based on the selected parcels
                    string sMessage = "Deleting lines...";
                    int    iSetCnt  = sOIDList.GetLength(0);
                    if (iSetCnt > 1)
                    {
                        sMessage += "Step " + Convert.ToString(iStepCnt) + " of " + Convert.ToString(iSetCnt);
                    }
                    if (m_bShowProgressor)
                    {
                        m_pStepProgressor.Message = sMessage;
                    }
                    if (!bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsByFIDSet(pLinesTable, m_pFIDSetLines, m_pStepProgressor, m_pTrackCancel);
                    }
                    if (bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pLinesTable, m_pFIDSetLines, m_pStepProgressor, m_pTrackCancel);
                    }
                    if (!bSuccess)
                    {
                        if (!bIsUnVersioned)
                        {
                            pFabLocks.UndoLastAcquiredLocks();
                        }

                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }

                    //delete the line points for the deleted parcels
                    //build the list of the line points that need to be deleted.
                    //IFeatureClass pFeatCLLinePoints = CFLinePointLayer.FeatureClass;
                    string NewInClause = "";
                    //remove trailing comma
                    if ((inClause.Substring(inClause.Length - 1, 1)) == ",")
                    {
                        NewInClause = inClause.Substring(0, inClause.Length - 1);
                    }

                    //m_pQF.WhereClause = (sPref + "parcelid" + sSuff).Trim() + " IN " + NewInClause + ")";
                    m_pQF.WhereClause = "PARCELID IN " + NewInClause + ")";
                    ICursor pLinePointCurs = pLinePtsTable.Search(m_pQF, false);
                    IRow    pLinePointFeat = pLinePointCurs.NextRow();

                    //Build an IDSet of linepoints for parcels to be deleted
                    IFIDSet pFIDSetLinePoints = new FIDSetClass();

                    while (pLinePointFeat != null)
                    {
                        pFIDSetLinePoints.Add(pLinePointFeat.OID);
                        Marshal.ReleaseComObject(pLinePointFeat); //garbage collection
                        pLinePointFeat = pLinePointCurs.NextRow();
                    }

                    //===========deletes linepoints associated with parcels
                    iSetCnt  = sOIDList.GetLength(0);
                    sMessage = "Deleting line-points...";
                    if (iSetCnt > 1)
                    {
                        sMessage += "Step " + Convert.ToString(iStepCnt) + " of " + Convert.ToString(iSetCnt);
                    }
                    if (m_bShowProgressor)
                    {
                        m_pStepProgressor.Message = sMessage;
                    }

                    if (!bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsByFIDSet(pLinePtsTable,
                                                                  pFIDSetLinePoints, m_pStepProgressor, m_pTrackCancel);
                    }
                    if (bUseNonVersionedDelete)
                    {
                        bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pLinePtsTable,
                                                                     pFIDSetLinePoints, m_pStepProgressor, m_pTrackCancel);
                    }
                    if (!bSuccess)
                    {
                        if (!bIsUnVersioned)
                        {
                            pFabLocks.UndoLastAcquiredLocks();
                        }

                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);

                        if (pLinePointCurs != null)
                        {
                            Marshal.ReleaseComObject(pLinePointCurs); //garbage
                        }
                        return;
                    }

                    ///////==============================================

                    Marshal.ReleaseComObject(pLinePointCurs); //garbage
                    iStepCnt++;
                }

                //now need to get points that should not be deleted, because they are used by lines that are not deleted.
                //first search for the remaining lines. Any that have from/to points that are in the point fidset are the points
                //that should stay
                IFIDSet pFIDSetNullGeomLinePtFrom = new FIDSetClass();
                IFIDSet pFIDSetNullGeomLinePtTo   = new FIDSetClass();
                if (m_bShowProgressor)
                {
                    m_pStepProgressor.Message = "Updating point delete list...";
                }

                for (int z = 0; z <= iCnt; z++)
                {
                    //remove trailing comma
                    if ((sPointOIDList[z].Trim() == ""))
                    {
                        break;
                    }
                    if ((sPointOIDList[z].Substring(sPointOIDList[z].Length - 1, 1)) == ",")
                    {
                        sPointOIDList[z] = sPointOIDList[z].Substring(0, sPointOIDList[z].Length - 1);
                    }
                }

                //string TheWhereClause = "(" + (sPref + "frompointid" + sSuff).Trim() + " IN (";

                //UpdateDeletePointList(ref sPointOIDList, ref m_pFIDSetPoints, "frompointid",
                //  TheWhereClause, pLinesTable, out pFIDSetNullGeomLinePtFrom);

                //TheWhereClause = "(" + (sPref + "topointid" + sSuff).Trim() + " IN (";

                //UpdateDeletePointList(ref sPointOIDList, ref m_pFIDSetPoints, "topointid",
                //  TheWhereClause, pLinesTable, out pFIDSetNullGeomLinePtTo);

                string TheWhereClause = "(FROMPOINTID IN (";

                UpdateDeletePointList(ref sPointOIDList, ref m_pFIDSetPoints, "FROMPOINTID",
                                      TheWhereClause, pLinesTable, out pFIDSetNullGeomLinePtFrom);

                TheWhereClause = "(TOPOINTID IN (";

                UpdateDeletePointList(ref sPointOIDList, ref m_pFIDSetPoints, "TOPOINTID",
                                      TheWhereClause, pLinesTable, out pFIDSetNullGeomLinePtTo);

                if (m_bShowProgressor)
                {
                    m_pStepProgressor.Message = "Deleting points...";
                }

                if (!bUseNonVersionedDelete)
                {
                    bSuccess = FabricUTILS.DeleteRowsByFIDSet(pPointsTable, m_pFIDSetPoints,
                                                              m_pStepProgressor, m_pTrackCancel);
                }
                if (bUseNonVersionedDelete)
                {
                    bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pPointsTable, m_pFIDSetPoints,
                                                                 m_pStepProgressor, m_pTrackCancel);
                }
                if (!bSuccess)
                {
                    if (!bIsUnVersioned)
                    {
                        pFabLocks.UndoLastAcquiredLocks();
                    }

                    AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                    return;
                }

                //====Phase 2 of line-point delete. Remove the Line-points that no longer have underlying points.
                if (m_bShowProgressor)
                {
                    m_pStepProgressor.Message = "Deleting line-points...";
                }
                for (int z = 0; z <= iCnt; z++)
                {
                    if ((sPointOIDList[z].Trim() == ""))
                    {
                        continue;
                    }
                    //remove line points where underlying points were deleted
                    bSuccess = FabricUTILS.DeleteByQuery(pWS, pLinePtsTable, pLinePtsTable.Fields.get_Field(pLinePtsTable.FindField("LinePointID")),
                                                         sPointOIDList, !bIsUnVersioned, m_pStepProgressor, m_pTrackCancel);
                    if (!bSuccess)
                    {
                        if (!bIsUnVersioned)
                        {
                            pFabLocks.UndoLastAcquiredLocks();
                        }

                        AbortEdits(bUseNonVersionedDelete, pEd, pWS);
                        return;
                    }
                }

                //=====

                //Empty geometry on points that are floating points on unjoined parcels
                m_pEmptyGeoms = new FIDSetClass();
                FabricUTILS.IntersectFIDSetCommonIDs(pFIDSetNullGeomLinePtTo, pFIDSetNullGeomLinePtFrom, out m_pEmptyGeoms);

                ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
                pSchemaEd.ReleaseReadOnlyFields(pPointsTable, esriCadastralFabricTable.esriCFTPoints); //release safety-catch
                if (!bUseNonVersionedDelete)
                {
                    FabricUTILS.EmptyGeometries((IFeatureClass)pPointsTable, m_pEmptyGeoms);
                }
                else
                {
                    FabricUTILS.EmptyGeometriesUnversioned(pWS, CFPointLayer.FeatureClass, m_pEmptyGeoms);
                }

                pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);//set safety back on

                if (m_bShowProgressor)
                {
                    m_pStepProgressor.Message = "Resetting control point associations...";
                }

                for (int z = 0; z <= iCnt; z++)
                {
                    if ((sPointOIDList[z].Trim() == ""))
                    {
                        break;
                    }
                    //cleanup associated control points, and associations where underlying points were deleted
                    //m_pQF.WhereClause = (sPref + "pointid" + sSuff).Trim() + " IN (" + sPointOIDList[z] + ")";
                    m_pQF.WhereClause = "POINTID IN (" + sPointOIDList[z] + ")";
                    pSchemaEd.ReleaseReadOnlyFields(pControlTable, esriCadastralFabricTable.esriCFTControl); //release safety-catch
                    if (!FabricUTILS.ResetControlAssociations(pControlTable, m_pQF, bUseNonVersionedDelete))
                    {
                        pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);//set safety back on
                    }
                }
                pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);//set safety back on

                if (bUseNonVersionedDelete)
                {
                    FabricUTILS.StopEditing(pWS);
                }

                if (pEd.EditState == esriEditState.esriStateEditing)
                {
                    pEd.StopOperation("Delete parcels");
                }

                //clear selection, to make sure the parcel explorer is updated and refreshed properly
                if (pFeatSel != null && bMoreThan995UnjoinedParcels)
                {
                    pFeatSel.Clear();
                }
            }

            catch (Exception ex)
            {
                if (bUseNonVersionedDelete)
                {
                    FabricUTILS.AbortEditing(pWS);
                }

                if (pEd != null)
                {
                    if (pEd.EditState == esriEditState.esriStateEditing)
                    {
                        pEd.AbortOperation();
                    }
                }

                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                RefreshMap(pActiveView, CFParcelLayers, CFPointLayer, CFLineLayer, CFControlLayer, CFLinePointLayer);
                //update the TOC
                IMxDocument mxDocument = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(ArcMap.Application.Document);
                for (int i = 0; i < mxDocument.ContentsViewCount; i++)
                {
                    IContentsView pCV = (IContentsView)mxDocument.get_ContentsView(i);
                    pCV.Refresh(null);
                }

                if (pMouseCursor != null)
                {
                    pMouseCursor.SetCursor(0);
                }

                m_pStepProgressor = null;
                if (!(pProgressorDialog == null))
                {
                    pProgressorDialog.HideDialog();
                }
                pProgressorDialog = null;

                if (bUseNonVersionedDelete)
                {
                    pCadEd.CadastralFabricLayer = null;
                    CFParcelLayers   = null;
                    CFPointLayer     = null;
                    CFLineLayer      = null;
                    CFControlLayer   = null;
                    CFLinePointLayer = null;
                }
            }
        }