Inheritance: System.Windows.Forms.UserControl
コード例 #1
0
ファイル: LiveTelemetry.cs プロジェクト: llenroc/SimTelemetry
        /// <summary>
        /// Completely redraws the user interface. It will bring this window into 3 modes:
        /// A) Waiting for simulator.
        /// B) Waiting for session.
        /// C) Telemetry window.
        ///
        /// The simulator panel displays all installed modules of simulators (if an image is found).
        /// The session panel displays the full-size simulator image (if exists) with "waiting for session".
        /// The telemetry window adds the controls track map, lap chart, session status. It initializes panel sizes
        /// via Telemetry_ResizePanels and sets the user panel via SetStatusControls.
        /// </summary>
        private void SetupUI()
        {
            if (Telemetry.m.Active_Session)
            {
                this.Controls.Clear();
                this.Padding = new Padding(0);

                Controls.Add(ucTrackmap);
                Controls.Add(ucLapChart);
                Controls.Add(ucSessionData);
                //Controls.Add(FuelData);
                Telemetry_ResizePanels(null, null);
                SetStatusControls(null, null);
            }
            else if (Telemetry.m.Active_Sim)
            {
                this.Controls.Clear();
                this.Padding = new Padding(0);
                // draw sim pic.

                Label t = new Label {
                    Text = "Waiting for session"
                };
                t.Font      = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
                t.ForeColor = Color.White;
                t.Size      = new Size(this.Size.Width - 80, 60);
                t.TextAlign = ContentAlignment.MiddleCenter;

                FlowLayoutPanel panel = new FlowLayoutPanel();

                if (File.Exists("Simulators/" + Telemetry.m.Sim.ProcessName + ".png") && this.Width > 80 && this.Height > 100)
                {
                    ucResizableImage pb = new ucResizableImage("Simulators/" + Telemetry.m.Sim.ProcessName + ".png");
                    pb.Crop(Size.Width - 80, Size.Height - 70);
                    panel.Controls.Add(pb);
                    panel.Location = new Point(40, (Height - pb.Size.Height - 60) / 2);
                    panel.Size     = new Size(Width - 80, 60 + pb.Size.Height);
                }
                else
                {
                    panel.Size     = new Size(Width, 60);
                    panel.Location = new Point(40, (Height - 60) / 2);
                }
                panel.Controls.Add(t);

                Controls.Add(panel);
            }
            else
            {
                Controls.Clear();

                // draw sim gallery
                FlowLayoutPanel panel = new FlowLayoutPanel();
                this.Padding = new Padding(35);

                int columns = (int)Math.Ceiling(Math.Sqrt(Telemetry.m.Sims.Sims.Count));
                if (columns == 0)
                {
                    columns = 1;
                }
                if (Telemetry.m.Sims.Sims.Count % columns == 1)
                {
                    columns++;
                }
                if (this.Width > 233)
                {
                    while (233 * columns > this.Width)
                    {
                        columns--;
                    }
                }
                int rows = (int)Math.Ceiling(Telemetry.m.Sims.Sims.Count * 1.0 / columns) + 1;

                panel.Size     = new Size(233 * columns, rows * 140);
                panel.Location = new Point((this.Width - panel.Size.Width) / 2, (this.Height - panel.Size.Height) / 2);

                foreach (ISimulator sim in Telemetry.m.Sims.Sims)
                {
                    if (File.Exists("Simulators/" + sim.ProcessName + ".png"))
                    {
                        ucResizableImage pb = new ucResizableImage("Simulators/" + sim.ProcessName + ".png");
                        pb.Margin = new Padding(10);
                        pb.Crop(213, 120);
                        panel.Controls.Add(pb);
                    }
                }

                Label t = new Label {
                    Text = "Waiting for simulator"
                };
                t.Font      = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
                t.ForeColor = Color.White;
                t.Size      = new Size(panel.Size.Width, 50);
                t.TextAlign = ContentAlignment.MiddleCenter;
                panel.Controls.Add(t);

                Controls.Add(panel);
            }

            if (btGarage != null)
            {
                Controls.Add(btGarage);
                Controls.Add(btSettings);
                Controls.Add(btNetwork);

#if DEBUG
                Button dataDebug = new Button
                {
                    Text = "Data debug", Size = new Size(75, 25), Location = new Point(280, 10), BackColor = Color.Red
                };
                dataDebug.Click += (s, e) =>
                {
                    Data d = new Data();
                    d.Show();
                };
                Controls.Add(dataDebug);
#endif
            }
        }
