示例#1
0
        public UnoView(IScheduler dispatcher, IReport log, IRenderTarget renderTarget)
            : base(v => dispatcher.Schedule(v), new CGRect(0, 0, 0, 0))
        {
            _renderTarget = renderTarget;
            _log          = log;

            _unoWindow   = new PlatformWindowHandleImpl(this);
            _unoGraphics = new GraphicsContextHandleImpl(_unoWindow);

            Reshape();
        }
示例#2
0
        public UnoControl(DpiAwareForm form, IReport log)
        {
            _form = form;
            _log  = log;

            SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            DoubleBuffered = false;
            Dock           = DockStyle.Fill;

            // set up an OpenTK context
            Toolkit.Init(new ToolkitOptions {
                Backend = PlatformBackend.PreferNative
            });
            var windowInfo = Utilities.CreateWindowsWindowInfo(Handle);

            _glContext = ContextFactory.CreateContext(windowInfo);
            _glContext.SwapInterval = 0;

            _unoWindow   = new PlatformWindowHandleImpl(this);
            _unoGraphics = new GraphicsContextHandleImpl(_unoWindow);


            _form.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

                var codeWithoutModifiers = e.KeyCode & (~Keys.Control) & (~Keys.Shift);

                switch (codeWithoutModifiers)
                {
                case Keys.Left:
                case Keys.Right:
                case Keys.Up:
                case Keys.Down:
                case Keys.Tab:
                    e.IsInputKey = true;
                    break;
                }
            };

            Focus();
        }