Ejemplo n.º 1
0
 private void GridListItemRequestActionDate(object sender, InternalSpinBox.SpinItemRequestEventArgs e)
 {
     if (sender is InternalSpinBox.SpinList)
     {
         InternalSpinBox.SpinList spinList = (InternalSpinBox.SpinList)sender;
         int num = e.Index % spinList.ListItemNum;
         if (num < 0)
         {
             num += spinList.ListItemNum;
         }
         InternalSpinBox.SpinItem listItem = spinList.GetListItem(num);
         if (listItem != null)
         {
             string text = (num + 1).ToString("00");
             if (listItem.ImageAsset != null)
             {
                 listItem.ImageAsset.Dispose();
             }
             listItem.ImageAsset = this.textRenderer.DrawText(ref text, 80, 40);
             listItem.ShaderType = ShaderType.TextTexture;
             listItem.Width      = spinList.ItemGapStep;
             listItem.Height     = spinList.ItemGapLine;
             listItem.Enabled    = (listItem.ItemId + 1 <= this.GetDaysInMonth());
         }
     }
 }
Ejemplo n.º 2
0
 private void GridListItemRequestActionYear(object sender, InternalSpinBox.SpinItemRequestEventArgs e)
 {
     if (sender is InternalSpinBox.SpinList)
     {
         InternalSpinBox.SpinList spinList = (InternalSpinBox.SpinList)sender;
         InternalSpinBox.SpinItem listItem = spinList.GetListItem(e.Index);
         if (listItem != null && 0 <= e.Index && e.Index < spinList.ListItemNum)
         {
             string text;
             if (e.Index < InternalSpinBox.visibleCount / 2 || e.Index >= spinList.ListItemNum - InternalSpinBox.visibleCount / 2)
             {
                 text = "";
             }
             else
             {
                 text = (e.Index + this.MinYear - InternalSpinBox.visibleCount / 2).ToString("0000");
             }
             if (listItem.ImageAsset != null)
             {
                 listItem.ImageAsset.Dispose();
             }
             listItem.ImageAsset = this.textRenderer.DrawText(ref text, 128, 40);
             listItem.ShaderType = ShaderType.TextTexture;
             listItem.Width      = spinList.ItemGapStep;
             listItem.Height     = spinList.ItemGapLine;
         }
     }
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 private void GridListItemRequestAction1Origin(object sender, InternalSpinBox.SpinItemRequestEventArgs e)
 {
     if (sender is InternalSpinBox.SpinList)
     {
         InternalSpinBox.SpinList spinList = (InternalSpinBox.SpinList)sender;
         int num = e.Index % spinList.ListItemNum;
         if (num < 0)
         {
             num += spinList.ListItemNum;
         }
         InternalSpinBox.SpinItem listItem = spinList.GetListItem(num);
         if (listItem != null)
         {
             string text = (num + 1).ToString("00");
             listItem.ImageAsset = this.textRenderer.DrawText(ref text, (int)this.unitWidth, (int)this.unitHeight);
             listItem.ShaderType = ShaderType.TextTexture;
             listItem.Width      = spinList.ItemGapStep;
             listItem.Height     = spinList.ItemGapLine;
         }
     }
 }
Ejemplo n.º 5
0
 private void GridListItemRequestActionAmPm(object sender, InternalSpinBox.SpinItemRequestEventArgs e)
 {
     if (sender is InternalSpinBox.SpinList)
     {
         InternalSpinBox.SpinList spinList = (InternalSpinBox.SpinList)sender;
         InternalSpinBox.SpinItem listItem = spinList.GetListItem(e.Index);
         if (listItem != null && 0 <= e.Index && e.Index < spinList.ListItemNum)
         {
             string text;
             if (e.Index < SpinBox.visibleCount / 2 || e.Index >= spinList.ListItemNum - SpinBox.visibleCount / 2)
             {
                 text = "";
             }
             else
             {
                 text = SpinBox.noonText[e.Index - SpinBox.visibleCount / 2];
             }
             listItem.ImageAsset = this.textRenderer.DrawText(ref text, (int)this.unitWidth, (int)this.unitHeight);
             listItem.ShaderType = ShaderType.TextTexture;
             listItem.Width      = spinList.ItemGapStep;
             listItem.Height     = spinList.ItemGapLine;
         }
     }
 }
Ejemplo n.º 6
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;
 }