Пример #1
0
        public ProgressOperationControl(ProgressOperationsManager manager, ProgressOperation operation)
        {
            this.Tag                  = operation;
            this.Operation            = operation;
            this.manager              = manager;
            this.Height               = 2;
            messageAndOperationsPanel = Add(new StackPanel()
            {
                Orientation = Orientation.Vertical
            }).Fill();

            messageLabel = messageAndOperationsPanel.Add(new Label()
            {
                Mode = LabelRenderMode.ManualSizing
            }).FillHorizontally();
            messageLabel.CanFocus = true;

            messageLabel.KeyInputReceived.SubscribeForLifetime((k) =>
            {
                if (k.Key == ConsoleKey.Enter)
                {
                    var msg = operation.Message;
                    if (operation.Details != null)
                    {
                        msg += "\n" + operation.Details;
                    }
                    Dialog.ShowMessage(msg);
                }
                else if (k.Key == ConsoleKey.Delete)
                {
                    var app = Application;
                    manager.Operations.Remove(operation);
                    app.FocusManager.TryMoveFocus();
                }
            }, this);


            actionPanel = messageAndOperationsPanel.Add(new StackPanel()
            {
                Orientation = Orientation.Horizontal, Height = 1, Margin = 2
            }).FillHorizontally(messageAndOperationsPanel);
            spinner = actionPanel.Add(new Spinner()
            {
                CanFocus = false
            });
            timeLabel = actionPanel.Add(new Label()
            {
                Mode = LabelRenderMode.SingleLineAutoSize, Text = operation.StartTime.ToFriendlyPastTimeStamp().ToConsoleString()
            });


            spinner.IsSpinning = operation.State == OperationState.InProgress;

            foreach (var action in operation.Actions)
            {
                BindActionToActionPanel(action);
            }

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
        }
Пример #2
0
 public FramerateControl(SpacetimePanel scene)
 {
     this.scene    = scene;
     this.AutoSize = true;
     nowControl    = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     sceneFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     renderFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     paintFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     sceneBusyPercentageLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     AddedToVisualTree.SubscribeForLifetime(SetupPolling, this);
 }
Пример #3
0
        public LineChart()
        {
            ViewModel = new LineChartViewModel();

            YAxisLeftOffset = 14;
            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
            KeyInputReceived.SubscribeForLifetime(OnKeyInputReceived, this.LifetimeManager);
        }
Пример #4
0
        internal void AddedToVisualTreeInternal()
        {
            if (hasBeenAddedToVisualTree)
            {
                throw new ObjectDisposedException(Id, "This control has already been added to a visual tree and cannot be reused.");
            }

            hasBeenAddedToVisualTree = true;
            AddedToVisualTree.Fire();
            SubscribeForLifetime(ObservableObject.AnyProperty, Application.Paint, this.LifetimeManager);
        }
Пример #5
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.Activated.SubscribeForLifetime(Escape, this.LifetimeManager);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this.LifetimeManager);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this.LifetimeManager);
 }
Пример #6
0
 private Dialog(DialogOptions options)
 {
     this.options = options;
     Add(options.GetContent()).Fill(padding: new Thickness(0, 0, 1, 1));
     closeButton = Add(new Button()
     {
         Text = "Close (ESC)".ToConsoleString(), Background = DefaultColors.H1Color, Foreground = ConsoleColor.Black
     }).DockToRight(padding: 1);
     closeButton.Pressed.SubscribeForLifetime(Escape, this);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
 }
Пример #7
0
 public Dialog(ConsoleControl content)
 {
     Add(content).Fill(padding: new Thickness(0, 0, 1, 1));
     AllowEscapeToCancel = true;
     closeButton         = Add(new Button()
     {
         Text = "Close (ESC)".ToConsoleString(), Background = DefaultColors.H1Color, Foreground = ConsoleColor.Black
     }).DockToRight(padding: 1);
     closeButton.Pressed.SubscribeForLifetime(Escape, this);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
 }
Пример #8
0
        public PowerArgsGamesIntro() : base(52, 7)
        {
            Background = ConsoleColor.Black;
            factory    = new SceneFactory(new List <ItemReviver>()
            {
                new LetterReviver()
            });
            AddedToVisualTree.SubscribeOnce(() =>
            {
                this.CenterBoth();

                Application.FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.Enter, null, () =>
                {
                    Cleanup();
                }, this);
            });
        }
 public FramerateControl(Scene scene)
 {
     this.scene    = scene;
     this.AutoSize = true;
     sceneFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHoriontally();
     renderFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHoriontally();
     paintFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHoriontally();
     AddedToVisualTree.SubscribeForLifetime(SetupPolling, this.LifetimeManager);
 }
Пример #10
0
        public ScrollablePanel()
        {
            ScrollableContent = Add(new ConsolePanel()
            {
                IsVisible = false
            }).Fill();

            verticalScrollbar = Add(new Scrollbar(Orientation.Vertical)
            {
                Width = 1
            }).DockToRight();
            horizontalScrollbar = Add(new Scrollbar(Orientation.Horizontal)
            {
                Height = 1
            }).DockToBottom();

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
            RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this.LifetimeManager);
        }
Пример #11
0
        public ScrollablePanel()
        {
            ScrollableContent = Add(new ConsolePanel()
            {
                IsVisible = true
            }).Fill();
            SynchronizeForLifetime(nameof(Background), () => ScrollableContent.Background = Background, this);
            verticalScrollbar = Add(new Scrollbar(Orientation.Vertical)
            {
                Width = 1
            }).DockToRight();
            horizontalScrollbar = Add(new Scrollbar(Orientation.Horizontal)
            {
                Height = 1
            }).DockToBottom();

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
            RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
        }
