Exemplo n.º 1
0
 public InternalSpinBox()
 {
     base.Width                    = 80f;
     base.Height                   = 204f;
     this.backgraundImage          = new ImageAsset(SystemImageAsset.SpinBoxBase);
     this.centerImage              = new ImageAsset(SystemImageAsset.SpinBoxCenter);
     this.backgroundImageNinePatch = AssetManager.GetNinePatchMargin(SystemImageAsset.SpinBoxBase);
     this.centerImageNinePatch     = AssetManager.GetNinePatchMargin(SystemImageAsset.SpinBoxCenter);
     this.backPrim                 = new UIPrimitive((DrawMode)4, 16, 28);
     this.backPrim.Image           = this.backgraundImage;
     this.backPrim.ShaderType      = ShaderType.Texture;
     UIPrimitiveUtility.SetupNinePatch(this.backPrim, 80f, 204f, 0f, 0f, this.backgroundImageNinePatch);
     this.backPrim.SetPosition(0f, 0f);
     base.RootUIElement.AddChildLast(this.backPrim);
     this.centerPrim            = new UIPrimitive((DrawMode)4, 16, 28);
     this.centerPrim.Image      = this.centerImage;
     this.centerPrim.ShaderType = ShaderType.Texture;
     UIPrimitiveUtility.SetupNinePatch(this.centerPrim, 80f, 54f, 0f, 0f, this.centerImageNinePatch);
     this.centerPrim.SetPosition(0f, 75f);
     base.RootUIElement.AddChildLast(this.centerPrim);
     this.spinList                   = new InternalSpinBox.SpinList();
     this.spinList.Width             = 80f;
     this.spinList.Height            = 40f * (float)InternalSpinBox.visibleCount;
     this.spinList.X                 = 0f;
     this.spinList.Y                 = 2f;
     this.spinList.ItemGapLine       = 40f;
     this.spinList.ScrollAreaLineNum = InternalSpinBox.visibleCount;
     base.AddChildLast(this.spinList);
     this.PriorityHit = true;
 }
Exemplo n.º 2
0
 public static void SetupNinePatch(UIPrimitive primitive, float width, float height, float offsetX, float offsetY, NinePatchMargin ninePatchMargin)
 {
     if (ninePatchMargin.Top == 0 && ninePatchMargin.Bottom == 0)
     {
         UIPrimitiveUtility.SetupHorizontalThreePatch(primitive, width, height, offsetX, offsetY, (float)ninePatchMargin.Left, (float)ninePatchMargin.Right);
         return;
     }
     if (ninePatchMargin.Left == 0 && ninePatchMargin.Right == 0)
     {
         UIPrimitiveUtility.SetupVerticalThreePatch(primitive, width, height, offsetX, offsetY, (float)ninePatchMargin.Top, (float)ninePatchMargin.Bottom);
         return;
     }
     UIPrimitiveUtility.SetupNinePatch(primitive, width, height, offsetX, offsetY, default(ImageRect), ninePatchMargin);
 }
Exemplo n.º 3
0
 private void UpdateBackgroundSprite()
 {
     if ((this.updateFlags & Button.UpdateFlags.Background) == Button.UpdateFlags.Background)
     {
         this.updateFlags &= ~Button.UpdateFlags.Background;
         ImageAsset imageAsset = this.backgroundImages[(int)this.Style, (int)this.State];
         if (imageAsset == null)
         {
             this.backgroundPrim.Image   = null;
             this.backgroundPrim.Visible = true;
             return;
         }
         if (imageAsset.Ready)
         {
             this.backgroundPrim.Image       = imageAsset;
             this.backgroundPrim.VertexCount = 9;
             this.backgroundPrim.Visible     = true;
             UIPrimitiveUtility.SetupNinePatch(this.backgroundPrim, this.Width, this.Height, 0f, 0f, this.backgroundNinePatchs[(int)this.Style]);
             return;
         }
         this.backgroundPrim.Visible = false;
         this.updateFlags           |= Button.UpdateFlags.Background;
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 private void SetupUIPrimitiveNinePatch()
 {
     this.sprt.Visible          = false;
     this.ninePatchPrim.Visible = true;
     UIPrimitiveUtility.SetupNinePatch(this.ninePatchPrim, this.Width, this.Height, 0f, 0f, this.cropArea, this.ninePatchMargin);
 }