コード例 #1
0
        /// <summary>
        /// gets all active layers within a view given a layer type constant
        /// </summary>
        /// <param name="lyrTyp">layer type constant</param>
        /// <returns>Layer enumartor</returns>
        public IEnumLayer getActiveViewLayers(string lyrTyp)
        {
            ESRI.ArcGIS.esriSystem.UID uid = getUID(lyrTyp);
            IMap       eMap    = acView as IMap;
            IEnumLayer eLayers = eMap.get_Layers(uid, true);

            return(eLayers);
        }
コード例 #2
0
        //Pan모드 선택처리
        public void FindCommandAndExecute(IApplication application)
        {
            ESRI.ArcGIS.Framework.ICommandBars commandBars = application.Document.CommandBars;
            ESRI.ArcGIS.esriSystem.UID         uid         = new ESRI.ArcGIS.esriSystem.UID();
            uid.Value = "esriControls.ControlsMapPanTool";
            ESRI.ArcGIS.Framework.ICommandItem commandItem = commandBars.Find(uid, false, false);

            if (commandItem != null)
            {
                commandItem.Execute();
            }
        }
コード例 #3
0
        /// <summary>
        /// Execute the Selection Tool
        /// </summary>
        public void ExecuteSelectionTool()
        {
            ESRI.ArcGIS.Framework.IApplication app = this.Hook as ESRI.ArcGIS.Framework.IApplication;

            // TODO: Handle Engine where the hook is a mapcontrol or toolbar control
            if (null != app)
            {
                ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UID();
                uid.Value = "esriControls.SelectFeaturesTool";

                ESRI.ArcGIS.Framework.ICommandItem selectCommand = app.Document.CommandBars.Find(uid, false, false);
                if (null != selectCommand)
                {
                    selectCommand.Execute();
                }
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: sishui198/Arcgis-Engine-c-
        private void Form1_Load(object sender, EventArgs e)
        {
            UID pUid = new ESRI.ArcGIS.esriSystem.UID();            //初始化菜单工具栏命令

            pUid.Value = "esriControls.ControlsOpenDocCommand";
            axToolbarControl1.AddItem(pUid, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);
            pUid.Value = "esriControls.ControlsMapZoomInTool";
            axToolbarControl1.AddItem(pUid, -1, -1, true, 0, esriCommandStyles.esriCommandStyleIconAndText);
            pUid.Value = "esriControls.ControlsMapZoomOutTool";
            axToolbarControl1.AddItem(pUid, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            pUid.Value = "esriControls.ControlsMapPanTool";
            axToolbarControl1.AddItem(pUid, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            pUid.Value = "esriControls.ControlsMapFullExtentCommand";
            axToolbarControl1.AddItem(pUid, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconAndText);
            pUid.Value = "esriControls.ControlsMapZoomToLastExtentBackCommand";
            axToolbarControl1.AddItem(pUid, -1, -1, true, 20, esriCommandStyles.esriCommandStyleIconOnly);
            pUid.Value = "esriControls.ControlsMapZoomToLastExtentForwardCommand";
            axToolbarControl1.AddItem(pUid, -1, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly);


            //右键菜单
            m_ToolbarMenu = new ESRI.ArcGIS.Controls.ToolbarMenu();

            String progID;//初始化地图控件右键快捷菜单工具栏命令

            progID = "esriControls.ControlsMapFullExtentCommand";
            m_ToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconOnly);
            progID = "esriControls.ControlsMapZoomPanTool";
            m_ToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconOnly);
            progID = "esriControls.ControlsMapZoomInTool";
            m_ToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconOnly);
            progID = "esriControls.ControlsMapZoomOutTool";
            m_ToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconOnly);
            progID = "esriControls.ControlsMapPanTool";
            m_ToolbarMenu.AddItem(progID, -1, -1, false, esriCommandStyles.esriCommandStyleIconOnly);
            m_ToolbarMenu.SetHook(axMapControl1);
        }
		void formAdvanced_doneFormEvent(object sender, AdvancedEvents e)
		{
			m_pSDS.DesignMode = true;
			formAdvanced.Cursor = System.Windows.Forms.Cursors.WaitCursor;
			//process the algorithm if there is one
			if (e.AlgorithmName != "")
			{
				ISchematicAlgoSmartTree a = new SchematicAlgoSmartTreeClass();
				if (e.AlgorithmParams.Count > 0)
				{
					Dictionary<string, string>.KeyCollection keys = e.AlgorithmParams.Keys;
					string strValue = "";
					foreach (string s in keys)
					{
						if (s == "Direction")
						{
							e.AlgorithmParams.TryGetValue(s, out strValue);

							if (strValue == "Top to Bottom")
							{
								a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoTopDown;
							}
							else if (strValue == "Bottom to Top")
							{
								a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoBottomUp;
							}
							else if (strValue == "Left to Right")
							{
								a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoLeftRight;
							}
							else
							{
								a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoRightLeft;
							}
						}
					}
					if (e.RootClass != "")
					{
						ISchematicElementClassContainer pECC = (ISchematicElementClassContainer)m_pSDS;
						ISchematicElementClass pEC = pECC.GetSchematicElementClass(e.RootClass);
						ESRI.ArcGIS.esriSystem.UID u = new ESRI.ArcGIS.esriSystem.UID();
						u.Value = "{3AD9D8B8-0A1D-4F32-ABB5-54B848A46F85}";

						ISchematicAttributeConstant pAttrConst = (ISchematicAttributeConstant)pEC.CreateSchematicAttribute("RootFlag", u);
						ISchematicAttributeManagement pAttrMgmt = (ISchematicAttributeManagement)pAttrConst;
						pAttrMgmt.StorageMode = esriSchematicAttributeStorageMode.esriSchematicAttributeFieldStorage;
						pAttrConst.ConstantValue = "-1";
					}
				}

				m_pSDT.SchematicAlgorithm = (ISchematicAlgorithm)a;

			}

			//check to see if we need to add associated fields
			if (e.FieldsToCreate != null)
			{
				if (e.FieldsToCreate.Count > 0)
				{
					ISchematicElementClassContainer pECC = (ISchematicElementClassContainer)m_pSDS;

					//create the associated field attributes
					string[] keys = e.FieldsToCreate.AllKeys;
					foreach (string s in keys)
					{
						//get the feature class
						ISchematicElementClass pEC = pECC.GetSchematicElementClass(s);
						if (pEC != null)
						{
							string strName = "";
							string[] values = e.FieldsToCreate.GetValues(s);
							foreach (string v in values)
							{
								//create the field
								ESRI.ArcGIS.esriSystem.UID u = new ESRI.ArcGIS.esriSystem.UID();
								u.Value = "{7DE3A19D-32D0-41CD-B896-37CA3AFBD88A}";

								IClass pClass = (IClass)pEC;
								//only handle names that don't already exist in the schematic tables
								if (pClass.FindField(v) == -1)
								{
									strName = v.ToString();

									ISchematicAttributeAssociatedField pFieldAttr = (ISchematicAttributeAssociatedField)pEC.CreateSchematicAttribute(strName, u);
									pFieldAttr.AssociatedFieldName = v;
									ISchematicAttributeManagement pAttrMgmt = (ISchematicAttributeManagement)pFieldAttr;
									pAttrMgmt.StorageMode = esriSchematicAttributeStorageMode.esriSchematicAttributeFieldStorage;
								}
							}
						}
					}
				}
			}

			m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersionCurrent, true);
			m_pSDS.DesignMode = false;
			formAdvanced.Cursor = System.Windows.Forms.Cursors.Default;
			formAdvanced.Close();
		}
コード例 #6
0
 internal static ESRI.ArcGIS.esriSystem.UID ToUID(this System.String id)
 {
     ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UID();
     uid.Value = id;
     return(uid);
 }
コード例 #7
0
        /// <summary>
        /// Execute the Selection Tool 
        /// </summary>
        public void ExecuteSelectionTool()
        {
            ESRI.ArcGIS.Framework.IApplication app = this.Hook as ESRI.ArcGIS.Framework.IApplication;

            // TODO: Handle Engine where the hook is a mapcontrol or toolbar control
            if (null != app)
            {
                ESRI.ArcGIS.esriSystem.UID uid = new ESRI.ArcGIS.esriSystem.UID();
                uid.Value = "esriControls.SelectFeaturesTool";

                ESRI.ArcGIS.Framework.ICommandItem selectCommand = app.Document.CommandBars.Find(uid, false, false);
                if (null != selectCommand)
                {
                    selectCommand.Execute();
                }
            }
        }
コード例 #8
0
        public IFeatureClass createFeatureClassInMemory(string strName, IFields FeatureFields, IWorkspace pWS, esriFeatureType featType)
        {
            ESRI.ArcGIS.esriSystem.UID CLSID = null;
            //ESRI.ArcGIS.esriSystem.UID CLSEXT = null;
            IFeatureWorkspace pFWS = null;

            ESRI.ArcGIS.Geodatabase.IFieldChecker   fieldChecker    = null;
            ESRI.ArcGIS.Geodatabase.IEnumFieldError enumFieldError  = null;
            ESRI.ArcGIS.Geodatabase.IFields         validatedFields = null;
            try
            {
                //CLSEXT = null;

                pFWS = (IFeatureWorkspace)pWS;


                if (CLSID == null)
                {
                    CLSID       = new ESRI.ArcGIS.esriSystem.UIDClass();
                    CLSID.Value = "esriGeoDatabase.Feature";
                }


                fieldChecker    = new ESRI.ArcGIS.Geodatabase.FieldCheckerClass();
                enumFieldError  = null;
                validatedFields = null;
                fieldChecker.ValidateWorkspace = pWS;
                fieldChecker.Validate(FeatureFields, out enumFieldError, out validatedFields);
                bool          FCCreated = false;
                IFeatureClass newFeat   = null;
                int           loopCnt   = 0;
                while (FCCreated == false)
                {
                    try
                    {
                        if (loopCnt == 0)
                        {
                            loopCnt = loopCnt + 1;
                            newFeat = pFWS.CreateFeatureClass(strName, validatedFields, null, null, featType, "SHAPE", "");
                        }
                        else
                        {
                            loopCnt = loopCnt + 1;
                            newFeat = pFWS.CreateFeatureClass(strName + (loopCnt - 1).ToString(), validatedFields, null, null, featType, "SHAPE", "");
                        }
                        FCCreated = true;
                    }
                    catch
                    {
                        FCCreated = false;
                    }
                    if (loopCnt == 100)
                    {
                        FCCreated = true;
                    }
                }
                return(newFeat);
            }
            catch
            {
                return(null);
            }
            finally
            {
                CLSID = null;

                pFWS = null;

                fieldChecker    = null;
                enumFieldError  = null;
                validatedFields = null;
            }
        }
        void formAdvanced_doneFormEvent(object sender, AdvancedEvents e)
        {
            m_pSDS.DesignMode   = true;
            formAdvanced.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            //process the algorithm if there is one
            if (e.AlgorithmName != "")
            {
                ISchematicAlgoSmartTree a = new SchematicAlgoSmartTreeClass();
                if (e.AlgorithmParams.Count > 0)
                {
                    Dictionary <string, string> .KeyCollection keys = e.AlgorithmParams.Keys;
                    string strValue = "";
                    foreach (string s in keys)
                    {
                        if (s == "Direction")
                        {
                            e.AlgorithmParams.TryGetValue(s, out strValue);

                            if (strValue == "Top to Bottom")
                            {
                                a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoTopDown;
                            }
                            else if (strValue == "Bottom to Top")
                            {
                                a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoBottomUp;
                            }
                            else if (strValue == "Left to Right")
                            {
                                a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoLeftRight;
                            }
                            else
                            {
                                a.Direction = esriSchematicAlgoDirection.esriSchematicAlgoRightLeft;
                            }
                        }
                    }
                    if (e.RootClass != "")
                    {
                        ISchematicElementClassContainer pECC = (ISchematicElementClassContainer)m_pSDS;
                        ISchematicElementClass          pEC  = pECC.GetSchematicElementClass(e.RootClass);
                        ESRI.ArcGIS.esriSystem.UID      u    = new ESRI.ArcGIS.esriSystem.UID();
                        u.Value = "{3AD9D8B8-0A1D-4F32-ABB5-54B848A46F85}";

                        ISchematicAttributeConstant   pAttrConst = (ISchematicAttributeConstant)pEC.CreateSchematicAttribute("RootFlag", u);
                        ISchematicAttributeManagement pAttrMgmt  = (ISchematicAttributeManagement)pAttrConst;
                        pAttrMgmt.StorageMode    = esriSchematicAttributeStorageMode.esriSchematicAttributeFieldStorage;
                        pAttrConst.ConstantValue = "-1";
                    }
                }

                m_pSDT.SchematicAlgorithm = (ISchematicAlgorithm)a;
            }

            //check to see if we need to add associated fields
            if (e.FieldsToCreate != null)
            {
                if (e.FieldsToCreate.Count > 0)
                {
                    ISchematicElementClassContainer pECC = (ISchematicElementClassContainer)m_pSDS;

                    //create the associated field attributes
                    string[] keys = e.FieldsToCreate.AllKeys;
                    foreach (string s in keys)
                    {
                        //get the feature class
                        ISchematicElementClass pEC = pECC.GetSchematicElementClass(s);
                        if (pEC != null)
                        {
                            string   strName = "";
                            string[] values  = e.FieldsToCreate.GetValues(s);
                            foreach (string v in values)
                            {
                                //create the field
                                ESRI.ArcGIS.esriSystem.UID u = new ESRI.ArcGIS.esriSystem.UID();
                                u.Value = "{7DE3A19D-32D0-41CD-B896-37CA3AFBD88A}";

                                IClass pClass = (IClass)pEC;
                                //only handle names that don't already exist in the schematic tables
                                if (pClass.FindField(v) == -1)
                                {
                                    strName = v.ToString();

                                    ISchematicAttributeAssociatedField pFieldAttr = (ISchematicAttributeAssociatedField)pEC.CreateSchematicAttribute(strName, u);
                                    pFieldAttr.AssociatedFieldName = v;
                                    ISchematicAttributeManagement pAttrMgmt = (ISchematicAttributeManagement)pFieldAttr;
                                    pAttrMgmt.StorageMode = esriSchematicAttributeStorageMode.esriSchematicAttributeFieldStorage;
                                }
                            }
                        }
                    }
                }
            }

            m_pSDS.Save(ESRI.ArcGIS.esriSystem.esriArcGISVersion.esriArcGISVersionCurrent, true);
            m_pSDS.DesignMode   = false;
            formAdvanced.Cursor = System.Windows.Forms.Cursors.Default;
            formAdvanced.Close();
        }