コード例 #2
0
ファイル: LiveTelemetry.cs プロジェクト: nlhans/SimTelemetry
        /// <summary>
        /// Completely redraws the user interface. It will bring this window into 3 modes:
        /// A) Waiting for simulator.
        /// B) Waiting for session.
        /// C) Telemetry window.
        /// 
        /// The simulator panel displays all installed modules of simulators (if an image is found).
        /// The session panel displays the full-size simulator image (if exists) with "waiting for session".
        /// The telemetry window adds the controls track map, lap chart, session status. It initializes panel sizes
        /// via Telemetry_ResizePanels and sets the user panel via SetStatusControls.
        /// </summary>
        private void SetupUI()
        {
            if (Telemetry.m.Active_Session)
            {
                this.Controls.Clear();
                this.Padding = new Padding(0);

                Controls.Add(ucTrackmap);
                Controls.Add(ucLapChart);
                Controls.Add(ucSessionData);
                //Controls.Add(FuelData);
                Telemetry_ResizePanels(null, null);
                SetStatusControls(null, null);

            }
            else if (Telemetry.m.Active_Sim)
            {
                this.Controls.Clear();
                this.Padding = new Padding(0);
                // draw sim pic.

                Label t = new Label { Text = "Waiting for session" };
                t.Font = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
                t.ForeColor = Color.White;
                t.Size = new Size(this.Size.Width - 80, 60);
                t.TextAlign = ContentAlignment.MiddleCenter;

                FlowLayoutPanel panel = new FlowLayoutPanel();

                if (File.Exists("Simulators/" + Telemetry.m.Sim.ProcessName + ".png") && this.Width > 80 && this.Height > 100)
                {
                    ucResizableImage pb = new ucResizableImage("Simulators/" + Telemetry.m.Sim.ProcessName + ".png");
                    pb.Crop(Size.Width - 80, Size.Height - 70);
                    panel.Controls.Add(pb);
                    panel.Location = new Point(40, (Height - pb.Size.Height - 60) / 2);
                    panel.Size = new Size(Width - 80, 60 + pb.Size.Height);

                }
                else
                {
                    panel.Size = new Size(Width, 60);
                    panel.Location = new Point(40, (Height - 60) / 2);
                }
                panel.Controls.Add(t);

                Controls.Add(panel);

            }
            else
            {
                Controls.Clear();

                // draw sim gallery
                FlowLayoutPanel panel = new FlowLayoutPanel();
                this.Padding = new Padding(35);

                int columns = (int)Math.Ceiling(Math.Sqrt(Telemetry.m.Sims.Sims.Count));
                if (columns == 0) columns = 1;
                if (Telemetry.m.Sims.Sims.Count % columns == 1)
                    columns++;
                if (this.Width > 233)
                {
                    while (233 * columns > this.Width)
                        columns--;
                }
                int rows = (int)Math.Ceiling(Telemetry.m.Sims.Sims.Count * 1.0 / columns) + 1;

                panel.Size = new Size(233 * columns, rows * 140);
                panel.Location = new Point((this.Width - panel.Size.Width) / 2, (this.Height - panel.Size.Height) / 2);

                foreach (ISimulator sim in Telemetry.m.Sims.Sims)
                {
                    if (File.Exists("Simulators/" + sim.ProcessName + ".png"))
                    {
                        ucResizableImage pb = new ucResizableImage("Simulators/" + sim.ProcessName + ".png");
                        pb.Margin = new Padding(10);
                        pb.Crop(213, 120);
                        panel.Controls.Add(pb);
                    }
                }

                Label t = new Label { Text = "Waiting for simulator" };
                t.Font = new Font("Arial", 32.0f, FontStyle.Italic | FontStyle.Bold);
                t.ForeColor = Color.White;
                t.Size = new Size(panel.Size.Width, 50);
                t.TextAlign = ContentAlignment.MiddleCenter;
                panel.Controls.Add(t);

                Controls.Add(panel);
            }

            if (btGarage != null)
            {
                Controls.Add(btGarage);
                Controls.Add(btSettings);
                Controls.Add(btNetwork);

            #if DEBUG
                Button dataDebug = new Button
                                       {Text = "Data debug", Size = new Size(75, 25), Location = new Point(280, 10), BackColor= Color.Red};
                dataDebug.Click += (s, e) =>
                                       {
                                           Data d = new Data();
                                           d.Show();
                                       };
                Controls.Add(dataDebug);
            #endif
            }
        }