示例#1
0
 void HandleAuthenticationStateChangeEvent(object sender, Extension.Auth.AuthenticationStateChangeEventArgs e)
 {
     // an authentication event occured, determine which one and act accordingly
     if (e.isAuthorized && ext.isExtensionEnabled() &&
         ext.hasAtLeastOneLayer())
     {
         // the user is authorized, verify the button is also enabled
         log.Debug("Extension is enabled, enable button and check to verify the user has an auth token.");
         this.Enabled = true;
     }
     else
     {
         // unsupress/uncheck the button
         this.Enabled = false;
     }
 }
 void HandleSelectionChange(object sender, Extension.SelectionChangeEventArgs e)
 {
     // check to see if there is a map feature selected
     log.Debug("Verifying map feature selected.");
     if (e.isSelected)
     {
         // verify the extension is enabled and there is auth
         // also, only when there is one feature selected...do not handle multiple features
         if (ext.isExtensionEnabled() && ext.isAuthorizationAvailable() && e.selectedFeaturesCount == 1)
         {
             // there is a map feature selected, enable this button for user to click
             log.Debug("there is a map feature selected, enable this button for user to click");
             this.Enabled = true;
         }
         else
         {
             // the extension or authorization is not enabled, diable button
             log.Debug("the extension or authorization is not enabled, diable button.");
             this.Enabled = false;
         }
     }
     else
     {
         // disable this button as no feature selected
         log.Debug("There is no feature selected, disable button.");
         this.Enabled = false;
     }
 }
        public ToolsCommand_FindAsset()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_FindAsset initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (!ext.isExtensionEnabled())
            {
                this.Enabled = false;
            }
            else
            {
                if (!ext.isAuthorizationAvailable())
                {
                    this.Enabled = false;
                }
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;
        }
        public ToolsCommand_FindAsset()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_FindAsset initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (!ext.isExtensionEnabled())
            {
                this.Enabled = false;
            }
            else
            {
                if (!ext.isAuthorizationAvailable())
                    this.Enabled = false;
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;
        }
示例#5
0
 protected override void OnClick()
 {
     // check to see if the extension is enabled
     log.Debug("Verifying extension is enabled.");
     if (ext.isExtensionEnabled())
     {
         ext.clearToken();
     }
 }
        public ToolsCommand_UploadToGoogleMapsEngine()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_UploadToGoogleEarthBuilder initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (ext.isExtensionEnabled())
            {
                // the extension is enabled, verify the button is also enabled
                log.Debug("Extension is enabled, enable button and check to verify the user has an auth token.");
                this.Enabled = true;

                // check to see if the user has an auth code
                log.Debug("Checking to see if the user has an OAuth code");
                if (ext.isAuthorizationAvailable() && !ext.getToken().isViewOnly
                    && ext.hasAtLeastOneLayer())
                {
                    // the user has an OAuth code available for use
                    log.Debug("User has an OAuth code available. Check the button.");
                    this.Enabled = true;
                }
                else
                {
                    // the user does not have an OAuth code available for use
                    log.Debug("User does not have an OAuth code available. Uncheck the button.");
                    this.Enabled = false;
                }
            }
            else
            {
                // disable this button
                log.Debug("The extension is disabled, disable this button.");
                this.Enabled = false;
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;

            // subscribe to map layer selection change events through the extension
            ext.RaiseMapLayerStateChangeEvent += HandleMapLayerSelectionStateChangeEvent;
        }
        public ToolsCommand_UploadToGoogleMapsEngine()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_UploadToGoogleEarthBuilder initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (ext.isExtensionEnabled())
            {
                // the extension is enabled, verify the button is also enabled
                log.Debug("Extension is enabled, enable button and check to verify the user has an auth token.");
                this.Enabled = true;

                // check to see if the user has an auth code
                log.Debug("Checking to see if the user has an OAuth code");
                if (ext.isAuthorizationAvailable() && !ext.getToken().isViewOnly &&
                    ext.hasAtLeastOneLayer())
                {
                    // the user has an OAuth code available for use
                    log.Debug("User has an OAuth code available. Check the button.");
                    this.Enabled = true;
                }
                else
                {
                    // the user does not have an OAuth code available for use
                    log.Debug("User does not have an OAuth code available. Uncheck the button.");
                    this.Enabled = false;
                }
            }
            else
            {
                // disable this button
                log.Debug("The extension is disabled, disable this button.");
                this.Enabled = false;
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;

            // subscribe to map layer selection change events through the extension
            ext.RaiseMapLayerStateChangeEvent += HandleMapLayerSelectionStateChangeEvent;
        }
