Example #1
0
        public override void OnClick()
        {
            //Get the current extent of the active view
            IActiveView activeView = m_HookHelper.ActiveView;
            IEnvelope   envelope   = activeView.Extent;

            //Get the extension manager
            ExtensionManager extensionManager = new ExtensionManagerClass();
            //Get the extension from the extension manager
            IExtension extension = extensionManager.FindExtension("Zoom Factor Extension");

            //Get the zoom factor from the extension
            double zoomFactor = 1.1;

            if (extension != null)
            {
                IZoomExtension zoomExtension = (IZoomExtension)extension;
                zoomFactor = zoomExtension.ZoomFactor;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("The extension cannot be found!");
            }

            //Update the current extent of the active view
            envelope.Expand((System.Convert.ToDouble(1.0) / zoomFactor), (System.Convert.ToDouble(1.0) / zoomFactor), true);
            activeView.Extent = envelope;
            activeView.Refresh();
        }
Example #2
0
        private bool EnablePublisherExtension()
        {
            bool checkedOutOK = false;

            try
            {
                IExtensionManager extMgr = new ExtensionManagerClass();

                IExtensionManagerAdmin extAdmin = (IExtensionManagerAdmin)extMgr;

                UID uid = new UID();
                uid.Value = "esriPublisherUI.Publisher";
                object obj = 0;
                extAdmin.AddExtension(uid, ref obj);

                IExtensionConfig extConfig = (IExtensionConfig)extMgr.FindExtension(uid);

                if ((!(extConfig.State == esriExtensionState.esriESUnavailable)))
                {
                    //This checks on the extension
                    extConfig.State = esriExtensionState.esriESEnabled;
                    checkedOutOK    = true;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Publisher extension has failed to check out.", "Error");
            }

            return(checkedOutOK);
        }
        public override void OnClick()
        {
            //Get the extension manager
            ExtensionManager extensionManager = new ExtensionManagerClass();
            //Get the extension from the extension manager
            IExtension extension = extensionManager.FindExtension("Zoom Factor Extension");

            IZoomExtension zoomExtension = (IZoomExtension)extension;
            double         zoomFactor    = zoomExtension.ZoomFactor;

            //Get a zoom factor from the user
            InputFormResult res = InputForm.ShowModal(null, "Enter a zoom factor", "ZoomExtension Sample", zoomExtension.ZoomFactor.ToString());

            if (res.Result == DialogResult.Cancel)
            {
                return;
            }
            string zoomString = res.InputString;

            if (zoomString.Trim() == "")
            {
                return;
            }

            //Set the zoom factor
            if (System.Char.IsNumber(zoomString, 0) == true)
            {
                zoomExtension.ZoomFactor = System.Convert.ToDouble(zoomString);
            }
        }
        private bool EnablePublisherExtension()
        {

            bool checkedOutOK = false;

            try
            {
                IExtensionManager extMgr = new ExtensionManagerClass();

                IExtensionManagerAdmin extAdmin = (IExtensionManagerAdmin)extMgr;

                UID uid = new UID();
                uid.Value = "esriPublisherUI.Publisher";
                object obj = 0;
                extAdmin.AddExtension(uid, ref obj);

                IExtensionConfig extConfig = (IExtensionConfig)extMgr.FindExtension(uid);

                if ((!(extConfig.State == esriExtensionState.esriESUnavailable)))
                {
                    //This checks on the extension
                    extConfig.State = esriExtensionState.esriESEnabled;
                    checkedOutOK = true;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Publisher extension has failed to check out.", "Error");
            }

            return checkedOutOK;
        } 
		public override void OnClick()
		{
			//Get the current extent of the active view
			IActiveView activeView = m_HookHelper.ActiveView;
			IEnvelope envelope = activeView.Extent;

			//Get the extension manager
			ExtensionManager extensionManager = new ExtensionManagerClass();
			//Get the extension from the extension manager
			IExtension extension = extensionManager.FindExtension("Zoom Factor Extension");

			//Get the zoom factor from the extension
			double zoomFactor = 1.1;
			if (extension != null)
			{
				IZoomExtension zoomExtension = (IZoomExtension) extension;
				zoomFactor = zoomExtension.ZoomFactor;
			}
			else
			{
				System.Windows.Forms.MessageBox.Show("The extension cannot be found!");
			}

			//Update the current extent of the active view
			envelope.Expand((System.Convert.ToDouble(1.0)/ zoomFactor), (System.Convert.ToDouble(1.0) / zoomFactor), true);
			activeView.Extent = envelope;
			activeView.Refresh();
		}
		public override void OnClick()
		{
			//Get the extension manager
			ExtensionManager extensionManager = new ExtensionManagerClass();
			//Get the extension from the extension manager
			IExtension extension = extensionManager.FindExtension("Zoom Factor Extension");

			IZoomExtension zoomExtension = (IZoomExtension) extension;
			double zoomFactor = zoomExtension.ZoomFactor;

			//Get a zoom factor from the user
			InputFormResult res = InputForm.ShowModal(null,"Enter a zoom factor","ZoomExtension Sample", zoomExtension.ZoomFactor.ToString() );

			if (res.Result == DialogResult.Cancel) return;
			string zoomString = res.InputString;
			if (zoomString.Trim() == "") return;

			//Set the zoom factor
			if (System.Char.IsNumber(zoomString,0) == true) zoomExtension.ZoomFactor = System.Convert.ToDouble(zoomString);
		}