Coder Social home page Coder Social logo

spvessel / spacevil Goto Github PK

View Code? Open in Web Editor NEW
56.0 5.0 7.0 1.49 MB

Simple examples of SpaceVIL implementation for C# / .NET Framework, C# / .NET Core and Java.

Home Page: https://spvessel.com

License: MIT License

Java 29.60% C# 70.14% Batchfile 0.26%

spacevil's Introduction

SpaceVIL

SpaceVIL (Space of Visual Items Layout) is a cross-platform and multilingual framework for creating GUI client applications for .NET Standard, .NET Core and JVM. SpaceVIL is based on OpenGL graphic technology and glfw. Using this framework in conjunction with .Net Core or with a JVM, you can work and create graphical client applications on Linux, Mac OS X and Windows. See more on youtube channel - https://youtu.be/kJ6n1fTHXws You can also view SpaceVIL documentation.

SpaceVIL's source code is available on GitHub for Java and C#.

Get started with SpaceVIL

In this tutorial, you will learn how to create a simple cross-platform application using the SpaceVIL framework. We hope you will enjoy the framework.

Step 1: Implementing SpaceVIL into you Project

C# / .NET Standard / Visual Studio

ATTENTION FOR WINDOWS OS USERS: GLFW library should be renamed to "glfw.dll" (if you download binaries from the official GLFW website, you get a library named "glfw3.dll")

  • Create console project
  • Download SpaceVIL for .NET Standard
  • Download glfw and copy next to the executable file.
  • Add Reference to SpaceVIL.dll
  • Check the framework by adding the line:
    using SpaceVIL;
    

C# / .NET Core / Visual Studio Code (or any other text editor)

  • Create console project by executing the command in terminal:

    dotnet new console --output MyProject
    
  • Download SpaceVIL for .NET Core

  • Windows: Download glfw and copy next to the executable file. Linux: install libglfw3 and libglfw3-dev via repository. Mac OS X (simplest way): extract libglfw.dylib from lwjgl-glfw-natives-macos.jar (or you can compile libglfw.dylib from sources) and copy next to the executable file.

  • Copy SpaceVIL.dll in the MyProject folder

  • Add code below into MyProject.csproj:

    <ItemGroup> 
      <Reference Include="SpaceVIL.dll"/> 
    </ItemGroup>
    

Windows / Linux:

  • Install System.Drawing.Common from NuGet by command:
    dotnet add package System.Drawing.Common --version 4.6.0-preview7.19362.9
    
    or just add code below and then execute command in terminal: dotnet restore
    <ItemGroup> 
      <PackageReference Include="System.Drawing.Common" Version="4.6.0-preview7.19362.9" /> 
    </ItemGroup>
    

For Mac OS:

  • Install CoreCompat.System.Drawing.v2 from NuGet by command:
    dotnet add package System.Drawing.Common --version 4.6.0-preview7.19362.9
    
  • Install runtime.osx.10.10-x64.CoreCompat.System.Drawing from NuGet by command:
    dotnet add package runtime.osx.10.10-x64.CoreCompat.System.Drawing --version 5.8.64
    
    or just add code below and then execute command in terminal: dotnet restore
    <ItemGroup> 
      <PackageReference Include="System.Drawing.Common" Version="4.6.0-preview7.19362.9" /> 
      <PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="5.8.64" /> 
    </ItemGroup>
    
  • Check the framework by adding the line:
    using SpaceVIL;
    

JAVA / Gradle

  • Download SpaceVIL for JVM
  • Download lwjgl
  • Create directory for project
  • Create gradle project by executing the command in terminal:
    gradle init --type java-application
    
  • Create directory libs in the project directory
  • Copy into libs downloaded file spacevil.jar
  • Copy this lwjgl files below into libs directory:
    lwjgl.jar
    lwjgl-glfw.jar
    lwjgl-glfw-natives-linux.jar
    lwjgl-glfw-natives-macos.jar
    lwjgl-glfw-natives-windows.jar
    lwjgl-natives-linux.jar
    lwjgl-natives-macos.jar
    lwjgl-natives-windows.jar
    lwjgl-opengl.jar
    lwjgl-opengl-natives-linux.jar
    lwjgl-opengl-natives-macos.jar
    lwjgl-opengl-natives-windows.jar
    
  • In build.gradle add line into dependencies block:
    compile fileTree(dir: 'libs', include: '*.jar')
    

