示例#1
0
文件: Column.cs 项目: zhaohuwei/ZHSan
        public void Draw()
        {
            if (this.DisplayPosition.Right > this.tabList.VisibleLowerClient.Right)
            {
                if (this.DisplayPosition.Left < this.tabList.VisibleLowerClient.Right)
                {
                    CacheManager.Draw(this.tabList.rightArrowTexture, StaticMethods.LeftRectangle(this.DisplayPosition, new Rectangle(0, 0, this.tabList.rightArrowTexture.Width, this.tabList.rightArrowTexture.Height)), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.035f);
                }
            }
            else if (this.DisplayPosition.Left < this.tabList.VisibleLowerClient.Left)
            {
                if (this.DisplayPosition.Right > this.tabList.VisibleLowerClient.Left)
                {
                    CacheManager.Draw(this.tabList.leftArrowTexture, StaticMethods.RightRectangle(this.DisplayPosition, new Rectangle(0, 0, this.tabList.leftArrowTexture.Width, this.tabList.leftArrowTexture.Height)), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.035f);
                }
            }
            else
            {
                Rectangle?sourceRectangle = null;
                CacheManager.Draw(this.tabList.columnheaderTexture, this.DisplayPosition, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.035f);
                sourceRectangle = null;
                CacheManager.Draw(this.tabList.columnspliterTexture, this.SpliterPosition, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.035f);
                this.Text.Draw(0.03499f);
                for (int i = 0; i < this.ColumnTextList.Count; i++)
                {
                    if (((this.ColumnTextList.DisplayPosition(i).Bottom <= this.tabList.VisibleLowerClient.Bottom) && (this.ColumnTextList.DisplayPosition(i).Top >= this.DisplayPosition.Bottom)))  // (!String.IsNullOrEmpty(this.ColumnTextList[i].Text)))
                    {
                        if (this.Editable)
                        {
                            if (this.ColumnTextList[i].TextTexture == null)
                            {
                                var rec = StaticMethods.CenterRectangle(this.ColumnTextList.DisplayPosition(i), new Rectangle(0, 0, this.tabList.checkboxWidth, this.tabList.checkboxWidth));
                                var pos = new Vector2(rec.X, rec.Y);
                                //CacheManager.DrawString(Session.Current.Font, this.ColumnTextList[i].Text, pos, Color.White, 0f, Vector2.Zero, Text.Builder.Scale, SpriteEffects.None, 0.3499f);
                            }
                            else
                            {
                                sourceRectangle = null;

                                var rec = StaticMethods.CenterRectangle(this.ColumnTextList.DisplayPosition(i), new Rectangle(0, 0, this.tabList.checkboxWidth, this.tabList.checkboxWidth));

                                CacheManager.Draw(this.ColumnTextList[i].TextTexture, rec, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.03499f);
                            }
                        }
                        else
                        {
                            this.ColumnTextList.Draw(i, 0.03499f);
                        }
                    }
                }
            }
        }
示例#2
0
        private void ResetAlignedPosition(int index)
        {
            switch (this.align)
            {
            case TextAlign.Left:
                this.TextList[index].AlignedPosition = StaticMethods.LeftRectangle(this.DisplayPosition(index), new Microsoft.Xna.Framework.Rectangle(0, 0, this.Width(index), this.Height(index)));
                break;

            case TextAlign.Middle:
                this.TextList[index].AlignedPosition = StaticMethods.CenterRectangle(this.DisplayPosition(index), new Microsoft.Xna.Framework.Rectangle(0, 0, this.Width(index), this.Height(index)));
                break;

            case TextAlign.Right:
                this.TextList[index].AlignedPosition = StaticMethods.RightRectangle(this.DisplayPosition(index), new Microsoft.Xna.Framework.Rectangle(0, 0, this.Width(index), this.Height(index)));
                break;
            }
        }
示例#3
0
        private void ResetAlignedPosition()
        {
            if (((this.align != TextAlign.None) && (this.textTexture != null)) && !(this.position == Microsoft.Xna.Framework.Rectangle.Empty))
            {
                switch (this.align)
                {
                case TextAlign.Left:
                    this.alignedPosition = StaticMethods.LeftRectangle(this.DisplayPosition, new Microsoft.Xna.Framework.Rectangle(0, 0, this.textTexture.Width, this.textTexture.Height));
                    break;

                case TextAlign.Middle:
                    this.alignedPosition = StaticMethods.CenterRectangle(this.DisplayPosition, new Microsoft.Xna.Framework.Rectangle(0, 0, this.textTexture.Width, this.textTexture.Height));
                    break;

                case TextAlign.Right:
                    this.alignedPosition = StaticMethods.RightRectangle(this.DisplayPosition, new Microsoft.Xna.Framework.Rectangle(0, 0, this.textTexture.Width, this.textTexture.Height));
                    break;
                }
            }
        }
示例#4
0
 public void Draw(SpriteBatch spriteBatch)
 {
     if (this.DisplayPosition.Right > this.tabList.VisibleLowerClient.Right)
     {
         if (this.DisplayPosition.Left < this.tabList.VisibleLowerClient.Right)
         {
             spriteBatch.Draw(this.tabList.rightArrowTexture, StaticMethods.LeftRectangle(this.DisplayPosition, new Rectangle(0, 0, this.tabList.rightArrowTexture.Width, this.tabList.rightArrowTexture.Height)), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.35f);
         }
     }
     else if (this.DisplayPosition.Left < this.tabList.VisibleLowerClient.Left)
     {
         if (this.DisplayPosition.Right > this.tabList.VisibleLowerClient.Left)
         {
             spriteBatch.Draw(this.tabList.leftArrowTexture, StaticMethods.RightRectangle(this.DisplayPosition, new Rectangle(0, 0, this.tabList.leftArrowTexture.Width, this.tabList.leftArrowTexture.Height)), null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.35f);
         }
     }
     else
     {
         Rectangle?sourceRectangle = null;
         spriteBatch.Draw(this.tabList.columnheaderTexture, this.DisplayPosition, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.35f);
         sourceRectangle = null;
         spriteBatch.Draw(this.tabList.columnspliterTexture, this.SpliterPosition, sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.35f);
         this.Text.Draw(spriteBatch, 0.3499f);
         for (int i = 0; i < this.ColumnTextList.Count; i++)
         {
             if (((this.ColumnTextList.DisplayPosition(i).Bottom <= this.tabList.VisibleLowerClient.Bottom) && (this.ColumnTextList.DisplayPosition(i).Top >= this.DisplayPosition.Bottom)) && (this.ColumnTextList[i].TextTexture != null))
             {
                 if (this.Editable)
                 {
                     sourceRectangle = null;
                     spriteBatch.Draw(this.ColumnTextList[i].TextTexture, StaticMethods.CenterRectangle(this.ColumnTextList.DisplayPosition(i), new Rectangle(0, 0, this.tabList.checkboxWidth, this.tabList.checkboxWidth)), sourceRectangle, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.3499f);
                 }
                 else
                 {
                     this.ColumnTextList.Draw(spriteBatch, i, 0.3499f);
                 }
             }
         }
     }
 }
