goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
718 stars 62 forks source link

Invalid Handle #58

Closed bouldrini closed 3 years ago

bouldrini commented 4 years ago

I receive Invald Handle Exception when running

ProgressBar bar = new ProgressBar(PbStyle.DoubleLine, m);

in a Windows Application. In Console Application this works very well. Is there a workaround to use library in Windows Applications Output Window ?

goblinfactory commented 4 years ago

Hi @bouldrini you need to either use Konsole from within a console application, or write an IConsole provider. The current version of Konsole has a faulty interface for IHighSpeedWriter which is essentially what should be used, and all youd need to do is implement that for windows forms, That will be fixed in the next release, and will be replaced with a IConsoleProvider, with a much simpler interface that should be used to allow Konsole to be used in a new platform of any kind.

I will probably write a windows forms provider for Konsole, that will be based on RichText control using fixedWidth font. Please remind in a two weeks time and I'll take a look at putting together a small prototype and add that to the next release.

https://github.com/goblinfactory/konsole/blob/master/src/Konsole/Platform/IHighspeedWriter.cs

is faulty, printAt is missing void PrintAt(Colors colors, int x, int y, char c); (roughtly) I will need to double check this specifically.

    public interface IHighspeedWriter : IDisposable
    {
        void ClearScreen();
        char ClearScreenChar { get; set; }

        Colors Colors { get; set; }
        void Flush();

        bool AutoFlush { get; }

     // missing!
        void PrintAt(Colors colors, int x, int y, char c);
     // missing
     int Width { get; }
     int Height { get; }
     // missing cursor settings, visible, and position
    }

this is not a bug, because it's not a planned feature for this release, so will leave this comment here for a bit, then will close as 'will be added to next major release'.

goblinfactory commented 3 years ago

closing this issue as not a bug. replacing with new feature request, for winforms console control. should be fun to write.