Giter Site home page Giter Site logo

yuaom / switch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wyrover/switch

0.0 0.0 0.0 204.3 MB

Native C++ port of .Net Framework on Windows, macOS, Linux, iOS and android (WinForms included).

Home Page: https://gammasoft71.wixsite.com/switch

License: Other

CMake 0.80% Batchfile 0.04% Shell 0.16% C++ 98.22% Objective-C++ 0.77%

switch's Introduction

GitHub Logo


build status Build status codecov license GPL v3 © Gammasoft std c++17 ready os Windows, macOS, linux development status

The Switch framework is...

  • a collection of native C++ classes libraries, similar to the .NET Framework;
  • written in efficient, modern C++14;
  • and highly portable and available on many different platforms (Windows, macOS, Linux, iOS and android);

For more information see Switch website (or markdown Documentations) and Reference Guide

Examples

The classic first application 'Hello World'.

Console

HelloWorld.cpp:

#include <Switch/Switch>

using namespace System;

namespace HelloWorld {
  class Program {
  public:
    static void Main() {
      Console::WriteLine("Hello, World!");
    }
  };
}

startup_(HelloWorld::Program);

CMakeLists.txt:

cmake_minimum_required(VERSION 3.2)

Project(HelloWorld)
find_package(Switch REQUIRED)
add_executable(HelloWorld HelloWorld.cpp)
target_link_libraries(HelloWorld Switch.System)

Forms

HelloWorldForm.cpp:

#include <Switch/Switch>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace HelloWorld {
  class Program {
  public:
    static void Main() {
      Application::EnableVisualStyles();
      
      Button button;
      button.Text = "Click me";
      button.Location = Point(10, 10);
      button.Click += delegate_(const object& sender, const EventArgs& e) {
        MessageBox::Show("Hello, World!");
      };
      
      Form form;
      form.Text = "Hello World Form";
      form.Controls().Add(button);
      
      Application::Run(form);
    }
  };
}

startup_(HelloWorld::Program);

CMakeLists.txt:

cmake_minimum_required(VERSION 3.2)

Project(HelloWorldForm)
find_package(Switch REQUIRED)
add_executable(HelloWorldForm ${SWITCH_GUI} HelloWorldForm.cpp)
target_link_libraries(HelloWorldForm Switch.System.Windows.Forms)

TUnit

HelloWorldTest.cpp:

#include <Switch/Switch>

using namespace TUnit::Framework;
using namespace System;

namespace UnitTests {
  class TestFixture_(HelloWorldTest) {
    void Test_(CreateStringFromLiteral) {
      string s = "Hello, World!";
      Assert::AreEqual("Hello, World!", s);
    }

    void Test_(CreateStringFromChars) {
      string s = {'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!'};
      Assert::AreEqual("Hello, World!", s);
    }
  };

  AddTestFixture_(HelloWorldTest);
}

CMakeLists.txt:

cmake_minimum_required(VERSION 3.2)

Project(HelloWorldTest)
find_package(Switch REQUIRED)
add_executable(HelloWorldTest HelloWorldTest.cpp)
target_link_libraries(HelloWorldTest Switch.TUnit.Main)

For more examples see Examples

Download and install Switch

Before running examples you must download and install Switch. To download and install it read Downloads page or Downloads.md file.

switch's People

Contributors

yfiumefreddo avatar gammasoft71 avatar

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.