Giter VIP home page Giter VIP logo

c-sharp-console-gui-framework's People

Contributors

bt-02 avatar ciwchris avatar ittennull avatar tomaszrewak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c-sharp-console-gui-framework's Issues

new feature: menus

Have you given any thoughts on supporting menus with perhaps sub-menus?

DataGrid pages

Hi,
would it be possible to have side page scrolling for the DataGrid?
Let's say the DataGrid contains more items than the console can contain for it's size, it could display only a determinate amount of them and allow page navigation with left and right arrows, cycling through the items.
My current solution for this is having custom input on the tab the DataGrid is in, and 2 Arrays, one as "all items" and one as the DataGrid source. On arrow press, i update the DataGrid source array with the range of items needed, it works fine but can you perhaps suggest of a better way?

Please tell me if I'm missing something, I am aware of the endless vertical panel, but i need not to lose track of how many items are behind.

Thanks

Multi color multi line textbox

A feature idea. Change the color or background color based on some rules.

E.g. first char on the line is simple rule that governs colouring git diffs

Updating Content within InputListener

Hi, thanks for a great library.
I was testing something out for a project in which I want to update the ConsoleManager.Content from within the IInputListener so I created a few test files and it seems that the window isn't updating properly. I wondered whether perhaps it was because you shouldn't be able to do this, or if it is a genuine bug (or maybe something I'm missing)?

Code

Program.cs

ConsoleManager.Setup();
ConsoleManager.Content = new TestView(1);
var flag = new TestFlag();
var listener = new TestListener(2, flag);
while(!flag.Exit)
{
    Thread.Sleep(10);
    ConsoleManager.ReadInput(new[] { listener });
}

TestFlag.cs

public class TestFlag
{
    public bool Exit { get; set; }
}

TestListener.cs

public class TestListener : IInputListener
{
    private readonly int i;
    private readonly TestFlag flag;

    public TestListener(int i, TestFlag flag)
    {
        this.i = i;
        this.flag = flag;
    }

    public void OnInput(InputEvent inputEvent)
    {
        if (inputEvent.Key.Key == System.ConsoleKey.Enter)
        {
            ConsoleManager.Content = new TestView(i);
            var listener = new TestListener(i + 1, flag);
            while (!flag.Exit)
            {
                ConsoleManager.ReadInput(new[] { listener });
            }
            inputEvent.Handled = true;
        }
        else if(inputEvent.Key.Key == System.ConsoleKey.Q)
        {
            flag.Exit = true;
            inputEvent.Handled = true;
        }
    }
}

TestView.cs

public class TestView : SimpleControl
{
    public TestView(int i)
    {
        Content = new Border { Content = new TextBlock { Text = $"test {i}" } };
    }
}

Result

The first iteration appears as you would expect:
image

However subsequent iterations look like only the changed cell is displayed (no border or "test"):
image

Alternative frameworks

Found out about a parallel project to yours, here: https://parall.ax/blog/view/3131/vtop-revisiting-the-activity-monitor

Quote:

I decided to write vtop using Node.js. It’s built on Chrome’s V8 JavaScript engine and allows you to write fast and scalable applications. This choice could pave the way for a web-based frontend to be added in the future. JavaScript is coming into it’s own – it’s no longer the scrappy, badly implemented language that everyone used to make sparkles follow your cursor on your Geocities page. Node.js has evolved the language – it’s now a a fully formed toolchain with a thriving community. There’s a Node package for just about anything you can think of, you can really hit the ground running by picking up other people’s modules instead of writing from scratch.

At the beginning of the rewrite, I made an outline using simple box drawing characters that I used to love playing with in my early DOS programming days. While this worked ok, I felt there might be an easier way. I’d seen ncurses and wondered if there was anything more modern kicking about. I eventually came across Blessed.

Blessed abstracts away the complexities of drawing a GUI in the terminal. You tell it where to draw boxes, and they are automatically resized based on the terminal width and height. You can also listen to scroll wheel and click events to enable even easier interaction. I’d highly recommend you check it out.

How to disable border on DataGrid?

Thanks for making this amazing framework of making console GUI.

I don't know how to disable the border line between rows in DataGrid.

Feature request: Character column

Support for a control for drawing vertical columns of characters.

So far I've tried using a BreakPanel and a VerticalSeparator within a Box control.
Both methods yield inconsistent results. A BreakPanel displays no text inside a Box control's content, unlike a plain TextBlock (Which doesn't repect line break characters). And a VerticalSeparator for some reason fills the whole Box control both diagonally and vertically with the VerticalSeparator's characters.

In case these shortcomings aren't replicable, here is my code:

_window = new Overlay                                                                  //Base window element for vertical bar graph
{
    TopContent = new Margin                                                          //Title formatting for window element
    {
        Offset = new Offset(1, 0, 0, 0),                                               
        Content = _titleText                                                          
    },
    BottomContent = new Border                                                     //Borders for Window element
    {
        BorderPlacement = BorderPlacement.All,                                         
        BorderStyle = BorderStyle.Single,                                              
                                                                                       
        Content = new Box                                                                  //Box control for vertical character columns
        {
            HorizontalContentPlacement = Box.HorizontalPlacement.Center,
            VerticalContentPlacement = Box.VerticalPlacement.Center,
            Content = _barStack                                                             //_barStack to be used for character column control
        }
    }
};

Create an editor

I kind of need some guidance. I am trying to implement a simple editor. Im using the new BreakPanel. My issue is that the content is larger than the allocated screen. So when I move right I expect the content to change when I reach the end of the lowest line. It doesn't

I also would expect the TextBox to support arrow up/down.

Maybe I need to

	class Program
	{
		static void Main(string[] args)
		{
			// optional: adjusts the buffer size and sets the output encoding to the UTF8
			ConsoleManager.Setup();

			// optional: resizes the console window (the size is set in a number of characters, not pixels)
			ConsoleManager.Resize(new Size(50, 10));

			var textBox = new TextBox()
			{
				
				Text = @"1 alsjdasldk
2 asjdkalsj
3 iieieiei
4 fkkrkrk
5 fldksjf
6 fsdlkfjls
7 dslakfj
8 sldkf
9 sdlkf
10 dkdkdkdk
11 jdjdjdjd
12 qpqpqpqpq

the end", 
			};

			ConsoleManager.Content =
				new Border()
				{
					Content = new BreakPanel(){Content =  textBox, }
				};

			var input = new IInputListener[] {textBox};

			while (true)
			{
				Thread.Sleep(10);
				ConsoleManager.ReadInput(input);
			}

			Console.ReadKey();
		}
	}

wrapping it in a ScrollPanel gives a nice schrollbar. But no scrolling

        ConsoleManager.Content =
            new Border()
            {
                Content =
                    new VerticalScrollPanel()
                    {
                        Content = new BreakPanel() {Content = textBox,}
                    }
            };

Sadly not working under Linux / JetBrains Rider

It just puts out an unhandled exception:

Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform.GUI.Example/bin/Debug/netcoreapp3.0/ConsoleGUI.Example.dll at System.ConsolePal.SetWindowPosition(Int32 left, Int32 top) at System.Console.SetWindowPosition(Int32 left, Int32 top) at ConsoleGUI.ConsoleManager.ResizeBuffer(Int32 width, Int32 height) in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI/ConsoleManager.cs:line 139 at ConsoleGUI.ConsoleManager.Setup() in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI/ConsoleManager.cs:line 124 at ConsoleGUI.Example.Program.Main() in /home/benjamin.piepiora/Downloads/C-sharp-console-gui-framework-master/ConsoleGUI.Example/Program.cs:line 266

Is it possible to work around that?

Bug: BreakPanels display newline as an empty character

Hello.
I have an issue, where drawing over a Border control with a BreakPanel results in every newline character \n overdrawn as an empty character over the underlying control, even when using an Overlay control.
For example:

Content = new BreakPanel
{
    Content = new TextBlock {Text = "┬\n│\n│\nTest\n[Value]" }
}

Drawn over a border looks like this:
fig0

correct formatting?

Just learning the framework. Is this as expected?

class Program
{
    static void Main(string[] args)
    {
        ConsoleManager.Setup();
        ConsoleManager.Resize(new Size(150, 40));
        ConsoleManager.Content =
            new Box()
            {
                Content = new Border()
                {
                    Content =
                        new HorizontalStackPanel()
                        {
                            Children = new[] { new TextBlock { Text = "Hello world" }, new TextBlock { Text = "22Hello world22" }, }
                        }
                }
            };

        Console.ReadKey();
    }
}

image

Expanding elements without using `Box`

Just learning the framework. Is this as expected? I thought it required a ´Box´ in order for the content to be centered.

class Program
{
    static void Main(string[] args)
    {
        ConsoleManager.Setup();
        ConsoleManager.Resize(new Size(150, 40));

        ConsoleManager.Content =

                new Border()
                {
                    Content =
                        new HorizontalStackPanel()
                        {
                            Children = new[] { new TextBlock { Text = "Hello world" }, new TextBlock { Text = "22Hello world22" }, }
                        }
                }
            ;

        Console.ReadKey();
    }

image

Add mouse support

So I've spent some time thinking about how may I implement the mouse support for this library and this it the proposal:

