Esempio n. 1
0
        public ImageBox()
        {
            this.sprt = new UISprite(1);
            base.RootUIElement.AddChildLast(this.sprt);
            this.sprt.ShaderType = ShaderType.Texture;
            this.ninePatchPrim   = new UIPrimitive((DrawMode)4, 16, 28);
            base.RootUIElement.AddChildLast(this.ninePatchPrim);
            this.ninePatchPrim.ShaderType = ShaderType.Texture;
            this.ninePatchPrim.Visible    = false;
            this.ninePatchMargin          = NinePatchMargin.Zero;
            this.scale           = ImageScaleType.Stretch;
            this.cropArea        = new ImageRect(0, 0, 0, 0);
            this.clipImageX      = 0f;
            this.clipImageY      = 0f;
            this.clipImageWidth  = 0f;
            this.clipImageHeight = 0f;
            Dictionary <ImageScaleType, ImageBox.SetupUISpriteImageScale> dictionary = new Dictionary <ImageScaleType, ImageBox.SetupUISpriteImageScale>();

            dictionary.Add(ImageScaleType.Stretch, new ImageBox.SetupUISpriteImageScale(this.SetupUISpriteNormal));
            dictionary.Add(ImageScaleType.AspectInside, new ImageBox.SetupUISpriteImageScale(this.SetupUISpriteAspectInside));
            dictionary.Add(ImageScaleType.AspectOutside, new ImageBox.SetupUISpriteImageScale(this.SetupUISpriteAspectOutside));
            dictionary.Add(ImageScaleType.NinePatch, new ImageBox.SetupUISpriteImageScale(this.SetupUIPrimitiveNinePatch));
            dictionary.Add(ImageScaleType.Center, new ImageBox.SetupUISpriteImageScale(this.SetupUISpriteNone));
            this.setupSpriteImageScale = dictionary;
        }
Esempio n. 2
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;
 }
Esempio n. 3
0
        public LiveSphere()
        {
            int num  = this.sphereDiv;
            int num2 = this.sphereDiv * 2;

            this.spherePrim                    = new UIPrimitive((DrawMode)4, (num + 1) * (num2 + 1), num * 2 * (num2 + 1));
            this.spherePrim.Culling            = true;
            this.spherePrim.InternalShaderType = InternalShaderType.LiveSphere;
            float num3 = 3.14159274f / (float)num;
            float num4 = 6.28318548f / (float)num2;
            float num5 = 1f / (float)num2;
            float num6 = 1f / (float)num;

            for (int i = 0; i < num + 1; i++)
            {
                for (int j = 0; j < num2 + 1; j++)
                {
                    float             num7   = -(float)Math.Sin((double)((float)i * num3)) * (float)Math.Cos((double)((float)j * num4));
                    float             num8   = -(float)Math.Cos((double)((float)i * num3));
                    float             num9   = -(float)Math.Sin((double)((float)i * num3)) * (float)Math.Sin((double)((float)j * num4));
                    UIPrimitiveVertex vertex = this.spherePrim.GetVertex(i * (num2 + 1) + j);
                    vertex.Position3D = new Vector3(num7, num8, num9);
                    vertex.U          = num5 * (float)j;
                    vertex.V          = num6 * (float)i;
                }
            }
            ushort[] array = new ushort[num * 2 * (num2 + 1)];
            for (int k = 0; k < num; k++)
            {
                for (int l = 0; l < num2 + 1; l++)
                {
                    array[k * (num2 + 1) * 2 + l * 2]     = (ushort)(k * (num2 + 1) + l);
                    array[k * (num2 + 1) * 2 + l * 2 + 1] = (ushort)((k + 1) * (num2 + 1) + l);
                }
            }
            this.spherePrim.SetIndices(array);
            base.RootUIElement.AddChildLast(this.spherePrim);
            this.LightDirection = new Vector4((float)(Math.Sin((double)this.LightZAngle) * Math.Cos((double)this.LightYAngle)), (float)Math.Cos((double)this.LightZAngle), (float)(Math.Sin((double)this.LightZAngle) * Math.Sin((double)this.LightYAngle)), 0f);
            this.spherePrim.ShaderUniforms["Shininess"] = new float[]
            {
                this.Shininess
            };
            this.spherePrim.ShaderUniforms["Specular"] = new float[]
            {
                this.Specular
            };
            this.SetSize(this.radius * 2f, this.radius * 2f);
            this.flickGesture                = new FlickGestureDetector();
            this.flickGesture.Direction      = FlickDirection.All;
            this.flickGesture.FlickDetected += new EventHandler <FlickEventArgs>(this.FlickEventHandler);
            base.AddGestureDetector(this.flickGesture);
            this.dragGesture = new DragGestureDetector();
            this.dragGesture.DragDetected += new EventHandler <DragEventArgs>(this.DragEventHandler);
            base.AddGestureDetector(this.dragGesture);
            this.PriorityHit = true;
        }
