コード例 #1
0
        private void AddStorageAccount_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            AddAccountDialog dlg = new AddAccountDialog(false);

            dlg.Owner = MainWindow.Window;
            dlg.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            dlg.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
            if (dlg.ShowDialog().Value)
            {
                try
                {
                    string name     = dlg.AccountName.Text;
                    string key      = dlg.AccountKey.Text;
                    bool   useHttps = dlg.UseHttps.IsChecked.Value;
                    bool   proceed  = false;

                    if (name == "DevStorage")
                    {
                        if (!DeveloperStorageRunning())
                        {
                            MessageBox.Show("Windows Azure Developer Storage is not running.\r\n\r\nThe process DSService.exe is not detected", "Developer Storage Not Detected", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                            return;
                        }
                        proceed = true;
                    }
                    else
                    {
                        if (MessageBox.Show("Please note, the first time your blob containers are scanned there may be a wait of several minutes if any old format containers are encountered. They will be automatically upgraded to current Azure standards.\r\n\r\nFor more information, see http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/5926f6dc-2e46-4654-a3c9-b397d0598a16",
                                            "New Storage Account", MessageBoxButton.OKCancel, MessageBoxImage.Information)
                            == MessageBoxResult.OK)
                        {
                            proceed = true;
                        }
                    }

                    if (proceed)
                    {
                        StorageAccountsComboBox.SelectedItem = ViewModel.AddAccount(name, key, useHttps, false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred saving the configuration.\r\n\r\n" + ex.ToString(),
                                    "Could Not Save Configuration", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
コード例 #2
0
 private async void Add_Click(object sender, RoutedEventArgs e)
 {
     AccountViewModel.account = new Account();
     AddAccountDialog md = new AddAccountDialog(AccountViewModel);
     await md.ShowAsync();
 }
コード例 #3
0
        private void EditStorageAccount_Click(object sender, RoutedEventArgs e)
        {
            if (StorageAccountsComboBox.SelectedIndex <= 0 || StorageAccountsComboBox.SelectedItem == null)
            {
                MessageBox.Show("Please select a storage account to edit.", "Selection Required", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            AccountViewModel avm = StorageAccountsComboBox.SelectedItem as AccountViewModel;

            AddAccountDialog dlg = new AddAccountDialog(true);

            dlg.Owner = MainWindow.Window;
            dlg.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            dlg.VerticalAlignment   = System.Windows.VerticalAlignment.Center;

            string oldName = avm.AccountName;

            dlg.AccountName.Text   = avm.AccountName;
            dlg.AccountKey.Text    = avm.Key;
            dlg.UseHttps.IsChecked = avm.UseHttps;
            if (avm.AccountName == "DevStorage")
            {
                dlg.DevStorage.IsChecked = true;
            }

            if (dlg.ShowDialog().Value)
            {
                try
                {
                    string name     = dlg.AccountName.Text;
                    string key      = dlg.AccountKey.Text;
                    bool   useHttps = dlg.UseHttps.IsChecked.Value;
                    bool   proceed  = false;

                    if (name == "DevStorage")
                    {
                        if (!DeveloperStorageRunning())
                        {
                            MessageBox.Show("Windows Azure Developer Storage is not running.\r\n\r\nThe process DSService.exe is not detected", "Developer Storage Not Detected", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                            return;
                        }
                        proceed = true;
                    }
                    else
                    {
                        proceed = true;
                    }

                    if (proceed)
                    {
                        avm.AccountName = name;
                        avm.Key         = key;
                        avm.UseHttps    = useHttps;
                        StorageAccountsComboBox.SelectedItem = ViewModel.UpdateAccount(avm);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occurred saving the configuration.\r\n\r\n" + ex.ToString(),
                                    "Could Not Save Configuration", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }