Esempio n. 1
0
    private static void HandleUilayoutEvent(WidgetEvent ev)
    {
        UIWidget widget = (UIWidget)ev.Target;

        if (widget.Equals(null))
        {
            return;
        }
        if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK)
        {
            if (widget.GetId() == "go_layout_config")    // its LAYOUT-O-MATIC time.
            {
                AtomicMain.AppLog("UILayout action : " + widget.GetId() + " was pressed, its LAYOUT-O-MATIC time");
                UIView   someview = widget.GetView();
                UIWindow window   = new UIWindow();
                window.SetSettings(UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_DEFAULT);
                window.SetText("LAYOUT-O-MATIC(tm)");
                window.Load("Scenes/view_layout.ui.txt");
                window.ResizeToFitContent();
                someview.AddChild(window);

                UIWidget okbutt = window.GetWidget("ok");
                okbutt.SubscribeToEvent <WidgetEvent> (okbutt, HandleUilayoutEvent);

                var lox = new AtomicEngine.Vector <AtomicEngine.UIWidget>();
                window.SearchWidgetClass("TBRadioButton", lox);
                for (var ii = 0; ii < lox.Size; ii++)
                {
                    lox[ii].SubscribeToEvent <WidgetEvent> (lox [ii], HandleUilayoutEvent);
                }
            }
            if (widget.GetId() == "ok")
            {
                UIWindow mywindow = (UIWindow)AtomicMain.FindTheWindowParent(widget);
                if (!mywindow.Equals(null))
                {
                    mywindow.Close();
                }
            }
            if (widget.GetId() == "set_ax")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'X');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_ay")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(0, 'Y');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_sza")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_szp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(1, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }


            if (widget.GetId() == "set_posc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_posr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(2, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dista")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'A');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distg")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'G');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_distp")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(3, 'P');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }

            if (widget.GetId() == "set_dpc")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'C');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpl")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'L');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
            if (widget.GetId() == "set_dpr")
            {
                UILayout      targetl = (UILayout)widget.FindWidget("target_layout"); // who to operate on.
                UIRadioButton setla   = (UIRadioButton)widget;                        // who we are
                if (!targetl.Equals(null) && !setla.Equals(null))
                {
                    if (setla.GetValue() == 1)
                    {
                        ReplaceChar(4, 'R');
                        targetl.SetLayoutConfig(layoutomaticstr);
                    }
                }
            }
        }
    }