Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public TablePage()
        {
            Grid.NoDataMessage           = "No table entities";
            Grid.NoVisibleColumnsMessage = "Loading..."; // override NoVisibleColumnsMessage because we won't know the columns until the data arrives
            Grid.PropertyResolver        = ResolveProperty;

            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Delete entity", Shortcut = new KeyboardShortcut(ConsoleKey.Delete, null), CanFocus = false
            });
            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            deleteButton.Pressed.SubscribeForLifetime(BeginDeleteSelectedEntityIfExists, LifetimeManager);
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedTableEntityChanged, this.LifetimeManager);
        }
Exemplo n.º 3
0
        public ServicesPage()
        {
            CommandBar.Add(new NotificationButton(ProgressOperationManager));

            Grid.DataSource = new MemoryDataSource()
            {
                Items = new List <object>()
                {
                    new Service("containers"), new Service("tables"), new Service("queues")
                }
            };
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(Service.Name).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.SelectedItemActivated += Navigate;
        }
Exemplo n.º 4
0
        public ContainerPage()
        {
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(CloudBlob.Name).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.VisibleColumns.Add(new ColumnViewModel(SizeColumn.ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.NoDataMessage = "No blobs";

            uploadButton = CommandBar.Add(new Button()
            {
                Text = "Upload blob", Shortcut = new KeyboardShortcut(ConsoleKey.U, ConsoleModifiers.Alt)
            });
            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Delete blob", CanFocus = false, Shortcut = new KeyboardShortcut(ConsoleKey.Delete, null)
            });
            openButton = CommandBar.Add(new Button()
            {
                Text = "Open blob", CanFocus = false, Shortcut = new KeyboardShortcut(ConsoleKey.O, ConsoleModifiers.Alt)
            });

            uploadButton.Activated.SubscribeForLifetime(UploadBlob, LifetimeManager);
            deleteButton.Activated.SubscribeForLifetime(DeleteSelectedBlob, LifetimeManager);
            openButton.Activated.SubscribeForLifetime(OpenSelectedBlob, LifetimeManager);

            Grid.PropertyResolver = (o, prop) =>
            {
                if (prop == nameof(CloudBlob.Name))
                {
                    return((o as CloudBlob).Name);
                }
                else if (prop == SizeColumn)
                {
                    return(Friendlies.ToFriendlyFileSize((o as CloudBlockBlob).Properties.Length));
                }
                else
                {
                    throw new NotSupportedException("Property not supported: " + prop);
                }
            };

            CommandBar.Add(new NotificationButton(ProgressOperationManager));

            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
Exemplo n.º 5
0
        public ContainersPage()
        {
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(CloudBlobContainer.Name).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.NoDataMessage = "No containers";

            addButton = CommandBar.Add(new Button()
            {
                Text = "Add container", Shortcut = new KeyboardShortcut(ConsoleKey.A, ConsoleModifiers.Alt)
            });
            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Delete container", CanFocus = false, Shortcut = new KeyboardShortcut(ConsoleKey.Delete)
            });

            addButton.Activated.SubscribeForLifetime(AddContainer, LifetimeManager);
            deleteButton.Activated.SubscribeForLifetime(DeleteSelectedContainer, LifetimeManager);
            Grid.SelectedItemActivated += NavigateToContainer;

            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
Exemplo n.º 6
0
        public TablesPage()
        {
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(CloudTable.Name).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.NoDataMessage           = "No tables";
            Grid.NoVisibleColumnsMessage = "Loading...";
            addButton = CommandBar.Add(new Button()
            {
                Text = "Add table"
            });
            addButton.Activated.SubscribeForLifetime(AddTable, LifetimeManager);

            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Delete table", Shortcut = new KeyboardShortcut(ConsoleKey.Delete, null), CanFocus = false
            });
            deleteButton.Activated.SubscribeForLifetime(DeleteSelectedTable, LifetimeManager);


            Grid.SelectedItemActivated += NavigateToTable;

            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }