Example #1
0
        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);
        }
Example #2
0
        protected virtual void RenderProgress(DrawArgs drawArgs)
        {
            drawArgs.device.Transform.World = Matrix.Translation(
                (float)-drawArgs.WorldCamera.ReferenceCenter.X,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Y,
                (float)-drawArgs.WorldCamera.ReferenceCenter.Z
                );

            device.RenderState.ZBufferEnable = false;
            double centerLat = 0.5 * (maxLat + minLat);
            double centerLon = 0.5 * (maxLon + 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.Transform.Projection, drawArgs.device.Transform.View, drawArgs.device.Transform.World);

                MenuUtils.DrawBox((int)v.X, (int)v.Y, 200, 40, 0.0f, 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, progressBarOutlineColor, drawArgs.device);

                drawArgs.defaultDrawingFont.DrawText(null,
                                                     "Downloading Remote Image...",
                                                     new System.Drawing.Rectangle((int)v.X + 5, (int)v.Y + 5, 200, 50),
                                                     DrawTextFormat.NoClip, textColor);

                DrawProgressBar(drawArgs, v.X + 100, v.Y + 30, 180, 10, World.Settings.downloadProgressColor);
            }
            device.RenderState.ZBufferEnable = true;
            drawArgs.device.Transform.World  = drawArgs.WorldCamera.WorldMatrix;
        }