Esempio n. 1
0
        private void Elements_draw(List <string> Elements_selected, List <string> Elements_available, Form Form, FontFamily Dosis_font_family)
        {
            this.Controls.Clear();

            int i = 0;

            foreach (string element in Elements_selected)
            {
                Color Hover_Color = Color.FromArgb(109, 109, 109);
                Color Prime_Color;
                if (i == Selected_index && Selected_left_bool)
                {
                    Prime_Color = Color.FromArgb(196, 196, 198);
                }
                else
                {
                    Prime_Color = Color.FromArgb(142, 140, 144);
                }

                PictureBox PB = new PictureBox();
                PB.BackColor = Prime_Color;
                PB.Location  = new Point(10, 15 * i + 30);
                PB.Size      = new Size(101, 15);
                PB.Cursor    = Cursors.Hand;
                this.Controls.Add(PB);
                Label PB_label = new Label();
                PB_label.Parent      = PB;
                PB_label.Text        = element;
                PB_label.TextAlign   = ContentAlignment.TopCenter;
                PB_label.ForeColor   = Color.White;
                PB_label.Font        = new Font(Dosis_font_family, 8, FontStyle.Bold);
                PB_label.MouseEnter += (object o, EventArgs EA) => { PB.BackColor = Hover_Color; };
                PB_label.MouseLeave += (object o, EventArgs EA) => { PB.BackColor = Prime_Color; };
                PB_label.Click      += (object o, EventArgs EA) => { Selected_index = Elements_selected.IndexOf(element); Selected_left_bool = true; Elements_draw(Elements_selected, Elements_available, Form, Dosis_font_family); };
                i++;
            }

            int j = 0;

            foreach (string element in Elements_available)
            {
                Color Hover_Color = Color.FromArgb(109, 109, 109);
                Color Prime_Color;
                if (j == Selected_index && !Selected_left_bool)
                {
                    Prime_Color = Color.FromArgb(196, 196, 198);
                }
                else
                {
                    Prime_Color = Color.FromArgb(142, 140, 144);
                }

                PictureBox PB = new PictureBox();
                PB.BackColor = Prime_Color;
                PB.Location  = new Point(114, 15 * j + 30);
                PB.Size      = new Size(100, 15);
                PB.Cursor    = Cursors.Hand;
                this.Controls.Add(PB);
                Label PB_label = new Label();
                PB_label.Parent      = PB;
                PB_label.Text        = element;
                PB_label.TextAlign   = ContentAlignment.TopCenter;
                PB_label.ForeColor   = Color.White;
                PB_label.Font        = new Font(Dosis_font_family, 8, FontStyle.Bold);
                PB_label.MouseEnter += (object o, EventArgs EA) => { PB.BackColor = Hover_Color; };
                PB_label.MouseLeave += (object o, EventArgs EA) => { PB.BackColor = Prime_Color; };
                PB_label.Click      += (object o, EventArgs EA) => { Selected_index = Elements_available.IndexOf(element); Selected_left_bool = false; Elements_draw(Elements_selected, Elements_available, Form, Dosis_font_family); };
                j++;
            }


            CurvedButtons Add = new CurvedButtons(new Size(17, 17), new Point(104, 66), 10,
                                                  "../../User Interface Recources/Selection_Box_Add.png", Color.FromArgb(255, 255, 255));

            Add.Click += (object o, EventArgs EA) => { string name = Interaction.InputBox("Enter Name: ", "Driver", "no name", 100, 100); Elements_selected.Add(name); Elements_draw(Elements_selected, Elements_available, Form, Dosis_font_family); };
            this.Controls.Add(Add);
            Add.BringToFront();

            CurvedButtons To_left = new CurvedButtons(new Size(17, 17), new Point(104, 80), 10,
                                                      "../../User Interface Recources/Selection_Box_To_Left.png", Color.FromArgb(255, 255, 255));

            To_left.Click += (object o, EventArgs EA) => { Elements_switch(Elements_selected, Elements_available, Selected_index, Selected_left_bool, Form, Dosis_font_family, 0); };
            this.Controls.Add(To_left);
            To_left.BringToFront();

            CurvedButtons To_right = new CurvedButtons(new Size(17, 17), new Point(104, 94), 10,
                                                       "../../User Interface Recources/Selection_Box_To_Right.png", Color.FromArgb(255, 255, 255));

            To_right.Click += (object o, EventArgs EA) => { Elements_switch(Elements_selected, Elements_available, Selected_index, Selected_left_bool, Form, Dosis_font_family, 1); };
            this.Controls.Add(To_right);
            To_right.BringToFront();
        }
