Example #1
0
        public AddAPIKeyDlg(apiKeyViewModel vm)
        {
            if (vm != null)
            kvm = vm;

             InitializeComponent();
        }
Example #2
0
        private void doProcess(object sender, RoutedEventArgs e)
        {
            try
             {
            APIObject api = null;

            if (SelectedKey == null)
            {
               MessageBox.Show("Error: SelectedKey is NULL.");
               return;
            }

            if (SelectedKey.Characters.Count > 0)
            {
               if (SelectedKey.Characters.Count == 1)
               {
                  SelectedKey.ActorID = SelectedKey.Characters[0].characterID.ToString(CultureInfo.InvariantCulture);
               }
               else
               {
                  Plugins.AccountManager.SelectCharacterDlg dlg
                     = new Plugins.AccountManager.SelectCharacterDlg(SelectedKey.Characters);

                  dlg.ShowDialog();
                  if (dlg.DialogResult == true)
                  {
                     SelectedKey.ActorID = dlg.SelectedCharacter.characterID.ToString(CultureInfo.InvariantCulture);
                  }
               }
            }

            if (APICalls[apiBox.SelectedIndex].Contains("ImageServer"))
            {
               apiKeyViewModel keyInfo = new apiKeyViewModel(SelectedKey.ID, SelectedKey.vCode);
               keyInfo.Refresh();

               api = new ImageServer(keyInfo.KeyType == "Corporation" ? ImageServer.ImageType.Corporation : ImageServer.ImageType.Character, 256, SelectedKey.ActorID);
               api.Query();
            }
            else
            {
               api = AppTemplate.Utilities.ObjectFactory<APIObject>.Instance.Create(APICalls[apiBox.SelectedIndex]);

               api.actorID = SelectedKey.ActorID;
               api.vCode = SelectedKey.vCode;
               api.keyID = SelectedKey.ID;

               api.Query();
            }

            propertyGrid.SelectedObject = api;

            if (api is ImageServer)
            {
               ImagePathConverter ipc = new ImagePathConverter();

               SelectedImagePath = System.IO.Path.GetFullPath((api as ImageServer).FileName);
               imageView.Source = ipc.Convert(SelectedImagePath, null, null, null) as ImageSource;
               imageView.Height = imageView.Source.Height;
               imageView.Width = imageView.Source.Width;
            }
            else
            {
               xmlViewer.Load((api as IAPIReader).CacheFile);
               foldingStrategy.UpdateFoldings(foldingManager, xmlViewer.Document);
            }
             }
             catch (ArgumentException)
             {
            MessageBox.Show("This API call requires additional arguments which this test utility is not prepared to provide.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             catch (Exception ex)
             {
            MessageBox.Show("Unexpected error. Details: " + ex.Format(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
        }