Ejemplo n.º 1
0
        static int Main()
        {
#if DEBUG
            Helpers.LoadDebugVariables();
#endif

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Thread.Sleep(10);
                    GC.Collect(GC.MaxGeneration);
                }
                // ReSharper disable FunctionNeverReturns
            });
            // ReSharper restore FunctionNeverReturns

            using (var r = new StringVector(0))
            {
                using (var app = new QGuiApplication(r))
                {
                    using (var engine = new QQmlApplicationEngine())
                    {
                        QQmlApplicationEngine.RegisterType <TestQmlImport>("test", 1, 1);

                        engine.loadFile("main.qml");
                        return(app.exec());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void LoadQml() {
            // 1. File Access
            QmlEngine = new QQmlApplicationEngine("main.qml");

            // 2. File Access
            //QmlEngine = new QQmlApplicationEngine();
            //QmlEngine.Load("main.qml");

            // 3. Url Access
            //QUrl url1 = QUrl.FromLocalFile("main.qml");
            //QmlEngine = new QQmlApplicationEngine(url1);

            // 4. LoadData
            //string qmltxt = System.IO.File.ReadAllText("main.qml");
            //QByteArray qarr = new QByteArray(qmltxt, qmltxt.Length);
            //QmlEngine = new QQmlApplicationEngine();
            //QmlEngine.LoadData(qarr);

            // This shows an empty form, perhaps it's supposed to
            //QQuickView quickView = new QQuickView();
            //quickView.Source = QUrl.FromLocalFile(@"main.qml");
            //quickView.Show();

            //This seems to bomb out horribly
            //QmlEngine = new QQmlApplicationEngine();
            //Comp = new QQmlComponent(QmlEngine, QUrl.FromLocalFile("main.qml"));
            //CompObj = Comp.Create();
            //QQmlApplicationEngine.SetObjectOwnership(CompObj, QQmlEngine.ObjectOwnership.CppOwnership);

            // http://stackoverflow.com/questions/23936169/whats-the-difference-between-qquickview-and-qquickwindow
            //QmlEngine = new QQmlApplicationEngine();
            //QmlEngine.Load ("main.qml");
            // To access the QQuickView inside QmlEngine we need to access the rootObjects()
            // rootObjects appears to be a function which returns a QList of pointers to QObject, not visible because it's templated
        }
Ejemplo n.º 3
0
        /*static int Main(string[] args)
         * {
         *  using (var app = new QGuiApplication(args))
         *  {
         *      using (var engine = new QQmlApplicationEngine())
         *      {
         *          // TODO: Register your .NET types.
         *          // Qml.RegisterType<NetObject>("test");
         *
         *          engine.Load("Main.qml");
         *
         *          return app.Exec();
         *      }
         *  }
         * }*/
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            using (var app = new QGuiApplication(args))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    // TODO: Register your .NET types to be used in Qml
                    Qml.Net.Qml.RegisterType <QmlType>("TestApp", 1, 1);       // in QML file: import TestApp 1.1
                    Qml.Net.Qml.RegisterType <YourNetObject>("YourApp", 2, 1); // in QML file: import YourApp 2.1


                    var netObject = new YourNetObject();
                    // You can attach signal handlers from both .NET and QML:
                    netObject.AttachToSignal("signalName", new Action <string, int>((param1, param2) =>
                    {
                        Console.WriteLine("Signal raised from .NET! {0} {1}", param1, param2);
                    }));


                    engine.Load("Main.qml");


                    // You can raise signals from .NET:
                    netObject.ActivateSignal("signalName", "param", 3);


                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 4
0
        static int Main(string[] args)
        {
            _CheckTimer = new Timer((e) =>
            {
                CheckAndPrint();
            });
            _CheckTimer.Change(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5));

            using (var app = new QGuiApplication(args))
            {
                _App = app;
                AppModel.UIDispatch += (a) => _App.Dispatch(a);
                QQmlApplicationEngine.ActivateMVVMBehavior();
                using (var engine = new QQmlApplicationEngine())
                {
                    QQmlApplicationEngine.RegisterType <AppModel>("app", 1, 1);

                    var assemblyDir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().Location).AbsolutePath);
                    var mainQmlPath = Path.Combine(assemblyDir, "UI", "QML", "main.qml");
                    engine.Load(mainQmlPath);
                    int result = app.Exec();
                    _App = null;
                    return(result);
                }
            }
        }
