Example #1
0
        public override void Click()
        {
            IMapControl     mapControl = (_hook as IHookOfAgileMap).MapControl;
            IOperationStack oprStack   = mapControl.OperationStack;

            oprStack.Redo();
        }
Example #2
0
        public ClsEditorMain(IToolbarControl pToolbarControl, AxMapControl pMapControl, object _frmMain)
        {
            m_EditType        = "CallOut";
            frmMain           = _frmMain;
            ToolState         = false;
            mToolbarControl   = pToolbarControl;
            m_pOperationStack = pToolbarControl.OperationStack;

            PToolbar       = pToolbarControl;
            m_pMapControl  = pMapControl;
            DefaultVersion = null;
            SnapEnv        = null;
            BEndInkText    = false;

            //初始化有个默认的捕捉类,避免程序中某些用到的地方出现错误
            SnapPoint = new SnapPointClass();

            Type type = frmMain.GetType();

            MethodInfo_RefreshCommandArgs         = type.GetMethod("RefreshCommandArgs");
            MethodInfo_GetCommandTipEventArgs     = type.GetMethod("GetCommandTipEventArgs");
            MethodInfo_SetFocusEventArgs          = type.GetMethod("SetFocusEventArgs");
            MethodInfo_PopupMenuEventArgs         = type.GetMethod("PopupMenuEventArgs");
            MethodInfo_GetGeometryEventArgs       = type.GetMethod("GetGeometry");
            MethodInfo_SetBuddyTB                 = type.GetMethod("SetBuddyTool");
            MethodInfo_CustomSetToolState         = type.GetMethod("CustomSetToolState");
            MethodInfo_GetCurrentVersionID        = type.GetMethod("GetCurrentVersionID");
            MethodInfo_GetToolbar                 = type.GetMethod("GetToolbar");
            MethodInfo_CartoCommondTip            = type.GetMethod("CartoCommondTip");
            MethodInfo_PopupMenuEventArgsForCarto = type.GetMethod("PopupMenuEventArgsForCarto");
            MethodInfo_GetBufferSetForm           = type.GetMethod("GetBufferSetForm");
        }
Example #3
0
        public void BuddyToolBarControl(IToolbarControl pControl)
        {
            this._oStack            = new ControlsOperationStackClass();
            pControl.OperationStack = this._oStack;
            IExtension extension          = this._editor as IExtension;
            object     initializationData = pControl.Object;

            extension.Startup(ref initializationData);
        }
Example #4
0
 public CalcForm(IOperationStack stack, IOperationFactory factory)
 {
     this.stack = stack;
     InitializeComponent();
     txtInput.Focus();
     foreach (var symbol in factory.AvailableOperations)
     {
         listViewSymbols.Items.Add(new ListViewItem(new[] { symbol.Symbol, symbol.Description }));
     }
 }
        private void EditorForm_Load(object sender, EventArgs e)
        {
            //*********  Important *************
            //Obtain a reference to the MainForm using the EditHelper class
            m_mainForm = EditHelper.TheMainForm;
            m_mapControl = m_mainForm.MapControl;

            //buddy the toolbars with the MapControl
            axBlankToolBar.SetBuddyControl(m_mapControl);
            axModifyToolbar.SetBuddyControl(m_mapControl);
            axReshapeToolbar.SetBuddyControl(m_mapControl);
            axUndoRedoToolbar.SetBuddyControl(m_mapControl);
            axCreateToolbar.SetBuddyControl(m_mapControl);

            //Create and share command pool
            m_pool = new CommandPoolClass();
            axCreateToolbar.CommandPool = m_pool;
            axBlankToolBar.CommandPool = m_pool;
            axModifyToolbar.CommandPool = m_pool;
            axReshapeToolbar.CommandPool = m_pool;
            axUndoRedoToolbar.CommandPool = m_pool;

            //Create and share operation stack
            m_operationStack = new ControlsOperationStackClass();
            axModifyToolbar.OperationStack = m_operationStack;
            axReshapeToolbar.OperationStack = m_operationStack;
            axUndoRedoToolbar.OperationStack = m_operationStack;
            axCreateToolbar.OperationStack = m_operationStack;

            //load items for the axModifyToolbar
            axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axReshapeToolbar
            axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axCreateToolbar
            axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //set up the EngineEditor
            m_engineEditor = new EngineEditorClass();
            m_engineEditor.EnableUndoRedo(true);
            ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000;
            object tbr = (object)axCreateToolbar.Object;
            IExtension engineEditorExt = m_engineEditor as IExtension;
            engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly

            //Listen to OnSketchModified engine editor event
            ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified);
            //listen to MainForm events in case application is closed while editing
            EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing);

            #region Form Management
            m_commands = new ArrayList();
            m_commands.Add(cmdModify);
            m_commands.Add(cmdReshape);
            m_commands.Add(cmdCreate);

            DisableButtons();
            txtInfo.Text = "";
            this.Size = new Size(242, 208);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetErrorLabel("");
            EditHelper.IsEditorFormOpen = true;
            #endregion
        }
Example #6
0
        // check a numberic field for decimals
        private void btnDecimalsCheck_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboCheckDecimals.SelectedIndex == -1)
                {
                    MessageBox.Show("You must select a field to check.", "Select Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // show the cursor as busy
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                // query for layer's specified field looking for decimals
                IQueryFilter arcQFilter = new QueryFilter();
                arcQFilter.WhereClause = ""; // strActiveComboBox + " not like '%.0000%'";

                ITable   arcTable   = (ITable)clsGlobals.arcFeatLayer;
                IDataset arcDataset = (IDataset)clsGlobals.arcFeatLayer;

                if (arcDataset.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriLocalDatabaseWorkspace)
                {
                    // fgdb
                    MessageBox.Show("This function has not been coded to work on a file geodatabase... yet.  Talk to Greg Bunce.", "Not on FGDB", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else if (arcDataset.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    //sde
                    arcQFilter.WhereClause = cboCheckDecimals.Text.ToString() + " not like '%.0000%'";
                }
                else
                {
                    // shapefile
                    MessageBox.Show("This function has not been coded to work on a shapefile... yet.  Talk to Greg Bunce.", "Not on Shapefile", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                // select the records that have decimals
                ISelectionSet arcSelSet = arcTable.Select(arcQFilter, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, arcDataset.Workspace);

                ISelectFeaturesOperation arcSeleFeatOperation;
                arcSeleFeatOperation              = new SelectFeaturesOperationClass();
                arcSeleFeatOperation.ActiveView   = clsGlobals.pActiveView;
                arcSeleFeatOperation.Layer        = clsGlobals.arcFeatLayer;
                arcSeleFeatOperation.SelectionSet = arcSelSet;

                //perform the operation
                clsGlobals.pMxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                IOperationStack arcOperationStack = clsGlobals.pMxDocument.OperationStack;
                arcOperationStack.Do((IOperation)arcSeleFeatOperation);

                clsGlobals.pMxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "Push Utrans Roads to SGID!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #7
0
        private void EditorForm_Load(object sender, EventArgs e)
        {
            //*********  Important *************
            //Obtain a reference to the MainForm using the EditHelper class
            m_mainForm   = EditHelper.TheMainForm;
            m_mapControl = m_mainForm.MapControl;

            //buddy the toolbars with the MapControl
            axBlankToolBar.SetBuddyControl(m_mapControl);
            axModifyToolbar.SetBuddyControl(m_mapControl);
            axReshapeToolbar.SetBuddyControl(m_mapControl);
            axUndoRedoToolbar.SetBuddyControl(m_mapControl);
            axCreateToolbar.SetBuddyControl(m_mapControl);

            //Create and share command pool
            m_pool = new CommandPoolClass();
            axCreateToolbar.CommandPool   = m_pool;
            axBlankToolBar.CommandPool    = m_pool;
            axModifyToolbar.CommandPool   = m_pool;
            axReshapeToolbar.CommandPool  = m_pool;
            axUndoRedoToolbar.CommandPool = m_pool;

            //Create and share operation stack
            m_operationStack = new ControlsOperationStackClass();
            axModifyToolbar.OperationStack   = m_operationStack;
            axReshapeToolbar.OperationStack  = m_operationStack;
            axUndoRedoToolbar.OperationStack = m_operationStack;
            axCreateToolbar.OperationStack   = m_operationStack;

            //load items for the axModifyToolbar
            axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axReshapeToolbar
            axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //load items for the axCreateToolbar
            axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly);

            //set up the EngineEditor
            m_engineEditor = new EngineEditorClass();
            m_engineEditor.EnableUndoRedo(true);
            ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000;
            object     tbr             = (object)axCreateToolbar.Object;
            IExtension engineEditorExt = m_engineEditor as IExtension;

            engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly

            //Listen to OnSketchModified engine editor event
            ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified);
            //listen to MainForm events in case application is closed while editing
            EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing);

            #region Form Management
            m_commands = new ArrayList();
            m_commands.Add(cmdModify);
            m_commands.Add(cmdReshape);
            m_commands.Add(cmdCreate);

            DisableButtons();
            txtInfo.Text         = "";
            this.Size            = new Size(242, 208);
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetErrorLabel("");
            EditHelper.IsEditorFormOpen = true;
            #endregion
        }
        private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass,
                                            string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS)
        {
            if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr"))
            {
                return;
            }

            // Create a new GxLayer
            IGxLayer gxLayer = new GxLayerClass();
            IGxFile  gxFile  = (IGxFile)gxLayer;

            // Set the path for where the layerfile is located on disk
            gxFile.Path = layerPathFile;

            // Test if we have a valid layer and add it to the map
            if (!(gxLayer.Layer == null))
            {
                if (!(gxLayer.Layer is ICompositeLayer))
                {
                    return;
                }
                ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer;
                for (int i = 0; i < pCompLyr.Count; i++)
                {
                    ILayer pLyr = pCompLyr.get_Layer(i);
                    //
                    if (pLyr is IFeatureLayer)
                    {
                        IFeatureLayer pFlyr = (IFeatureLayer)pLyr;
                        //now update the definition query
                        IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr;
                        string sLyrName = pFlyr.Name;
                        bool   bExc     = false;
                        if (sLyrName.Contains("Minus"))
                        {
                            pFlyr.FeatureClass = SourceLineFeatureClass;
                            bExc = false;

                            //ILayerFields pLayerFields = pFlyr as ILayerFields;
                            //First turn off all layers
                            //for (int kk = 0; kk < pLayerFields.FieldCount; kk++)
                            //{
                            //  IFieldInfo pFieldInfo = pLayerFields.get_FieldInfo(kk);
                            //  pFieldInfo.Visible = false;
                            //}

                            SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);
                            if (bExc || bFabricIsInGCS)
                            {
                                int jj = pFlyr.FeatureClass.FindField("ComputedMinusObserved");
                                if (jj > -1)
                                {
                                    string sVal     = (0.1 / metersPerUnit).ToString("0.00");
                                    string sCminusO = pFlyr.FeatureClass.Fields.get_Field(jj).Name;
                                    pFeatLyrDef.DefinitionExpression = sCminusO + " > " + sVal + " AND " + sCminusO + " < " + sVal;

                                    //IFieldInfo pFieldInfo = pLayerFields.get_Field(jj) as IFieldInfo;
                                    //pFieldInfo.Visible = true;
                                }
                                continue;
                            }
                            string s      = pFeatLyrDef.DefinitionExpression;
                            int    iField = SourceLineFeatureClass.FindField("ArcLength");
                            if (iField > -1)
                            {
                                //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo;
                                //pFieldInfo.Visible = true;

                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2);
                                pFeatLyrDef.DefinitionExpression = s.Replace("ArcLength", s2);
                            }

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourceLineFeatureClass.FindField("Distance");
                            if (iField > -1)
                            {
                                //IFieldInfo pFieldInfo = pLayerFields.get_Field(iField) as IFieldInfo;
                                //pFieldInfo.Visible = true;

                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2);
                                pFeatLyrDef.DefinitionExpression = s.Replace("Distance", s2);
                            }

                            s = pFeatLyrDef.DefinitionExpression;
                            pFeatLyrDef.DefinitionExpression = s.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name);
                        }
                        else if (sLyrName.Contains("Parcel"))
                        { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present.
                          //Can test if the release is 10.1 and knock out the def query, or else exclude the layers.

                            string s      = pFeatLyrDef.DefinitionExpression;
                            int    iField = SourcePolygonFeatureClass.FindField("MiscloseDistance");
                            string s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2);
                            pFeatLyrDef.DefinitionExpression = s.Replace("MiscloseDistance", s2);

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE");
                            s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2);
                            pFeatLyrDef.DefinitionExpression = s.Replace("ShapeStdErrorE", s2);

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN");
                            s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2);
                            pFeatLyrDef.DefinitionExpression = s.Replace("ShapeStdErrorN", s2);

                            pFlyr.FeatureClass = SourcePolygonFeatureClass;
                            SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);

                            if (s.ToLower().Contains("power") && bIsBefore1022)
                            {//remove the def query CR278039
                                pFeatLyrDef.DefinitionExpression = "";
                                continue;
                            }
                        }
                    }
                }
                gxLayer.Layer.Name = "QA Symbology";

                IMxDocument         pMXDoc    = ArcMap.Document;
                IOperationStack     pOpSt     = pMXDoc.OperationStack;
                IAddLayersOperation pAddLyrOp = new AddLayersOperationClass();
                pAddLyrOp.SetDestinationInfo(0, map, null);
                pAddLyrOp.Name = "Add Fabric QA Layer";
                pAddLyrOp.AddLayer(gxLayer.Layer);
                IOperation pOp = (IOperation)pAddLyrOp;
                pOpSt.Do(pOp);
            }
        }