示例#5
0
        public void Draw()
        {
            if (this.Visible)
            {
                Rectangle?nullable;

                var widthHeight = this.contextMenu.LeftClickFreeTextBuilder.GetWidthHeight(this.DisplayName);
                var width       = Convert.ToInt32(widthHeight.X);
                var height      = Convert.ToInt32(widthHeight.Y);

                if (this.selected || this.open)
                {
                    if (this.menuKind.IsLeft)
                    {
                        nullable = null;
                        CacheManager.Draw(this.Enabled ? this.contextMenu.LeftClickItemSelectedTexture : this.contextMenu.DisabledItemSelectedTexture
                                          , this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                        nullable = null;
                        var rec   = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                        var pos   = new Vector2(rec.X, rec.Y);
                        var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;
                        if (Session.LargeContextMenu)
                        {
                            pos    = new Vector2(rec.X, rec.Y) * 1.3f;
                            scale *= 1.3f;
                        }
                        if (!this.open)
                        {
                            nullable = null;
                            //var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                            //var pos = new Vector2(rec.X, rec.Y);
                            //var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;
                            CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, this.Enabled ? Color.White : this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                        }
                        else
                        {
                            nullable = null;
                            //var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                            //var pos = new Vector2(rec.X, rec.Y);
                            var color = this.Enabled ? Color.Gold : this.contextMenu.DisabledTextColor;
                            //var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;
                            CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                        }
                    }
                    else
                    {
                        nullable = null;
                        CacheManager.Draw(this.Enabled ? this.contextMenu.RightClickItemSelectedTexture : this.contextMenu.RightDisabledItemSelectedTexture, this.Position, nullable, this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                        nullable = null;

                        var rec   = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                        var pos   = new Vector2(rec.X, rec.Y);
                        var color = this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor;

                        var scale = this.contextMenu.RightClickFreeTextBuilder.Scale;
                        if (Session.LargeContextMenu)
                        {
                            pos    = new Vector2(rec.X, rec.Y) * 1.3f;
                            scale *= 1.3f;
                        }
                        CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, color, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                    }
                    if (this.open)
                    {
                        foreach (MenuItem item in this.MenuItems)
                        {
                            item.Draw();
                        }
                    }
                    else if (this.HasChild)
                    {
                        if (!this.menuKind.ShowLeft)
                        {
                            CacheManager.Draw(this.contextMenu.HasChildTexture, StaticMethods.CenterRectangle(new Rectangle(this.Position.Right, this.Position.Top, this.contextMenu.HasChildTexture.Width, this.Position.Height), new Rectangle(0, 0, this.contextMenu.HasChildTexture.Width, this.contextMenu.HasChildTexture.Height)), null, this.Enabled ? Color.White : this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                        }
                        else
                        {
                            CacheManager.Draw(this.contextMenu.HasChildTexture, StaticMethods.CenterRectangle(new Rectangle(this.Position.Left, this.Position.Top, -this.contextMenu.HasChildTexture.Width, this.Position.Height), new Rectangle(0, 0, -this.contextMenu.HasChildTexture.Width, -this.contextMenu.HasChildTexture.Height)), null, this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                        }
                    }
                }
                else if (this.menuKind.IsLeft)
                {
                    var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                    var pos = new Vector2(rec.X, rec.Y);

                    var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;
                    if (Session.LargeContextMenu)
                    {
                        pos    = new Vector2(rec.X, rec.Y) * 1.3f;
                        scale *= 1.3f;
                    }
                    if (this.Enabled)
                    {
                        nullable = null;
                        CacheManager.Draw(this.contextMenu.LeftClickItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);

                        //var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                        //var pos = new Vector2(rec.X, rec.Y);

                        //var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;

                        CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, this.contextMenu.LeftClickTextColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                    }
                    else
                    {
                        nullable = null;
                        CacheManager.Draw(this.contextMenu.DisabledItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);

                        //var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));

                        //var pos = new Vector2(rec.X, rec.Y);

                        //var scale = this.contextMenu.LeftClickFreeTextBuilder.Scale;

                        CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                    }
                }
                else
                {
                    if (this.Enabled)
                    {
                        nullable = null;
                        CacheManager.Draw(this.contextMenu.RightClickItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);

                        var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));

                        var pos = new Vector2(rec.X, rec.Y);

                        var scale = this.contextMenu.RightClickFreeTextBuilder.Scale;
                        if (Session.LargeContextMenu)
                        {
                            pos    = new Vector2(rec.X, rec.Y) * 1.3f;
                            scale *= 1.3f;
                        }
                        CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, this.contextMenu.RightClickTextColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                    }
                    else
                    {
                        nullable = null;
                        CacheManager.Draw(this.contextMenu.RightDisabledItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);

                        var rec = StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, width, height));
                        var pos = new Vector2(rec.X, rec.Y);

                        var scale = this.contextMenu.RightClickFreeTextBuilder.Scale;

                        CacheManager.DrawString(Session.Current.Font, this.DisplayName, pos, this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, scale, SpriteEffects.None, 0.0399f);
                    }
                }
            }
        }