  • The library will continue to be dependency free and platform agnostic
  • The user will be able to easily hook up a library of choice to this framework (for example the MouseKeyHook: https://github.com/gmamaladze/globalmousekeyhook)
  • The Character struct will be extended by two fields:
    • Control - the top level IControl that produced this character
    • Position - a local position of the Control from which the character was produced
  • Some interactive controls (like a Button) will be able to override the Control and Position fields of characters they are passing through
  • The ConsoleManager will be extended with a method that returns a Control and Position values of a specific "pixel".
  • A new IMouseListener interface will be added (the list of methods to be decided, but probably OnMuseDown(Position local), OnMouseMove(Position local), OnMoseUp(Position local))
  • Whenever an external library detects a mouse input, the user should get the Control and its local Position at the specified global position, check if that control is in fact an instance of the IMouseListener, and call the proper callback.
  • The rest is up to the internal implementation of the control

That should keep the interface simple and make it possible to hook up the mouse using one of the already existing projects.

feature: listview

What are your thoughts on listviews? Is it something I have to compose from existing components?

for my application I need to display a lot of lines and have the user select one of them. The line currently being the candidate for selection is hightligted and some hotkey defines that the selection is made (possibly enter).

Naviagation of the current selected line needs to be accessed from outside the component (eg. a method MoveUpOne(), MoveUpPage(), MoveDownOne(),..). This allows me to combine the listview with a textfield so that the content of the listview is filtered.

Cleanup console

Is it possible to use the library to prompt an user for input, and then cleanup all the elements and proceed the console application as if nothing happened?

Right now all console output is removed after drawing elements on the screen.

Missing using directive in TabPanel example

There is a missing using directive in the TabPanel example. When I was trying to implement the example this error was thrown:
error CS0246: The type or namespace name 'IControl' could not be found (are you missing a using directive or an assembly reference?)

The fix was to add using ConsoleGUI; to the TabPanel.cs file. I suggest that the example is updated unless it is an error that is solely on my machine for some reason.

IOException thrown when calling AdjustWindowSize

Calling ConsoleManager.AdjustWindowSize() in a tight loop while resizing the window with the mouse can cause a System.IO.IOException to be thrown.

Exception Details

System.IO.IOException: The parameter is incorrect.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at ConsoleGUI.Api.StandardConsole.set_Size(Size value)
   at ConsoleGUI.ConsoleManager.Resize(Size& size)
   at ConsoleGUI.ConsoleManager.AdjustWindowSize()

Might want to add a SafeConsole.SetCursorPosition method.

.NET Standard

Please make it clear in the README that this targets netstandard2.0 (a good thing!) and not .NET framework :)

Custom control margin not updating.

I have a custom control for labels with an equal spacing using the Margin control:

    internal class LabelControl: SimpleControl
    {
        private readonly TextBlock _label;
        private readonly TextBlock _value;
        private Offset _offset;
        public LabelControl()
        {
            _label = new TextBlock();   //┤
            _value = new TextBlock();
            _offset = new Offset(0,0,0,0);
            Content = new Margin
            {
                Offset = _offset,
                Content = new Overlay
                {
                    
                    TopContent = _label,
                    BottomContent = _value
                }
            };
        }
        public Offset Margin
        {
            get => _offset;
            set => _offset = value;
        }
        public string Label
        {
            get => _label.Text;
            set => _label.Text = value;
        }
        public string Value
        {
            get => _value.Text;
            set => _value.Text = value;
        }
    }

Changing parameters Label and Value within each instance after initialization changes the text within the accordingly assigned TextBlock controls just fine (e.g, mylabelcontrol.Value = "new value", mylabelcontrol.Label = "new label").
However, assigning a new Offset for the Margin control after initialization yields no result (e.g: mylabelcontrol.Margin = new Offset(1,2,3,4)). Is this behaviour by design?

Create Controls of XML-files

It might be possible to use XML-files to create a "Control-Tree", it would be a bit easier to use and is just an idea...

Support Console Resize w/ Caveat Lector

@bpiepiora wrote:

Is it possible to detect size changes of the console and update the content accordingly?

@jzabroski wrote:

Handling console window size changes is not safe: https://stackoverflow.com/a/34208406

@TomaszRewak wrote

Yeah, unfortunately that's the case.
But actually thinking about it I could add a new method to the ConsoleManager that the user would have to call each "frame" (the same way it's currently implemented for keyboard input handling) that would simply check if the size of the window has changed as compared to the value from the previous frame.
It wouldn't be 100% foolproof (because if the window size would change to a different value and back to the initial value during one frame it might break the layout), but it would still be better than nothing.

Not working example

After download zip file and run example there only works Key UP/DOWN on Popup.
Example not reacts on mouse when i want e.g change tabs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.