Example #1
0
        public void Draw()
        {
            this.BackColor = Color.Black;
            Controls.Clear();

            // draw sim gallery
            panel            = new BufferedFlowLayoutPanel();
            panel.AutoScroll = false;
            Padding          = new Padding(35);

            lbl_selectsim = new Label {
                Text = "Select simulator"
            };
            lbl_selectsim.Font      = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
            lbl_selectsim.ForeColor = Color.White;
            lbl_selectsim.TextAlign = ContentAlignment.MiddleCenter;
            panel.Controls.Add(lbl_selectsim);

            foreach (ISimulator sim in Telemetry.m.Sims.Sims)
            {
                bool validSim = (sim.Garage == null || sim.Garage.Available == false ||
                                 !Directory.Exists(sim.Session.GameDirectory));
                if (File.Exists("Simulators/" + sim.ProcessName + ".png"))
                {
                    ucResizableImage pb = new ucResizableImage("Simulators/" + sim.ProcessName + ".png");
                    pb.Margin = new Padding(10);
                    pb.Name   = sim.Name;
                    if (validSim)
                    {
                        pb.Disabled = true;
                    }
                    else
                    {
                        pb.Cursor = Cursors.Hand;
                        pb.Click += new EventHandler(pb_Click);
                    }
                    pb.Crop(213, 120);
                    panel.Controls.Add(pb);
                }
                else
                {
                    Label l = new Label {
                        Text = sim.Name
                    };
                    l.Size      = new Size(213, 120);
                    l.Font      = new Font("Tahoma", 24.0f, FontStyle.Bold);
                    l.TextAlign = ContentAlignment.MiddleCenter;
                    l.Name      = sim.Name;
                    if (validSim)
                    {
                        l.ForeColor = Color.Gray;
                    }
                    else
                    {
                        l.ForeColor = Color.White;
                        l.Click    += new EventHandler(pb_Click);
                        l.Cursor    = Cursors.Hand;
                    }
                    panel.Controls.Add(l);
                }
            }
            Controls.Add(panel);
        }
Example #2
0
        public void Draw()
        {
            if (fGarage.Sim == null)
            {
                // TODO: Display errors.
                // TODO: Check if sim is installed.
                if (Close != null)
                {
                    Close();
                }
                return;
            }
            ControlsAdded = false;
            if (ControlsAdded == false)
            {
                Controls.Clear();;
                Controls.Add(txt_loading);
                ControlsAdded = true;
                mods_list     = new List <Control>();
                panel.Controls.Clear();
                panel.Controls.Add(t);

                this.BackColor = Color.Black;
                Loading        = true;

                Task load = new Task(() =>
                {
                    if (fGarage.Sim != null && fGarage.Sim.Garage != null && fGarage.Sim.Garage.Mods != null)
                    {
                        foreach (IMod mod in fGarage.Sim.Garage.Mods)
                        {
                            // If required, scan:
                            mod.Scan();

                            if (mod.Image != "" &&
                                File.Exists(mod.Image))
                            {
                                ucResizableImage pb =
                                    new ucResizableImage(mod.Image);
                                pb.Caption = mod.Name;
                                pb.Margin  = new Padding(10);
                                pb.Name    = mod.Name;
                                if (mod.Models.Count == 0)
                                {
                                    pb.Disabled = true;
                                }
                                else
                                {
                                    pb.Cursor = Cursors.Hand;
                                    pb.Click +=
                                        new EventHandler(pb_Click);
                                }
                                pb.Crop(220, 220);
                                mods_list.Add(pb);
                            }
                            else
                            {
                                Label l = new Label();
                                l.Text  = mod.Name;
                                l.Name  = mod.Name;
                                l.Font  = new Font("Tahoma", 24.0f,
                                                   FontStyle.Bold);
                                l.Size = new Size(213, 120);
                                if (mod.Models.Count == 0)
                                {
                                    l.ForeColor = Color.Gray;
                                }
                                else
                                {
                                    l.ForeColor = Color.White;
                                    l.Cursor    = Cursors.Hand;
                                    l.Click    += pb_Click;
                                }
                                mods_list.Add(l);
                            }
                        }
                    }
                });
                load.ContinueWith((result) =>
                {
                    DrawPanel();
                });

                Task loadtracks = new Task(() =>
                {
                    TrackThumbnail thumbnail_generator = new TrackThumbnail();
                    fGarage.Sim.Garage.Scan();
                    if (fGarage.Sim.Garage.Tracks != null)
                    {
                        foreach (ITrack track in fGarage.Sim.Garage.Tracks)
                        {
                            track.Scan();
                            if (File.Exists(track.Thumbnail) == false)
                            {
                                track.ScanRoute();
                                thumbnail_generator.Create(track.Thumbnail, track.Name,
                                                           track.Version, track.Route,
                                                           220,
                                                           220);
                            }

                            if (File.Exists(track.Thumbnail))
                            {
                                ucResizableImage pb =
                                    new ucResizableImage(track.Thumbnail);
                                pb.Caption = track.Name;
                                pb.Margin  = new Padding(10);
                                pb.Name    = track.Name;
                                pb.Cursor  = Cursors.Hand;
                                //pb.Click +=pb_Click;
                                pb.Crop(220, 220);
                                mods_list.Add(pb);
                            }
                        }
                    }
                });
                loadtracks.ContinueWith((r) => {
                    load.Start();
                });
                loadtracks.Start();
                //load.Start();
            }
        }