Esempio n. 2
0
        //Cleaner but General_form should be just form

        /*public bool Simulation_state_playing = false;
         * public Simulation_sub_menu(int Sub_menu_width, General_form General_form, FontFamily Dosis_font_family)
         * {
         *  this.BackColor = Color.FromArgb(255,255,255);
         *  this.Size = new Size(250,General_form.Height);
         *  this.Location = new Point(General_form.Width-Sub_menu_width, General_form.Height);
         *  this.AutoScroll = true;
         *  Initialize(General_form, Sub_menu_width, Dosis_font_family);
         *  General_form.SizeChanged += (object o, EventArgs EA) => {
         *      this.Size = new Size(Sub_menu_width, General_form.Height);
         *      this.Location = new Point(General_form.Width - Sub_menu_width, 0);
         *      this.Controls.Clear();
         *      Initialize(General_form, Sub_menu_width, Dosis_font_family);
         *  };
         * }*/

        private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family)
        {
            Dictionary <string, int> menu = User_Controls.Config.simSubMenu;

            CurvedButtons Logo = new CurvedButtons(Form, 1);

            Logo.Location = new Point(User_Controls.Config.standardSubMenu["logoX"], User_Controls.Config.standardSubMenu["logoY"]);
            this.Controls.Add(Logo);

            Move_panel Drag_pad = new Move_panel(Form);

            this.Controls.Add(Drag_pad);

            CurvedButtons Divider1 = new CurvedButtons();

            Divider1.Location = new Point(User_Controls.Config.standardSubMenu["deviderX"], User_Controls.Config.standardSubMenu["logoY"]);
            this.Controls.Add(Divider1);

            CurvedButtons Settings_header = new CurvedButtons(new Size(menu["settingsHeaderSizeX"], menu["settingsHeaderSizeY"]),                                                 //settingsHeaderSizeX //settingsHeaderSizeY
                                                              new Point(menu["settingsHeaderX"], menu["settingsHeaderY"]), "../../User Interface Recources/Settings_Header.png"); //settingsHeaderX //settingsHeaderY

            this.Controls.Add(Settings_header);

            //ButtonSize //ButtonY
            int _buttonSize = menu["ButtonSize"];

            CurvedButtons Weather = new CurvedButtons(new Size(_buttonSize, _buttonSize),
                                                      new Point(menu["buttonStart"], menu["ButtonY"]), 30,    //weatherX
                                                      "../../User Interface Recources/Weather_Setting_Button.png", this.BackColor);

            this.Controls.Add(Weather);
            Weather.Click += (object obj, EventArgs args) => { General_Form.Main.SimulationScreen.SwitchSubMenus("Weather");; };

            CurvedButtons Vehicle = new CurvedButtons(new Size(_buttonSize, _buttonSize),
                                                      new Point(menu["buttonStart"] + menu["ButtonX"], menu["ButtonY"]), 30,   //vehicleX
                                                      "../../User Interface Recources/Vehicle_Setting_Button.png", this.BackColor);

            this.Controls.Add(Vehicle);
            Vehicle.Click += (object obj, EventArgs args) => { General_Form.Main.SimulationScreen.SwitchSubMenus("Vehicle");; };

            CurvedButtons Driver = new CurvedButtons(new Size(_buttonSize, _buttonSize),
                                                     new Point(menu["buttonStart"] + menu["ButtonX"] * 2, menu["ButtonY"]), 30,   //driverX
                                                     "../../User Interface Recources/Driver_Setting_Button.png", this.BackColor);

            this.Controls.Add(Driver);
            Driver.Click += (object obj, EventArgs args) => { General_Form.Main.SimulationScreen.SwitchSubMenus("Driver");; };

            CurvedButtons Divider2 = new CurvedButtons();

            Divider2.Location = new Point(0, menu["devider2"]);                              //devider2
            this.Controls.Add(Divider2);

            CurvedButtons Divider3 = new CurvedButtons();

            Divider3.Location = new Point(0, this.Height - menu["devider3"]);                //devider3
            this.Controls.Add(Divider3);

            CurvedButtons Start = new CurvedButtons(new Size(_buttonSize, _buttonSize),           //controlsX, controlsY
                                                    new Point(menu["buttonStart"], Form.Height - menu["controlsY"]), 35,
                                                    "../../User Interface Recources/Play_Simulation_Button.png", this.BackColor);

            this.Controls.Add(Start);
            Start.BringToFront();

            CurvedButtons Pause = new CurvedButtons(new Size(60, 60),
                                                    new Point(20, Form.Height - 80), 35,
                                                    "../../User Interface Recources/Pause_Button.png", this.BackColor);

            Pause.Hide();
            this.Controls.Add(Pause);
            Pause.BringToFront();
            Pause.Click += (object o, EventArgs EA) => { Pause.Hide(); Start.Show(); General_Form.Main.UserInterface.SimDataM.Stop_timer(); };
            Start.Click += (object o, EventArgs EA) => { Start.Hide(); Pause.Show(); General_Form.Main.UserInterface.SimDataM.Start_timer(); };

            CurvedButtons Reset = new CurvedButtons(new Size(_buttonSize, _buttonSize),
                                                    new Point(menu["buttonStart"] + menu["ButtonX"], Form.Height - menu["controlsY"]), 35,
                                                    "../../User Interface Recources/Reset_Simulation_Button.png", this.BackColor);

            this.Controls.Add(Reset);

            CurvedButtons Stop = new CurvedButtons(new Size(_buttonSize, _buttonSize),
                                                   new Point(menu["buttonStart"] + menu["ButtonX"] * 2, Form.Height - menu["controlsY"]), 35,
                                                   "../../User Interface Recources/Stop_Simulation_Button.png", this.BackColor);

            this.Controls.Add(Stop);
            Stop.Click += (object obj, EventArgs args) => {
                General_Form.Main.SwitchControllers(General_Form.Main.BuildScreen);
                General_Form.Main.UserInterface.SimDataM.Reset_timer();
                Pause.Hide();
                Start.Show();
            };

            CurvedButtons SimulationSpeed_header = new CurvedButtons(new Size(menu["speedHeaderSizeX"], menu["speedHeaderSizeY"]),                                                                       //speedHeaderSizeX //speedHeaderSizeY
                                                                     new Point(menu["speedHeaderX"], this.Height - menu["speedHeaderY"]), "../../User Interface Recources/Simulation_Speed_Header.png"); //speedHeaderX //speedHeaderY

            this.Controls.Add(SimulationSpeed_header);

            Slider SimulationSpeed = new Slider(new Point(menu["speedX"], this.Height - menu["speedY"]), 0, 100); //speedX //speedY

            this.Controls.Add(SimulationSpeed);

            Reset.BringToFront();
            Reset.Click += (object o, EventArgs EA) =>
            {
                if (Pause.Visible)
                {
                    General_Form.Main.UserInterface.SimDataM.Reset_timer();
                    Pause.Hide();
                    Start.Show();
                    SimulationSpeed.Value = 1;
                }
                else if (Start.Visible && General_Form.Main.UserInterface.SimDataM.Stopwatch.Elapsed.ToString() != "00:00:00")
                {
                    General_Form.Main.UserInterface.SimDataM.Reset_timer();
                    SimulationSpeed.Value = 1;
                }
            };
        }