Пример #1
0
        private static TrackThumbnail CreateTrackThumbnail(string sTrack, TelemetryInfo data, string file)
        {
            TrackThumbnail t     = new TrackThumbnail();
            var            track =
                new SimTelemetry.Game.Rfactor.Garage.rFactorTrack(sTrack);

            track.Scan();
            track.ScanRoute();
            t.Create(file, "Spa Franchorchamps", "", track.Route, data.TrackMapSize.Width, data.TrackMapSize.Height);
            return(t);
        }
Пример #2
0
        private static void DrawGauges(TelemetryLogReader read, double alpha, int frameNumber, Point positionGauge, double sample, Graphics g, Image imgTrack, TrackThumbnail TrackThumbnail)
        {
            var Brush_PedalsBackground = GetBrush(alpha, 255, 100, 100, 100);
            var Brush_PedalsBrake      = GetBrush(alpha, 255, 200, 0, 0);
            var Brush_PedalsThrottle   = GetBrush(alpha, 255, 0, 100, 0);
            var BrushWhite             = GetBrush(alpha, 255, 255, 255, 255);
            var BrushTime       = GetBrush(1, 255, 255, 255, 255);
            var BrushGray       = GetBrush(alpha, 255, 200, 200, 200);
            var BrushBackground = GetBrush(alpha, 100, 0, 0, 0);

            var GaugeWhite3 = new Pen(BrushWhite, 3.0f);
            var GaugeWhite2 = new Pen(BrushWhite, 2.0f);
            var GaugeWhite1 = new Pen(BrushWhite, 1.0f);

            double throttle = 0, brake = 0, rpm = 0, speed = 0, rpm_max = 0, rpm_min = 0, redline = 0;
            object gear = 0;

            try
            {
                throttle = read.GetDouble(sample, "Driver.Throttle");
                brake    = read.GetDouble(sample, "Player.Pedals_Brake");
                rpm      = Rotations.Rads_RPM(read.GetDouble(sample, "Driver.RPM"));
                gear     = read.Get(sample, "Driver.Gear");
                speed    = read.GetDouble(sample, "Driver.Speed") * 3.6;

                rpm_max = 18000;
                rpm_min = 6000;

                rpm_max = 1000 * Math.Ceiling(1.05 * rpm_max / 1000.0);
                redline = (rpm - 17000) / 1000.0;
                if (redline < 0)
                {
                    redline = 0;
                }
                if (redline > 1)
                {
                    redline = 1;
                }
            }
            catch (Exception ex)
            {
            }
            var BrushGear = GetBrush(alpha, 255, 255, 255 - Convert.ToInt32(redline * 200), 255 - Convert.ToInt32(redline * 200));

            /******** SPEEDO etc ********/

            g.DrawString(Math.Round(speed).ToString("000"), new Font("Tahoma", 36, FontStyle.Bold), BrushWhite, positionGauge.X + 200 - 50, positionGauge.Y + 200 + 35);
            g.DrawString("km/h", new Font("Tahoma", 14), BrushWhite, positionGauge.X + 200 - 20, positionGauge.Y + 200 + 90);

            g.DrawString(gear.ToString(), new Font("Tahoma", 48), BrushGear, positionGauge.X + 200 + 30, positionGauge.Y + 200 + 110);

            /******** LAPTIME *******/
            var tijd    = sample / 1000.0;
            var minutes = (tijd - (tijd % 60)) / 60;
            var seconds = Math.Floor(tijd - minutes * 60);
            var mills   = (tijd % 1.0) * 1000;
            var txt     = String.Format("{0:00}:{1:00}.{2:000}", minutes, seconds, mills);

            g.DrawString(txt, new Font("Tahoma", 48), BrushTime, positionGauge.X + 50, positionGauge.Y + 450);

            /******** RPM GAUGE ********/
            g.FillEllipse(BrushBackground, positionGauge.X, positionGauge.Y, 400, 400);
            g.DrawArc(GaugeWhite1, positionGauge.X + 45, positionGauge.Y + 45, 310, 310, 90, 270);
            g.DrawArc(GaugeWhite1, positionGauge.X + 50, positionGauge.Y + 50, 300, 300, 90, 270);
            g.DrawArc(GaugeWhite3, positionGauge.X + 55, positionGauge.Y + 55, 290, 290, 90, 270);

            for (int r = (int)(rpm_min / 1000); r <= (rpm_max) / 1000; r++)
            {
                var angle = (r * 1000 - rpm_min) / (rpm_max - rpm_min);
                angle *= 270;
                angle += 90;
                angle *= Math.PI;
                angle /= 180;
                var x1 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 155.0f;
                var y1 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 155.0f;

                var x2 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 165.0f;
                var y2 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 165.0f;

                var x3 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 180.0f;
                var y3 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 180.0f;

                g.DrawLine(GaugeWhite2, x1, y1, x2, y2);

                x3 -= 14;
                y3 -= 12;

                g.DrawString(r.ToString(), new Font("Tahoma", 16.0f, FontStyle.Bold), BrushWhite, x3, y3);
            }

            // NEEDLE
            g.FillEllipse(BrushWhite, positionGauge.X + 400 / 2 - 15, positionGauge.Y + 400 / 2 - 15, 30, 30);

            var angle_needle = 90 + 270 * (rpm - rpm_min) / (rpm_max - rpm_min);

            angle_needle *= Math.PI;
            angle_needle /= 180;

            // Tip of needle
            var nx1 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle) * 155.0f;
            var ny1 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle) * 155.0f;
            // Tip of needle
            var nx1a = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle - 0.5 / 180.0 * Math.PI) * 155.0f;
            var ny1a = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle - 0.5 / 180.0 * Math.PI) * 155.0f;

            // Tip of needle
            var nx1b = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle + 0.5 / 180.0 * Math.PI) * 155.0f;
            var ny1b = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle + 0.5 / 180.0 * Math.PI) * 155.0f;

            // Back (white)
            var nx2a = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle + 25.0 / 180 * Math.PI) * -25.0f;
            var ny2a = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle + 25.0 / 180 * Math.PI) * -25.0f;

            // Back (gray)
            var nx2b = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle - 25.0 / 180 * Math.PI) * -25.0f;
            var ny2b = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle - 25.0 / 180 * Math.PI) * -25.0f;

            // Middle (white)
            var nx3 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle) * -17.0f;
            var ny3 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle) * -17.0f;

            var arr = new[] { new PointF(nx1, ny1), new PointF(nx1b, ny1b), new PointF(nx2b, ny2b), new PointF(nx3, ny3) };

            g.FillPolygon(BrushGray, arr);
            arr = new[] { new PointF(nx1, ny1), new PointF(nx1a, ny1a), new PointF(nx2a, ny2a), new PointF(nx3, ny3) };
            g.FillPolygon(BrushWhite, arr);

            /******** PEDALS ********/

            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 260, positionGauge.Y + 220, 140, 30);
            g.FillRectangle(Brush_PedalsThrottle, positionGauge.X + 260, positionGauge.Y + 220, Convert.ToInt32(throttle * 140), 30);
            g.DrawString("Throttle", new Font("Tahoma", 14.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 290, positionGauge.Y + 225);

            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 260, positionGauge.Y + 260, 140, 30);
            g.FillRectangle(Brush_PedalsBrake, positionGauge.X + 260, positionGauge.Y + 260, Convert.ToInt32(brake * 140), 30);
            g.DrawString("Brake", new Font("Tahoma", 14.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 302, positionGauge.Y + 265);
        }