Example #9
0
 public ConsoleView(IOperationStack operationStack)
 {
     this.operationStack = operationStack;
 }
        public static void InitEditEnvironment()
        {
            g_operationStack = new ControlsOperationStackClass();
            g_tbCtlEdit.OperationStack = g_operationStack;
            g_engineEditor = new EngineEditorClass();
            g_engineEditLayers = (IEngineEditLayers)g_engineEditor;

            System.Object tbr = g_tbCtlEdit.Object;
            IExtension engineEditorExt = (IExtension)g_engineEditor;
            engineEditorExt.Startup(tbr);
            g_EngineEditEvents = (IEngineEditEvents_Event)g_engineEditor;
        }
Example #11
0
 private static void old_acctor_mc()
 {
     m_pOperationStack = new OperationStackClass();
     m_pStyleGallery   = null;
 }
Example #12
0
        // select all the records from the specified field that have null or blank values
        private void btnSelectBlankNulls_Click(object sender, EventArgs e)
        {
            try
            {
                // clear the progress bar, in case it has been used before
                pBar.Value = 1;

                if (cboChooseFields.SelectedIndex == -1)
                {
                    MessageBox.Show("Please select a field from the dropdown list", "Must Select Field", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                //show the cursor as busy
                System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;

                // cast the layer to itable interface b/c it makes use of the layer's definition query or join, if any.. and does the select based on that
                ITable arcTable = (ITable)clsGlobals.arcFeatLayer;

                IDataset     arcDataset     = (IDataset)clsGlobals.arcFeatLayer;
                IQueryFilter arcQueryFilter = new QueryFilter();
                arcQueryFilter.WhereClause = null;

                // check what type of layer this is, to determine the query syntax
                //shapefile//
                if (arcDataset.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriFileSystemWorkspace)
                {
                    //check the field type, look for either text or double/integer to determine what type of query to set up
                    if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeString)
                    {
                        if (chkNullOnly.Checked == true)
                        {
                            arcQueryFilter.WhereClause = "\"" + cboChooseFields.Text.ToString().Trim() + "\" is null";
                        }
                        else
                        {
                            arcQueryFilter.WhereClause = "\"" + cboChooseFields.Text.ToString().Trim() + "\" is null or \"" + cboChooseFields.Text.ToString().Trim() + "\" = ''";
                        }
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeDouble)
                    {
                        arcQueryFilter.WhereClause = "\"" + cboChooseFields.Text.ToString().Trim() + "\" is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeInteger)
                    {
                        arcQueryFilter.WhereClause = "\"" + cboChooseFields.Text.ToString().Trim() + "\" is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeSmallInteger)
                    {
                        arcQueryFilter.WhereClause = "\"" + cboChooseFields.Text.ToString().Trim() + "\" is null";
                    }
                    else
                    {
                        MessageBox.Show("You're asking to do a query on a field type that is not supported by this code.  If you need this field type to be supported talk to Greg Bunce.  He will make it happen.", "Not Supported Field Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                //fgdb//
                if (arcDataset.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriLocalDatabaseWorkspace)
                {
                    //check the field type, look for either text or double/integer to determine what type of query to set up
                    if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeString)
                    {
                        if (chkNullOnly.Checked == true)
                        {
                            arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                        }
                        else
                        {
                            arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null or " + cboChooseFields.Text.ToString().Trim() + " = ''";
                        }
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeDouble)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeInteger)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeSmallInteger)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else
                    {
                        MessageBox.Show("You're asking to do a query on a field type that is not supported by this code.  If you need this field type to be supported talk to Greg Bunce.  He will make it happen.", "Not Supported Field Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                //sde//
                if (arcDataset.Workspace.WorkspaceFactory.WorkspaceType == esriWorkspaceType.esriRemoteDatabaseWorkspace)
                {
                    //check the field type, look for either text or double/integer to determine what type of query to set up
                    if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeString)
                    {
                        if (chkNullOnly.Checked == true)
                        {
                            arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                        }
                        else
                        {
                            arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null or (" + "LTRIM(RTRIM(" + cboChooseFields.Text.ToString().Trim() + ")) = '')";
                        }
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeDouble)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeInteger)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else if (clsPushSgidStaticClass.GetArcGisFieldType(cboChooseFields.Text) == esriFieldType.esriFieldTypeSmallInteger)
                    {
                        arcQueryFilter.WhereClause = cboChooseFields.Text.ToString().Trim() + " is null";
                    }
                    else
                    {
                        MessageBox.Show("You're asking to do a query on a field type that is currently not supported by this code.  If you need this field type to be supported talk to Greg Bunce.  He will make it happen.", "Not Supported Field Type", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }

                // select the records that have nulls or blanks
                ISelectionSet arcSelSet = arcTable.Select(arcQueryFilter, esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, arcDataset.Workspace);

                ISelectFeaturesOperation arcSeleFeatOperation;
                arcSeleFeatOperation              = new SelectFeaturesOperationClass();
                arcSeleFeatOperation.ActiveView   = clsGlobals.pActiveView;
                arcSeleFeatOperation.Layer        = clsGlobals.arcFeatLayer;
                arcSeleFeatOperation.SelectionSet = arcSelSet;

                //perform the operation
                clsGlobals.pMxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                IOperationStack arcOperationStack = clsGlobals.pMxDocument.OperationStack;
                arcOperationStack.Do((IOperation)arcSeleFeatOperation);

                clsGlobals.pMxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                ////IFeatureLayer arcFeatLayer = clsGlobals.pGFlayer;
                //IFeatureLayerDefinition arcFeatureLayerDef = (IFeatureLayerDefinition)clsGlobals.pGFlayer;
                //string strExistingDefQuery = arcFeatureLayerDef.DefinitionExpression;

                //// select the records that have nulls or blanks
                //IQueryFilter arcQueryFilter = new QueryFilter();
                //arcQueryFilter.WhereClause = "(" + strExistingDefQuery + ") AND " + cboChooseFields.Text.ToString().Trim() + " is null";

                //IDataset arcDataset = (IDataset)clsGlobals.pGFlayer.FeatureClass;
                //ISelectionSet arcSelSet = clsGlobals.pGFlayer.FeatureClass.Select(arcQueryFilter,esriSelectionType.esriSelectionTypeHybrid, esriSelectionOption.esriSelectionOptionNormal, arcDataset.Workspace);

                //clsGlobals.pActiveView.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "Push Utrans Roads to SGID error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #13
0
        private void AddQALayerToActiveView(IMap map, IFeatureClass SourceLineFeatureClass, IFeatureClass SourcePolygonFeatureClass,
                                            string layerPathFile, double metersPerUnit, bool bIsBefore1022, bool bFabricIsInGCS)
        {
            if (map == null || layerPathFile == null || !layerPathFile.EndsWith(".lyr"))
            {
                return;
            }

            IWorkspace pWS         = SourceLineFeatureClass.FeatureDataset.Workspace;
            bool       bIsPostGres = false;

            if (pWS.Type != esriWorkspaceType.esriLocalDatabaseWorkspace)
            {
                IDatabaseConnectionInfo2 connectionInfo2 = (IDatabaseConnectionInfo2)(pWS);
                bIsPostGres = (connectionInfo2.ConnectionDBMS == esriConnectionDBMS.esriDBMS_PostgreSQL);
            }

            // Create a new GxLayer
            IGxLayer gxLayer = new GxLayerClass();
            IGxFile  gxFile  = (IGxFile)gxLayer;

            // Set the path for where the layerfile is located on disk
            gxFile.Path = layerPathFile;

            // Test if we have a valid layer and add it to the map
            if (!(gxLayer.Layer == null))
            {
                if (!(gxLayer.Layer is ICompositeLayer))
                {
                    return;
                }
                ICompositeLayer pCompLyr = (ICompositeLayer)gxLayer.Layer;
                for (int i = 0; i < pCompLyr.Count; i++)
                {
                    ILayer pLyr = pCompLyr.get_Layer(i);
                    //
                    if (pLyr is IFeatureLayer)
                    {
                        IFeatureLayer pFlyr = (IFeatureLayer)pLyr;
                        //now update the definition query
                        IFeatureLayerDefinition pFeatLyrDef = (IFeatureLayerDefinition)pFlyr;
                        string sLyrName = pFlyr.Name;
                        bool   bExc     = false;
                        if (sLyrName.Contains("Minus"))
                        {
                            pFlyr.FeatureClass = SourceLineFeatureClass;
                            bExc = false;

                            SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);
                            if (bExc || bFabricIsInGCS)
                            {
                                int jj = pFlyr.FeatureClass.FindField("ComputedMinusObserved");
                                if (jj > -1)
                                {
                                    string sVal     = (0.1 / metersPerUnit).ToString("0.00");
                                    string sCminusO = pFlyr.FeatureClass.Fields.get_Field(jj).Name;
                                    pFeatLyrDef.DefinitionExpression = "(" + sCminusO + " > " + sVal + " OR " + sCminusO + " < -" + sVal + ") AND (" + sCminusO + " IS NOT NULL)";

                                    if (bIsPostGres)
                                    {
                                        pFeatLyrDef.DefinitionExpression = "(((st_length(shape) - distance) > " + sVal +
                                                                           " OR (st_length(shape) - distance) < -" + sVal + " OR (distance - st_length(shape)) > " + sVal +
                                                                           " OR  (distance - st_length(shape)) < -" + sVal +
                                                                           ") AND (radius IS NULL AND (densifytype IS NULL OR densifytype <> 3))  AND category <> 4) OR ( ( ((st_length(shape) - arclength) > " + sVal +
                                                                           " OR (st_length(shape) - arclength) < -" + sVal + ")    OR (arclength - st_length(shape)) > " + sVal +
                                                                           " OR  (arclength - st_length(shape)) < -" + sVal + ") AND ( NOT arclength IS NULL ) )"; //this is query for ST_Geometry as well as PG_Geometry
                                    }
                                }
                                continue;
                            }

                            string s      = pFeatLyrDef.DefinitionExpression;
                            int    iField = SourceLineFeatureClass.FindField("ArcLength");
                            if (iField > -1)
                            {
                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"ArcLength\"", s2);
                                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ArcLength", s2);
                            }

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourceLineFeatureClass.FindField("Category");
                            if (iField > -1)
                            {
                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"Category\"", s2);
                                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Category", s2);
                            }

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourceLineFeatureClass.FindField("Radius");
                            if (iField > -1)
                            {
                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"Radius\"", s2);
                                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Radius", s2);
                            }

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourceLineFeatureClass.FindField("Distance");
                            if (iField > -1)
                            {
                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"Distance\"", s2);
                                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Distance", s2);
                            }

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourceLineFeatureClass.FindField("DensifyType");
                            if (iField > -1)
                            {
                                string s2 = SourceLineFeatureClass.Fields.get_Field(iField).Name;
                                pFeatLyrDef.DefinitionExpression = s.Replace("\"DensifyType\"", s2);
                                pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("DensifyType", s2);
                            }


                            s = pFeatLyrDef.DefinitionExpression;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"Shape_Length\"", SourceLineFeatureClass.LengthField.Name);
                            pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("Shape_Length", SourceLineFeatureClass.LengthField.Name);
                        }
                        else if (sLyrName.Contains("Parcel"))
                        { //In 10.1 start editing crashes if the definition query in these layers that use POWER function is present.
                          //Can test if the release is 10.1 and knock out the def query, or else exclude the layers.

                            string s      = pFeatLyrDef.DefinitionExpression;
                            int    iField = SourcePolygonFeatureClass.FindField("MiscloseDistance");
                            string s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"MiscloseDistance\"", s2);
                            pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("MiscloseDistance", s2);

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorE");
                            s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorE\"", s2);
                            pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorE", s2);

                            s      = pFeatLyrDef.DefinitionExpression;
                            iField = SourcePolygonFeatureClass.FindField("ShapeStdErrorN");
                            s2     = SourcePolygonFeatureClass.Fields.get_Field(iField).Name;
                            pFeatLyrDef.DefinitionExpression = s.Replace("\"ShapeStdErrorN\"", s2);
                            pFeatLyrDef.DefinitionExpression = pFeatLyrDef.DefinitionExpression.Replace("ShapeStdErrorN", s2);

                            pFlyr.FeatureClass = SourcePolygonFeatureClass;
                            SetLabelExpressionOnFeatureLayer(pFlyr, out bExc);

                            if (s.ToLower().Contains("power") && bIsBefore1022)
                            {//remove the def query CR278039
                                pFeatLyrDef.DefinitionExpression = "";
                                continue;
                            }
                        }
                    }
                }
                gxLayer.Layer.Name = "QA Symbology";

                IMxDocument         pMXDoc    = ArcMap.Document;
                IOperationStack     pOpSt     = pMXDoc.OperationStack;
                IAddLayersOperation pAddLyrOp = new AddLayersOperationClass();
                pAddLyrOp.SetDestinationInfo(0, map, null);
                pAddLyrOp.Name = "Add Fabric QA Layer";
                pAddLyrOp.AddLayer(gxLayer.Layer);
                IOperation pOp = (IOperation)pAddLyrOp;
                pOpSt.Do(pOp);
            }
        }