Esempio n. 4
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);
 }
Esempio n. 5
0
 public Button()
 {
     this.backgroundPrim = new UIPrimitive((DrawMode)4, 16, 28);
     base.RootUIElement.AddChildLast(this.backgroundPrim);
     this.backgroundPrim.ShaderType = ShaderType.Texture;
     this.iconSprt = new UISprite(1);
     base.RootUIElement.AddChildLast(this.iconSprt);
     this.iconSprt.ShaderType = ShaderType.SolidFill;
     this.iconSprt.Visible    = false;
     this.textSprt            = new UISprite(1);
     base.RootUIElement.AddChildLast(this.textSprt);
     this.textSprt.ShaderType = ShaderType.TextTexture;
     this.textSprt.Visible    = false;
     this.State                   = Button.ButtonState.Normal;
     this.updateFlags             = Button.UpdateFlags.Background;
     this.backgroundImages        = new ImageAsset[Enum.GetValues(typeof(ButtonStyle)).Length, Enum.GetValues(typeof(Button.ButtonState)).Length];
     this.backgroundImages[0, 0]  = new ImageAsset(SystemImageAsset.ButtonBackgroundNormal);
     this.backgroundImages[0, 1]  = new ImageAsset(SystemImageAsset.ButtonBackgroundPressed);
     this.backgroundImages[0, 2]  = new ImageAsset(SystemImageAsset.ButtonBackgroundDisabled);
     this.backgroundNinePatchs    = new NinePatchMargin[Enum.GetValues(typeof(ButtonStyle)).Length];
     this.backgroundNinePatchs[0] = AssetManager.GetNinePatchMargin(SystemImageAsset.ButtonBackgroundNormal);
     this.CustomImage             = null;
     this.IconImage               = null;
     this.Text                = "";
     this.TextFont            = UISystem.DefaultFont;
     this.TextTrimming        = TextTrimming.EllipsisCharacter;
     this.TextColor           = new UIColor(1f, 1f, 1f, 1f);
     this.TextShadow          = null;
     this.HorizontalAlignment = HorizontalAlignment.Center;
     this.VerticalAlignment   = VerticalAlignment.Middle;
     this.Style               = ButtonStyle.Default;
     this.Enabled             = true;
     this.Width               = 214f;
     this.Height              = 56f;
     this.PriorityHit         = true;
 }
Esempio 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;
 }
