コード例 #1
0
ファイル: Select.cs プロジェクト: dustingibson/HJEngine2
        public Select(gfx.Graphics graphics, string bind, string value,
                      Color borderColor, prim.Size borderSize,
                      int fontSize, string fontType, Color fontColor, prim.Point point,
                      prim.Size size, XmlNodeList choiceNodes)
            : base(graphics, "select", "", point, size)
        {
            this.bind = bind;

            choices      = new List <Choice>();
            choiceLabels = new List <Label>();

            selectIndex = 0;

            LAmouseOverState = new prim.MouseOverStateMachine();
            RAmouseOverState = new prim.MouseOverStateMachine();


            float triH = size.h;
            float triW = graphics.getWSquareSize(triH);

            float[] lVertices =
            {
                point.x + triW, point.y + triH,          0.0f, 1.0f, 1.0f,
                point.x + triW, point.y,                 0.0f, 1.0f, 0.0f,
                point.x,        point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };
            //Remember to add size.x to point.x
            float[] rVertices =
            {
                point.x + size.w,        point.y,                 0.0f, 1.0f, 1.0f,
                point.x + size.w,        point.y + triH,          0.0f, 1.0f, 0.0f,
                point.x + triW + size.w, point.y + (triH / 2.0f), 0.0f, 0.0f, 0.5f
            };

            uint[] indices =
            {
                0, 1, 2
            };

            //leftArrow = new gfx.ColorTexture(graphics, borderColor, lVertices, indices);
            //rightArrow = new gfx.ColorTexture(graphics, borderColor, rVertices, indices);
            leftArrow  = new ArrowButton(graphics, "left", fontColor, new prim.Point(point), new prim.Size(triW, triH));
            rightArrow = new ArrowButton(graphics, "right", fontColor, new prim.Point(point.x + size.w, point.y), new prim.Size(triW, triH));



            foreach (XmlNode choiceNode in choiceNodes)
            {
                Choice choice = new Choice(choiceNode.Attributes["text"].Value,
                                           choiceNode.Attributes["value"].Value);
                choices.Add(choice);
                Label choiceLabel = new Label(graphics, choice.name, fontSize, fontType, fontColor, new prim.Point(point), new prim.Size(0, 0));
                choiceLabel.point.x = triW + (point.x + ((size.w - triW) / 2)) - (choiceLabel.size.w / 2);
                choiceLabel.point.y = (point.y + (size.h / 2)) - (choiceLabel.size.h / 2);
                choiceLabel.Update();
                choiceLabels.Add(choiceLabel);
            }

            SetValue(value);

            selectPane = new Pane(graphics, Color.FromArgb(0, 0, 0, 0), borderColor, borderSize, new prim.Point(point.x + triW, point.y), new prim.Size(size.w - triW, size.h));
        }