public static string GetBingMapsKey()
        {
            string exePath = Application.ResourceAssembly.Location;
            Configuration config = ConfigurationManager.OpenExeConfiguration(exePath);
            KeyValueConfigurationElement appMapKeySetting = config.AppSettings.Settings["BingMapKey"];
            if (appMapKeySetting != null)
            {
                return appMapKeySetting.Value;
            }

            BingMapsApplicationIdPromptWindow inputBingMapKeyWindow = new BingMapsApplicationIdPromptWindow();
            inputBingMapKeyWindow.Owner = Application.Current.MainWindow;
            inputBingMapKeyWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (inputBingMapKeyWindow.ShowDialog().GetValueOrDefault() && IsBingMapsKeyValid(inputBingMapKeyWindow.ApplicationId))
            {
                SaveBingMapsKey(inputBingMapKeyWindow.ApplicationId);
                return inputBingMapKeyWindow.ApplicationId;
            }
            return string.Empty;
        }
Exemplo n.º 2
0
        public static string GetBingMapsKey()
        {
            string        exePath = Application.ResourceAssembly.Location;
            Configuration config  = ConfigurationManager.OpenExeConfiguration(exePath);
            KeyValueConfigurationElement appMapKeySetting = config.AppSettings.Settings["BingMapKey"];

            if (appMapKeySetting != null)
            {
                return(appMapKeySetting.Value);
            }

            BingMapsApplicationIdPromptWindow inputBingMapKeyWindow = new BingMapsApplicationIdPromptWindow();

            inputBingMapKeyWindow.Owner = Application.Current.MainWindow;
            inputBingMapKeyWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            if (inputBingMapKeyWindow.ShowDialog().GetValueOrDefault() && IsBingMapsKeyValid(inputBingMapKeyWindow.ApplicationId))
            {
                SaveBingMapsKey(inputBingMapKeyWindow.ApplicationId);
                return(inputBingMapKeyWindow.ApplicationId);
            }
            return(string.Empty);
        }