/// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IComPropertySheet myPropertySheet = new ComPropertySheetClass();

            myPropertySheet.Title          = "Simplified Layer Properties (C#)";
            myPropertySheet.HideHelpButton = true;

            //Add by component category - all pages registered in the layer property page
            //UID layerPropertyID = new UIDClass();
            //layerPropertyID.Value = m_layerCategoryID;
            //myPropertySheet.AddCategoryID(layerPropertyID);

            //Or add page by page - but have to call Applies yourself
            myPropertySheet.ClearCategoryIDs();
            myPropertySheet.AddCategoryID(new UIDClass());                                    //a dummy empty UID
            myPropertySheet.AddPage(new LayerVisibilityPage());                               //my custom page
            myPropertySheet.AddPage(new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass()); //feature layer symbology

            //Pass in layer, active view and the application
            ISet           propertyObjects = new SetClass();
            IBasicDocument basicDocument   = m_application.Document as IBasicDocument;

            propertyObjects.Add(basicDocument.ActiveView);
            propertyObjects.Add(basicDocument.SelectedLayer); //or check ContextItem is a layer?
            propertyObjects.Add(m_application);               //optional?

            //Show the property sheet
            if (myPropertySheet.CanEdit(propertyObjects))
            {
                myPropertySheet.EditProperties(propertyObjects, m_application.hWnd);
            }
        }
예제 #2
0
        private void 符合设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_curLayer == null)
            {
                return;
            }

            var PSheet = new ComPropertySheetClass();

            PSheet.HideHelpButton = true;

            ISet PSet = new SetClass();

            PSet.Add(_curLayer);
            PSheet.ClearCategoryIDs();
            PSheet.AddCategoryID(new UIDClass());

            PSheet.AddPage(new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass());
            PSheet.Title = "显示属性设置";
            if (PSheet.CanEdit(PSet))
            {
                if (PSheet.EditProperties(PSet, 0))
                {
                    axTOCControl1.Refresh();
                }
            }
        }
예제 #3
0
        /// <summary>
        ///     Perform find functionality.
        /// </summary>
        /// <param name="findCallBack">The find call back.</param>
        protected override void InternalFind(IFindCallBack findCallBack)
        {
            try
            {
                var doc = findCallBack.Application.Document as IMxDocument;
                if (doc == null)
                {
                    return;
                }

                var map = doc.FocusMap;
                if (map == null)
                {
                    return;
                }

                var request = _Control.GetSearchRequest();
                if (request == null)
                {
                    return;
                }

                var service  = new MapSearchService();
                var response = service.Find(request, map, _CancellationTokenSource);
                var set      = new SetClass();

                foreach (var values in response.Values)
                {
                    for (int i = values.Count - 1; i >= 0; i--)
                    {
                        var featureFindData = values[i];
                        set.Add(featureFindData);

                        findCallBack.ColumnValue[0] = featureFindData.Feature.OID.ToString(CultureInfo.InvariantCulture);
                        findCallBack.ColumnValue[1] = featureFindData.Layer.Name;
                        findCallBack.Object         = featureFindData;
                        findCallBack.AddNewRow();

                        bool quitProcessing;
                        findCallBack.ProcessMessages(out quitProcessing);

                        if (quitProcessing)
                        {
                            break;
                        }
                    }
                }

                doc.ContextItem = set;
            }
            catch (Exception ex)
            {
                Log.Error(this, ex);
            }
        }
예제 #4
0
        public override void Flush(CoLayerMapper coLayerMapper_1)
        {
            int            num;
            IFeatureBuffer buffer;

            this.coLayerMapper_0 = coLayerMapper_1;
            if (this.ifeatureClass_0.FeatureType == esriFeatureType.esriFTAnnotation)
            {
                this.bool_0 = false;
            }
            else
            {
                this.bool_0 = true;
            }
            if (this.bool_0)
            {
                if (this.ifeatureCursor_1 == null)
                {
                    this.ifeatureCursor_1 = this.ifeatureClass_0.Insert(true);
                }
                for (num = 0; num < base.XpgisLayer.FeatureCount; num++)
                {
                    buffer = this.method_9(base.XpgisLayer.GetFeatureByIndex(num));
                    if (buffer != null)
                    {
                        this.ifeatureCursor_1.InsertFeature(buffer);
                    }
                }
                try
                {
                    this.ifeatureCursor_1.Flush();
                }
                catch
                {
                }
            }
            else
            {
                IFeatureClassWrite write = this.ifeatureClass_0 as IFeatureClassWrite;
                ISet features            = new SetClass();
                for (num = 0; num < base.XpgisLayer.FeatureCount; num++)
                {
                    buffer = this.method_9(base.XpgisLayer.GetFeatureByIndex(num));
                    if (buffer != null)
                    {
                        features.Add(buffer as IFeature);
                    }
                }
                write.WriteFeatures(features);
            }
            base.XpgisLayer.RemoveAllFeature();
        }