Пример #12
0
 public FramerateControl(SpaceTimePanel scene)
 {
     this.scene    = scene;
     this.AutoSize = true;
     nowControl    = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     elementsControl = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     functionsControl = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     renderFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     paintFPSLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     sleepTimeLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     zeroSpinsLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     nonZeroSpinsLabel = Add(new Label()
     {
         Text = "".ToConsoleString()
     }).FillHorizontally();
     AddedToVisualTree.SubscribeForLifetime(SetupPolling, this);
 }
Пример #13
0
 public CpuAndMemoryChart()
 {
     InitSeries();
     InitAxes();
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
 }
Пример #14
0
        private void ConfigueEditor()
        {
            if (innerEditor != null)
            {
                this.Controls.Remove(innerEditor);
            }

            innerEditor = Add(new ConsoleBitmapEditor(currentLevel != null ? currentLevel.Width : Level.DefaultWidth, currentLevel != null ? currentLevel.Height : Level.DefaultHeight)).CenterBoth();
            innerEditor.BitmapChanged.SubscribeForLifetime(() => hasUnsavedChanges = true, innerEditor);

            var commandBar = Add(new StackPanel()
            {
                Height = 1, Orientation = Orientation.Horizontal
            }).FillHorizontally().DockToTop();
            var tagBar = Add(new Label()).FillHorizontally().DockToTop(padding: 1);

            innerEditor.CursorMoved.SubscribeForLifetime(() => tagBar.Text = FormatTags(), this);

            innerEditor.CreateStandardButtons().ForEach(b => commandBar.Add(b));
            var newCommand = commandBar.Add(new Button()
            {
                Text = "New".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.N, ConsoleModifiers.Alt)
            });
            var openCommand = commandBar.Add(new Button()
            {
                Text = "Open".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.O, ConsoleModifiers.Alt)
            });

            saveCommand = commandBar.Add(new Button()
            {
                Text = "Save".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.S, ConsoleModifiers.Alt)
            });
            var saveAsCommand = commandBar.Add(new Button()
            {
                Text = "Save as".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.A, ConsoleModifiers.Alt)
            });
            var discardCommand = commandBar.Add(new Button()
            {
                Text = "Discard".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.D, ConsoleModifiers.Alt)
            });
            var tagCommand = commandBar.Add(new Button()
            {
                Text = "Tag".ToConsoleString(), Shortcut = new KeyboardShortcut(ConsoleKey.T, ConsoleModifiers.Alt)
            });

            newCommand.Pressed.SubscribeForLifetime(() =>
            {
                if (hasUnsavedChanges == false)
                {
                    LoadLevel(null);
                    currentLevelPath = null;
                }
                else
                {
                    UnsavedChanges(() =>
                    {
                        LoadLevel(null);
                        currentLevelPath = null;
                    });
                }
            }, this);


            saveCommand.Pressed.SubscribeForLifetime(() =>
            {
                if (currentLevelPath != null)
                {
                    var level = ExtractLevel();
                    var text  = Serialize(level);
                    File.WriteAllText(currentLevelPath, text);
                    hasUnsavedChanges = false;
                }
                else
                {
                    saveAsCommand.Pressed.Fire();
                }
            }, this);


            saveAsCommand.Pressed.SubscribeForLifetime(() =>
            {
                Dialog.ShowRichTextInput(new RichTextDialogOptions()
                {
                    Message = "Choose a name for this level".ToConsoleString(),
                    TextBox = new TextBox()
                    {
                        Value = currentLevelPath != null ? currentLevelPath.ToConsoleString() : Path.Combine(Environment.CurrentDirectory, "Level1" + LevelFileExtension).ToConsoleString()
                    }
                }).Then((val) =>
                {
                    currentLevelPath = val.ToString();
                    saveCommand.Pressed.Fire();
                });
            }, this);

            discardCommand.Pressed.SubscribeForLifetime(() =>
            {
                Dialog.ShowYesConfirmation("Are you sure you want to discard your unsaved changed?").Then(() =>
                {
                    if (currentLevelPath != null)
                    {
                        Load(currentLevelPath);
                    }
                    else
                    {
                        ConfigueEditor();
                    }
                });
            }, this);

            tagCommand.Pressed.SubscribeForLifetime(() =>
            {
                if (tags.TryGetValue(innerEditor.CursorPosition, out List <string> tagsForPosition) == false)
                {
                    tagsForPosition = new List <string>();
                    tags.Add(innerEditor.CursorPosition, tagsForPosition);
                }

                var tagsString = string.Join(";", tagsForPosition);

                Dialog.ShowRichTextInput(new RichTextDialogOptions()
                {
                    Message = "Add/edit semi-colon delimited tags. Press enter to cmmmit".ToYellow(),
                    TextBox = new TextBox()
                    {
                        Value = tagsString.ToConsoleString()
                    }
                }).Then((newString) =>
                {
                    var split = newString.ToString().Split(';').ToList();
                    tagsForPosition.Clear();
                    tagsForPosition.AddRange(split);
                });
            }, this);
            tags.Clear();
            if (currentLevelPath == null)
            {
                AddedToVisualTree.SubscribeOnce(() => Application.QueueAction(newCommand.Pressed.Fire));
            }
            else
            {
                AddedToVisualTree.SubscribeOnce(() => Application.QueueAction(() => Load(currentLevelPath)));
            }
        }
Пример #15
0
 public BreadcrumbBar()
 {
     this.Height   = 1;
     this.CanFocus = false;
     AddedToVisualTree.SubscribeForLifetime(Compose, this);
 }