For Mac OS:

  • ATTENTION! To get your app work you should run jvm on Mac OS with -XstartOnFirstThread argument! In build.gradle add line:

    applicationDefaultJvmArgs = ['-XstartOnFirstThread']
    

    or run your compiled *.jar file with command:

    java -jar -XstartOnFirstThread your_app.jar
    
  • Check the framework by adding the line:

    import com.spvessel.spacevil;
    

Step 2: Creating and running a new window

C#

  • Create in project source file named for example MainWindow.cs (name may be different)
  • Create class MainWindow
  • Class MainWindow must be inherited from class SpaceVIL.ActiveWindow
  • Override method InitWindow
  • Set basic parameters of window via method SetParameters()
  • Code should look like this:
    using System;
    using System.Drawing;
    using SpaceVIL;
    namespace MyProject
    {
      class MainWindow : ActiveWindow
      {
        public override void InitWindow()
        {
          SetParameters(nameof(MainWindow), nameof(MainWindow), 800, 600);
          SetMinSize(400, 300);
          SetBackground(32, 34, 37);
        }
      }
    }
    
  • In Program.cs add line on top of the file:
    using SpaceVIL;
    
  • In Program.cs of project source file inside Main function add lines:
    Common.CommonService.InitSpaceVILComponents();
    MainWindow mw = new MainWindow();
    mw.Show();
    
  • Code should look like this:
    using System;
    using SpaceVIL;
    namespace MyProject
    {
      class Program
      {
        static void Main(string[] args)
        {
          Common.CommonService.InitSpaceVILComponents();
          MainWindow mw = new MainWindow();
          mw.Show();
        }
      }
    }
    
  • Compile and run project to check

JAVA

  • Create in project source file named for example MainWindow.java (name may be different)
  • Create class MainWindow
  • Class MainWindow must be inherited from class com.spvessel.spacevil.ActiveWindow
  • Override method initWindow
  • Set basic parameters of window via method setParameters()
  • Code should look like this:
    import java.awt.Color;
    import com.spvessel.spacevil.*;
    class MainWindow extends ActiveWindow {
      @Override
      public void initWindow() {
        setParameters(this.getClass().getSimpleName(), "App", 360, 500);
        setMinSize(350, 500);
        setBackground(45, 45, 45);
      }
    }
    
  • In App.java add line on top of the file: import com.spvessel.spacevil.*;
  • In App.java of project source file inside main function add lines:
    com.spvessel.spacevil.Common.CommonService.initSpaceVILComponents();
    MainWindow mw = new MainWindow();
    mw.show();
    
  • Code should look like this:
    import com.spvessel.spacevil.*;
    public class App {
      public static void main(String[] args) {
        com.spvessel.spacevil.Common.CommonService.initSpaceVILComponents();
        MainWindow mw = new MainWindow();
        mw.show();
      }
    }
    
  • Compile and run project to check

Step 3: Adding items to the window

C#

  • Items can be added to the window as follows:

    AddItem(item2);
    

  • Items can be added to another item simply by calling method:

    item1.AddItem(item2);
    

JAVA

  • Items can be added to the window as follows:
    addItem(item2);
    

  • Items can be added to another item simply by calling method:
    item1.addItem(item2);
    

Step 4: Assigning actions to events

You can assign unlimited count of action to one event of an item.

C#

  • Assign an action (lambda expression or method) to all avaliable item events as follows:
    btn.EventMouseClick += (sender, args) =>
    {
     //do something
    };
    

JAVA

  • In Java, you can assign an action to item events as follows:
    btn.eventMouseClick.add( (sender, args) -> {
      //do something
    });
    

Authors

  • Roman Sedaikin
  • Valeriia Sedaikina

License

Examples is licensed under the MIT License. See the LICENSE.md file for details.

spacevil's People

Contributors

rsedaikin avatar spvessel avatar vsedaikina 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

Watchers

 avatar  avatar  avatar  avatar  avatar

spacevil's Issues