예제 #5
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            ISet set = new SetClass();

            for (int i = 0; i < this.checkedListBox1.Items.Count; i++)
            {
                if (this.checkedListBox1.GetItemChecked(i))
                {
                    object obj2 = this.checkedListBox1.Items[i];
                    set.Add((obj2 as LayerObject).Layer);
                }
            }
            if (set.Count > 0)
            {
                (this.Map as IMapClipOptions).ClipFilter = set;
            }
            else
            {
                (this.Map as IMapClipOptions).ClipFilter = null;
            }
            base.DialogResult = DialogResult.OK;
        }
예제 #6
0
파일: 1.cs 프로젝트: trainsn/LBS
        /// <summary>
        /// 从选择要素中生成草图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void biGenerate_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                if (_startPoint != null)
                {
                    XtraMessageBox.Show(String.Format("当前处于编辑草图状态无法生成草图,请先删除草图!"), "提示");
                }

                ISet iSet = new SetClass();
                ISelection iSelection = null;

                iSelection = TheReferenceInstances.TheProjectAgent.Map.FeatureSelection;
                IEnumFeatureSetup iSetUp = iSelection as IEnumFeatureSetup;
                iSetUp.AllFields = true;
                iSetUp.Recycling = false;

                IEnumFeature iEnumFeat = iSelection as IEnumFeature;
                iEnumFeat.Reset();
                IFeature iFeat = null;
                IGeometry iGeo = null;
                while ((iFeat = iEnumFeat.Next()) != null)
                {
                    iGeo = iFeat.Shape;
                    iSet.Add(iGeo);
                }

                if (iSet.Count < 1)
                {
                    XtraMessageBox.Show(String.Format("当前无被选中的地物!"), "提示");
                    return;
                }

                int n = TheReferenceInstances.TheAEditer.SketchEdit.PntColl.PointCount;
                if (n > 0)
                {
                    TheReferenceInstances.TheAEditer.SketchEdit.PntColl.RemovePoints(0, n);
                }

                SpatialTool spatialTool = new SpatialTool();

                IGeometry iGeometry = null;
                if (_subType == 1)
                {
                    if (iSet.Count > 1 && !spatialTool.CanMergeAsSinglePath(iSet))
                    {
                        XtraMessageBox.Show(String.Format("要素不相邻或者自相交, 不能进行合并!"), "提示");
                    }

                    iGeometry = spatialTool.UnionPolylines(iSet) as IGeometry;

                    if (iGeometry == null)
                    {
                        XtraMessageBox.Show(String.Format("合并要素失败!"), "提示");
                        return;
                    }
                    (_geometryFeedback as INewLineFeedback).Stop();
                }
                else if (_subType == 2)
                {
                    iGeometry = spatialTool.UnionPolygons(iSet) as IGeometry;
                    if (iGeometry == null)
                    {
                        XtraMessageBox.Show(String.Format("合并要素失败!"), "提示");
                        return;
                    }

                    if ((iGeometry as IPolygon).ExteriorRingCount > 1)
                    {
                        XtraMessageBox.Show(String.Format("要素不相邻,不能合并!"), "提示");
                        return;
                    }
                    (_geometryFeedback as INewPolygonFeedback).Stop();
                }

                //从CAD转化来的图形可能含有Z值,造成后续iNewFeat.Shape = iGeometry时出错。故进行转化。
                IZAware iZAware = iGeometry as IZAware;
                if (iZAware != null && iZAware.ZAware == true)
                {
                    iZAware.ZAware = false;
                }

                TheReferenceInstances.TheAEditer.SketchEdit.DrawGeometry = iGeometry;
                TheReferenceInstances.TheProjectAgent.Map.ClearSelection();

                _startPoint = null;
                RefreshFeedBack();
                (myHook.FocusMap as IActiveView).Refresh();
            }
            catch (System.Exception ex)
            {
                XtraMessageBox.Show(String.Format("从选择要素中生成草图失败!\n{0}", ex.Message), "提示");
            }
        }
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            IComPropertySheet myPropertySheet = new ComPropertySheetClass();
            myPropertySheet.Title = "Simplified Layer Properties (C#)";
            myPropertySheet.HideHelpButton = true;

            //Add by component category - all pages registered in the layer property page
            //UID layerPropertyID = new UIDClass();
            //layerPropertyID.Value = m_layerCategoryID;
            //myPropertySheet.AddCategoryID(layerPropertyID);

            //Or add page by page - but have to call Applies yourself
            myPropertySheet.ClearCategoryIDs();
            myPropertySheet.AddCategoryID(new UIDClass()); //a dummy empty UID
            myPropertySheet.AddPage(new LayerVisibilityPage()); //my custom page
            myPropertySheet.AddPage(new ESRI.ArcGIS.CartoUI.LayerDrawingPropertyPageClass()); //feature layer symbology

            //Pass in layer, active view and the application
            ISet propertyObjects = new SetClass();
            IBasicDocument basicDocument = m_application.Document as IBasicDocument;

            propertyObjects.Add(basicDocument.ActiveView);
            propertyObjects.Add(basicDocument.SelectedLayer); //or check ContextItem is a layer?
            propertyObjects.Add(m_application); //optional?

            //Show the property sheet
            if (myPropertySheet.CanEdit(propertyObjects))
                myPropertySheet.EditProperties(propertyObjects, m_application.hWnd);
        }