Esempio n. 7
0
 public static void SetupVerticalThreePatch(UIPrimitive primitive, float width, float height, float offsetX, float offsetY, float topMargin, float bottomMargin)
 {
     if (primitive.MaxVertexCount < 8)
     {
         throw new ArgumentOutOfRangeException("primitive", "UIPrimitive MaxVertexCount is out of range.");
     }
     if (primitive.Image != null)
     {
         int height2 = primitive.Image.Height;
         if ((float)height2 == 0f)
         {
             return;
         }
         float   num   = (float)height2;
         float[] array = new float[]
         {
             0f,
             width
         };
         float[] array2 = new float[]
         {
             0f,
             (topMargin < height) ? topMargin : height,
             (bottomMargin < height) ? (height - bottomMargin) : 0f,
             height
         };
         if (array2[1] > array2[2])
         {
             array2[1] = (array2[2] = (array2[1] + array2[2]) / 2f);
         }
         float[] array3 = new float[]
         {
             0f,
             1f
         };
         float   num2   = (topMargin < array2[1]) ? topMargin : array2[1];
         float   num3   = (bottomMargin < height - array2[2]) ? bottomMargin : (height - array2[2]);
         float[] array4 = new float[]
         {
             0f,
             num2 / num,
             (num - num3) / num,
             1f
         };
         if (array4[2] < 0f)
         {
             array4[2] = 0f;
         }
         if (array4[1] > 1f)
         {
             array4[1] = 1f;
         }
         primitive.VertexCount = 8;
         primitive.SetIndices(new ushort[]
         {
             0,
             1,
             2,
             3,
             4,
             5,
             6,
             7
         });
         primitive.IndexCount = 8;
         for (int i = 0; i < 4; i++)
         {
             for (int j = 1; j >= 0; j--)
             {
                 UIPrimitiveVertex vertex = primitive.GetVertex(i * 2 + j);
                 vertex.X = array[j] + offsetX;
                 vertex.Y = array2[i] + offsetY;
                 vertex.U = array3[j];
                 vertex.V = array4[i];
             }
         }
     }
 }
Esempio n. 8
0
 public static void SetupNinePatch(UIPrimitive primitive, float width, float height, float offsetX, float offsetY, ImageRect imageRect, NinePatchMargin ninePatchMargin)
 {
     if (primitive.MaxVertexCount < 16)
     {
         throw new ArgumentOutOfRangeException("primitive", "UIPrimitive MaxVertexCount is out of range.");
     }
     if (primitive.MaxIndexCount < 28)
     {
         throw new ArgumentOutOfRangeException("primitive", "UIPrimitive MaxIndexCount is out of range.");
     }
     if (primitive.Image != null)
     {
         float[] array = new float[]
         {
             0f,
             (float)ninePatchMargin.Left,
             width - (float)ninePatchMargin.Right,
             width
         };
         float[] array2 = new float[]
         {
             0f,
             (float)ninePatchMargin.Top,
             height - (float)ninePatchMargin.Bottom,
             height
         };
         if (array[1] > width)
         {
             array[1] = width;
         }
         if (array[2] < 0f)
         {
             array[2] = 0f;
         }
         if (array[1] > array[2])
         {
             array[1] = (array[2] = (array[1] + array[2]) / 2f);
         }
         if (array2[1] > height)
         {
             array2[1] = height;
         }
         if (array2[2] < 0f)
         {
             array2[2] = 0f;
         }
         if (array2[1] > array2[2])
         {
             array2[1] = (array2[2] = (array2[1] + array2[2]) / 2f);
         }
         int num     = 0;
         int num2    = 0;
         int width2  = primitive.Image.Width;
         int height2 = primitive.Image.Height;
         int num3    = width2;
         int num4    = height2;
         if (imageRect.X < width2 && imageRect.Y < height2 && imageRect.Width > 0 && imageRect.Height > 0)
         {
             if (imageRect.X > 0)
             {
                 num = imageRect.X;
             }
             num3 = num + imageRect.Width;
             if (num3 > width2)
             {
                 num3 = width2;
             }
             if (imageRect.Y > 0)
             {
                 num2 = imageRect.Y;
             }
             num4 = num2 + imageRect.Height;
             if (num4 > height2)
             {
                 num4 = height2;
             }
         }
         float   num5   = (float)width2;
         float   num6   = (float)height2;
         float   num7   = ((float)ninePatchMargin.Left < array[1] - array[0]) ? ((float)(num + ninePatchMargin.Left)) : ((float)num + array[1] - array[0]);
         float   num8   = ((float)ninePatchMargin.Right < array[3] - array[2]) ? ((float)(num3 - ninePatchMargin.Right)) : ((float)num3 - (array[3] - array[2]));
         float   num9   = ((float)ninePatchMargin.Top < array2[1] - array2[0]) ? ((float)(num2 + ninePatchMargin.Top)) : ((float)num2 + array2[1] - array2[0]);
         float   num10  = ((float)ninePatchMargin.Bottom < array2[3] - array2[2]) ? ((float)(num4 - ninePatchMargin.Bottom)) : ((float)num4 - (array2[3] - array2[2]));
         float[] array3 = new float[]
         {
             (float)num / num5,
             num7 / num5,
             num8 / num5,
             (float)num3 / num5
         };
         float[] array4 = new float[]
         {
             (float)num2 / num6,
             num9 / num6,
             num10 / num6,
             (float)num4 / num6
         };
         if (array3[2] < array3[0])
         {
             array3[2] = array3[0];
         }
         if (array4[2] < array4[0])
         {
             array4[2] = array4[0];
         }
         if (array3[1] > array3[3])
         {
             array3[1] = array3[3];
         }
         if (array4[1] > array4[3])
         {
             array4[1] = array4[3];
         }
         primitive.VertexCount = 16;
         primitive.SetIndices(new ushort[]
         {
             0,
             4,
             1,
             5,
             2,
             6,
             3,
             7,
             7,
             4,
             4,
             8,
             5,
             9,
             6,
             10,
             7,
             11,
             11,
             8,
             8,
             12,
             9,
             13,
             10,
             14,
             11,
             15
         });
         primitive.IndexCount = 28;
         for (int i = 0; i < 4; i++)
         {
             for (int j = 0; j < 4; j++)
             {
                 UIPrimitiveVertex vertex = primitive.GetVertex(i * 4 + j);
                 vertex.X = array[j] + offsetX;
                 vertex.Y = array2[i] + offsetY;
                 vertex.U = array3[j];
                 vertex.V = array4[i];
             }
         }
     }
 }
