コード例 #1
0
        public void Restore()
        {
            if ((options & WindowPersistOptions.Size) != 0)
            {
                int width  = WidthSchema.Get();
                int height = HeightSchema.Get();

                if (width != 0 && height != 0)
                {
                    window.Resize(width, height);
                }
            }

            if ((options & WindowPersistOptions.Position) != 0)
            {
                int x = XPosSchema.Get();
                int y = YPosSchema.Get();

                if (x == 0 && y == 0)
                {
                    window.SetPosition(Gtk.WindowPosition.Center);
                }
                else
                {
                    window.Move(x, y);
                }
            }

            if ((options & WindowPersistOptions.Size) != 0)
            {
                if (MaximizedSchema.Get())
                {
                    window.Maximize();
                }
                else
                {
                    window.Unmaximize();
                }
            }
        }
コード例 #2
0
        public void Run()
        {
            Gtk.Application.Init();

            ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkUIElementPointersSupport(o));

            _window = new Gtk.Window("Uno Host");
            _window.SetDefaultSize(1024, 800);
            _window.SetPosition(Gtk.WindowPosition.Center);

            _window.DeleteEvent += delegate
            {
                Gtk.Application.Quit();
            };

            Windows.UI.Core.CoreDispatcher.DispatchOverride
                = d =>
                {
                if (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration(false);
                }

                GLib.Idle.Add(delegate
                {
                    Console.WriteLine("iteration");
                    try
                    {
                        d();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    return(false);
                });
                };

            _window.Realized += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight));
            };

            _window.SizeAllocated += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height));
            };

            var area = new UnoDrawingArea();

            _window.Add(area);

            /* avoids double invokes at window level */
            area.AddEvents((int)(
                               Gdk.EventMask.PointerMotionMask
                               | Gdk.EventMask.ButtonPressMask
                               | Gdk.EventMask.ButtonReleaseMask
                               ));

            _window.ShowAll();

            WUX.Application.Start(_ => _appBuilder());

            Gtk.Application.Run();
        }
コード例 #3
0
ファイル: GtkHost.cs プロジェクト: jokm1/uno-2
        public void Run()
        {
            Gtk.Application.Init();

            ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkUIElementPointersSupport(o));
            ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o));
            ApiExtensibility.Register(typeof(IApplicationExtension), o => new GtkApplicationExtension(o));
            ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window));

            _window = new Gtk.Window("Uno Host");
            _window.SetDefaultSize(1024, 800);
            _window.SetPosition(Gtk.WindowPosition.Center);

            _window.DeleteEvent += delegate
            {
                Gtk.Application.Quit();
            };

            Windows.UI.Core.CoreDispatcher.DispatchOverride
                = d =>
                {
                if (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration(false);
                }

                GLib.Idle.Add(delegate
                {
                    if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace))
                    {
                        this.Log().Trace($"Iteration");
                    }

                    try
                    {
                        d();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    return(false);
                });
                };

            _window.Realized += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight));
            };

            _window.SizeAllocated += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height));
            };

            _area = new UnoDrawingArea();
            _window.Add(_area);

            /* avoids double invokes at window level */
            _area.AddEvents((int)(
                                Gdk.EventMask.PointerMotionMask
                                | Gdk.EventMask.ButtonPressMask
                                | Gdk.EventMask.ButtonReleaseMask
                                ));

            _window.ShowAll();

            void CreateApp(ApplicationInitializationCallbackParams _)
            {
                var app = _appBuilder();

                app.Host = this;
            }

            WUX.Application.Start(CreateApp, _args);

            UpdateWindowPropertiesFromPackage();

            Gtk.Application.Run();
        }
コード例 #4
0
ファイル: GtkHost.cs プロジェクト: patmosxx-v2/uno
        public void Run()
        {
            Gtk.Application.Init();
            ApiExtensibility.Register(typeof(Windows.UI.Core.ICoreWindowExtension), o => new GtkCoreWindowExtension(o));
            ApiExtensibility.Register(typeof(Windows.UI.ViewManagement.IApplicationViewExtension), o => new GtkApplicationViewExtension(o));
            ApiExtensibility.Register(typeof(ISystemThemeHelperExtension), o => new GtkSystemThemeHelperExtension(o));
            ApiExtensibility.Register(typeof(Windows.Graphics.Display.IDisplayInformationExtension), o => _displayInformationExtension ??= new GtkDisplayInformationExtension(o, _window));

            _isDispatcherThread = true;
            _window             = new Gtk.Window("Uno Host");
            _window.SetDefaultSize(1024, 800);
            _window.SetPosition(Gtk.WindowPosition.Center);

            _window.DeleteEvent += delegate
            {
                Gtk.Application.Quit();
            };

            bool EnqueueNative(DispatcherQueuePriority priority, DispatcherQueueHandler callback)
            {
                Dispatch(() => callback());

                return(true);
            }

            Windows.System.DispatcherQueue.EnqueueNativeOverride = EnqueueNative;

            void Dispatch(Action d)
            {
                if (Gtk.Application.EventsPending())
                {
                    Gtk.Application.RunIteration(false);
                }

                GLib.Idle.Add(delegate
                {
                    if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Trace))
                    {
                        this.Log().Trace($"Iteration");
                    }

                    try
                    {
                        d();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }

                    return(false);
                });
            }

            Windows.UI.Core.CoreDispatcher.DispatchOverride        = Dispatch;
            Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride = () => _isDispatcherThread;

            _window.Realized += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(_window.AllocatedWidth, _window.AllocatedHeight));
            };

            _window.SizeAllocated += (s, e) =>
            {
                WUX.Window.Current.OnNativeSizeChanged(new Windows.Foundation.Size(e.Allocation.Width, e.Allocation.Height));
            };

            _area = new UnoDrawingArea();
            _window.Add(_area);

            /* avoids double invokes at window level */
            _area.AddEvents((int)GtkCoreWindowExtension.RequestedEvents);

            _window.ShowAll();

            void CreateApp(ApplicationInitializationCallbackParams _)
            {
                var app = _appBuilder();

                app.Host = this;
            }

            WUX.Application.Start(CreateApp, _args);

            UpdateWindowPropertiesFromPackage();

            Gtk.Application.Run();
        }