ShowRichTextInput() public static method

public static ShowRichTextInput ( ConsoleString message, Action resultCallback, System.Action cancelCallback = null, bool allowEscapeToCancel = true, int maxHeight = 12, TextBox inputBox = null ) : void
message ConsoleString
resultCallback Action
cancelCallback System.Action
allowEscapeToCancel bool
maxHeight int
inputBox TextBox
return void
Beispiel #1
0
        private async void SaveAsCommandImpl()
        {
            var input = await Dialog.ShowRichTextInput(new RichTextDialogOptions()
            {
                Message = "Select destination".ToYellow()
            });

            if (input == null)
            {
                return;
            }
            SaveCommon(input.StringValue);
        }
Beispiel #2
0
        private async void NewCommandImpl()
        {
            if (await ConfirmOkToProceedWithPendingChanges("Are you sure you want to start a new project?") == false)
            {
                return;
            }

            var w = await Dialog.ShowRichTextInput(new RichTextDialogOptions()
            {
                Message = "Width".ToYellow()
            });

            if (w == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(w?.StringValue) || int.TryParse(w.StringValue, out int width) == false)
            {
                await Dialog.ShowMessage($"Invalid width: '{w.StringValue}'");

                return;
            }

            var h = await Dialog.ShowRichTextInput(new RichTextDialogOptions()
            {
                Message = "Height".ToYellow()
            });

            if (h == null)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(h?.StringValue) || int.TryParse(h.StringValue, out int height) == false)
            {
                await Dialog.ShowMessage($"Invalid height: '{h.StringValue}'");

                return;
            }

            currentlyOpenedFile = null;
            animation.Frames.Clear();
            animation.Frames.Add(new InMemoryConsoleBitmapFrame()
            {
                Bitmap = new ConsoleBitmap(width, height), FrameTime = TimeSpan.Zero
            });
            CurrentFrameIndex = 0;
            undoRedo.Clear();
            undoRedo.Do(new ClearPendingChangesAction(this));
            Refresh();
        }
Beispiel #3
0
        private async void OpenCommandImpl()
        {
            if (await ConfirmOkToProceedWithPendingChanges("Are you sure you want to open another project?") == false)
            {
                return;
            }

            var tb = new TextBox()
            {
                Value = lastOpenDialogInput?.ToConsoleString() ?? ConsoleString.Empty
            };
            var input = await Dialog.ShowRichTextInput(new RichTextDialogOptions()
            {
                TextBox = tb,
                Message = "Enter file path".ToYellow(),
            });

            if (input == null)
            {
                return;
            }

            lastOpenDialogInput = input.StringValue;
            if (File.Exists(lastOpenDialogInput) == false)
            {
                await Dialog.ShowMessage($"File not found: {lastOpenDialogInput}".ToRed());

                OpenCommandImpl();
                return;
            }

            if (TryOpenConsoleBitmapReaderFormat(lastOpenDialogInput) == false && TryOpenVisualFormat(lastOpenDialogInput) == false)
            {
                await Dialog.ShowMessage($"Failed to load file: {lastOpenDialogInput}".ToRed());
            }
            else
            {
                currentlyOpenedFile = lastOpenDialogInput;
                Refresh();
            }
        }