RELEASE: XLibSharp 0.0.1-ALPHA OUT!!!!

RELEASE: XLibSharp 0.0.1-ALPHA OUT!!!!

I would like to show how do you write simple XLib/X11 Apps from C# - Sorry for some invalid methods or non existing contexts. I promise you that I will release next version. Okay. Please forgive me! I am working hard. Because I tried to find in public methods. Thanks!

Hello everyone,


I have published initial release of XLibSharp but it is still Alpha version. Sorry for inconvenience about non existing methods or more important context of XLib-Frameworks.

I hope you understand me.

If you download from my Patrean-account than you can do that.

It works only Mono 4.5 / NetFx 4.5 - No Dotnet ( I will release later )

Now you can change "MainClass" to "HelloWorld"

And you can write code:

private XDisplay display; 
private XWindow window;
private XEvent xev;
private string display_name;

public HelloWorld() { xev = new XEvent(); }


Than you should create void method:

 private void Run()
 {

}

Than you need to write behind in method Run()

 Console.WriteLine("Hello World, Load XLibSharp.\n");
 display_name = GetEnvironmentVariable("DISPLAY");

Console.WriteLine(display_name); display = XOpenDisplay(display_name); if (display == NULL) {     Console.Out.WriteLine("Error: Couldn't open display!\n");     Exit(1); }

Than you will create window:

 else
 {
     window = XCreateSimpleWindow(display,
     XRootWindow(display, XDefaultScreen(display)),
     new XRectangle(100, 100, 200, 200), 5, 0ul, XColor.OrangeRed);

    if (window == NULL)     {         Console.Out.WriteLine("Error: Failed to open window!\n");         Exit(1);     }     else     {         XStoreName(display, window, "#XLibSharp");         XMapWindow(display, window);         XSelectInput(display, window, EventMask.KeyPressMask |         EventMask.ExposureMask | EventMask.ButtonPressMask);         XFlush(display);     } }

Than you would like to write loop while:

while (true)
{
    XNextEvent(display, ref xev);
    if (xev.type == XEventName.Expose)
    {
        XFillRectangle(display, new XDrawable(window),
        new XColor(0x222222ul), 20, 20, 160, 160);
        XFlush(display);
    }

    if (xev.type == XEventName.KeyPress)     {         break;     }

    if (xev.type == XEventName.ClientMessage)     {         XDestroyWindow(display, window);         XNoOp(display);         XCloseDisplay(display);         break;     }

    if (xev.type == XEventName.ButtonPress)     {         break;     } }

And you need to write complete in static void Main()

static void Main(string[] args)
{
    new HelloWorld().Run();
}

And save it.

If you have problem if it throws error:

 using System;
 using static System.Environment;
 using static XLibSharp.XLib;

namespace XLibSharp_Test {     class HelloWorld     {         /*            XLibSharp Example           /

        private XDisplay display;          private XWindow window;         private XEvent xev;         private string display_name;

        public HelloWorld()         {             xev = new XEvent();         }                  private void Run()         {             Console.WriteLine("Hello World, Load XLibSharp.\n");             display_name = GetEnvironmentVariable("DISPLAY");

            Console.WriteLine(display_name);             display = XOpenDisplay(display_name);             if (display == NULL)             {                 Console.Out.WriteLine("Error: Couldn't open display!\n");                 Exit(1);             }             else             {                 window = XCreateSimpleWindow(display,                 XRootWindow(display, XDefaultScreen(display)),                 new XRectangle(100, 100, 200, 200), 5, 0ul, XColor.OrangeRed);

                if (window == NULL)                 {                     Console.Out.WriteLine("Error: Failed to open window!\n");                     Exit(1);                 }                 else                 {                     XStoreName(display, window, "#XLibSharp");                     XMapWindow(display, window);                     XSelectInput(display, window, EventMask.KeyPressMask |                     EventMask.ExposureMask | EventMask.ButtonPressMask);                     XFlush(display);                 }             }

            while (true)             {                 XNextEvent(display, ref xev);                 if (xev.type == XEventName.Expose)                 {                     XFillRectangle(display, new XDrawable(window),                     new XColor(0x222222ul), 20, 20, 160, 160);                     XFlush(display);                 }

                if (xev.type == XEventName.KeyPress)                 {                     break;                 }

                if (xev.type == XEventName.ClientMessage)                 {                     XDestroyWindow(display, window);                     XNoOp(display);                     XCloseDisplay(display);                     break;                 }

                if (xev.type == XEventName.ButtonPress)                 {                     break;                 }             }         }

        static void Main(string[] args)         {             new HelloWorld().Run();         }     } }

And run it and result is like this:

I hope you understand you have not problem with XLibSharp.

Please remember! Don't write "null" as string because XOpenDisplay crashes as dump critical error.

Please write safe!


Happy coding

c-sharp

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five

C. C++. C#. 차이점 알려드림. 5분 순삭. Explain C.C++.C#. Like I'm Five. 아시죠? C는 C++.C# 줄인말이 아니라는거?

Dicey Issues in C/C++

C/C++ problems. If you are familiar with C/C++then you must have come across some unusual things and if you haven’t, then you are about to. The below codes are checked twice before adding, so feel free to share this article with your friends.

Learn how to perform CRUD operations using C Sharp

QuickStart: CRUD Operations in C Sharp. Learn how to perform CRUD operations using C Sharp for MongoDB databases.

Loops in C++ | For, While, and Do While Loops in C++

In this Video We are going to see how to use Loops in C++. We will see How to use For, While, and Do While Loops in C++.

Using isdigit() in C/C++

In this article, we'll take a look at using the isdigit() function in C/C++. This is a very simple way to check if any value is a digit or not. Let's look