示例#1
0
        public GLGui(GameWindow parent) : base(null)
        {
            GLCursor.LoadCursors(parent);

            Gui          = this;
            base.Parent  = this;
            ParentWindow = parent;
            Outer        = parent.ClientRectangle;
            Anchor       = GLAnchorStyles.All;

            parent.Mouse.Move         += (s, e) => DoMouseMove(e);
            parent.Mouse.ButtonDown   += OnMouseDown;
            parent.Mouse.ButtonUp     += OnMouseUp;
            parent.Mouse.WheelChanged += (s, e) => DoMouseWheel(e);
            parent.MouseEnter         += (s, e) => DoMouseEnter();
            parent.MouseLeave         += (s, e) => DoMouseLeave();
            parent.KeyDown            += (s, e) => DoKeyDown(e);
            parent.KeyUp    += (s, e) => DoKeyUp(e);
            parent.KeyPress += (s, e) => DoKeyPress(e);
            parent.Resize   += (s, e) => Outer = parent.ClientRectangle;
        }
示例#2
0
        public GLGui(OpenTK.GLControl parent) : base(null)
        {
            GLCursor.LoadCursors(null);

            Gui           = this;
            base.Parent   = this;
            ParentControl = parent;
            Outer         = parent.ClientRectangle;
            Anchor        = GLAnchorStyles.All;

            int lastX = 0, lastY = 0, wheelValue = 0;

            parent.MouseMove  += (s, e) => { DoMouseMove(new MouseMoveEventArgs(e.X, e.Y, e.X - lastX, e.Y - lastY)); lastX = e.X; lastY = e.Y; };
            parent.MouseDown  += (s, e) => OnMouseDown(s, new MouseButtonEventArgs(e.X, e.Y, ToOpenTK(e.Button), true));
            parent.MouseUp    += (s, e) => OnMouseUp(s, new MouseButtonEventArgs(e.X, e.Y, ToOpenTK(e.Button), false));
            parent.MouseWheel += (s, e) => { wheelValue += e.Delta; DoMouseWheel(new MouseWheelEventArgs(e.X, e.Y, wheelValue, e.Delta)); };
            parent.MouseEnter += (s, e) => DoMouseEnter();
            parent.MouseLeave += (s, e) => DoMouseLeave();
            parent.KeyDown    += (s, e) => DoKeyDown(ToOpenTK(e));
            parent.KeyUp      += (s, e) => DoKeyUp(ToOpenTK(e));
            parent.KeyPress   += (s, e) => DoKeyPress(new KeyPressEventArgs(e.KeyChar));
            parent.Resize     += (s, e) => Outer = parent.ClientRectangle;
        }