Esempio n. 1
0
        /// <summary>
        /// Renders property row key text and icon.
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        protected void RenderName(Graphics graphics, int x, int y)
        {
            IFont font = this.Parent.Parent.FontInfo.Font;

            if (null != font)
            {
                String name = (null != this.property) ? this.property.Text : this.controlText;

                graphics.SetColor(this.Parent.Parent.TextColor);

                int len = name.Length;

                while (font.TextLength(name, 0, len) > this.Bounds.Width / 2 - 16)
                {
                    len--;
                }

                int xOffset = 0;

                if (this.parentGrid.RowHeight > 0)
                {
                    xOffset = this.parentGrid.RowHeight;
                }

                RenderText(graphics, x + xOffset, y, ContentAlignment.MiddleLeft, name);
            }

            RenderIcon(graphics, x, y);
        }
Esempio n. 2
0
        protected void RenderValue(Graphics graphics, int x, int y)
        {
            IFont font = this.Parent.Parent.FontInfo.Font;

            if (null != font)
            {
                String value = this.property.ToString();

                int len = value.Length;

                while (font.TextLength(value, 0, len) > this.Bounds.Width / 2 - 16)
                {
                    len--;
                }

                font.DrawText(graphics, 4 + x + this.Bounds.X + this.Bounds.Width / 2, y + this.Bounds.Y + 4, value, 0, len);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Updates control size based on font.
        /// </summary>
        /// <param name="font">font for menu item rendering.</param>
        internal void UpdateSizes(IFont font)
        {
            if (0 == this.menuItems.Count)
            {
                return;
            }

            if (this.controlsBounds.Width < 0)
            {
                int maxWidth = 40;                  // minimum Width == 40
                int h        = 1;

                // calculate max Width
                foreach (MenuItem menuItem in this.menuItems)
                {
                    if (false == menuItem.IsHr)
                    {
                        int len = 24 + ((null != font) ? font.TextLength(menuItem.Text) : menuItem.Text.Length * Menu.defaultCharWidth);

                        if (len > maxWidth)
                        {
                            maxWidth = len;
                        }
                    }
                }

                maxWidth += 32 + 4 + 4 + Menu.defaultCharWidth * 2;

                int offX          = this.bounds.X;
                int offY          = this.bounds.Y;
                int nButtonHeight = (null != font) ? 15 + font.TextHeight("") : 23;

                if (true == this.topItem)
                {
                    offY += this.bounds.Height;
                }
                else
                {
                    offX += this.bounds.Width + 1;
                }

                // Update sizes
                foreach (MenuItem menuItem in this.menuItems)
                {
                    if (true == menuItem.IsHr)
                    {
                        menuItem.SetSize(offX + 2, offY + h + 1, maxWidth - 4, 1);

                        h += 2;
                    }
                    else
                    {
                        menuItem.SetSize(offX + 2, offY + h + 1, maxWidth - 4, nButtonHeight - 1);

                        h += nButtonHeight;

                        menuItem.UpdateSizes(font);
                    }
                }

                h += 2;

                this.controlsBounds.X      = offX;
                this.controlsBounds.Y      = offY;
                this.controlsBounds.Width  = maxWidth;
                this.controlsBounds.Height = h;
            }
        }