예제 #1
0
        public StorageAccountsPage()
        {
            Grid.DataSource = new MemoryDataSource()
            {
                Items = new List <object>(StorageAccountInfo.Load())
            };
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(StorageAccountInfo.AccountName).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(StorageAccountInfo.Key).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(StorageAccountInfo.UseHttps).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.NoDataMessage = "No storage accounts";
            Grid.KeyInputReceived.SubscribeForLifetime(HandleGridDeleteKeyPress, this.LifetimeManager);
            addButton = CommandBar.Add(new Button()
            {
                Text = "Add account", Shortcut = new KeyboardShortcut(ConsoleKey.A, ConsoleModifiers.Alt)
            });
            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Forget account", CanFocus = false, Shortcut = new KeyboardShortcut(ConsoleKey.F, ConsoleModifiers.Alt)
            });
            CommandBar.Add(new NotificationButton(ProgressOperationManager));

            addButton.Activated.SubscribeForLifetime(AddStorageAccount, LifetimeManager);
            deleteButton.Activated.SubscribeForLifetime(ForgetSelectedStorageAccount, LifetimeManager);

            Grid.SelectedItemActivated += NavigateToStorageAccount;
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
예제 #2
0
        protected override void OnLoad()
        {
            base.OnLoad();
            var accountName = RouteVariables["account"];
            var accountInfo = (from account in StorageAccountInfo.Load() where account.AccountName == accountName select account).FirstOrDefault();

            currentStorageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountInfo.Key), accountInfo.UseHttps);
            Grid.DataSource       = new ContainerListDataSource(currentStorageAccount.CreateCloudBlobClient(), Application.MessagePump);
        }
예제 #3
0
        private void ForgetSelectedStorageAccount()
        {
            var selectedAccount = Grid.SelectedItem as StorageAccountInfo;

            Dialog.ConfirmYesOrNo("Are you sure you want to forget storage account " + selectedAccount.AccountName, () =>
            {
                (Grid.DataSource as MemoryDataSource).Items.Remove(selectedAccount);
                StorageAccountInfo.Save((Grid.DataSource as MemoryDataSource).Items);
                PageStack.TryRefresh();
            });
        }
예제 #4
0
        protected override void OnLoad()
        {
            base.OnLoad();
            var accountName = RouteVariables["account"];
            var tableName   = RouteVariables["table"];
            var accountInfo = (from account in StorageAccountInfo.Load() where account.AccountName == accountName select account).FirstOrDefault();

            currentStorageAccount = new CloudStorageAccount(new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(accountName, accountInfo.Key), accountInfo.UseHttps);
            table                        = currentStorageAccount.CreateCloudTableClient().GetTableReference(tableName);
            Grid.DataSource              = new TableEntityDataSource(currentStorageAccount.CreateCloudTableClient().GetTableReference(tableName), Application);
            Grid.DataSource.DataChanged += OnDataLoad;
        }
예제 #5
0
 private void AddStorageAccount()
 {
     Dialog.ShowTextInput("Enter storage account name".ToConsoleString(), (name) =>
     {
         Dialog.ShowTextInput("Enter storage account key".ToConsoleString(), (key) =>
         {
             var data = (Grid.DataSource as MemoryDataSource).Items;
             data.Add(new StorageAccountInfo()
             {
                 AccountName = name.ToString(), Key = key.ToString(), UseHttps = true
             });
             StorageAccountInfo.Save(data);
             (Grid.DataSource as MemoryDataSource).Invalidate();
         });
     });
 }