• 0

Creating Graphical Command Line Interface (from scratch)


Question

Hello all,


I'm trying to create my own version of "ncurses" from scratch because I am bored, also I am trying to learn C# programming. I know that I can very easily create a GUI using Visual Studio, however I like graphical console apps.


Does anybody know of reading material that may help me understand the relations between windows, screens, and form elements. I so far have created a drawing system using box characters, as well as a basic system that holds an array of "Pixels", which is a class that I made that holds the following information:

...    
class Pixel
{
        private Coordinates location;	//a struct of (ushort x, ushort y)
        private char character;			// Holds any single character of "Text"
		private ConsoleColor characterColor;	// Holds the color of the single character of text
        private char backgroundCharacter;	// Holds a box character
        private ConsoleColor backgroundCharacterColor;			// Holds the backgroundCharacter color
....

Here is a quick preview of my window class:

...   
class Window
{
        private ushort windowWidth;
        private ushort windowHeight;
        private Coordinates origin;
        private String windowTitle;
        private BorderType border;
        private ConsoleColor borderColor;
        private ConsoleColor textColor;
        private ConsoleColor titleColor;
        private ConsoleColor backgroundColor;

        private Pixel[][] pixels;

       public Window(ushort _width, ushort _height, ushort originX, ushort originY, ConsoleColor _backgroundColor, ConsoleColor _textColor, String _title, ConsoleColor _titleColor)
        {
            this.windowWidth = _width;
            this.windowHeight = _height;
            origin.X = originX;
            origin.Y = originY;
            this.textColor = _textColor;
            this.titleColor = _titleColor;
            this.windowTitle = _title;
            this.backgroundColor = _backgroundColor;

            for (ushort x = 0; x < windowWidth; x++)
            {
                for (ushort y = 0; y < windowHeight; y++)
                {
                    this.pixels[x][y] = new Pixel(x, y);
                    this.pixels[x][y].setColor(this.backgroundColor);
                }
            }
        }
...

I am trying to find the most effective way to update the Window and currently have a blank screen class that will handle all the drawing. I have searched for a diagram that shows the different layers of a user interface to get an idea of how the events are handled and drawn, but haven't found anything that has helped my understanding. Is there any books that cover developing a graphical user interface or online articles? I don't want to learn how to use existing API's, but rather see one developed from scratch.

 

It would be totally easier if their was a port of ncurses for Windows 10. PDCurses was last updated in 2008, so I do not wish to use that. If anybody has heard of an alternative that works with today that I can use C# to program, I'd love to hear it.

 

Hopefully I didn't completely confuse everybody. Thanks!

1 answer to this question

Recommended Posts

  • 0
  On 24/07/2016 at 01:12, SpeedyTheSnail said:

