コード例 #1
0
        static void Main()
        {
            GL.Initialize(new DummyGL());
            GraphicsContextBackend.SetInstance(new DummyGC());
            WindowBackend.SetInstance(new DummyWindow());

            UnoGenerated();
            DotNetApplication.Start();

            const double targetTime = 1.0 / 60;

            while (Application.Current != null)
            {
                var startTime = Clock.GetSeconds();

                Bootstrapper.OnUpdate();
                Bootstrapper.OnDraw();

                var renderTime = Clock.GetSeconds() - startTime;
                var msTimeout  = (int)((targetTime - renderTime) * 1000.0 + 0.5);

                if (msTimeout > 0)
                {
                    Thread.Sleep(msTimeout);
                }
            }
        }
コード例 #2
0
        public MainForm(Action initializeApp)
        {
            InitializeComponent();
            Controls.Add(_control);
            _control.Initialize(this);
            var dpi = DpiAwareness.GetDpi(Handle);

            _control.SetDensity((float)dpi);
            ClientSize   = new Size((int)(375 * dpi), (int)(667 * dpi));
            FormClosing += (sender, e) => e.Cancel = _control.OnClosing();
            FormClosed  += (sender, e) => _control.OnClosed();
            Title        = GetAssemblyTitle();

            initializeApp();
            DotNetApplication.Start();
        }
コード例 #3
0
ファイル: AppDelegate.cs プロジェクト: mortend/uno
        public override void DidFinishLaunching(NSNotification notification)
        {
            var initialWindowSize = new CGRect(0, 0, 375, 667);
            var windowStyle       = NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Miniaturizable | NSWindowStyle.Closable;

            _control = new UnoGLView(initialWindowSize);
            _window  = new NSWindow(
                initialWindowSize,
                windowStyle,
                NSBackingStore.Buffered,
                false)
            {
                Title       = GetAssemblyTitle(),
                ContentView = _control
            };

            _window.MakeKeyAndOrderFront(_control);
            _control.Initialize();

            Program.UnoGenerated();
            DotNetApplication.Start();
            _control.Run(60.0);
        }
コード例 #4
0
        public void Initialize(IUnoWindow parent)
        {
            Window = parent;
            OpenGL.GL.Initialize(GL, !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DEBUG_GL")));
            GraphicsContextBackend.SetInstance(CoreGC);
            WindowBackend.SetInstance(CoreWindow);

            SizeChanged += (sender, e) => Bootstrapper.OnWindowSizeChanged(CoreWindow);

            MouseDown += (sender, e) =>
            {
                MouseButton button;
                if (!WinFormsHelper.TryGetUnoMouseButton(e.Button, out button))
                {
                    return;
                }

                _hasDown    = true;
                _lastX      = e.X;
                _lastY      = e.Y;
                _lastbutton = button;
                Bootstrapper.OnMouseDown(CoreWindow, e.X, e.Y, button);
            };

            MouseUp += (sender, e) =>
            {
                MouseButton button;
                if (!WinFormsHelper.TryGetUnoMouseButton(e.Button, out button))
                {
                    return;
                }

                Bootstrapper.OnMouseUp(CoreWindow, e.X, e.Y, button);
                _hasDown = false;
            };

            MouseLeave += (sender, e) => Bootstrapper.OnMouseOut(CoreWindow);
            MouseMove  += (sender, e) => Bootstrapper.OnMouseMove(CoreWindow, e.X, e.Y);

            MouseWheel += (sender, e) =>
            {
                var numLinesPerScroll = SystemInformation.MouseWheelScrollLines;
                var deltaMode         = numLinesPerScroll > 0
                    ? WheelDeltaMode.DeltaLine
                    : WheelDeltaMode.DeltaPage;

                var delta = deltaMode == WheelDeltaMode.DeltaLine ? (e.Delta / 120.0f) * numLinesPerScroll : e.Delta / 120.0f;
                Bootstrapper.OnMouseWheel(CoreWindow, 0, delta, (int)deltaMode);
            };

            PreviewKeyDown += (sender, e) =>
            {
                // TODO: By doing this the tab key will not be sent to wpf at all, it should be treated as IsInputKey only when not handled by Uno. A better solution could be done by reading http://msdn.microsoft.com/en-us/library/ms742474%28v=vs.110%29.aspx and http://blogs.msdn.com/b/nickkramer/archive/2006/06/09/623203.aspx
                switch (e.KeyData)
                {
                case Keys.Left:
                case Keys.Right:
                case Keys.Up:
                case Keys.Down:
                case Keys.Tab:
                    e.IsInputKey = true;
                    break;

                case Keys.Control | Keys.Left:
                case Keys.Control | Keys.Right:
                case Keys.Control | Keys.Up:
                case Keys.Control | Keys.Down:
                case Keys.Control | Keys.Tab:
                    e.IsInputKey = true;
                    break;

                case Keys.Shift | Keys.Left:
                case Keys.Shift | Keys.Right:
                case Keys.Shift | Keys.Up:
                case Keys.Shift | Keys.Down:
                case Keys.Shift | Keys.Tab:
                    e.IsInputKey = true;
                    break;

                case Keys.Control | Keys.Shift | Keys.Left:
                case Keys.Control | Keys.Shift | Keys.Right:
                case Keys.Control | Keys.Shift | Keys.Up:
                case Keys.Control | Keys.Shift | Keys.Down:
                case Keys.Control | Keys.Shift | Keys.Tab:
                    e.IsInputKey = true;
                    break;
                }
            };

            KeyDown += (sender, e) =>
            {
                Key key;
                if (!WinFormsHelper.TryGetUnoKey(e.KeyCode, out key))
                {
                    return;
                }

                e.Handled = Bootstrapper.OnKeyDown(CoreWindow, key);

                if (!e.Handled && key == Key.F11)
                {
                    Window.IsFullscreen = !Window.IsFullscreen;
                }
            };

            KeyUp += (sender, e) =>
            {
                Key key;
                if (!WinFormsHelper.TryGetUnoKey(e.KeyCode, out key))
                {
                    return;
                }

                e.Handled = Bootstrapper.OnKeyUp(CoreWindow, key);
            };

            KeyPress += (sender, e) =>
            {
                if (CoreWindow.IsTextInputActive() && (ModifierKeys & (Keys.Control | Keys.Alt)) != Keys.Control)
                {
                    e.Handled = Bootstrapper.OnTextInput(CoreWindow, e.KeyChar.ToString());
                }
            };

            GotFocus  += (sender, e) => DotNetApplication.EnterInteractive();
            LostFocus += (senders, e) => DotNetApplication.ExitInteractive();
        }
コード例 #5
0
 public void StartApp(MethodInfo entrypoint)
 {
     entrypoint.Invoke(null, null);
     DotNetApplication.Start();
 }