示例#8
0
        protected override void OnClick()
        {
            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            GoogleMapsEngineToolsExtensionForArcGIS ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (ext.isExtensionEnabled())
            {
                Extension.Dialogs.Settings.Preferences preferencesForm = new Extension.Dialogs.Settings.Preferences();
                preferencesForm.Show();
            }
        }
 void HandleMapLayerSelectionStateChangeEvent(object sender, Extension.MapLayerStateChangeEventArgs e)
 {
     // check to see if the extension is enabled
     log.Debug("Verifying extension is enabled.");
     if (e.isLayerSelected && ext.isExtensionEnabled() &&
         ext.isAuthorizationAvailable() && !ext.getToken().isViewOnly)
     {
         // the extension is enabled, verify the button is also enabled
         log.Debug("Extension is enabled, enable button and check to verify the user has an auth token.");
         this.Enabled = true;
     }
     else
     {
         // disable this button
         log.Debug("The extension is disabled, disable this button.");
         this.Enabled = false;
     }
 }
        protected override void OnClick()
        {
            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            GoogleMapsEngineToolsExtensionForArcGIS ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (ext.isExtensionEnabled())
            {
                // initialize the About form
                log.Info("Initializing dialogs.settings.About and showing it.");
                Extension.Dialogs.Settings.About aboutForm = new Extension.Dialogs.Settings.About();

                // make the about form visible
                aboutForm.Show();
            }
        }
示例#11
0
        public ToolsCommand_UserSignout()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_UserSignout initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (!ext.isExtensionEnabled())
            {
                // the extension is not enabled, diable the button
                log.Debug("Disabling the sign-out button, as the extension is disabled.");
                this.Enabled = false;
            }
            else
            {
                // by default, if there is no auth object, disable sign-out
                log.Debug("Extension enabled, checking to see if there is a valid auth token.");
                if (ext.isAuthorizationAvailable())
                {
                    // there is an auth token, verify the button is enabled
                    log.Debug("The auth token is available, setting the button to enabled.");
                    this.Enabled = true;
                }
                else
                {
                    // there is no auth token, setting the button to disabled
                    log.Debug("The auth token isn't available, disabling the sign-out button.");
                    this.Enabled = false;
                }
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;
        }
        public ToolsCommand_UserSignout()
        {
            // initialize and configure log4net, reading from Xml .config file
            log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));

            log.Info("ToolsCommand_UserSignout initializing.");

            // to check the state of the extension, get the extension
            log.Info("Retrieving a reference to the extension object to check state.");
            ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

            // check to see if the extension is enabled
            log.Debug("Verifying extension is enabled.");
            if (!ext.isExtensionEnabled())
            {
                // the extension is not enabled, diable the button
                log.Debug("Disabling the sign-out button, as the extension is disabled.");
                this.Enabled = false;
            }
            else
            {
                // by default, if there is no auth object, disable sign-out
                log.Debug("Extension enabled, checking to see if there is a valid auth token.");
                if (ext.isAuthorizationAvailable())
                {
                    // there is an auth token, verify the button is enabled
                    log.Debug("The auth token is available, setting the button to enabled.");
                    this.Enabled = true;
                }
                else
                {
                    // there is no auth token, setting the button to disabled
                    log.Debug("The auth token isn't available, disabling the sign-out button.");
                    this.Enabled = false;
                }
            }

            // subscribe to extension state change events through the extension
            ext.RaiseExtensionStateChangeEvent += HandleExtensionStateChange;

            // subscribe to Authentication state change events through the extension
            ext.RaiseAuthenticationStateChangeEvent += HandleAuthenticationStateChangeEvent;
        }
        protected override void OnClick()
        {
            try
            {
                // to check the state of the extension, get the extension
                log.Info("Retrieving a reference to the extension object to check state.");
                GoogleMapsEngineToolsExtensionForArcGIS ext = GoogleMapsEngineToolsExtensionForArcGIS.GetExtension();

                // check to see if the extension is enabled
                log.Debug("Verifying extension is enabled.");
                if (ext.isExtensionEnabled())
                {
                    // create an update check object
                    log.Debug("Creating an update check object.");
                    Extension.Update.ExtensionUpdateCheck updateCheck = new Extension.Update.ExtensionUpdateCheck();

                    // check to see if there is an update available
                    log.Debug("Checking to see if there is an update available.");
                    if (updateCheck.isUpdateAvailable())
                    {
                        log.Debug("isUpdateAvailable = true");

                        // create a dialog to inform the user of an update
                        log.Debug("Showing the user an OK/Cancel dialog to notify them of an update.");
                        if (System.Windows.Forms.MessageBox.Show("An update to the Google Maps Engine Tools for ArcGIS is avaiable.  Would you like to update the Add-in now?"
                                                                 , "Update Available (" + updateCheck.getLocalVersion().ToString() + " < " + updateCheck.getServerVersion().ToString() + ")"
                                                                 , System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
                        {
                            // launch browser at the URL provided in the update check
                            log.Debug("Launching the browser to the update URL, as the user selected OK.");
                            System.Diagnostics.Process.Start(updateCheck.getUpdateURI());
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                // an error occured
                log.Error(ex);
            }
        }