Ejemplo n.º 5
0
 protected AbstractBaseQmlTests()
 {
     _coreApplication        = new QGuiApplication(new[] { "-platform", "offscreen" });
     qmlApplicationEngine    = new QQmlApplicationEngine();
     TypeCreator             = new MockTypeCreator();
     Net.TypeCreator.Current = TypeCreator;
 }
Ejemplo n.º 6
0
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            using (var app = new QGuiApplication(args))
            {
                Qml.Net.Qml.RegisterType <Trans>("TaoQuickNet");
                var trans = new Trans();
                trans.loadFolder(Config.Config.transPath);
                using (var engine = new QQmlApplicationEngine())
                {
                    Console.WriteLine("importPath " + Config.Config.importPath);
                    Console.WriteLine("imgPath " + Config.Config.imgPath);

                    engine.AddImportPath(Config.Config.importPath);
                    engine.SetContextProperty("imgPath", Config.Config.imgPath);
                    engine.SetContextProperty("qmlPath", Config.Config.qmlPath);
                    engine.SetContextProperty("contentsPath", Config.Config.contentsPath);
                    engine.SetContextProperty("isDebug", true);

                    engine.SetContextProperty("taoQuickImagePath", Config.Config.importPath + "TaoQuick/Images/");

                    engine.SetContextProperty("trans", trans);

                    engine.Load(Config.Config.qmlPath + "main.qml");
                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 7
0
 public void GlobalSetup()
 {
     if (!_initialized)
     {
         QQmlApplicationEngine.RegisterType <QmlType>("tests");
         _initialized = true;
     }
 }
Ejemplo n.º 8
0
 protected void RegisterType <T>()
 {
     if (_registeredTypes.Contains(typeof(T)))
     {
         return;
     }
     _registeredTypes.Add(typeof(T));
     QQmlApplicationEngine.RegisterType <T>("tests");
 }
Ejemplo n.º 9
0
 static void Main(string[] args)
 {
     using (var application = new QGuiApplication(args))
     {
         using (var engine = new QQmlApplicationEngine())
         {
             engine.Load("Tutorial01.qml");
             application.Exec();
         }
     }
 }
Ejemplo n.º 10
0
 protected virtual void AddImportPath(QQmlApplicationEngine engine)
 {
     if (Builder.ImportPath.Count() == 0)
     {
         return;
     }
     foreach (var path in Builder.ImportPath)
     {
         engine.AddImportPath(path);
     }
 }
Ejemplo n.º 11
0
        public static bool RunQml(QQmlApplicationEngine qmlEngine, string qml, bool runEvents = false, bool failOnQmlWarnings = true)
        {
            var warnings = new List <string>();
            var result   = Interop.NetTestHelper.RunQml(qmlEngine.Handle, qml, runEvents ? (byte)1 : (byte)0, warnings.Add);

            if (warnings.Count > 0 && failOnQmlWarnings)
            {
                throw new Exception(string.Join("\n", warnings));
            }

            return(result == 1);
        }
Ejemplo n.º 12
0
 private static int Main(string[] args)
 {
     RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
     Qt.PutEnv("QT_QUICK_CONTROLS_CONF", System.IO.Directory.GetCurrentDirectory() + "/qml/qtquickcontrols2.conf");
     QmlNetConfig.ShouldEnsureUIThread  = false;            // remove this line when fixed in qml.net: temporary workaround for https://github.com/qmlnet/qmlnet/issues/112
     using QGuiApplication app          = new QGuiApplication(args);
     using QQmlApplicationEngine engine = new QQmlApplicationEngine();
     // Register our new type to be used in Qml
     QmlBridge.RegisterTypes();
     engine.Load(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "qml", "main.qml"));
     return(app.Exec());
 }
Ejemplo n.º 13
0
        public BaseTests()
        {
            Monitor.Enter(LockObject);

#if DEBUG
            Helpers.LoadDebugVariables();
#endif

            _applicationArgs = new StringVector();
            _coreApplication = new QGuiApplication(_applicationArgs);

            qmlApplicationEngine = new QQmlApplicationEngine();
        }
Ejemplo n.º 14
0
        static int Main(string[] args)
        {
            PrepareRuntime();

            using var app    = new QGuiApplication(args);
            using var engine = new QQmlApplicationEngine();

            Qml.Net.Qml.RegisterType <NetObject>("app");

            engine.Load("Main.qml");

            return(app.Exec());
        }
Ejemplo n.º 15
0
 protected AbstractBaseQmlTests()
 {
     _coreApplication        = new QGuiApplication(new [] { "-platform", "offscreen" });
     qmlApplicationEngine    = new QQmlApplicationEngine();
     TypeCreator             = new MockTypeCreator();
     Net.TypeCreator.Current = TypeCreator;
     TypeCreator.SetInstance(typeof(TestContext), new TestContext(_coreApplication));
     if (!_testContextRegistered)
     {
         QQmlApplicationEngine.RegisterType <TestContext>("testContext");
         _testContextRegistered = true;
     }
 }
Ejemplo n.º 16
0
 public void GlobalSetup()
 {
     _guiApplication       = new QGuiApplication(new[] { "-platform", "offscreen" });
     _qmlApplicationEngine = new QQmlApplicationEngine();
     NetTestHelper.RunQml(
         _qmlApplicationEngine,
         @"
                 import QtQuick 2.0
                 import tests 1.0
                 Item {{
                 }}");
     _qObject = Qt.BuildQObject("TestQObject*");
 }
Ejemplo n.º 17
0
 static int Main(string[] args)
 {
     RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
     QQuickStyle.SetStyle("Material");
     using (var application = new QGuiApplication(args))
     {
         using (var qmlEngine = new QQmlApplicationEngine())
         {
             Qml.Net.Qml.RegisterType <TrayModel>("app");
             qmlEngine.Load("TrayIcon.qml");
             return(application.Exec());
         }
     }
 }
Ejemplo n.º 18
0
        override protected int RunHostOverride(string[] _)
        {
            using (var app = new QGuiApplication(_))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    RegisterTypes();

                    LoadViews(engine);

                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 19
0
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            using (var app = new QGuiApplication(args))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    Qml.Net.Qml.RegisterType <EditorModel>("Editor");
                    engine.Load("main.qml");
                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 20
0
 static int Main(string[] args)
 {
     Qt.PutEnv("QT_OPENGL", "angle");
     Qt.PutEnv("QT_ANGLE_PLATFORM", "warp");
     Qt.PutEnv("QT_DISABLE_SHADER_DISK_CACHE", "1");
     using (var app = new QGuiApplication(args))
     {
         using (var engine = new QQmlApplicationEngine())
         {
             Qml.Net.Qml.RegisterType <EditorModel>("Editor");
             engine.Load("main.qml");
             return(app.Exec());
         }
     }
 }
Ejemplo n.º 21
0
        static int Main(string[] args)
        {
            using (var app = new QGuiApplication(args))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    // TODO: Register your .NET types.
                    // Qml.RegisterType<NetObject>("test");

                    engine.Load("Main.qml");

                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 22
0
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();


            using (var application = new QGuiApplication(args))
            {
                using (var qmlEngine = new QQmlApplicationEngine())
                {
                    qmlEngine.Load("photoshopGUI.qml");

                    return(application.Exec());
                }
            }
        }
Ejemplo n.º 23
0
        static int Main(string[] args)
        {
            //RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            using (var app = new QGuiApplication(args))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    // Register our new type to be used in Qml
                    //Qml.Net.Qml.RegisterType<QmlType>("test", 1, 1);
                    engine.Load("qml/main.qml");
                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 24
0
 static int Main(string[] args)
 {
     using (var app = new QGuiApplication(args))
     {
         using (var engine = new QQmlApplicationEngine())
         {
             Qml.Net.Qml.RegisterType <QmlNetBridge>(uri: "app");
             var content = System.IO.File.ReadAllText(@"mainWindow.qml");
             content = "import app 1.0\n" + content;
             content = content.Replace(@"//<C#>", @"");
             engine.LoadData(content);
             return(app.Exec());
         }
     }
 }
Ejemplo n.º 25
0
 private static bool Init(ref string[] args)
 {
     qmlFilesPath = Path.Combine(Directory.GetCurrentDirectory(), "qml");
     if (qmlFilesPath.Length > 0)
     {
         app       = new QGuiApplication(args);
         qmlEngine = new QQmlApplicationEngine();
         Qml.Net.Qml.RegisterType <Models.AudioModel>("AudioModel", 0, 1);
         Qml.Net.Qml.RegisterType <Models.ListAudioModels>("ListAudioModels", 0, 1);
         Qml.Net.Qml.RegisterType <Models.IconModel>("IconModel", 0, 1);
         qmlEngine.Load(Path.Combine(qmlFilesPath, "Main.qml"));
         return(true);
     }
     return(false);
 }
Ejemplo n.º 26
0
        private static int Main(string[] args)
        {
            GetResponse();

            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
            QQuickStyle.SetStyle("Material");

            using (var application = new QGuiApplication())
            {
                using (var qmlEngine = new QQmlApplicationEngine())
                {
                    qmlEngine.Load("Main.qml");
                    return(application.Exec());
                }
            }
        }
Ejemplo n.º 27
0
        static int Main(string[] args)
        {
            using (var app = new QGuiApplication(args))
            {
                using (var engine = new QQmlApplicationEngine())
                {
                    engine.AddImportPath(Path.Combine(Directory.GetCurrentDirectory(), "Qml"));

                    Qml.RegisterType <TestQmlImport>("test");

                    engine.Load("main.qml");

                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 28
0
        static int Main(string[] args)
        {
            var path = System.Environment.GetEnvironmentVariable("PATH");

            path += ";" + @"D:\Git\Github\pauldotknopf\net-core-qml\src\native\build-QtNetCoreQml-Desktop_Qt_5_9_1_MSVC2017_64bit-Debug\debug";
            System.Environment.SetEnvironmentVariable("PATH", path);

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Thread.Sleep(1000);
                    GC.Collect(GC.MaxGeneration);
                }
            });

            using (var r = new StringVector(0))
            {
                using (var app = new QGuiApplication(r))
                {
                    using (var engine = new QQmlApplicationEngine())
                    {
                        QQmlApplicationEngine.RegisterType <TestQmlImport>("test", 1, 1);

                        var method = NetTypeInfoManager.GetTypeInfo <TestQmlImport>().GetMethod(0);
                        Console.WriteLine(method.GetMethodName());

                        NetTestHelper.RunMethod(engine,
                                                @"
                                import QtQuick 2.0
                                import test 1.1

                                TestQmlImport {
                                }
                            ",
                                                method,
                                                null,
                                                null);

                        //engine.loadFile("main.qml");
                        //return app.exec();
                    }
                }
            }

            return(0);
        }
Ejemplo n.º 29
0
        static int Main(string[] args)
        {
            var coll = new ServiceCollection().AddHttpClient();

            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();
            using (var app = new QGuiApplication())
            {
                Console.WriteLine("entered 1st using");
                using (var engine = new QQmlApplicationEngine())
                {
                    Console.WriteLine("entered 2nd using");
                    Qml.Net.Qml.RegisterType <QmlType>("test", 1, 1);
                    engine.Load("qml/main.qml");
                    return(app.Exec());
                }
            }
        }
Ejemplo n.º 30
0
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            Init();

            //QQuickStyle.SetStyle("Material");

            using (var application = new QGuiApplication(args))
            {
                using (var qmlEngine = new QQmlApplicationEngine())
                {
                    Qml.Net.Qml.RegisterType <LibraryList>("MIXManga.NET.VS");
                    qmlEngine.Load("Main.qml");
                    return(application.Exec());
                }
            }
        }
Ejemplo n.º 31
0
        static int Main(string[] args)
        {
            RuntimeManager.DiscoverOrDownloadSuitableQtRuntime();

            QQuickStyle.SetStyle("Material");

            using (var application = new QGuiApplication(args))
            {
                using (var qmlEngine = new QQmlApplicationEngine())
                {
                    Qml.Net.Qml.RegisterType <MainController>("Controllers");
                    Qml.Net.Qml.RegisterType <SimpleList>("Lists");
                    qmlEngine.Load("Main.qml");

                    return(application.Exec());
                }
            }
        }