Window doesn`t show, app fail with code -1073741819

Hello.
I started using spacevil relatively recently. I readed the docs, and decided build and run example from this repository. I tried using .net framework 4.7.2 and .net 5, OS Windows. The results are the same - console window remains opened several seconds and app fail with code -1073741819. I tried creating window with "hello world" label - the same thing. Do you know what to do?
I really like spacevil and I don't really want to switch to other frameworks.

P.S. Sorry for the grammar - I'm not from an English-speaking country

UPD: I understood why the window is not displayed. I used 32 bit GLFW, and compiled app for x86. When i switched architecture to x64, it worked. However, the problem remains: 32 bit apps aren`t works. I recommend compiling separate binary files for x86 and x64 architectures, it may solve the problem.

Table View

Is there an analogue of the table (eg javafx.scene.control.TableView) in the framework?

Unable to find an entry point named 'glfwGetMonitorContentScale' in shared library 'glfw'

When following the steps to create a project using SpaceVIL on Ubuntu 18.04 using Dot Net Core 3.1 following the steps from the official website (https://spvessel.com/#downloads) an unhandled exception is thrown:

Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'glfwGetMonitorContentScale' in shared library 'glfw'.
   at A.b.A(q , Single* , Single* )
   at A.b.A(q , Single& , Single& )
   at SpaceVIL.Common.CommonService.InitSpaceVILComponents()
   at MyApp.Program.Main(String[] args) in /home/username/MyApp/Program.cs:line 10

Code

Program.cs

using System;
using SpaceVIL;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            if(!SpaceVIL.Common.CommonService.InitSpaceVILComponents())
            {
                return;
            }
            MainWindow mainWindow = new MainWindow();
            mainWindow.Show();
        }
    }
}

MainWindow.cs

using SpaceVIL;

namespace MyApp
{
    public class MainWindow : ActiveWindow
    {
        public override void InitWindow()
        {
            SetParameters(nameof(MainWindow), nameof(MainWindow), 800, 600);
            SetMinSize(400, 300);
            SetBackground(32, 34, 37);
        }
    }
}

MyApp.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="SpaceVIL.dll" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="System.Drawing.Common" Version="4.6.0-preview7.19362.9" />
  </ItemGroup>

</Project>

System.AccessViolationException: Attempted to read or write protected memory.

SpaceVIL version: 0.3.6.0-ALPHA - June 2020
Platform: .Net Core
OS type: Linux
OS: Arch Linux (KDE)

Open Kate -> Copy Text -> Close Kate -> Paste Text in TextEdit-> Exception

How to catch it?

Unhandled exception. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Runtime.InteropServices.Marshal.ReadByte(IntPtr ptr, Int32 ofs)
at A.b.A(IntPtr )
at A.b.f(Int64 )
at SpaceVIL.Common.CommonService.GetClipboardString()
at A.N.A(ITextShortcuts , KeyArgs )
at B.W.a(Object , KeyArgs )
at A.g.A(Int64 , KeyCode , Int32 , InputState , KeyMods )
at A.e.A(Int64 , KeyCode , Int32 , InputState , KeyMods )
at A.b.A(Double )
at SpaceVIL.WindowManager.A.b()
at SpaceVIL.WindowManager.b()
at A.o.D()
at SpaceVIL.CoreWindow.Show()

P.S. sorry if this is not a library problem

ComboBox example for C#

Hello, im looking for exaple how to use ComboBox in C#, and also is is possible to bind image to a MenuItem?

TextEdit.SetFontSize() not setting font size

Have tried to use TextEdit.SetFontSize() the same way I have used it with the Label element, but when I have looked at the Mimic example I found that SetFont() and SetSubstrateFontSize() are used instead. It is a bit unexpected that SetFontSize() is available, but has no effect. In fact, using SetFont() and SetSubstrateFontSize() also had no effect. :)

Have tried manipulating font size in the code below:

TextEdit textEdit = new TextEdit();
textEdit.SetFont(DefaultsService.GetDefaultFont(5));
textEdit.SetSubstrateText("Placeholder");
textEdit.SetSubstrateFontStyle(FontStyle.Regular);
textEdit.SetSubstrateFontSize(5);
textEdit.SetHeightPolicy(SizePolicy.Fixed);
textEdit.SetHeight(5);

Could you please let me know if I am missing something in my code?

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.