示例#6
0
 internal void Draw(SpriteBatch spriteBatch)
 {
     if (this.Visible)
     {
         Rectangle?nullable;
         if (this.selected || this.open)
         {
             if (this.menuKind.IsLeft)
             {
                 nullable = null;
                 spriteBatch.Draw(this.Enabled ? this.contextMenu.LeftClickItemSelectedTexture : this.contextMenu.DisabledItemSelectedTexture
                                  , this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 if (!this.open)
                 {
                     nullable = null;
                     spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), nullable, this.Enabled ? Color.White : this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
                 }
                 else
                 {
                     nullable = null;
                     spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), nullable, this.Enabled ? Color.Gold : this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
                 }
             }
             else
             {
                 nullable = null;
                 spriteBatch.Draw(this.Enabled ? this.contextMenu.RightClickItemSelectedTexture : this.contextMenu.RightDisabledItemSelectedTexture, this.Position, nullable, this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 nullable = null;
                 spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), nullable, this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
             }
             if (this.open)
             {
                 foreach (MenuItem item in this.MenuItems)
                 {
                     item.Draw(spriteBatch);
                 }
             }
             else if (this.HasChild)
             {
                 if (!this.menuKind.ShowLeft)
                 {
                     spriteBatch.Draw(this.contextMenu.HasChildTexture, StaticMethods.CenterRectangle(new Rectangle(this.Position.Right, this.Position.Top, this.contextMenu.HasChildTexture.Width, this.Position.Height), new Rectangle(0, 0, this.contextMenu.HasChildTexture.Width, this.contextMenu.HasChildTexture.Height)), null, this.Enabled ? Color.White : this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 }
                 else
                 {
                     spriteBatch.Draw(this.contextMenu.HasChildTexture, StaticMethods.CenterRectangle(new Rectangle(this.Position.Left, this.Position.Top, -this.contextMenu.HasChildTexture.Width, this.Position.Height), new Rectangle(0, 0, -this.contextMenu.HasChildTexture.Width, -this.contextMenu.HasChildTexture.Height)), null, this.Enabled ? Color.White : this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 }
             }
         }
         else if (this.menuKind.IsLeft)
         {
             if (this.Enabled)
             {
                 nullable = null;
                 spriteBatch.Draw(this.contextMenu.LeftClickItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), null, this.contextMenu.LeftClickTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
             }
             else
             {
                 nullable = null;
                 spriteBatch.Draw(this.contextMenu.DisabledItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), null, this.contextMenu.DisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
             }
         }
         else
         {
             if (this.Enabled)
             {
                 nullable = null;
                 spriteBatch.Draw(this.contextMenu.RightClickItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), null, this.contextMenu.RightClickTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
             }
             else
             {
                 nullable = null;
                 spriteBatch.Draw(this.contextMenu.RightDisabledItemTexture, this.Position, nullable, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.04f);
                 spriteBatch.Draw(this.TextTexture, StaticMethods.CenterRectangle(this.Position, new Rectangle(0, 0, this.TextTexture.Width, this.TextTexture.Height)), null, this.contextMenu.RightDisabledTextColor, 0f, Vector2.Zero, SpriteEffects.None, 0.0399f);
             }
         }
     }
 }