예제 #8
0
        private ISet GetSelectedPrimaryParcels(IFeatureLayer surveyParcelLayer, IWorkspace tantalisWorkspace)
        {
            // Mar 12, 2008
            m_pISDUTExt = RestTransactionManager.Instance.BaseTransactionManager.extension(); //(ISDUTExtension)_App.FindExtensionByName("SUITT Extension");
            this.TANTschema = m_pISDUTExt.get_SystemValue("db.tant.schema") + ".";

            ISet theReturn = null;

            if (surveyParcelLayer == null)
                return null;

            IQueryFilter theQF = new QueryFilterClass();
            util.Logger.Write("Fetching all selected parcels");

            //theQF.WhereClause = PARCEL_TYPE_FIELD_NAME + " = " + PRIMARY_PARCEL_CODE;
            //util.Logger.Write("Fetching parcels where: " + PARCEL_TYPE_FIELD_NAME + " = " + PRIMARY_PARCEL_CODE);

            if (tantalisWorkspace != null)
            {
                // Create in-memory join
                IRelationshipClass2 theRC = null;
                try
                {
                    // Open the related table
                    ITable theOsdbTable = ((IFeatureWorkspace)tantalisWorkspace).OpenTable(TANTschema + SURVEY_PARCEL_TAB_NAME);

                    IMemoryRelationshipClassFactory theFactory = new MemoryRelationshipClassFactoryClass();
                    theRC = (IRelationshipClass2)theFactory.Open(
                        SURVEY_PARCEL_FC_NAME + "_to_" + SURVEY_PARCEL_TAB_NAME,
                        (IObjectClass)surveyParcelLayer.FeatureClass,
                        SURVEY_PARCEL_FK_NAME,
                        (IObjectClass)theOsdbTable,
                        SURVEY_PARCEL_FK_NAME,
                        "forward",
                        "backward",
                        esriRelCardinality.esriRelCardinalityOneToOne);
                }
                catch (Exception ex)
                {
                    util.Logger.Write("Error creating memory relationship class between " + SURVEY_PARCEL_FC_NAME + " and " + SURVEY_PARCEL_TAB_NAME + ":" + Environment.NewLine
                        + ex.Message + Environment.NewLine + ex.StackTrace);
                    return null;
                }

                // Loop through the selected features
                ISet theSelectedSPs = new SetClass();
                ICursor theCursor = null;
                ((IFeatureSelection)surveyParcelLayer).SelectionSet.Search(null, false, out theCursor);
                IRow theSPRow = theCursor.NextRow();
                while (theSPRow != null)
                {
                    theSelectedSPs.Add(theSPRow);
                    theSPRow = theCursor.NextRow();
                }
                Marshal.ReleaseComObject(theCursor);

                IRelClassEnumRowPairs thePairs = theRC.GetObjectsMatchingObjectSetEx(theSelectedSPs, theQF, true);
                theReturn = new SetClass();

                IRow theOsdbRow;
                thePairs.Next(out theSPRow, out theOsdbRow);
                while (theSPRow != null)
                {
                    theReturn.Add(theSPRow);
                    thePairs.Next(out theSPRow, out theOsdbRow);
                }
            }
            else
            {
                // Loop through the selected features
                theReturn = new SetClass();
                ICursor theCursor = null;
                ((IFeatureSelection)surveyParcelLayer).SelectionSet.Search(theQF, false, out theCursor);
                IRow theSPRow = theCursor.NextRow();
                while (theSPRow != null)
                {
                    theReturn.Add(theSPRow);
                    theSPRow = theCursor.NextRow();
                }
                Marshal.ReleaseComObject(theCursor);
            }

            return theReturn;
        }
