Beispiel #1
0
        protected SurfaceBase(ISurfaceHandler events)
        {
            SurfaceHandler surfaceEvents = new SurfaceHandler
            {
                Draw = (IntPtr surfaceHandler, IntPtr surface, ref uiAreaDrawParams args) =>
                {
                    ControlSafeHandle surfaceHandle = new ControlSafeHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    DrawEventArgs     a             = (DrawEventArgs)args;
                    events.Draw(realSurface, ref a);
                },
                MouseEvent = (IntPtr surfaceHandler, IntPtr surface, ref uiAreaMouseEvent args) =>
                {
                    ControlSafeHandle surfaceHandle = new ControlSafeHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    MouseEventArgs    a             = (MouseEventArgs)args;
                    events.MouseEvent(realSurface, ref a);
                },
                MouseCrossed = (surfaceHandler, surface, left) =>
                {
                    ControlSafeHandle     surfaceHandle = new ControlSafeHandle(surface);
                    SurfaceBase           realSurface   = Surfaces[surfaceHandle];
                    MouseCrossedEventArgs a             = new MouseCrossedEventArgs(left);
                    events.MouseCrossed(realSurface, a);
                },
                DragBroken = (surfaceHandler, surface) =>
                {
                    ControlSafeHandle surfaceHandle = new ControlSafeHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    events.DragBroken(realSurface);
                },
                KeyEvent = (IntPtr surfaceHandler, IntPtr surface, ref uiAreaKeyEvent args) =>
                {
                    ControlSafeHandle surfaceHandle = new ControlSafeHandle(surface);
                    SurfaceBase       realSurface   = Surfaces[surfaceHandle];
                    KeyEventArgs      a             = (KeyEventArgs)args;
                    return(events.KeyEvent(realSurface, ref a));
                }
            };

            EventHandler = new uiAreaHandler
            {
                DragBroken   = Marshal.GetFunctionPointerForDelegate(surfaceEvents.DragBroken),
                Draw         = Marshal.GetFunctionPointerForDelegate(surfaceEvents.Draw),
                KeyEvent     = Marshal.GetFunctionPointerForDelegate(surfaceEvents.KeyEvent),
                MouseCrossed = Marshal.GetFunctionPointerForDelegate(surfaceEvents.MouseCrossed),
                MouseEvent   = Marshal.GetFunctionPointerForDelegate(surfaceEvents.MouseEvent)
            };
        }
Beispiel #2
0
 internal MenuStripItem(ControlSafeHandle handle)
 {
     Handle = handle;
     InitializeEvents();
 }