public ValueBox(gfx.Graphics graphics, string bind, string value, Color borderColor, prim.Size borderSize, int fontSize, string fontType, Color fontColor, prim.Point point, prim.Size size) : base(graphics, "select", "", point, size) { this.bind = bind; this.value = value; LAmouseOverState = new prim.MouseOverStateMachine(); RAmouseOverState = new prim.MouseOverStateMachine(); boxes = new List <Pane>(); 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)); 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)); for (int i = 0; i < 10; i++) { prim.Size paneSize = new prim.Size((this.size.w + this.leftArrow.size.w) * 0.1f, this.size.h); prim.Point panePoint = new prim.Point(leftArrow.size.w + point.x + paneSize.w * i, point.y); Pane curPane = new Pane(graphics, borderColor, borderColor, borderSize, panePoint, paneSize); boxes.Add(curPane); } }
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)); }