예제 #9
0
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngine, esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },
                                                         new esriLicenseExtensionCode[] { });
            //ESRI License Initializer generated code.

            IWorkspaceFactory2 wsf2 = new SdeWorkspaceFactoryClass() as IWorkspaceFactory2;
            IWorkspace         ws   = wsf2.OpenFromFile(@"C:\Users\User123\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\ConnectionToSQLServer.sde", 0);

            IFeatureWorkspace fws = ws as IFeatureWorkspace;

            ESRI.ArcGIS.Geodatabase.IFeatureClass fc = fws.OpenFeatureClass("DB_101.DBO.Points_Projected_UTMz11NCopy4_3");

            ITableWrite tw = fc as ITableWrite;

            int numRows = 300;

            Int32[] int32Array = new Int32[numRows];

            for (Int32 i = 0; i < numRows; i++)
            {
                int32Array[i] = i;
            }

            IGeoDatabaseBridge2 gdbBridge2 = new GeoDatabaseHelperClass();

            //IGeoDatabaseBridge2 fc_gdbBridge2 = fc as IGeoDatabaseBridge2;

            bool Recycling = false;

            IFeatureCursor featCursor = gdbBridge2.GetFeatures(fc, ref int32Array, Recycling);

            ISet setOfRows = new SetClass();

            IFeature feat;

            feat = featCursor.NextFeature();

            while (feat != null)
            {
                IObject obj = feat as IObject;
                setOfRows.Add(obj);
                feat = featCursor.NextFeature();
            }

            // TEST 1: ITableWrite.DeleteRows
            //-------------------------------

            DateTime dateTimeNow_Start = System.DateTime.Now;

            tw.DeleteRows(setOfRows);
            DateTime dateTimeNow_End = System.DateTime.Now;
            Double   timeDifference  = dateTimeNow_End.Subtract(dateTimeNow_Start).Milliseconds;

            System.Diagnostics.Debug.WriteLine("ITableWrite.DeleteRows(" + numRows + "rows): Processing time = " +
                                               timeDifference + " Milliseconds.");

            // TEST 2: ITableWrite.RemoveRows
            //-------------------------------

            //DateTime dateTimeNow_Start = System.DateTime.Now;
            //tw.RemoveRows(setOfRows);
            //DateTime dateTimeNow_End = System.DateTime.Now;
            //Double timeDifference = dateTimeNow_End.Subtract(dateTimeNow_Start).Milliseconds;
            //System.Diagnostics.Debug.WriteLine("ITableWrite.RemoveRows(" + numRows + "rows): Processing time = " +
            //                                                                timeDifference + " Milliseconds.");

            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }
