Пример #1
0
        public bool DrawCenteredText(Microsoft.DirectX.Direct3D.Font font, string text, int x, int y, int color)
        {
            int centeredX = 0;
            int centeredY = 0;
            Rectangle rect;

            if ((font == null) || (text == null) || (text.Length <= 0))
            {
                return false;
            }

            rect = font.MeasureString(null, text, DrawTextFormat.None, color);

            centeredX = x - rect.Width / 2;
            centeredY = y - rect.Height / 2;
            if (font.DrawText(null, text, centeredX, centeredY, color) == 0)
            {
                return false;
            }

            return true;
        }
Пример #2
0
 public void DrawObjectID(Canvas canvas, Microsoft.DirectX.Direct3D.Font font)
 {
     if (ID != string.Empty)
     {
         _text_rect = font.MeasureString(null, ID, DrawTextFormat.Center, TextColor);
         _text_rect.X = (SpriteArea.X + ((SpriteArea.Width - _text_rect.Width) / 2)) - 5;
         _text_rect.Y = SpriteArea.Bottom;
         _text_rect.Width += 10;
         canvas.DrawFillRect(_text_rect, _textbox_color_material);
    
         font.DrawText(null, ID, _text_rect, DrawTextFormat.Center, TextColor);
     }
 }
Пример #3
0
        public override void DrawSpecial(Microsoft.DirectX.Direct3D.Font font, RectangleF overlay_rect, Rectangle text_rect, Canvas canvas)
        {

            _overlay_rect = overlay_rect;
            _text_rect = text_rect;
            _progressbar_rect = text_rect;
            _border_rect = text_rect;

           

            if ((OwnerID == DDD_Global.Instance.PlayerID) && (DrawProgressBar))
            {

                _progressbar_rect.Y += text_rect.Height;
                _progressbar_rect.Height = _ProgressBarHeight_;
                _progressbar_rect.Width = _ProgressBarWidth_;
                _progressbar_rect.X += ((text_rect.Width - _progressbar_rect.Width) / 2);

                _border_rect.Height = _ProgressBarHeight_ + _text_rect.Height + 2;

                canvas.DrawFillRect(_border_rect, _textbox_color_material);

                DrawObjectID(canvas, font);
                canvas.DrawRect(_border_rect, BorderColor);

                if (FuelCapacity > 0)
                {
                    canvas.DrawProgressBar(_progressbar_rect,
                        progress_bar_background_material,
                        progress_bar_foreground_material,
                        FuelAmount / FuelCapacity);
                }
                else
                {
                    canvas.DrawProgressBar(_progressbar_rect,
                        progress_bar_background_material,
                        progress_bar_foreground_material,
                        0);
                }
            }
            else
            {
                if (DrawUnmanagedAssetLabel)
                {
                    DrawObjectID(canvas, font);
                    canvas.DrawRect(_border_rect, BorderColor);
                }

            }



            foreach (DDDObjects attacker in Attackers)
            {
                float _destinationX = attacker.SpriteArea.X + (attacker.SpriteArea.Width / 2);
                float _destinationY = attacker.SpriteArea.Y + (attacker.SpriteArea.Height / 2);
                canvas.DrawLine(Color.Red, 1,
                    SpriteArea.X + (SpriteArea.Width / 2),
                    SpriteArea.Y + (SpriteArea.Height / 2),
                    _destinationX,
                    _destinationY
                    );
                //engagment_rect.X = (int)(_destinationX - 3);
                //engagment_rect.Y = (int)(_destinationY - 3);
                //engagment_rect.Height = 6;
                //engagment_rect.Width = 6;
                //canvas.DrawFillRect(engagment_rect, red_material);
            }

            if (IsBeingAttacked)
            {
                engagment_rect = font.MeasureString(null, _engagementTimeStr, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red);
                engagment_rect.Width += 10;
                engagment_rect.X = (int)(_overlay_rect.X + (_overlay_rect.Width - engagment_rect.Width) / 2);
                engagment_rect.Y = (int)(_overlay_rect.Y + (_overlay_rect.Height - engagment_rect.Height) / 2);
                canvas.DrawFillRect(engagment_rect, black_material);
                canvas.DrawRect(engagment_rect, Color.Red);
                font.DrawText(null, _engagementTimeStr, engagment_rect, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red);
            }


            // Draw object "Tags"
            if (Tag != string.Empty && (DDD_Global.Instance.TagPosition != TagPositionEnum.INVISIBLE))
            {
                Rectangle tag_rect = font.MeasureString(null, Tag, DrawTextFormat.Center, Color.Black);

                switch (DDD_Global.Instance.TagPosition)
                {
                    case TagPositionEnum.ABOVE:
                        tag_rect.Y = (int)(overlay_rect.Y - tag_rect.Height);
                        tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        break;
                    case TagPositionEnum.BELOW:
                        if (!DrawUnmanagedAssetLabel && (OwnerID != DDD_Global.Instance.PlayerID))
                        {
                            tag_rect.Y = (int)(overlay_rect.Bottom + 1);
                            tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        }
                        else
                        {
                            tag_rect.Y = (int)(_border_rect.Bottom + 2);
                            tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        }
                        break;
                    case TagPositionEnum.CENTER:
                        //tag_rect.Y = (int)(overlay_rect.Y + ((overlay_rect.Height - tag_rect.Height) * .5f));
                        tag_rect.Y = (int)(overlay_rect.Bottom - tag_rect.Height - 2);
                        tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        break;
                }

                canvas.DrawFillRect(tag_rect, tag_material);
                font.DrawText(null, Tag, tag_rect, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, Color.Black);
            }


        }
Пример #4
0
 public AGT_Text(string message, Microsoft.DirectX.Direct3D.Font label_font)
 {
     _font = label_font;
     _label_message = message;
     _message_rect = label_font.MeasureString(null, message, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.White);
     _message_rect.X = 0;
     _message_rect.Y = 0;
     _label_rect.X = 0;
     _label_rect.Y = 0;
     _label_rect.Height = _message_rect.Height;
     _label_rect.Width = (int)(_message_rect.Width + (_message_rect.Width * .2));
 }
Пример #5
0
			public int Render(DrawArgs drawArgs, int x, int y, int yOffset, int width, int height, 
				Microsoft.DirectX.Direct3D.Font drawingFont,
				Microsoft.DirectX.Direct3D.Font wingdingsFont,
				Microsoft.DirectX.Direct3D.Font worldwinddingsFont, 
				LayerMenuItem mouseOverItem)
			{
				if(ParentControl == null)
					ParentControl = drawArgs.parentControl;

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

				int consumedHeight = 20;
				
				System.Drawing.Rectangle textRect = drawingFont.MeasureString(null,
					m_renderableObject.Name,
					DrawTextFormat.None,
					System.Drawing.Color.White.ToArgb());

				consumedHeight = textRect.Height;

				if (m_renderableObject.Description != null && m_renderableObject.Description.Length > 0 && !(m_renderableObject is WorldWind.Renderable.Icon))
				{
					System.Drawing.SizeF rectF = DrawArgs.Graphics.MeasureString(
						m_renderableObject.Description,
						drawArgs.defaultSubTitleFont,
						width - (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset)
						);
				
					consumedHeight += (int)rectF.Height + 15;
				}

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

				updateList();

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

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

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

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


					drawingFont.DrawText(
						null,
						m_renderableObject.Name,
						new System.Drawing.Rectangle(
						x + this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset,
						_y,
						width - (this._itemXOffset + this._expandArrowXSize + this._checkBoxXOffset),
						height),
						DrawTextFormat.None,
						color );

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

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

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

				return consumedHeight;
			}