Example #14
0
        /// <summary>
        /// Sets all the necessary references from the main view.
        /// </summary>
        /// <remarks>We don't use contructor injection here since most of other services use this one as a parameter.
        /// Perhaps property injection can be used.</remarks>
        internal void Init(
            IMainView mainView,
            IProjectService project,
            IConfigService configService,
            MapLegendPresenter mapLegendPresenter,
            OverviewPresenter overviewPresenter
            )
        {
            Logger.Current.Trace("Start AppContext.Init()");
            if (mainView == null)
            {
                throw new ArgumentNullException("mainView");
            }
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }
            if (mapLegendPresenter == null)
            {
                throw new ArgumentNullException("legendPresenter");
            }
            //初始化图例控件
            _mapLegendPresenter = mapLegendPresenter;
            var legend = _mapLegendPresenter.LegendControl;

            legend.LegendControl.SetBuddyControl(mainView.MapControl);


            // it's expected here that we are on the UI thread
            SynchronizationContext = SynchronizationContext.Current;

            PluginManager = Container.GetSingleton <IPluginManager>();
            Broadcaster   = Container.GetSingleton <IBroadcasterService>();
            Container.RegisterInstance <IMapControl2>(mainView.MapControl);

            MainView       = mainView;
            View           = new AppView(mainView, _styleService);
            _project       = project;
            _configService = configService;
            MainView.AddFrameworkControl(legend.LegendControl.Object);

            _overviewPresenter = overviewPresenter;
            _overviewPresenter.SetBuddyControl(mainView.MapControl);
            MainView.AddFrameworkControl(_overviewPresenter.OverviewControl);

            //  _map = mainView.Map;
            //
            //   Repository = repository;

            //  Legend.Lock();

            DockPanels = new DockPanelCollection(mainView.DockingManager, mainView as Form, Broadcaster, _styleService);

            //Menu到最后丢弃不用,Menu部分全部采用Ribbon
            RibbonMenu = RibbonFactory.InitMenus((RibbonControl)mainView.RibbonManager,
                                                 mainView.RibbonStatusBar as RibbonStatusBar);

            // Menu = MenuFactory.CreateMainMenu(mainView.RibbonManager,true);
            // Toolbars = MenuFactory.CreateMainToolbars(mainView.MenuManager);
            // StatusBar = MenuFactory.CreateStatusBar(mainView.RibbonStatusBar, PluginIdentity.Default);

            // _projectionDatabase.ReadFromExecutablePath(Application.ExecutablePath);

            // Repository.Initialize(this);

            // comment this line to prevent locator loading
            // may be useful for ocx debugging to not create additional
            // instance of map
            // _locator = new LocatorPresenter(_map);

            this.InitDocking();

            //YTHookHelper设置

            OperationStack  = new OperationStackClass();
            m_pStyleGallery = null;

            //Catalog配置
            GxCatalog = new GxCatalog();
            //GxSelection=new GxSelection();
            //if (this._gxSelection is IGxSelectionEvents)
            //{
            //    (this._gxSelection as IGxSelectionEvents).OnSelectionChanged += new OnSelectionChangedEventHandler(this.GxSelection_Changed);
            //}

            Initialized = true;
            Logger.Current.Trace("End AppContext.Init()");

            //为了减少修改,给ApplicationRef赋值
            ApplicationRef.AppContext = this;
        }