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(); }