Ejemplo n.º 1
0
        public static void UpdateLayout(object element, int typeId, int x, int y, int width, int height)
        {
            switch (typeId)
            {
            case 1:
                Element.Rectangle r = (Element.Rectangle)element;
                r.SetPosition(x, y, width, height);
                break;

            case 3:
                Element.ScrollPanel sp = (Element.ScrollPanel)element;
                sp.SetPosition(x, y, width, height);
                break;

            case 4:
                Element.Button btn = (Element.Button)element;
                btn.SetPosition(x, y, width, height);
                break;

            case 5:
                Element.Label lbl = (Element.Label)element;
                lbl.SetPosition(x, y, width, height);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
        public static void RegisterHandler(object element, int typeId, string type, int handlerId)
        {
            switch (typeId + ":" + type)
            {
            case "4:click":     // button click
                Element.Button btn = (Element.Button)element;
                btn.Click += (obj, args) => { EventHandlerCallback(handlerId); };
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 3
0
        public static object InstantiateElement(int type, ElementProperties properties)
        {
            int left   = properties.render_left;
            int top    = properties.render_top;
            int width  = properties.render_width;
            int height = properties.render_height;

            switch (type)
            {
            case 1:     // Rectangle
                Element.Rectangle rect = new Element.Rectangle();
                rect.SetColor(
                    properties.bg_red,
                    properties.bg_green,
                    properties.bg_blue,
                    properties.bg_alpha);
                return(rect);

            case 2:     // Canvas
                Element.Canvas canvas = new Element.Canvas();
                canvas.SetPosition(left, top, width, height);
                return(canvas);

            case 3:     // ScrollPanel
                Element.ScrollPanel scrollPanel = new Element.ScrollPanel();
                scrollPanel.SetPosition(left, top, width, height);
                return(scrollPanel);

            case 4:     // Button
                Element.Button button = new Element.Button();
                button.SetPosition(left, top, width, height);
                button.Text = properties.misc_string_0;
                return(button);

            case 5:     // Label
                Element.Label label = new Element.Label();
                label.Text = properties.misc_string_0;
                return(label);

            default:
                throw new NotImplementedException();
            }
        }