Inheritance: ConsoleControl
        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.Pressed.SubscribeForLifetime(UploadBlob, LifetimeManager);
            deleteButton.Pressed.SubscribeForLifetime(DeleteSelectedBlob, LifetimeManager);
            openButton.Pressed.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);
        }
Example #2
0
 public Dialog(ConsoleControl content)
 {
     Add(content).Fill(padding: new Thickness(0, 0, 1, 1));
     closeButton = Add(new Button() { Text = "Close (ESC)",Background = Theme.DefaultTheme.H1Color, Foreground = ConsoleColor.Black }).DockToRight(padding: 1);
     closeButton.Pressed.SubscribeForLifetime(Escape, this.LifetimeManager);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this.LifetimeManager);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this.LifetimeManager);
 }
Example #3
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);
        }
        public NotificationButton(ProgressOperationsManager manager)
        {
            this.manager = manager;

            launcher = Add(new Button());
            launcher.Shortcut = new KeyboardShortcut(ConsoleKey.N, ConsoleModifiers.Alt);
            launcher.Pressed.SubscribeForLifetime(NotificationButton_Activated, LifetimeManager);
            launcherFg = launcher.Foreground;
            spinner = Add(new Spinner() { IsVisible = false, IsSpinning = false, CanFocus = false, X = 1, Foreground = ConsoleColor.Cyan });
            Manager_ProgressOperationsChanged();
            manager.ProgressOperationsChanged += Manager_ProgressOperationsChanged;
            this.AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
        }
        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.Pressed.SubscribeForLifetime(AddContainer, LifetimeManager);
            deleteButton.Pressed.SubscribeForLifetime(DeleteSelectedContainer, LifetimeManager);
            Grid.SelectedItemActivated += NavigateToContainer;

            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
        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.Pressed.SubscribeForLifetime(AddTable, LifetimeManager);

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

            Grid.SelectedItemActivated += NavigateToTable;

            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
        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.Pressed.SubscribeForLifetime(AddStorageAccount, LifetimeManager);
            deleteButton.Pressed.SubscribeForLifetime(ForgetSelectedStorageAccount, LifetimeManager);

            Grid.SelectedItemActivated += NavigateToStorageAccount;
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
Example #8
0
        public static void ShowMessage(ConsoleString message, Action<DialogButton> resultCallback, bool allowEscapeToCancel = true, int maxHeight = 6, params DialogButton [] buttons)
        {
            if(buttons.Length == 0)
            {
                throw new ArgumentException("You need to specify at least one button");
            }

            ConsolePanel dialogContent = new ConsolePanel();

            Dialog dialog = new Dialog(dialogContent);
            dialog.MaxHeight = maxHeight;
            dialog.AllowEscapeToCancel = allowEscapeToCancel;
            dialog.Cancelled.SubscribeForLifetime(() => { resultCallback(null); }, dialog.LifetimeManager);

            ScrollablePanel messagePanel = dialogContent.Add(new ScrollablePanel()).Fill(padding: new Thickness(0, 0, 1, 3));
            Label messageLabel = messagePanel.ScrollableContent.Add(new Label() { Mode = LabelRenderMode.MultiLineSmartWrap, Text = message }).FillHoriontally(padding: new Thickness(3,3,0,0) );

            StackPanel buttonPanel = dialogContent.Add(new StackPanel() { Margin = 1, Height = 1, Orientation = Orientation.Horizontal }).FillHoriontally(padding: new Thickness(1,0,0,0)).DockToBottom(padding: 1);

            Button firstButton = null;
            foreach (var buttonInfo in buttons)
            {
                var myButtonInfo = buttonInfo;
                Button b = new Button() { Text = buttonInfo.DisplayText };
                b.Pressed.SubscribeForLifetime(() =>
                {
                    ConsoleApp.Current.LayoutRoot.Controls.Remove(dialog);
                    resultCallback(myButtonInfo);
                }, dialog.LifetimeManager);
                buttonPanel.Controls.Add(b);
                firstButton = firstButton ?? b;
            }
            ConsoleApp.Current.LayoutRoot.Controls.Add(dialog);
        }