Example #3
0
        public void Draw()
        {
            this.BackColor = Color.Black;
            Controls.Clear();

            // draw sim gallery
            panel = new BufferedFlowLayoutPanel();
            panel.AutoScroll = false;
            Padding = new Padding(35);

            lbl_selectsim = new Label { Text = "Select simulator" };
            lbl_selectsim.Font = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
            lbl_selectsim.ForeColor = Color.White;
            lbl_selectsim.TextAlign = ContentAlignment.MiddleCenter;
            panel.Controls.Add(lbl_selectsim);

            foreach (ISimulator sim in Telemetry.m.Sims.Sims)
            {
                bool validSim = (sim.Garage == null || sim.Garage.Available == false ||
                                 !Directory.Exists(sim.Session.GameDirectory));
                if (File.Exists("Simulators/" + sim.ProcessName + ".png"))
                {
                    ucResizableImage pb = new ucResizableImage("Simulators/" + sim.ProcessName + ".png");
                    pb.Margin = new Padding(10);
                    pb.Name = sim.Name;
                    if (validSim)
                    {
                        pb.Disabled = true;
                    }
                    else
                    {
                        pb.Cursor = Cursors.Hand;
                        pb.Click += new EventHandler(pb_Click);
                    }
                    pb.Crop(213, 120);
                    panel.Controls.Add(pb);
                }
                else
                {
                    Label l = new Label {Text = sim.Name};
                    l.Size = new Size(213, 120);
                    l.Font = new Font("Tahoma", 24.0f, FontStyle.Bold);
                    l.TextAlign = ContentAlignment.MiddleCenter;
                    l.Name = sim.Name;
                    if (validSim)
                    {
                        l.ForeColor = Color.Gray;
                    }
                    else
                    {
                        l.ForeColor = Color.White;
                        l.Click += new EventHandler(pb_Click);
                        l.Cursor = Cursors.Hand;
                    }
                    panel.Controls.Add(l);
                }
            }
            Controls.Add(panel);
        }
Example #4
0
        public void Draw()
        {
            if (fGarage.Sim == null)
            {
                // TODO: Display errors.
                // TODO: Check if sim is installed.
                if (Close != null)
                    Close();
                return;
            }
            ControlsAdded = false;
            if (ControlsAdded == false)
            {
                Controls.Clear();;
                Controls.Add(txt_loading);
                ControlsAdded = true;
                mods_list = new List<Control>();
                panel.Controls.Clear();
                panel.Controls.Add(t);

                this.BackColor = Color.Black;
                Loading = true;

                Task load = new Task(() =>
                                         {
                                             if (fGarage.Sim != null && fGarage.Sim.Garage != null && fGarage.Sim.Garage.Mods != null)
                                             {
                                                 foreach (IMod mod in fGarage.Sim.Garage.Mods)
                                                 {
                                                     // If required, scan:
                                                     mod.Scan();

                                                     if (mod.Image != "" &&
                                                         File.Exists(mod.Image))
                                                     {

                                                         ucResizableImage pb =
                                                             new ucResizableImage(mod.Image);
                                                         pb.Caption = mod.Name;
                                                         pb.Margin = new Padding(10);
                                                         pb.Name = mod.Name;
                                                         if (mod.Models.Count == 0)
                                                         {
                                                             pb.Disabled = true;
                                                         }
                                                         else
                                                         {
                                                             pb.Cursor = Cursors.Hand;
                                                             pb.Click +=
                                                                 new EventHandler(pb_Click);
                                                         }
                                                         pb.Crop(220, 220);
                                                         mods_list.Add(pb);
                                                     }
                                                     else
                                                     {
                                                         Label l = new Label();
                                                         l.Text = mod.Name;
                                                         l.Name = mod.Name;
                                                         l.Font = new Font("Tahoma", 24.0f,
                                                                           FontStyle.Bold);
                                                         l.Size = new Size(213, 120);
                                                         if (mod.Models.Count == 0)
                                                         {
                                                             l.ForeColor = Color.Gray;
                                                         }
                                                         else
                                                         {
                                                             l.ForeColor = Color.White;
                                                             l.Cursor = Cursors.Hand;
                                                             l.Click += pb_Click;
                                                         }
                                                         mods_list.Add(l);

                                                     }
                                                 }
                                             }
                                         });
                load.ContinueWith((result) =>
                                      {
                                          DrawPanel();
                                      });

                Task loadtracks = new Task(() =>
                                               {
                                                   TrackThumbnail thumbnail_generator = new TrackThumbnail();
                                                   fGarage.Sim.Garage.Scan();
                                                   if (fGarage.Sim.Garage.Tracks != null){
                                                       foreach (ITrack track in fGarage.Sim.Garage.Tracks)
                                                       {
                                                           track.Scan();
                                                           if (File.Exists(track.Thumbnail) == false)
                                                           {
                                                               track.ScanRoute();
                                                               thumbnail_generator.Create(track.Thumbnail, track.Name,
                                                                                          track.Version, track.Route,
                                                                                          220,
                                                                                          220);
                                                           }

                                                           if (File.Exists(track.Thumbnail))
                                                           {
                                                               ucResizableImage pb =
                                                                   new ucResizableImage(track.Thumbnail);
                                                               pb.Caption = track.Name;
                                                               pb.Margin = new Padding(10);
                                                               pb.Name = track.Name;
                                                               pb.Cursor = Cursors.Hand;
                                                               //pb.Click +=pb_Click;
                                                               pb.Crop(220, 220);
                                                               mods_list.Add(pb);
                                                           }
                                                       }
                                                   }
                                               });
                loadtracks.ContinueWith((r) => {
                                                   load.Start();
                });
                loadtracks.Start();
                //load.Start();
            }
        }