public TimePicker() { this.unitPosX = new float[] { default(float), 110f, 200f }; this.bgWidth = new float[] { 80f, 80f, 80f }; this.Time = DateTime.Now; this.textRenderer = new TextRenderHelper(); base.Width = this.bgWidth[2] + this.unitPosX[2]; base.Height = 204f; this.spinLeft = new InternalSpinBox(); this.spinLeft.Width = this.bgWidth[0]; this.spinLeft.X = this.unitPosX[0]; base.AddChildLast(this.spinLeft); this.separatorLabelLeft = new Label(); this.separatorLabelLeft.SetPosition(this.bgWidth[0], 0f); this.separatorLabelLeft.SetSize(30f, 204f); this.separatorLabelLeft.Font = this.textRenderer.Font; this.separatorLabelLeft.VerticalAlignment = VerticalAlignment.Middle; this.separatorLabelLeft.HorizontalAlignment = HorizontalAlignment.Center; this.separatorLabelLeft.Text = TimePicker.separatorCharactor; base.AddChildLast(this.separatorLabelLeft); this.spinMiddle = new InternalSpinBox(); this.spinMiddle.Width = this.bgWidth[1]; this.spinMiddle.X = this.unitPosX[1]; base.AddChildLast(this.spinMiddle); this.spinRight = new InternalSpinBox(); this.spinRight.Width = this.bgWidth[2]; this.spinRight.X = this.unitPosX[2]; base.AddChildLast(this.spinRight); this.spinLeft.spinList.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestAction0Origin); this.spinMiddle.spinList.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestAction0Origin); this.spinRight.spinList.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestActionAmPm); this.UpdateListTime(); this.spinLeft.spinList.StartItemRequest(); this.spinMiddle.spinList.StartItemRequest(); this.spinRight.spinList.StartItemRequest(); this.spinLeft.spinList.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.spinMiddle.spinList.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.spinRight.spinList.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.PriorityHit = true; this.lastHour = this.Hour; this.lastMinute = this.Minute; }
private void UpdateTextSprite() { if (string.IsNullOrEmpty(this.Text)) { this.textSprt.Visible = false; this.updateFlags &= ~Button.UpdateFlags.Text; } if ((this.updateFlags & Button.UpdateFlags.Text) == Button.UpdateFlags.Text) { TextRenderHelper textRenderHelper = new TextRenderHelper(); textRenderHelper.LineBreak = LineBreak.AtCode; textRenderHelper.HorizontalAlignment = this.HorizontalAlignment; textRenderHelper.VerticalAlignment = this.VerticalAlignment; textRenderHelper.Font = this.TextFont; textRenderHelper.TextTrimming = this.TextTrimming; UISpriteUnit unit = this.textSprt.GetUnit(0); unit.Width = this.Width; unit.Height = this.Height; unit.Color = this.TextColor; if (this.textSprt.Image != null) { this.textSprt.Image.Dispose(); } this.textSprt.Image = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height); this.textSprt.Alpha = ((this.State == Button.ButtonState.Disabled) ? 0.3f : 1f); this.textSprt.ShaderType = ShaderType.TextTexture; this.textSprt.Visible = true; this.iconSprt.Visible = false; if (this.TextShadow != null) { this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow; this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[] { this.TextShadow.Color.R, this.TextShadow.Color.G, this.TextShadow.Color.B, this.TextShadow.Color.A }; this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[] { this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width, this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height }; } this.updateFlags &= ~Button.UpdateFlags.Text; } }
private void UpdateTextSprite() { if ((this.updateFlags & Label.UpdateFlags.Text) == Label.UpdateFlags.Text) { //FIXME:refresh text texture UISpriteUnit unit = this.textSprt.GetUnit(0); unit.Width = this.Width; unit.Height = this.Height; unit.Color = this.TextColor; TextRenderHelper textRenderHelper = new TextRenderHelper(); textRenderHelper.Font = this.Font; textRenderHelper.HorizontalAlignment = this.HorizontalAlignment; textRenderHelper.VerticalAlignment = this.VerticalAlignment; textRenderHelper.LineBreak = this.LineBreak; textRenderHelper.TextTrimming = this.TextTrimming; textRenderHelper.LineGap = this.LineGap; this.textSprt.Visible = true; this.textSprt.ShaderType = ShaderType.TextTexture; this.textSprt.__name = "see UpdateTextSprite"; if (this.textSprt.Image != null) { this.textSprt.Image.Dispose(); } //FIXME:write text to memory bitmap this.textSprt.Image = textRenderHelper.DrawText(ref this.text, (int)unit.Width, (int)unit.Height); if (this.TextShadow != null) { this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow; this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[] { this.TextShadow.Color.R, this.TextShadow.Color.G, this.TextShadow.Color.B, this.TextShadow.Color.A }; this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[] { this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width, this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height }; } this.updateFlags &= ~Label.UpdateFlags.Text; } }
public SpinBox(SpinBoxStyle style) { this.Style = style; if (style == SpinBoxStyle.Date) { this.unitPosX = new float[] { default(float), 110f, 220f }; this.bgWidth = new float[] { 80f, 80f, 120f }; } else { this.unitPosX = new float[] { default(float), 110f, 200f }; this.bgWidth = new float[] { 80f, 80f, 80f }; } this.MinYear = DateTime.Now.Year - 20; this.MaxYear = DateTime.Now.Year + 20; this.DateTime = DateTime.Now; this.textRenderer = new TextRenderHelper(); this.backPrimitives = new UIPrimitive[3]; this.centerPrimitives = new UIPrimitive[3]; for (int i = 0; i < 3; i++) { UIPrimitive uIPrimitive = new UIPrimitive((DrawMode)4, 16, 28); uIPrimitive.Image = SpinBox.backgraundImage; uIPrimitive.ShaderType = ShaderType.Texture; UIPrimitiveUtility.SetupNinePatch(uIPrimitive, this.bgWidth[i], 204f, 0f, 0f, SpinBox.backgroundImageNinePatch); uIPrimitive.SetPosition(this.unitPosX[i], 0f); base.RootUIElement.AddChildLast(uIPrimitive); this.backPrimitives[i] = uIPrimitive; } for (int j = 0; j < 3; j++) { UIPrimitive uIPrimitive2 = new UIPrimitive((DrawMode)4, 16, 28); uIPrimitive2.Image = SpinBox.centerImage; uIPrimitive2.ShaderType = ShaderType.Texture; UIPrimitiveUtility.SetupNinePatch(uIPrimitive2, this.bgWidth[j], 54f, 0f, 0f, SpinBox.centerImageNinePatch); uIPrimitive2.SetPosition(this.unitPosX[j], 75f); base.RootUIElement.AddChildLast(uIPrimitive2); this.centerPrimitives[j] = uIPrimitive2; } base.Width = this.bgWidth[2] + this.unitPosX[2]; base.Height = 204f; this.listLeft = new InternalSpinBox.SpinList(); this.listLeft.Width = this.bgWidth[0]; this.listLeft.Height = this.unitHeight * (float)SpinBox.visibleCount; this.listLeft.X = this.unitPosX[0]; this.listLeft.Y = 2f; this.listLeft.ItemGapLine = this.unitHeight; this.listLeft.ScrollAreaLineNum = SpinBox.visibleCount; base.AddChildLast(this.listLeft); this.separatorLabelLeft = new Label(); this.separatorLabelLeft.SetPosition(this.bgWidth[0], 0f); this.separatorLabelLeft.SetSize(30f, 204f); this.separatorLabelLeft.Font = this.textRenderer.Font; this.separatorLabelLeft.VerticalAlignment = VerticalAlignment.Middle; this.separatorLabelLeft.HorizontalAlignment = HorizontalAlignment.Center; this.separatorLabelLeft.Text = SpinBox.separatorCharactor[(int)this.Style]; base.AddChildLast(this.separatorLabelLeft); this.listMiddle = new InternalSpinBox.SpinList(); this.listMiddle.Width = this.bgWidth[1]; this.listMiddle.Height = this.unitHeight * (float)SpinBox.visibleCount; this.listMiddle.X = this.unitPosX[1]; this.listMiddle.Y = this.listLeft.Y; this.listMiddle.ItemGapLine = this.unitHeight; this.listMiddle.ScrollAreaLineNum = SpinBox.visibleCount; base.AddChildLast(this.listMiddle); this.separatorLabelRight = new Label(); this.separatorLabelRight.SetPosition(this.unitPosX[1] + this.bgWidth[1], 0f); this.separatorLabelRight.SetSize(30f, 204f); this.separatorLabelRight.VerticalAlignment = VerticalAlignment.Middle; this.separatorLabelRight.HorizontalAlignment = HorizontalAlignment.Center; this.separatorLabelRight.Font = this.textRenderer.Font; this.separatorLabelRight.Text = ((this.Style == SpinBoxStyle.Date) ? SpinBox.separatorCharactor[(int)this.Style] : ""); base.AddChildLast(this.separatorLabelRight); this.listRight = new InternalSpinBox.SpinList(); this.listRight.Width = this.bgWidth[2]; this.listRight.Height = this.unitHeight * (float)SpinBox.visibleCount; this.listRight.X = this.unitPosX[2]; this.listRight.Y = this.listLeft.Y; this.listRight.ItemGapLine = this.unitHeight; this.listRight.ScrollAreaLineNum = SpinBox.visibleCount; base.AddChildLast(this.listRight); if (this.Style == SpinBoxStyle.Date) { this.listLeft.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestAction1Origin); this.listMiddle.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestActionDate); this.listRight.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestActionYear); this.UpdateListDate(); } else { this.listLeft.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestAction0Origin); this.listMiddle.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestAction0Origin); this.listRight.ItemRequestAction += new EventHandler <InternalSpinBox.SpinItemRequestEventArgs>(this.GridListItemRequestActionAmPm); this.UpdateListTime(); } this.listLeft.StartItemRequest(); this.listMiddle.StartItemRequest(); this.listRight.StartItemRequest(); this.listLeft.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.listMiddle.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.listRight.FocusChanged += new EventHandler <EventArgs>(this.ItemFocusChanged); this.PriorityHit = true; }
private void UpdateTextSprite() { if ((this.updateFlags & EditableText.UpdateFlags.Text) == EditableText.UpdateFlags.Text) { UISpriteUnit unit = this.textSprt.GetUnit(0); unit.X = 10f; unit.Y = 4f; unit.Width = this.Width - 20f; unit.Height = this.Height - 8f; TextRenderHelper textRenderHelper = new TextRenderHelper(); textRenderHelper.HorizontalAlignment = this.HorizontalAlignment; textRenderHelper.VerticalAlignment = this.VerticalAlignment; textRenderHelper.LineBreak = this.LineBreak; textRenderHelper.TextTrimming = this.TextTrimming; textRenderHelper.LineGap = this.LineGap; if (string.IsNullOrEmpty(this.Text)) { unit.Color = this.DefaultTextColor; textRenderHelper.Font = this.DefaultFont; this.textSprt.ShaderType = ShaderType.TextTexture; if (this.textSprt.Image != null) { this.textSprt.Image.Dispose(); } this.textSprt.Image = textRenderHelper.DrawText(ref this.defaultText, (int)unit.Width, (int)unit.Height); } else { string text; if (this.TextInputMode == (TextInputMode)2) { text = new string('*', this.Text.Length); } else { text = this.Text; } unit.Color = this.TextColor; textRenderHelper.Font = this.Font; this.textSprt.ShaderType = ShaderType.TextTexture; if (this.textSprt.Image != null) { this.textSprt.Image.Dispose(); } this.textSprt.Image = textRenderHelper.DrawText(ref text, (int)unit.Width, (int)unit.Height); } if (this.TextShadow != null) { this.textSprt.InternalShaderType = InternalShaderType.TextureAlphaShadow; this.textSprt.ShaderUniforms["u_ShadowColor"] = new float[] { this.TextShadow.Color.R, this.TextShadow.Color.G, this.TextShadow.Color.B, this.TextShadow.Color.A }; this.textSprt.ShaderUniforms["u_ShadowOffset"] = new float[] { this.TextShadow.HorizontalOffset / (float)this.textSprt.Image.Width, this.TextShadow.VerticalOffset / (float)this.textSprt.Image.Height }; } this.updateFlags &= ~EditableText.UpdateFlags.Text; } }