예제 #1
0
        void _mTelemetryLoading_Tick(object sender, EventArgs e)
        {
            if (_logReader != null && _logReader.Progress != 1000)
            {
                this.lbLoading.Visible    = true;
                this.lbLoadingbar.Visible = true;

                this.lbLoadingbar.Value = Limits.Clamp((int)_logReader.Progress, 0, 1000);
                this.btOpen.Enabled     = false;
            }
            else
            {
                this.lbLoading.Visible    = false;
                this.lbLoadingbar.Visible = false;
                this.btOpen.Enabled       = true;
            }
        }
예제 #2
0
        public void Create(string file, string name, string version, RouteCollection route, int width, int height)
        {
            Pen pen_track = new Pen(brush_sector1, track_width);

            try
            {
                Image    track_img = new Bitmap(width, height);
                Graphics g         = Graphics.FromImage(track_img);
                g.FillRectangle(Brushes.Black, 0, 0, width, height);

                if (route == null || route.Racetrack == null)
                {
                    return;
                }

                g.SmoothingMode = SmoothingMode.AntiAlias;

                pos_x_max = -100000;
                pos_x_min = 100000;
                pos_y_max = -100000;
                pos_y_min = 1000000;

                foreach (TrackWaypoint wp in route.Racetrack)
                {
                    if (wp.Route == TrackRoute.MAIN)
                    {
                        pos_x_max = Math.Max(wp.X, pos_x_max);
                        pos_x_min = Math.Min(wp.X, pos_x_min);
                        pos_y_max = Math.Max(wp.Y, pos_y_max);
                        pos_y_min = Math.Min(wp.Y, pos_y_min);
                    }
                }


                double scale      = Math.Max(pos_x_max - pos_x_min, pos_y_max - pos_y_min);
                double map_width  = width - 12;
                double map_height = height - 12;

                double offset_x = map_width / 2 - (pos_x_max - pos_x_min) / scale * map_width / 2;
                double offset_y = 0 - (scale - pos_y_max + pos_y_min) / scale * map_height / 2;
                bool   swap_xy  = false;
                if (pos_x_max + pos_x_min < pos_y_max + pos_y_min)
                {
                    swap_xy = true;
                }
                List <PointF> track = new List <PointF>();

                int i = 0;
                foreach (TrackWaypoint wp in route.Racetrack)
                {
                    if (wp.Route == TrackRoute.MAIN)
                    {
                        float x1 = Convert.ToSingle(6 + ((wp.X - pos_x_min) / scale * map_width) + offset_x);
                        float y1 = Convert.ToSingle(6 + (1 - (wp.Y - pos_y_min) / scale) * map_height + offset_y);

                        x1 = Limits.Clamp(x1, -1000, 1000);
                        y1 = Limits.Clamp(y1, -1000, 1000);

                        if (swap_xy)
                        {
                            track.Add(new PointF(y1, x1));
                        }
                        else
                        {
                            track.Add(new PointF(x1, y1));
                        }
                    }
                }

                // Draw polygons!
                if (track.Count > 0)
                {
                    g.DrawPolygon(pen_track, track.ToArray());
                }

                g.DrawString(version, font_version, Brushes.DarkRed, 5.0f, 5.0f);
                //g.DrawString(name, tf18, Brushes.White, 3.0f, Convert.ToSingle(map_height - 19.0f));

                track_img.Save(file);
            }
            catch (Exception ex)
            {
            }
        }
예제 #3
0
        public void Create(string file, string name, string version, RouteCollection route, int width, int height)
        {
            Pen pen_track = new Pen(brush_sector1, track_width);

            try
            {
                Image    track_img = new Bitmap(width, height);
                Graphics g         = Graphics.FromImage(track_img);
                g.Clear(Color.Transparent);
                //g.FillRectangle(Brushes.Black, 0, 0, width, height);

                if (route == null || route.Racetrack == null)
                {
                    return;
                }

                g.SmoothingMode = SmoothingMode.AntiAlias;

                pos_x_max = -100000;
                pos_x_min = 100000;
                pos_y_max = -100000;
                pos_y_min = 1000000;

                foreach (TrackWaypoint wp in route.Racetrack)
                {
                    if (wp.Route == TrackRoute.MAIN)
                    {
                        pos_x_max = Math.Max(wp.X, pos_x_max);
                        pos_x_min = Math.Min(wp.X, pos_x_min);
                        pos_y_max = Math.Max(wp.Z, pos_y_max);
                        pos_y_min = Math.Min(wp.Z, pos_y_min);
                    }
                }


                scale = Math.Max(pos_x_max - pos_x_min, pos_y_max - pos_y_min);

                map_width  = width - 12;
                map_height = height - 12;

                offset_x = map_width / 2 - (pos_x_max - pos_x_min) / scale * map_width / 2;
                offset_y = 0 - (scale - pos_y_max + pos_y_min) / scale * map_height / 2;

                List <PointF> track = new List <PointF>();

                int i = 0;
                foreach (TrackWaypoint wp in route.Racetrack)
                {
                    if (wp.Route == TrackRoute.MAIN)
                    {
                        float x1 = Convert.ToSingle(6 + ((wp.X - pos_x_min) / scale * map_width) + offset_x);
                        float y1 = Convert.ToSingle(6 + (1 - (wp.Z - pos_y_min) / scale) * map_height + offset_y);

                        x1 = Limits.Clamp(x1, -1000, 1000);
                        y1 = Limits.Clamp(y1, -1000, 1000);

                        track.Add(new PointF(x1, y1));
                    }
                }

                // Draw polygons!
                if (track.Count > 0)
                {
                    g.DrawPolygon(pen_track, track.ToArray());
                }


                track_img.Save(file);
            }
            catch (Exception ex)
            {
            }
        }