public void Render(DrawArgs drawArgs) { if ((DrawArgs.WorldWindow != null) && (DrawArgs.WorldWindow.MenuBar.Anchor == MenuAnchor.Bottom)) { this.Top = 0; this.Bottom = drawArgs.screenHeight - 120; } else { this.Top = 120; this.Bottom = drawArgs.screenHeight - 1; } MenuUtils.DrawBox(this.Left, this.Top, this.Right - this.Left, this.Bottom - this.Top, 0.0f, World.Settings.menuBackColor, drawArgs.device); this.RenderContents(drawArgs); this.outlineVerts[0].X = this.Left; this.outlineVerts[0].Y = this.Top; this.outlineVerts[1].X = this.Right; this.outlineVerts[1].Y = this.Top; this.outlineVerts[2].X = this.Right; this.outlineVerts[2].Y = this.Bottom; this.outlineVerts[3].X = this.Left; this.outlineVerts[3].Y = this.Bottom; this.outlineVerts[4].X = this.Left; this.outlineVerts[4].Y = this.Top; MenuUtils.DrawLine(this.outlineVerts, World.Settings.menuOutlineColor, drawArgs.device); }
public void Render(DrawArgs drawArgs) { if (!m_Visible) { return; } MenuUtils.DrawBox( m_Location.X, m_Location.Y, m_Size.Width, m_Size.Height, 0.0f, m_BackgroundColor.ToArgb(), drawArgs.device); if (m_Values == null || m_Values.Length == 0) { return; } float xIncr = (float)m_Size.Width / (float)m_Values.Length; m_Verts = new CustomVertex.TransformedColored[m_Values.Length]; if (m_ResetVerts) { for (int i = 0; i < m_Values.Length; i++) { if (m_Values[i] < m_Min) { m_Verts[i].Y = m_Location.Y + m_Size.Height; } else if (m_Values[i] > m_Max) { m_Verts[i].Y = m_Location.Y; } else { float p = (m_Values[i] - m_Min) / (m_Max - m_Min); m_Verts[i].Y = m_Location.Y + m_Size.Height - (float)m_Size.Height * p; } m_Verts[i].X = m_Location.X + i * xIncr; m_Verts[i].Z = 0.0f; m_Verts[i].Color = m_LineColor.ToArgb(); } } drawArgs.device.TextureState[0].ColorOperation = TextureOperation.Disable; drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.DrawUserPrimitives( PrimitiveType.LineStrip, m_Verts.Length - 1, m_Verts); }
public void Render(DrawArgs drawArgs) { if (!this.m_Visible) { return; } MenuUtils.DrawBox(this.m_Location.X, this.m_Location.Y, this.m_Size.Width, this.m_Size.Height, 0.0f, this.m_BackgroundColor.ToArgb(), drawArgs.device); if (this.m_Values == null || this.m_Values.Length == 0) { return; } float xIncr = (float)this.m_Size.Width / (float)this.m_Values.Length; this.m_Verts = new CustomVertex.TransformedColored[this.m_Values.Length]; if (this.m_ResetVerts) { for (int i = 0; i < this.m_Values.Length; i++) { if (this.m_Values[i] < this.m_Min) { this.m_Verts[i].Y = this.m_Location.Y + this.m_Size.Height; } else if (this.m_Values[i] > this.m_Max) { this.m_Verts[i].Y = this.m_Location.Y; } else { float p = (this.m_Values[i] - this.m_Min) / (this.m_Max - this.m_Min); this.m_Verts[i].Y = this.m_Location.Y + this.m_Size.Height - (float)this.m_Size.Height * p; } this.m_Verts[i].X = this.m_Location.X + i * xIncr; this.m_Verts[i].Z = 0.0f; this.m_Verts[i].Color = this.m_LineColor.ToArgb(); } } drawArgs.device.SetTextureStageState(0, TextureStage.ColorOperation, TextureOperation.Disable); drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.VertexFormat = CustomVertex.TransformedColored.Format; drawArgs.device.DrawUserPrimitives( PrimitiveType.LineStrip, this.m_Verts.Length - 1, this.m_Verts); }
protected virtual void RenderProgress(DrawArgs drawArgs) { drawArgs.device.SetTransform(TransformState.World, Matrix.Translation( (float)-drawArgs.WorldCamera.ReferenceCenter.X, (float)-drawArgs.WorldCamera.ReferenceCenter.Y, (float)-drawArgs.WorldCamera.ReferenceCenter.Z )); this.device.SetRenderState(RenderState.ZEnable , false); double centerLat = 0.5 * (this.maxLat + this.minLat); double centerLon = 0.5 * (this.maxLon + this.minLon); Vector3 v = MathEngine.SphericalToCartesian(centerLat, centerLon, this.layerRadius); if(drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v) && MathEngine.SphericalDistanceDegrees(centerLat, centerLon, drawArgs.WorldCamera.Latitude.Degrees, drawArgs.WorldCamera.Longitude.Degrees) < 2 * drawArgs.WorldCamera.ViewRange.Degrees ) { v.Project(drawArgs.device.Viewport, drawArgs.device.GetTransform(TransformState.Projection), drawArgs.device.GetTransform(TransformState.View), drawArgs.device.GetTransform(TransformState.World)); MenuUtils.DrawBox((int)v.X, (int)v.Y, 200, 40, 0.0f, this.progressBarBackColor, drawArgs.device); Vector2[] boxOutline = new Vector2[5]; boxOutline[0].X = (int)v.X; boxOutline[0].Y = (int)v.Y; boxOutline[1].X = (int)v.X + 200; boxOutline[1].Y = (int)v.Y; boxOutline[2].X = (int)v.X + 200; boxOutline[2].Y = (int)v.Y + 40; boxOutline[3].X = (int)v.X; boxOutline[3].Y = (int)v.Y + 40; boxOutline[4].X = (int)v.X; boxOutline[4].Y = (int)v.Y; MenuUtils.DrawLine(boxOutline, this.progressBarOutlineColor, drawArgs.device); drawArgs.defaultDrawingFont.DrawText(null, "Downloading Remote Image...", new System.Drawing.Rectangle((int)v.X + 5, (int)v.Y + 5, 200, 50), FontDrawFlags.NoClip, this.textColor); this.DrawProgressBar(drawArgs, v.X + 100, v.Y + 30, 180, 10, World.Settings.downloadProgressColor); } this.device.SetRenderState(RenderState.ZEnable , true); drawArgs.device.SetTransform(TransformState.World, drawArgs.WorldCamera.WorldMatrix; }
public override void RenderContents(DrawArgs drawArgs) { this.m_DrawArgs = drawArgs; try { if (this.itemFont == null) { this.itemFont = drawArgs.CreateFont(World.Settings.LayerManagerFontName, World.Settings.LayerManagerFontSize, World.Settings.LayerManagerFontStyle); // TODO: Fix wingdings menu problems Font localHeaderFont = new Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold); this.headerFont = new SharpDX.Direct3D9.Font(drawArgs.device, localHeaderFont); Font wingdings = new Font("Wingdings", 12.0f); this.wingdingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, wingdings); AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection(); fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); Font worldwinddings = new Font(fpc.Families[0], 12.0f); this.worldwinddingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, worldwinddings); } this.updateList(); this.worldwinddingsFont.DrawText( null, "E", new Rectangle(this.Right - 16, this.Top + 2, 20, this.topBorder), FontDrawFlags.None, this.TextColor); int numItems = this.GetNumberOfUncollapsedItems(); int totalHeight = this.GetItemsHeight(drawArgs); //numItems * ItemHeight; this.showScrollbar = totalHeight > this.ClientHeight; if (this.showScrollbar) { double percentHeight = (double)this.ClientHeight / totalHeight; int scrollbarHeight = (int)(this.ClientHeight * percentHeight); int maxScroll = totalHeight - this.ClientHeight; if (this.scrollBarPosition < 0) { this.scrollBarPosition = 0; } else if (this.scrollBarPosition > maxScroll) { this.scrollBarPosition = maxScroll; } // Smooth scroll const float scrollSpeed = 0.3f; float smoothScrollDelta = (this.scrollBarPosition - this.scrollSmoothPosition) * scrollSpeed; float absDelta = Math.Abs(smoothScrollDelta); if (absDelta > 100f || absDelta < 3f) { // Scroll > 100 pixels and < 1.5 pixels faster smoothScrollDelta = (this.scrollBarPosition - this.scrollSmoothPosition) * (float)Math.Sqrt(scrollSpeed); } this.scrollSmoothPosition += smoothScrollDelta; if (this.scrollSmoothPosition > maxScroll) { this.scrollSmoothPosition = maxScroll; } int scrollPos = (int)((float)percentHeight * this.scrollBarPosition); int color = this.isScrolling ? World.Settings.scrollbarHotColor : World.Settings.scrollbarColor; MenuUtils.DrawBox(this.Right - this.ScrollBarSize + 2, this.ClientTop + scrollPos, this.ScrollBarSize - 3, scrollbarHeight + 1, 0.0f, color, drawArgs.device); this.scrollbarLine[0].X = this.Right - this.ScrollBarSize; this.scrollbarLine[0].Y = this.ClientTop; this.scrollbarLine[1].X = this.Right - this.ScrollBarSize; this.scrollbarLine[1].Y = this.Bottom; MenuUtils.DrawLine(this.scrollbarLine, this.DialogColor, drawArgs.device); } this.headerFont.DrawText( null, "Layer Manager", new Rectangle(this.Left + 5, this.Top + 1, this.Width, this.topBorder - 2), FontDrawFlags.VerticalCenter, this.TextColor); SharpDX.Vector2[] headerLinePoints = new SharpDX.Vector2[2]; headerLinePoints[0].X = this.Left; headerLinePoints[0].Y = this.Top + this.topBorder - 1; headerLinePoints[1].X = this.Right; headerLinePoints[1].Y = this.Top + this.topBorder - 1; MenuUtils.DrawLine(headerLinePoints, this.DialogColor, drawArgs.device); int runningItemHeight = 0; if (this.showScrollbar) { runningItemHeight = -(int)Math.Round(this.scrollSmoothPosition); } // Set the Direct3D viewport to match the layer manager client area // to clip the text to the window when scrolling Viewport lmClientAreaViewPort = new Viewport(); lmClientAreaViewPort.X = this.ClientLeft; lmClientAreaViewPort.Y = this.ClientTop; lmClientAreaViewPort.Width = this.ClientWidth; lmClientAreaViewPort.Height = this.ClientHeight; Viewport defaultViewPort = drawArgs.device.Viewport; drawArgs.device.Viewport = lmClientAreaViewPort; for (int i = 0; i < this._itemList.Count; i++) { if (runningItemHeight > this.ClientHeight) { // No more space for items break; } LayerMenuItem lmi = (LayerMenuItem)this._itemList[i]; runningItemHeight += lmi.Render( drawArgs, this.ClientLeft, this.ClientTop, runningItemHeight, this.ClientWidth, this.ClientBottom, this.itemFont, this.wingdingsFont, this.worldwinddingsFont, this.MouseOverItem); } drawArgs.device.Viewport = defaultViewPort; } catch (Exception caught) { Log.Write(caught); } }
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); }