Exemple #1
0
 private void DrawText(Point location, string text, Color color)
 {
     DrawingFont.DrawText(null, text, location.X, location.Y, new ColorBGRA(color.R, color.G, color.B, color.A));
 }
Exemple #2
0
        public int Render(DrawArgs drawArgs, int x, int y, int yOffset, int width, int height,
                          SharpDX.Direct3D9.Font drawingFont,
                          SharpDX.Direct3D9.Font wingdingsFont,
                          SharpDX.Direct3D9.Font worldwinddingsFont,
                          LayerMenuItem mouseOverItem)
        {
            if (this.ParentControl == null)
            {
                this.ParentControl = drawArgs.parentControl;
            }

            this._x     = x;
            this._y     = y + yOffset;
            this._width = width;

            int consumedHeight = 20;

            Rectangle textRect = drawingFont.MeasureString(null, this.m_renderableObject.Name,
                                                           FontDrawFlags.SingleLine,
                                                           Color.White.ToArgb());

            consumedHeight = textRect.Height;

            if (this.m_renderableObject.Description != null && this.m_renderableObject.Description.Length > 0 && !(this.m_renderableObject is Icon))
            {
                SizeF rectF = DrawArgs.Graphics.MeasureString(this.m_renderableObject.Description,
                                                              drawArgs.defaultSubTitleFont,
                                                              width - (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset)
                                                              );

                consumedHeight += (int)rectF.Height + 15;
            }

            this.lastConsumedHeight = consumedHeight;
            // Layer manager client area height
            int totalHeight = height - y;

            this.updateList();

            if (yOffset >= -consumedHeight)
            {
                // Part of item or whole item visible
                int color = this.m_renderableObject.IsOn ? this.itemOnColor : this.itemOffColor;
                if (mouseOverItem == this)
                {
                    if (!this.m_renderableObject.IsOn)
                    {
                        // mouseover + inactive color (black)
                        color = 0xff << 24;
                    }
                    MenuUtils.DrawBox(this.m_parent.ClientLeft, this._y, this.m_parent.ClientWidth, consumedHeight, 0,
                                      World.Settings.menuOutlineColor, drawArgs.device);
                }

                if (this.m_renderableObject is RenderableObjectList)
                {
                    RenderableObjectList rol = (RenderableObjectList)this.m_renderableObject;
                    if (!rol.DisableExpansion)
                    {
                        worldwinddingsFont.DrawText(
                            null,
                            (this.isExpanded ? "L" : "A"),
                            new Rectangle(x + this._itemXOffset, this._y, this._expandArrowXSize, height),
                            FontDrawFlags.SingleLine,
                            color);
                    }
                }

                string checkSymbol = null;
                if (this.m_renderableObject.ParentList != null && this.m_renderableObject.ParentList.ShowOnlyOneLayer)
                {
                    // Radio check
                    checkSymbol = this.m_renderableObject.IsOn ? "O" : "P";
                }
                else
                {
                    // Normal check
                    checkSymbol = this.m_renderableObject.IsOn ? "N" : "F";
                }

                worldwinddingsFont.DrawText(
                    null,
                    checkSymbol,
                    new Rectangle(
                        x + this._itemXOffset + this._expandArrowXSize, this._y,
                        this._checkBoxXOffset,
                        height),
                    FontDrawFlags.NoClip,
                    color);


                drawingFont.DrawText(
                    null, this.m_renderableObject.Name,
                    new Rectangle(
                        x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset, this._y,
                        width - (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset),
                        height),
                    FontDrawFlags.SingleLine,
                    color);

                if (this.m_renderableObject.Description != null && this.m_renderableObject.Description.Length > 0 && !(this.m_renderableObject is Icon))
                {
                    drawArgs.defaultSubTitleDrawingFont.DrawText(
                        null, this.m_renderableObject.Description,
                        new Rectangle(
                            x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset, this._y + textRect.Height,
                            width - (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset),
                            height),
                        FontDrawFlags.WordBreak,
                        Color.Gray.ToArgb());
                }

                if (this.m_renderableObject.MetaData.Contains("InfoUri"))
                {
                    Vector2[] underlineVerts = new Vector2[2];
                    underlineVerts[0].X = x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset;
                    underlineVerts[0].Y = this._y + textRect.Height;
                    underlineVerts[1].X = underlineVerts[0].X + textRect.Width;
                    underlineVerts[1].Y = this._y + textRect.Height;

                    MenuUtils.DrawLine(underlineVerts, color, drawArgs.device);
                }
            }

            if (this.isExpanded)
            {
                for (int i = 0; i < this.m_subItems.Count; i++)
                {
                    int yRealOffset = yOffset + consumedHeight;
                    if (yRealOffset > totalHeight)
                    {
                        // No more space for items
                        break;
                    }
                    LayerMenuItem lmi = (LayerMenuItem)this.m_subItems[i];
                    consumedHeight += lmi.Render(
                        drawArgs,
                        x + this._subItemXIndent,
                        y,
                        yRealOffset,
                        width - this._subItemXIndent,
                        height,
                        drawingFont,
                        wingdingsFont,
                        worldwinddingsFont,
                        mouseOverItem);
                }
            }

            return(consumedHeight);
        }