예제 #1
0
파일: SnapEx.cs 프로젝트: 605258778/GISData
 public override void OnClick()
 {
     this._command.OnClick();
     this._cursor       = this._tool.Cursor;
     this._lineFeedback = null;
     this._bStarted     = false;
     this._bFinished    = false;
     this._bMouse       = false;
     try
     {
         IEngineSnapEnvironment engineEditor = Editor.UniqueInstance.EngineEditor as IEngineSnapEnvironment;
         engineEditor.SnapTolerance = 1.0;
         (Editor.UniqueInstance.EngineEditor as IEngineEditEvents_Event).OnSketchModified += (new IEngineEditEvents_OnSketchModifiedEventHandler(this.editEvents_OnSketchModified));
         IHookHelper2      helper           = this._hookHelper as IHookHelper2;
         IExtensionManager extensionManager = helper.ExtensionManager;
         if (extensionManager != null)
         {
             UID nameOrID = new UIDClass {
                 Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"
             };
             IExtension extension = extensionManager.FindExtension(nameOrID);
             this._snappingEnv  = extension as ISnappingEnvironment;
             this._snapFeedback = new SnappingFeedbackClass();
             this._snapFeedback.Initialize(this._hookHelper.Hook, this._snappingEnv, true);
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
        private void Toggle3DExtension(string strState)
        {
            try
            {
                IExtensionManagerAdmin pExtAdmin2   = new ExtensionManagerClass();
                IExtensionManager      pExtManager2 = pExtAdmin2 as IExtensionManager;
                UID pUID = new UID();
                pUID.Value = "{94305472-592E-11D4-80EE-00C04FA0ADF8}";
                IExtensionConfig pExtConfig2 = pExtManager2.FindExtension(pUID) as IExtensionConfig;

                switch (strState)
                {
                case "ON":
                    pExtConfig2.State = esriExtensionState.esriESEnabled;
                    break;

                case "OFF":
                    pExtConfig2.State = esriExtensionState.esriESDisabled;
                    break;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        private static void EnableEsriLiscences()
        {
            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
            ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);

            UID pUid = new UIDClass();

            pUid.Value = "esriSpatialAnalystUI.SAExtension";

            // Add Spatial Analyst extension to the license manager.
            object v = null;
            IExtensionManagerAdmin extensionManagerAdmin = new ExtensionManagerClass();

            extensionManagerAdmin.AddExtension(pUid, ref v);

            // Enable the license.
            IExtensionManager extensionManager = (IExtensionManager)extensionManagerAdmin;
            IExtension        extension        = extensionManager.FindExtension(pUid);
            IExtensionConfig  extensionConfig  = (IExtensionConfig)extension;

            if (extensionConfig.State != esriExtensionState.esriESUnavailable)
            {
                extensionConfig.State = esriExtensionState.esriESEnabled;
            }
            else
            {
                Console.WriteLine("No Spatial Analyst License available");
            }
        }
        private void chkExtension_CheckedChanged(object sender, System.EventArgs e)
        {
            //Get the extension manager
            IExtensionManager extensionManager = (IExtensionManager)m_ExtensionManagerAdmin;
            //Get the extension from the extension manager
            IExtensionConfig extensionConfig = (IExtensionConfig)extensionManager.FindExtension("Zoom Factor Extension");

            //Set the enabled state
            if (chkExtension.CheckState == CheckState.Checked)
            {
                extensionConfig.State = esriExtensionState.esriESEnabled;
            }
            else
            {
                extensionConfig.State = esriExtensionState.esriESDisabled;
            }
        }
예제 #5
0
        private void ToggleSA(bool toggle)
        {
            UID puid = new UID();

            puid.Value = "esriGeoAnalyst.SAExtension.1";

            object v = 0;
            IExtensionManagerAdmin pLicAdmin = new ExtensionManagerClass();

            pLicAdmin.AddExtension(puid, ref v);

            IExtensionManager pLicManager      = pLicAdmin as IExtensionManager;
            IExtensionConfig  pExtensionConfig = pLicManager.FindExtension(puid) as IExtensionConfig;

            if (toggle)
            {
                pExtensionConfig.State = esriExtensionState.esriESEnabled;
            }
            else
            {
                pExtensionConfig.State = esriExtensionState.esriESDisabled;
            }
        }
예제 #6
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;

            // TODO:  Add ToolNewDisplacement.OnCreate implementation
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            //m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
            //m_FrmVectorLinkTable.OriginPoints = OriginPoints;
            //m_FrmVectorLinkTable.TargetPoints = TargetPoints;
            m_FrmVectorLinkTable.IMUFeatureList             = m_IMUFeatureList;
            m_FrmVectorLinkTable.CenterlinePointFeatureList = m_CenterlinePointFeatureList;
            m_FrmVectorLinkTable.MapCtr = pMapCtr;
            //m_FrmVectorLinkTable.refreshLayer += new RefreshEvent(RefreshLayer);

            if (m_FrmVectorLinkTable != null)
            {
                m_FrmVectorLinkTable.Owner =
                    System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
            }

            IExtensionManager extensionManager = ((IHookHelper2)m_hookHelper).ExtensionManager;
            UID guid = new UIDClass();

            guid.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"; //Snapping extension.
            IExtension extension = extensionManager.FindExtension(guid);

            m_SnappingEnvironment = extension as ISnappingEnvironment;

            m_snappingFeed = new SnappingFeedbackClass();
            m_snappingFeed.Initialize(hook, m_SnappingEnvironment, true);
        }
예제 #7
0
        private bool method_2()
        {
            bool result;

            try
            {
                IExtensionManagerAdmin extensionManagerAdmin = new ExtensionManager() as IExtensionManagerAdmin;
                UID uID = new UID();
                uID.Value = "esriGeoDatabase.DddServerEnvironment";
                object obj = null;
                extensionManagerAdmin.AddExtension(uID, ref obj);
                IExtensionManager extensionManager = extensionManagerAdmin as IExtensionManager;
                IExtensionConfig  extensionConfig  = extensionManager.FindExtension(uID) as IExtensionConfig;
                extensionConfig.State = esriExtensionState.esriESEnabled;
                result = true;
                return(result);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            result = false;
            return(result);
        }