Exemplo n.º 1
0
        public void Render(Microsoft.SPOT.Bitmap screen)
        {
            screen.DrawLine(Color.White, 2, 0, AGENT.Size / 2, AGENT.Size, AGENT.Size / 2);

            DateTime now = DateTime.Now;
            int counter = (int)now.DayOfWeek;
            counter++;
            int left = buffer;
            IForecast nowForecast = null;
            bool needsDate = false;
            DateTime lastUpdated = DateTime.Now;
            for (int x = 0; x <= days; x++)
            {
                if (counter >= 7) counter = 0;
                string dayName = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames[counter];
                if (dayName.Length >= 3) dayName = dayName.Substring(0, 3);
                int width = drawing.MeasureString(dayName, font);
                screen.DrawText(dayName, font, Color.White, left, top);
                if (WeatherProvider != null && WeatherProvider.CurrentWeekForecast != null && WeatherProvider.CurrentWeekForecast.Count > 0)
                {
                    IForecast current = WeatherProvider.CurrentWeekForecast[0] as IForecast;
                    var startDate = now.Date.AddDays(x);
                    foreach (IForecast f in WeatherProvider.CurrentWeekForecast)
                    {
                        if (f.TimeStamp.Year == now.Date.Year && f.TimeStamp.Month == now.Date.Month && f.TimeStamp.Day == now.Date.Day)
                            nowForecast = f;
                        if (startDate.Year == f.TimeStamp.Year && startDate.Month == f.TimeStamp.Month && startDate.Day == f.TimeStamp.Day)
                        {
                            Debug.Print("Found match");
                            current = f;
                            break;
                        }
                    }
                    if (current != null)
                    {
                        needsDate = true;
                        screen.DrawText(current.Temperature.ToString(), font, Color.White, left + 4, top + font.Height + 2);
                        lastUpdated = current.TimeStamp;
                    }
                }
                counter++;
                if (counter > 6) counter = 0;
                left += width + buffer;
            }
            if (nowForecast != null)
            {
                string display = nowForecast.Temperature.ToString();
                int forecastLeft = AGENT.Size - drawing.MeasureString(display, bigfont);
                screen.DrawText(display, bigfont, Color.White, forecastLeft, (AGENT.Size / 2) + 2);
                needsDate = true;
                lastUpdated = nowForecast.TimeStamp;
            }
            if (needsDate)
            {
                screen.DrawText(lastUpdated.ToString(), smallFont, Color.White, 3, (AGENT.Size / 2) - smallFont.Height - 1);

            }

        }
Exemplo n.º 2
0
        public void Render(Microsoft.SPOT.Bitmap screen)
        {
           
            int height = width/2;
            
            drawing.DrawBattery(screen, new Point(AGENT.Contrib.Device.Size/2 - width/2, AGENT.Contrib.Device.Size/2 - height/2), width, height, 1,
                                Color.White, Color.Black, charging, AGENT.Contrib.Hardware.Battery.Level);

            screen.DrawText("width:" + width.ToString() + ", height:" + height.ToString(), font, Color.White, 0,
                            AGENT.Contrib.Device.Size - font.Height);
         
        }
Exemplo n.º 3
0
        public void Draw(string text, float x, float y, float width, float height, Microsoft.DirectX.Direct3D.Font font)
        {

            _background.Begin(SpriteFlags.AlphaBlend);
            _background.Transform = Matrix.Scaling(width / _window_texture_width, height / _window_texture_height, 0) * Matrix.Translation(x, y, 0);

            _background.Draw(_window_background, Vector3.Empty, Vector3.Empty, Color.White.ToArgb());

            _text_rectangle.X = (int)x + Padding;
            _text_rectangle.Y = (int)y + Padding;
            _text_rectangle.Width = (int)width - (2 * Padding);
            _text_rectangle.Height = (int)height - (2 * Padding);

            _background.Transform = Matrix.Scaling(1, 1, 1);
            font.DrawText(_background, text, _text_rectangle, Format, Foreground);
            if (Activated)
            {
                Activated = false;
            }
            _background.End();
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
		private void PrintString(string text,float x,float y,float z,Color color,Microsoft.DirectX.Direct3D.Font printFont) {
			Vector3 screenPoint=new Vector3(x,y,z);
			screenPoint.Project(device.Viewport,device.Transform.Projection,device.Transform.View,device.Transform.World);
			printFont.DrawText(null,text,new Point((int)Math.Ceiling(screenPoint.X),(int)Math.Floor(screenPoint.Y)),color);
		}
Exemplo n.º 7
0
        public void render(ref Device device, ref Microsoft.DirectX.Direct3D.Font directxFont)
        {
            if (this.functions != null && this.functions.Count > 0)
            {
                // Render this module name and bounding box

                // Draw the module name
                directxFont.DrawText(null, name, x, y, Color.White);

                // TODO: Draw the module border
            }
        }
Exemplo n.º 8
0
 //Display flying score
 public void DisplayScore(Microsoft.DirectX.Direct3D.Font font)
 {
     font.DrawText(null, "+" + scorenum, pos, Color.LightCyan);
 }
Exemplo n.º 9
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);
            }


        }
Exemplo n.º 10
0
        public bool Draw(Microsoft.DirectX.Direct3D.Font font, Rectangle client_rect, int offsetx, int offsety)
        {

            temp.X = client_rect.X - offsetx;
            temp.Y = client_rect.Y - offsety;
            
            if (offsety < client_rect.Bottom)
            {
                font.DrawText(null, _text, client_rect.X - (int)offsetx, offsety, Foreground);
                return true;
            }
            return false;

        }
Exemplo n.º 11
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;
			}