 am trying to find the most effective way to update the Window and currently have a blank screen class that will handle all the drawing. I have searched for a diagram that shows the different layers of a user interface to get an idea of how the events are handled and drawn, but haven't found anything that has helped my understanding. Is there any books that cover developing a graphical user interface or online articles? I don't want to learn how to use existing API's, but rather see one developed from scratch.

 

It would be totally easier if their was a port of ncurses for Windows 10. PDCurses was last updated in 2008, so I do not wish to use that. If anybody has heard of an alternative that works with today that I can use C# to program, I'd love to hear it.

 

Hopefully I didn't completely confuse everybody. Thanks!

Expand  

https://github.com/search?utf8=✓&q=console+output+language%3Ac%23&type=Repositories&ref=searchresults

 

Also, the new Bash console in Windows 10 is well, Bash using code developed by Ubuntu guys

 

http://www.hanselman.com/blog/DevelopersCanRunBashShellAndUsermodeUbuntuLinuxBinariesOnWindows10.aspx

 

http://www.hanselman.com/blog/InstallingFishShellOnUbuntuOnWindows10.aspx

 

Also, new Windows 10 console in Anniversary Update has the ANSI stuff

 

http://www.hanselman.com/blog/ForgottenButAwesomeWindowsCommandPromptFeatures.aspx

 

Also, ConEmu:

 

http://conemu.github.io/en/Reviews.html

 

And of course we can't forget the REPL thing:

 

http://www.hanselman.com/blog/InteractiveCodingWithCAndFREPLsScriptCSOrTheVisualStudioInteractiveWindow.aspx

 

http://www.hanselman.com/blog/TheJoyOfLiveCodingCodePenREPLsTOPLAPAliveAndMore.aspx

 

 

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I have the Pixel 9 Pro XL...Unless this thing is "leaps and bounds" faster than the 9, I'll pass. And by leaps and bounds, I don't mean on benchmarks. "Real world" faster. Most people don't even come close to topping out the performance of their phones. Tensor G5 is Google's most powerful chip to date, boasting a staggering 36 percent performance leap over G4.
    • MIT's stunning 'bubble wrap' device squeezes water out from thin air even in deserts by Sayan Sen Image by Matteo Roman via Pexels Massachusetts Institute of Technology (MIT) engineers have built a new kind of device that can pull clean drinking water straight out of the air—no electricity needed. It’s designed for areas where water is scarce and traditional sources like rivers or lakes aren’t reliable. Right now, more than 2.2 billion people globally don’t have access to safe drinking water. In the United States alone, 46 million face water insecurity, with either no running water or water that’s not safe to drink. This new device, called an Atmospheric Water Harvesting Window (AWHW), uses a unique hydrogel panel that looks like black bubble wrap. These dome-shaped bubbles soak up water vapor from the air, especially at night when humidity is higher. During the day, sunlight makes the vapor inside evaporate. That vapor then condenses on a glass surface and drips down through a tube, turning into drinkable water. The AWHW doesn’t rely on power sources like batteries or solar panels. It’s completely passive, meaning it works on its own. The team tested a meter-sized panel in Death Valley, California, one of the driest places in North America, and got between 57.0 and 161.5 milliliters of water per day even with humidity as low as 21 percent. That’s more than what other similar passive devices have managed. “We have built a meter-scale device that we hope to deploy in resource-limited regions, where even a solar cell is not very accessible,” said Xuanhe Zhao, a professor at MIT. “It’s a test of feasibility in scaling up this water harvesting technology. Now people can build it even larger, or make it into parallel panels, to supply drinking water to people and achieve real impact.” Another cool part of the design is how they kept the water safe to drink. Usually, these kinds of hydrogels use salts like lithium chloride to absorb more vapor but that can lead to salt leaking into the water, which isn’t ideal. To solve this, MIT’s team mixed in glycerol, a compound that helps keep salt locked inside the gel. In testing, the lithium ion concentration in the harvested water stayed below 0.06 ppm (parts per million), which is way below the safe limit. The hydrogel domes also give the material more surface area, letting it collect more vapor. The outer glass panel is coated with a special polymer film that helps cool the glass, making it easier for vapor to condense. “This is just a proof-of-concept design, and there are a lot of things we can optimize,” said lead author Chang Liu, now a professor at the National University of Singapore. “For instance, we could have a multipanel design. And we’re working on a next generation of the material to further improve its intrinsic properties.” Published in Nature Water, the study says the AWHW could last at least a year and shows promise for making safe, sustainable water in places with harsh climates. The researchers believe an array of vertical panels could one day supply water to individual households, especially in remote or off-grid locations. Source: MIT News, Nature This article was generated with some help from AI and reviewed by an editor. Under Section 107 of the Copyright Act 1976, this material is used for the purpose of news reporting. Fair use is a use permitted by copyright statute that might otherwise be infringing.
    • Clear Linux is open source, indeed, so its source code is available for anyone. They're just shutting down its support from them, they're not forbidding anyone else from taking over.
    • Linux Mint is also my favorite distro, but I fear what will happen with it if Clem were to disappear tomorrow, to be honest.
    • Yeah, I totally get your point, which is possible it could happen. I just hope there is a few people around him who are similar to where if they took over things would run pretty much the same. if not, then yeah, it could start to decline rapidly etc. but I figure something that's been around for a longer period of time with a decent backing, and probably more users than most Linux distro's (which I would 'imagine' Mint is one of the more used Linux desktop distro's by volume of people who use it), is less likely to just disappear. but like you said, nothing is guaranteed. but I do think you are probably right in that Clem is probably the core of what keeps Mint, Mint. I like how it tends to stay pretty much the same with some slight tweaks here and there (but is largely the same) instead of that crap some people go for with change for the sake of change trying to create a overly fancy interface and other unnecessary stuff etc. I also feel Mint keeps a nice balance of things out-of-the-box where it's not too bloated, nor too striped down. p.s. but I see Mint as a better Ubuntu basically. but I get your point like if it was more of a really serious choice of needing a 'safe bet' to use long term, then yeah something like official Ubuntu would be one of the better choices for sure given what you said with it being backed by an actual company which makes it a safer bet than Mint which is smaller and 'could' potentially be more fragile.
  • Recent Achievements

    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
    • Dedicated
      MacDaddyAz earned a badge
      Dedicated
    • Explorer
      cekicen went up a rank
      Explorer
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      209
    3. 3
      Michael Scrip
      202
    4. 4
      Xenon
      144
    5. 5
      +FloatingFatMan
      121
  • Tell a friend

    Love Neowin? Tell a friend!