Exemple #1
0
    private static void HandleUimenuwindowEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uimenuwindowcode")
            {
                AtomicMain.AppLog("UIMenuWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uimenuwindow.cs", widget.GetParent());
            }
            if (widget.GetId() == "uimenuwindowlayout")
            {
                AtomicMain.AppLog("UIMenuWindow support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uimenuwindow.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "uimenuwindowpush")
            {
                AtomicMain.AppLog("UIMenuWindow action : " + widget.GetId() + " was pressed ");
                UIMenuWindow     mymenuwindow = new UIMenuWindow(widget, "MenuWindowDemo");
                UIMenuItemSource mis          = new UIMenuItemSource();
                mis.AddItem(new UIMenuItem("UISelectItem1", "item1"));
                mis.AddItem(new UIMenuItem("UISelectItem2", "item2", "Ctrl+C"));
                mis.AddItem(new UIMenuItem("UISelectItem3", "item3", "Ctrl+A", "DuckButton"));
                mis.AddItem(new UIMenuItem("UISelectItem4", "item4", "Ctrl+O", "LogoAtomic"));
                int xx = widget.GetX() + (widget.GetWidth() / 2);
                int yy = widget.GetY() + (widget.GetHeight() / 2);
                mymenuwindow.SubscribeToEvent <WidgetEvent> (mymenuwindow, HandleUimenuwindowEvent);
                mymenuwindow.Show(mis, xx, yy);
            }

            if (widget.GetId() == "MenuWindowDemo")
            {
                AtomicMain.AppLog("UIMenuWindow event : " + widget.GetId() + " and " + refid + " was selected ");
            }
        }
        else
        {
            if (widget.GetId() == "MenuWindowDemo")
            {
                AtomicMain.AppLog("UIMenuWindow event : " + widget.GetId() + " refid=" + refid + " event type=" + AtomicMain.EventReport((int)ev.Type));
            }
        }
    }
Exemple #2
0
    private static void HandleUimenuitemEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;
        string   refid  = (string)ev.RefID;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "uimenuitemcode")
            {
                AtomicMain.AppLog("UIMenuItem support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Components/code_uimenuitem.cs", widget.GetParent());
            }
            if (widget.GetId() == "uimenuitemlayout")
            {
                AtomicMain.AppLog("UIMenuItem support : " + widget.GetId() + " was pressed ");
                AtomicMain.ViewCode("Scenes/layout_uimenuitem.ui.txt", widget.GetParent());
            }

            if (widget.GetId() == "uimenuitempush")
            {
                UIMenuWindow mymenuwindow = new UIMenuWindow(widget, "MenuItemDemo");
                int          xx           = widget.GetX() + (widget.GetWidth() / 2);
                int          yy           = widget.GetY() + (widget.GetHeight() / 2);
                mymenuwindow.SubscribeToEvent <WidgetEvent> (mymenuwindow, HandleUimenuitemEvent);
                mymenuwindow.Show(mis, xx, yy);
            }

            if (widget.GetId() == "MenuItemDemo")
            {
                AtomicMain.AppLog("UIMenuItem event : " + widget.GetId() + " and " + refid + " was selected ");
            }

            if (widget.GetId() == "uimi1")
            {
                AtomicMain.AppLog("UIMenuItem action : " + widget.GetId() + " was pressed ");
                mis.AddItem(new UIMenuItem("New UIMenuItem"));
            }
            if (widget.GetId() == "uimi2")
            {
                AtomicMain.AppLog("UIMenuItem action : " + widget.GetId() + " was pressed ");
                mis.AddItem(new UIMenuItem("Newer UIMenuItem", "neweritem"));
            }
            if (widget.GetId() == "uimi3")
            {
                AtomicMain.AppLog("UIMenuItem action : " + widget.GetId() + " was pressed ");
                mis.AddItem(new UIMenuItem("A Duck", "aduck", "", "DuckButton"));
            }
            if (widget.GetId() == "uimi4")
            {
                AtomicMain.AppLog("UIMenuItem action : " + widget.GetId() + " was pressed ");
                mis.AddItem(new UIMenuItem("Atomic!", "atomic", "", "LogoAtomic"));
            }
            if (widget.GetId() == "uimi5")
            {
                AtomicMain.AppLog("UIMenuItem action : " + widget.GetId() + " was pressed ");
                mis.Clear();
            }
        }
    }