Esempio n. 9
0
 public static void SetupHorizontalThreePatch(UIPrimitive primitive, float width, float height, float offsetX, float offsetY, float leftMargin, float rightMargin)
 {
     if (primitive.MaxVertexCount < 8)
     {
         throw new ArgumentOutOfRangeException("primitive", "UIPrimitive MaxVertexCount is out of range.");
     }
     if (primitive.Image != null)
     {
         int width2 = primitive.Image.Width;
         if ((float)width2 == 0f)
         {
             return;
         }
         float   num   = (float)width2;
         float[] array = new float[]
         {
             0f,
             (leftMargin < width) ? leftMargin : width,
             (rightMargin < width) ? (width - rightMargin) : 0f,
             width
         };
         if (array[1] > array[2])
         {
             array[1] = (array[2] = (array[1] + array[2]) / 2f);
         }
         float[] array2 = new float[]
         {
             0f,
             height
         };
         float   num2   = (leftMargin < array[1]) ? leftMargin : array[1];
         float   num3   = (rightMargin < width - array[2]) ? rightMargin : (width - array[2]);
         float[] array3 = new float[]
         {
             0f,
             num2 / num,
             (num - num3) / num,
             1f
         };
         float[] array4 = new float[]
         {
             0f,
             1f
         };
         if (array3[2] < 0f)
         {
             array3[2] = 0f;
         }
         if (array3[1] > 1f)
         {
             array3[1] = 1f;
         }
         primitive.VertexCount = 8;
         primitive.SetIndices(new ushort[]
         {
             0,
             4,
             1,
             5,
             2,
             6,
             3,
             7
         });
         primitive.IndexCount = 8;
         for (int i = 0; i < 2; i++)
         {
             for (int j = 0; j < 4; j++)
             {
                 UIPrimitiveVertex vertex = primitive.GetVertex(i * 4 + j);
                 vertex.X = array[j] + offsetX;
                 vertex.Y = array2[i] + offsetY;
                 vertex.U = array3[j];
                 vertex.V = array4[i];
             }
         }
     }
 }