예제 #10
0
        private bool SetLayerPropertySheet(ILayer layer)
        {
            if (layer == null)
                return false;

            IComPropertySheet pComPropSheet;
            pComPropSheet = new ESRI.ArcGIS.Framework.ComPropertySheet();
            pComPropSheet.Title = layer.Name + " - ����";

            ESRI.ArcGIS.esriSystem.UID pPPUID = new UIDClass();
            pComPropSheet.AddCategoryID(pPPUID);

            // General....
            ESRI.ArcGIS.Framework.IPropertyPage pGenPage = new GeneralLayerPropPageClass();
            pComPropSheet.AddPage(pGenPage);

            // Source
            ESRI.ArcGIS.Framework.IPropertyPage pSrcPage = new FeatureLayerSourcePropertyPageClass();
            pComPropSheet.AddPage(pSrcPage);

            // Selection...
            IPropertyPage pSelectPage = new FeatureLayerSelectionPropertyPageClass();
            pComPropSheet.AddPage(pSelectPage);

            // Display....
            IPropertyPage pDispPage = new FeatureLayerDisplayPropertyPageClass();
            pComPropSheet.AddPage(pDispPage);

            // Symbology....
            ESRI.ArcGIS.Framework.IPropertyPage pDrawPage = new LayerDrawingPropertyPageClass();
            pComPropSheet.AddPage(pDrawPage);

            // Fields...
            ESRI.ArcGIS.Framework.IPropertyPage pFieldsPage = new LayerFieldsPropertyPageClass();
            pComPropSheet.AddPage(pFieldsPage);

            // Definition Query...
            ESRI.ArcGIS.Framework.IPropertyPage pQueryPage = new LayerDefinitionQueryPropertyPageClass();
            pComPropSheet.AddPage(pQueryPage);

            // Labels....
            ESRI.ArcGIS.Framework.IPropertyPage pSelPage = new LayerLabelsPropertyPageClass();
            pComPropSheet.AddPage(pSelPage);

            // Joins & Relates....
            ESRI.ArcGIS.Framework.IPropertyPage pJoinPage = new JoinRelatePageClass();
            pComPropSheet.AddPage(pJoinPage);

            // Setup layer link
            ESRI.ArcGIS.esriSystem.ISet pMySet = new SetClass();
            pMySet.Add(layer);
            pMySet.Reset();

            // make the symbology tab active
            pComPropSheet.ActivePage = 4;

            // show the property sheet
            bool bOK = pComPropSheet.EditProperties(pMySet, 0);

               return bOK;
        }
예제 #11
0
        static void Main(string[] args)
        {
            //ESRI License Initializer generated code.
            m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngine, esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },
            new esriLicenseExtensionCode[] { });
            //ESRI License Initializer generated code.

            IWorkspaceFactory2 wsf2 = new SdeWorkspaceFactoryClass() as IWorkspaceFactory2;
            IWorkspace ws = wsf2.OpenFromFile(@"C:\Users\User123\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\ConnectionToSQLServer.sde", 0);

            IFeatureWorkspace fws = ws as IFeatureWorkspace;
            ESRI.ArcGIS.Geodatabase.IFeatureClass fc = fws.OpenFeatureClass("DB_101.DBO.Points_Projected_UTMz11NCopy4_3");

            ITableWrite tw = fc as ITableWrite;

            int numRows = 300;
            Int32[] int32Array = new Int32[numRows];

            for (Int32 i = 0; i < numRows; i++)
            {
                int32Array[i] = i;
            }

            IGeoDatabaseBridge2 gdbBridge2 = new GeoDatabaseHelperClass();

            //IGeoDatabaseBridge2 fc_gdbBridge2 = fc as IGeoDatabaseBridge2;

            bool Recycling = false;

            IFeatureCursor featCursor = gdbBridge2.GetFeatures(fc, ref int32Array, Recycling);

            ISet setOfRows = new SetClass();

            IFeature feat;
            feat = featCursor.NextFeature();

            while (feat != null)
            {
                IObject obj = feat as IObject;
                setOfRows.Add(obj);
                feat = featCursor.NextFeature();
            }
            
            // TEST 1: ITableWrite.DeleteRows
            //-------------------------------

            DateTime dateTimeNow_Start = System.DateTime.Now;
            tw.DeleteRows(setOfRows);
            DateTime dateTimeNow_End = System.DateTime.Now;
            Double timeDifference = dateTimeNow_End.Subtract(dateTimeNow_Start).Milliseconds;
            System.Diagnostics.Debug.WriteLine("ITableWrite.DeleteRows(" + numRows + "rows): Processing time = " +
                                                                            timeDifference + " Milliseconds.");

            // TEST 2: ITableWrite.RemoveRows
            //-------------------------------

            //DateTime dateTimeNow_Start = System.DateTime.Now;
            //tw.RemoveRows(setOfRows);
            //DateTime dateTimeNow_End = System.DateTime.Now;
            //Double timeDifference = dateTimeNow_End.Subtract(dateTimeNow_Start).Milliseconds;
            //System.Diagnostics.Debug.WriteLine("ITableWrite.RemoveRows(" + numRows + "rows): Processing time = " +
            //                                                                timeDifference + " Milliseconds.");

            //Do not make any call to ArcObjects after ShutDownApplication()
            m_AOLicenseInitializer.ShutdownApplication();
        }