示例#1
0
        // ----------------------- 模板,勿删 -----------------------------------------
        //internal static void On(Widget widget, EventArg arg)
        //{
        //    widget.mHandle(widget.Name);
        //}
        //internal event Event. Event
        //{
        //    add
        //    {
        //        if (null == )
        //        {
        //            if (ICall_appendEvent(this, mInstance.Ptr, EventType.))
        //            {
        //                += value;
        //            }
        //        }
        //    }
        //    remove
        //    {
        //        -= value;
        //        if (null == )
        //        {
        //            ICall_removeEvent(this, mInstance.Ptr, EventType.);
        //        }
        //    }
        //}
        //protected Event. mHandle;



        unsafe private static void onEvent(Widget widget, IntPtr int_ptr)
        {
            EventArg arg = Util.PtrToStruct <EventArg>(int_ptr);

            switch (arg.EventType)
            {
            case EventType.MouseButtonClick:
            {
                Widget.OnMouseButtonClick(widget, Util.PtrToStruct <EventArg>(int_ptr));       //
            }
            break;

            case EventType.MouseButtonPressed:
            {
                Widget.OnMouseButtonPressed(widget, Util.PtrToStruct <MouseButtonEventArg>(int_ptr));
            }
            break;

            case EventType.MouseButtonReleased:
            {
                Widget.OnMouseButtonReleased(widget, Util.PtrToStruct <MouseButtonEventArg>(int_ptr));
            }
            break;

            case EventType.MouseButtonDoubleClick:
            {
                Widget.OnMouseButtonDoubleClick(widget, Util.PtrToStruct <EventArg>(int_ptr));
            }
            break;

            case EventType.MouseLostFocus:
            {
                Widget.OnMouseLostFocus(widget, Util.PtrToStruct <FocusEventArg>(int_ptr));
            }
            break;

            case EventType.MouseSetFocus:
            {
                Widget.OnMouseSetFocus(widget, Util.PtrToStruct <FocusEventArg>(int_ptr));
            }
            break;

            case EventType.MouseDrag:
            {
                Widget.OnMouseDrag(widget, Util.PtrToStruct <MouseDragEventArg>(int_ptr));
            }
            break;

            case EventType.MouseMove:
            {
                Widget.OnMouseMove(widget, Util.PtrToStruct <MouseMoveEventArg>(int_ptr));
            }
            break;

            case EventType.MouseWheel:
            {
                Widget.OnMouseWheel(widget, Util.PtrToStruct <MouseWheelEventArg>(int_ptr));
            }
            break;

            case EventType.KeyLostFocus:
            {
                Widget.OnKeyLostFocus(widget, Util.PtrToStruct <FocusEventArg>(int_ptr));
            }
            break;

            case EventType.KeySetFocus:
            {
                Widget.OnKeySetFocus(widget, Util.PtrToStruct <FocusEventArg>(int_ptr));
            }
            break;

            case EventType.KeyButtonPressed:
            {
                Widget.OnKeyButtonPressed(widget, Util.PtrToStruct <KeyButtonPressedEventArg>(int_ptr));
            }
            break;

            case EventType.KeyButtonReleased:
            {
                Widget.OnKeyButtonReleased(widget, Util.PtrToStruct <KeyButtonReleasedEventArg>(int_ptr));
            }
            break;

            case EventType.RootMouseChangeFocus:
            {
                Widget.OnRootMouseChangeFocus(widget, Util.PtrToStruct <RootChangeFocusEventArg>(int_ptr));
            }
            break;

            case EventType.RootKeyChangeFocus:
            {
                Widget.OnRootKeyChangeFocus(widget, Util.PtrToStruct <RootChangeFocusEventArg>(int_ptr));
            }
            break;

            case EventType.ToolTip:
            {
                Widget.OnToolTip(widget, Util.PtrToStruct <ToolTipEventArg>(int_ptr));
            }
            break;


            case EventType.ScrollChangePosition:
            {
                ScrollBar sb = widget as ScrollBar;
                if (null != sb)
                {
                    ScrollBar.OnScrollChangePosition(sb, Util.PtrToStruct <ScrollChangePositionEventArg>(int_ptr));
                }
            }
            break;

            // --------------------------------------- DDContainer event ------------------------------------------------
            case EventType.StartDrag:
            {
                DDContainer ct = widget as DDContainer;
                if (null != ct)
                {
                    DDContainer.OnStartDrag(ct, Util.PtrToStruct <DragEventArg>(int_ptr));
                }
            }
            break;

            case EventType.RequestDrop:
            {
                DDContainer ct = widget as DDContainer;
                if (null != ct)
                {
                    DDContainer.OnRequestDrop(ct, Util.PtrToStruct <DragEventArg>(int_ptr));
                }
            }
            break;

            case EventType.DropResult:
            {
                DDContainer ct = widget as DDContainer;
                if (null != ct)
                {
                    DDContainer.OnDropResult(ct, Util.PtrToStruct <DragEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ChangeDDState:
            {
                DDContainer ct = widget as DDContainer;
                if (null != ct)
                {
                    DDContainer.OnChangeDDState(ct, Util.PtrToStruct <ChangeDDStateEventArg>(int_ptr));
                }
            }
            break;

            case EventType.RequestDragWidgetInfo:
            {
                DDContainer ct = widget as DDContainer;
                if (null != ct)
                {
                    DDContainer.OnDragWidgetInfo(ct, Util.PtrToStruct <RequestDragWidgetInfoEventArg>(int_ptr));
                }
            }
            break;

            // --------------------------------------- item box event ------------------------------------------------
            case EventType.RequestCoordItem:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnRequestCoordItem(ib, Util.PtrToStruct <RequestCoordWidgetItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.RequestCreateWidgetItem:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnRequestCreateWidgetItem(ib, Util.PtrToStruct <RequestCreateWidgetItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.RequestDrawItem:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnRequestDrawItem(ib, Util.PtrToStruct <RequestDrawItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.SelectItemAccept:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnSelectItemAccept(ib, Util.PtrToStruct <ItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ChangeItemPosition:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnChangeItemPosition(ib, Util.PtrToStruct <ItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.MouseItemActivate:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnMouseItemActivate(ib, Util.PtrToStruct <ItemEventArg>(int_ptr));
                }
            }
            break;

            case EventType.NotifyItem:
            {
                ItemBox ib = widget as ItemBox;
                if (null != ib)
                {
                    ItemBox.OnNotifyItem(ib, Util.PtrToStruct <NotifyItemEventArg>(int_ptr));
                }
            }
            break;

            // -------------------------------- List Box event ----------------------------------
            case EventType.ListSelectAccept:
            {
                ListBox ib = widget as ListBox;
                if (null != ib)
                {
                    ListBox.OnListSelectAccept(ib, Util.PtrToStruct <ListBoxEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ListChangePosition:
            {
                ListBox ib = widget as ListBox;
                if (null != ib)
                {
                    ListBox.OnListChangePosition(ib, Util.PtrToStruct <ListBoxEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ListMouseItemActivate:
            {
                ListBox ib = widget as ListBox;
                if (null != ib)
                {
                    ListBox.OnListMouseItemActivate(ib, Util.PtrToStruct <ListBoxEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ListMouseItemFocus:
            {
                ListBox ib = widget as ListBox;
                if (null != ib)
                {
                    ListBox.OnListMouseItemFocus(ib, Util.PtrToStruct <ListBoxEventArg>(int_ptr));
                }
            }
            break;

            case EventType.ListChangeScroll:
            {
                ListBox ib = widget as ListBox;
                if (null != ib)
                {
                    ListBox.OnListChangeScroll(ib, Util.PtrToStruct <ListBoxEventArg>(int_ptr));
                }
            }
            break;

            // -------------------------------- Window event ----------------------------------
            case EventType.WindowButtonPressed:
            {
                Window window = widget as Window;
                if (null != window)
                {
                    Window.OnWindowButtonPressed(window, Util.PtrToStruct <WindowButtonPressedEventArg>(int_ptr));
                }
            }
            break;

            case EventType.WindowChangeCoord:
            {
                Window window = widget as Window;
                if (null != window)
                {
                    Window.OnWindowChangeCoord(window, arg);
                }
            }
            break;

            // -------------------------------- Canvas event ----------------------------------
            case EventType.PreTextureChanges:
            {
                Canvas canvas = widget as Canvas;
                if (null != canvas)
                {
                    Canvas.OnPreTextureChanges(canvas, Util.PtrToStruct <EventArg>(int_ptr));
                }
            }
            break;

            case EventType.RequestUpdateCanvas:
            {
                Canvas canvas = widget as Canvas;
                if (null != canvas)
                {
                    Canvas.OnRequestUpdateCanvas(canvas, Util.PtrToStruct <RequestUpdateCanvasEventArg>(int_ptr));
                }
            }
            break;

            default:
                break;
            }
        }