private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.buildElementsMenu; int _ButtonSize = menu["buttonSize"]; int _ButtonXbase = menu["buttonXbase"]; int _ButtonXdiff = menu["buttonXdiff"]; int _ButtonYbase = menu["buttonYbase"]; int _ButtonYdiff = menu["buttonYdiff"]; int _ButtonCurve = menu["buttonCurve"]; //------------------------------------------------------------- CurvedButtons Hand = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff * 0, _ButtonYbase), _ButtonCurve, "../../User Interface Recources/Hand_Button.png", this.BackColor); Hand.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Hand); CurvedButtons Fence = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff * 1, _ButtonYbase), _ButtonCurve, "../../User Interface Recources/Fence_Button.png", this.BackColor); Fence.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Fence); CurvedButtons Building = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff * 2, _ButtonYbase), _ButtonCurve, "../../User Interface Recources/Building_Button.png", this.BackColor); Building.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Building); }
private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.buildElementsMenu; int _ButtonSize = menu["buttonSize"]; int _ButtonXbase = menu["buttonXbase"]; int _ButtonXdiff = menu["buttonXdiff"]; int _ButtonYbase = menu["buttonYbase"]; int _ButtonYdiff = menu["buttonYdiff"]; int _ButtonCurve = menu["buttonCurve"]; CurvedButtons Hand = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Hand_Button.png", this.BackColor); Hand.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.builder.roadType = "X"; }; this.Controls.Add(Hand); CurvedButtons Diagonal_Road = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Road_Button.png", this.BackColor); Diagonal_Road.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.builder.roadType = "Diagonal"; }; this.Controls.Add(Diagonal_Road); CurvedButtons Curved_Road = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff * 2, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Reset_Simulation_Button.png", this.BackColor); Curved_Road.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.builder.roadType = "Curved"; }; this.Controls.Add(Curved_Road); }
private void Initialize(Form Form, int Sub_menu_width) //Cleaner but General_form should be just form /*public Start_main_menu(int Sub_menu_width, General_form General_form, FontFamily Dosis_font_family) * { * this.BackColor = Color.FromArgb(196, 196, 198); * this.Size = new Size(General_form.Width - Sub_menu_width, General_form.Height); * Initialize(General_form, Sub_menu_width); * * General_form.SizeChanged += (object o, EventArgs EA) => * { * this.Size = new Size(General_form.Width - Sub_menu_width, General_form.Height); * this.Controls.Clear(); * Initialize(General_form, Sub_menu_width); * }; * } * private void Initialize(General_form General_form, int Sub_menu_width) */ { int _ButtonSize = User_Controls.Config.startMainMenu["buttonSize"]; int _ButtonXdiff = User_Controls.Config.startMainMenu["buttonXdiff"]; int _ButtonYdiff = User_Controls.Config.startMainMenu["buttonYdiff"]; int _ButtonCurve = User_Controls.Config.startMainMenu["buttonCurve"]; CurvedButtons New_project_button = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point((Form.Width - Sub_menu_width) / 2 - _ButtonXdiff * 2 - (int)(0.1 * Form.Width), (Form.Height / 3) * 2 - _ButtonYdiff), _ButtonCurve, "../../User Interface Recources/New_Project_Button.png", this.BackColor); CurvedButtons Choose_preset_button = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point((Form.Width - Sub_menu_width) / 2 - _ButtonXdiff, (Form.Height / 3) * 2 - _ButtonYdiff), _ButtonCurve, "../../User Interface Recources/Choose_Preset_Button.png", this.BackColor); CurvedButtons Browse_directory_button = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point((Form.Width - Sub_menu_width) / 2 + (int)(0.1 * Form.Width), (Form.Height / 3) * 2 - _ButtonYdiff), _ButtonCurve, "../../User Interface Recources/Browse_Directory_Button.png", this.BackColor); PictureBox Logo = new PictureBox(); Logo.Size = new Size(User_Controls.Config.startMainMenu["logoXsize"], User_Controls.Config.startMainMenu["logoYsize"]); Logo.SizeMode = PictureBoxSizeMode.Zoom; Logo.Location = new Point((Form.Width - Sub_menu_width) / 2 - User_Controls.Config.startMainMenu["logoXfromMiddle"], Form.Height / 2 - User_Controls.Config.startMainMenu["logoYfromMiddle"]); Logo.Image = Image.FromFile("../../User Interface Recources/Logo.png"); this.Controls.Add(New_project_button); this.Controls.Add(Choose_preset_button); this.Controls.Add(Browse_directory_button); this.Controls.Add(Logo); New_project_button.Click += (object o, EventArgs EA) => { General_Form.Main.MenuController.SwitchToBuild(); }; Choose_preset_button.Click += (object o, EventArgs EA) => { }; Browse_directory_button.Click += (object o, EventArgs EA) => { OpenFileDialog open = new OpenFileDialog(); open.Filter = "*.txt|*.*"; open.Title = "Open file"; if (open.ShowDialog() == DialogResult.OK) { General_Form.Main.UserInterface.Open(open.FileName); } }; }
//Cleaner but General_form should be just form /* public Start_sub_menu(int Sub_menu_width, General_form General_form, FontFamily Dosis_font_family, string[] Recent_projects) * { * 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, 0); * Initialize(General_form, Sub_menu_width, Dosis_font_family, Recent_projects); * 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, Recent_projects); * }; * }*/ private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family, string[] Recent_projects) { Dictionary <string, int> menu = User_Controls.Config.standardSubMenu; Dictionary <string, int> startmenu = User_Controls.Config.startSubMenu; CurvedButtons Logo = new CurvedButtons(Form, 1); Logo.Location = new Point(menu["logoX"], menu["logoY"]); this.Controls.Add(Logo); CurvedButtons Divider1 = new CurvedButtons(); Divider1.Location = new Point(menu["deviderX"], menu["deviderY"]); this.Controls.Add(Divider1); Move_panel Drag_pad = new Move_panel(Form); this.Controls.Add(Drag_pad); PictureBox Project_header = new PictureBox(); Project_header.Size = new Size(startmenu["headerXsize"], startmenu["headerYsize"]); Project_header.SizeMode = PictureBoxSizeMode.StretchImage; Project_header.Location = new Point(startmenu["headerX"], startmenu["headerY"]); Project_header.Image = Image.FromFile("../../User Interface Recources/Recent_Project_Header.png"); this.Controls.Add(Project_header); int i = 0; foreach (string tekst in Recent_projects) { CurvedButtons Project = new CurvedButtons(new Size(startmenu["projectXsize"], startmenu["projectYsize"]), new Point(Sub_menu_width / 2 - startmenu["projectX"], startmenu["projectYbase"] + i * startmenu["projectYdiff"]), startmenu["projectButtonCurve"], "../../User Interface Recources/Custom_Button.png", tekst, Dosis_font_family, Form, Color.White); Project.Location = new Point(Sub_menu_width / 2 - startmenu["projectX"], startmenu["projectYbase"] + i * startmenu["projectYdiff"]); this.Controls.Add(Project); i++; } CurvedButtons Divider2 = new CurvedButtons(); Divider2.Location = new Point(startmenu["divider2X"], this.Height - startmenu["divider2Y"]); this.Controls.Add(Divider2); CurvedButtons About_button = new CurvedButtons(new Size(startmenu["projectXsize"], startmenu["projectYsize"]), new Point(Sub_menu_width / 2 - startmenu["aboutX"], Form.Height - startmenu["aboutY"]), startmenu["aboutCurve"], "../../User Interface Recources/Custom_Button.png", "About", Dosis_font_family, Form, this.BackColor); this.Controls.Add(About_button); }
private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.buildElementsMenu; int _ButtonSize = menu["buttonSize"]; int _ButtonXbase = menu["buttonXbase"]; int _ButtonXdiff = menu["buttonXdiff"]; int _ButtonYbase = menu["buttonYbase"]; int _ButtonYdiff = menu["buttonYdiff"]; int _ButtonCurve = menu["buttonCurve"]; CurvedButtons Hand = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Hand_Button.png", this.BackColor); Hand.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Hand); CurvedButtons Light = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Traffic_Light_Button.png", this.BackColor); Light.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Light); }
private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.buildElementsMenu; int _ButtonSize = menu["buttonSize"]; int _ButtonXbase = menu["buttonXbase"]; int _ButtonXdiff = menu["buttonXdiff"]; int _ButtonYbase = menu["buttonYbase"]; int _ButtonYdiff = menu["buttonYdiff"]; int _ButtonCurve = menu["buttonCurve"]; //----------------------------------------- CurvedButtons Hand = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Hand_Button.png", this.BackColor); Hand.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Hand); CurvedButtons Speed_sign = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Speed_Sign_Button.png", this.BackColor); Speed_sign.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Speed_sign); CurvedButtons Yield_sign = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff * 2, _ButtonYbase), menu["buttonCurve"], "../../User Interface Recources/Yield_Sign_Button.png", this.BackColor); Yield_sign.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Yield_sign); CurvedButtons Priority_road_sign = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase, _ButtonYbase + _ButtonYdiff), menu["buttonCurve"], "../../User Interface Recources/Priority_Road_Sign_Button.png", this.BackColor); Priority_road_sign.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Priority_road_sign); CurvedButtons Stop_sign = new CurvedButtons(new Size(_ButtonSize, _ButtonSize), new Point(_ButtonXbase + _ButtonXdiff, _ButtonYbase + _ButtonYdiff), menu["buttonCurve"], "../../User Interface Recources/Stop_Sign_Button.png", this.BackColor); Stop_sign.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Stop_sign); }
//Cleaner maar General_form moet form zijn /* * public Build_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, 0); * 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); * }; * 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.buildSubMenu; CurvedButtons Logo = new CurvedButtons(Form, 1); Logo.Location = new Point(User_Controls.Config.standardSubMenu["logoX"], User_Controls.Config.standardSubMenu["logoY"]); this.Controls.Add(Logo); CurvedButtons Divider1 = new CurvedButtons(); Divider1.Location = new Point(User_Controls.Config.standardSubMenu["deviderX"], User_Controls.Config.standardSubMenu["deviderY"]); this.Controls.Add(Divider1); Move_panel Drag_pad = new Move_panel(Form); this.Controls.Add(Drag_pad); PictureBox Elements_header = new PictureBox(); Elements_header.Size = new Size(menu["elementHeaderSizeX"], menu["elementHeaderSizeY"]); //elementHeaderSizeX , //elementHeaderSizeY Elements_header.SizeMode = PictureBoxSizeMode.StretchImage; Elements_header.Location = new Point(menu["elementHeaderX"], menu["elementHeaderY"]); //elementHeaderX, //elementHeaderY Elements_header.Image = Image.FromFile("../../User Interface Recources/Elements_Header.png"); this.Controls.Add(Elements_header); //buttonSizeL //buttonSizeS //devider2 //devider4 //devider3 /simStartSizeX /simStartSizeY / simStartX / simStartY / buttonL / buttonS / buttonHome / buttonSave / buttonRoad / buttonLight / buttonSign / buttonBuilding CurvedButtons Home_button = new CurvedButtons(new Size(menu["buttonSizeL"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 - menu["buttonHome"], menu["buttonL"]), 25, "../../User Interface Recources/Custom_Button_Small.png", "Home", Dosis_font_family, Form, this.BackColor); Home_button.Click += (object o, EventArgs EA) => { General_Form.Main.UserInterface.Menu_to_start(); }; this.Controls.Add(Home_button); CurvedButtons Save_button = new CurvedButtons(new Size(menu["buttonSizeL"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 + menu["buttonSave"], menu["buttonL"]), 25, "../../User Interface Recources/Custom_Button_Small.png", "Save", Dosis_font_family, Form, this.BackColor); Save_button.Click += (object o, EventArgs EA) => { }; this.Controls.Add(Save_button); CurvedButtons Road_button = new CurvedButtons(new Size(menu["buttonSizeS"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 - menu["buttonRoad"], menu["buttonS"]), 25, "../../User Interface Recources/Road_Button.png", this.BackColor); Road_button.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.SwitchSubMenus("Roads"); }; this.Controls.Add(Road_button); CurvedButtons Light_button = new CurvedButtons(new Size(menu["buttonSizeS"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 - menu["buttonLight"], menu["buttonS"]), 25, "../../User Interface Recources/Traffic_Light_Button.png", this.BackColor); Light_button.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.SwitchSubMenus("Lights"); }; this.Controls.Add(Light_button); CurvedButtons Sign_button = new CurvedButtons(new Size(menu["buttonSizeS"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 + menu["buttonSign"], menu["buttonS"]), 25, "../../User Interface Recources/Speed_Sign_Button.png", this.BackColor); Sign_button.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.SwitchSubMenus("Signs"); }; this.Controls.Add(Sign_button); CurvedButtons Building_button = new CurvedButtons(new Size(menu["buttonSizeS"], menu["buttonSizeS"]), new Point(Sub_menu_width / 2 + menu["buttonBuilding"], menu["buttonS"]), 25, "../../User Interface Recources/Building_Button.png", this.BackColor); Building_button.Click += (object o, EventArgs EA) => { General_Form.Main.BuildScreen.SwitchSubMenus("Buildings"); }; this.Controls.Add(Building_button); CurvedButtons Divider2 = new CurvedButtons(); Divider2.Location = new Point(0, menu["devider2"]); //devider2 this.Controls.Add(Divider2); CurvedButtons Divider4 = new CurvedButtons(); Divider4.Location = new Point(0, Form.Height - menu["devider4"]); //devider4 this.Controls.Add(Divider4); CurvedButtons Start_sim_button = new CurvedButtons(new Size(menu["simStartSizeX"], menu["simStartSizeY"]), new Point(Sub_menu_width / 2 - menu["simStartX"], Form.Height - menu["simStartY"]), 25, "../../User Interface Recources/Custom_Button.png", "Start simulation", Dosis_font_family, Form, this.BackColor); Start_sim_button.Click += (object o, EventArgs EA) => { General_Form.Main.MenuController.SwitchToSimulation();; }; this.Controls.Add(Start_sim_button); CurvedButtons Undo_button = new CurvedButtons(new Size(30, 30), new Point(10, Form.Height - menu["simStartY"]), 25, "../../User Interface Recources/Reset_Simulation_Button.png", this.BackColor); this.Controls.Add(Undo_button); CurvedButtons Divider3 = new CurvedButtons(); Divider3.Location = new Point(0, menu["devider3"]); //devider3 this.Controls.Add(Divider3); }
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(); }
private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.simElementsMenu; int _sliderX = menu["sliderX"]; int _startY = menu["sliderStartVehicleY"]; int _diffY = menu["sliderDiffY"]; int _textX = menu["sliderTextX"]; int _textY = menu["startTextY"]; List <string> _temp = VehicleController.getStringVehicleStats(); Selection_box = new Selection_box(Form, Dosis_font_family, _temp); if (Form.WindowState == FormWindowState.Maximized) { Selection_box.Location = new Point(User_Controls.Config.standardSubMenu["selectionBoxMaxX"], User_Controls.Config.standardSubMenu["selectionBoxMaxY"]); } else { Selection_box.Location = new Point(User_Controls.Config.standardSubMenu["selectionBoxX"], User_Controls.Config.standardSubMenu["selectionBoxY"]); } this.Controls.Add(Selection_box); Dictionary <string, int> vehiclemenu = User_Controls.Config.simVehicle; Slider Cw = new Slider(new Point(_sliderX, _startY + 2 * _diffY), vehiclemenu["surfaceMin"], vehiclemenu["surfaceMax"]); this.Controls.Add(Cw); SliderText Cw_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY + 2 * _diffY), "Drag Co:"); this.Controls.Add(Cw_label); SliderText Cw_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY + 2 * _diffY), (Cw.Value / 10).ToString() + " "); this.Controls.Add(Cw_Value); Cw.ValueChanged += (object o, EventArgs EA) => { Cw_Value.Text = (((double)(Cw.Value)) / 10).ToString() + " "; }; Slider Surface = new Slider(new Point(_sliderX, _startY + _diffY), vehiclemenu["surfaceMin"], vehiclemenu["surfaceMax"]); this.Controls.Add(Surface); SliderText Surface_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY + 1 * _diffY), "Frontal Surface:"); this.Controls.Add(Surface_label); SliderText Surface_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY + 1 * _diffY), (Surface.Value / 10).ToString() + " m^2"); this.Controls.Add(Surface_Value); Surface.ValueChanged += (object o, EventArgs EA) => { Surface_Value.Text = (((double)(Surface.Value)) / 10).ToString() + " m^2"; }; Slider Max_speed = new Slider(new Point(_sliderX, _startY), vehiclemenu["topSpeedMin"], vehiclemenu["topSpeedMax"]); this.Controls.Add(Max_speed); SliderText Max_speed_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY), "Topspeed:"); this.Controls.Add(Max_speed_label); SliderText Max_speed_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY), Max_speed.Value.ToString() + " km/h"); this.Controls.Add(Max_speed_Value); Max_speed.ValueChanged += (object o, EventArgs EA) => { Max_speed_Value.Text = Max_speed.Value.ToString() + " km/h"; }; Slider Length = new Slider(new Point(_sliderX, _startY - _diffY), vehiclemenu["lengthMin"], vehiclemenu["lengthMax"]); this.Controls.Add(Length); SliderText Length_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY - 1 * _diffY), "Length:"); this.Controls.Add(Length_label); SliderText Length_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY - 1 * _diffY), (Length.Value / 10).ToString() + " m"); this.Controls.Add(Length_Value); Length.ValueChanged += (object o, EventArgs EA) => { Length_Value.Text = (((double)(Length.Value)) / 10).ToString() + " m"; }; Slider HorsePower = new Slider(new Point(_sliderX, _startY - 2 * _diffY), vehiclemenu["horsepwrMin"], vehiclemenu["horsepwrMax"]); this.Controls.Add(HorsePower); SliderText HorsePower_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY - 2 * _diffY), "Horsepower:"); this.Controls.Add(HorsePower_label); SliderText HorsePower_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY - 2 * _diffY), HorsePower.Value.ToString() + " hp"); this.Controls.Add(HorsePower_Value); HorsePower.ValueChanged += (object o, EventArgs EA) => { HorsePower_Value.Text = HorsePower.Value.ToString() + " hp"; }; Slider Weight = new Slider(new Point(_sliderX, _startY - 3 * _diffY), vehiclemenu["weightMin"], vehiclemenu["weightMax"]); this.Controls.Add(Weight); SliderText Weight_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY - 3 * _diffY), "Weight:"); this.Controls.Add(Weight_label); SliderText Weight_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY - 3 * _diffY), Weight.Value.ToString() + " kg"); this.Controls.Add(Weight_Value); Weight.ValueChanged += (object o, EventArgs EA) => { Weight_Value.Text = Weight.Value.ToString() + " kg"; }; Slider Occurunce = new Slider(new Point(_sliderX, _startY - 4 * _diffY), vehiclemenu["occurenceMin"], vehiclemenu["occurenceMax"]); this.Controls.Add(Occurunce); SliderText Occurunce_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textY - 4 * _diffY), "Occurunce:"); this.Controls.Add(Occurunce_label); SliderText Occurunce_Value = new SliderText(Dosis_font_family, new Point(_textX, _textY - 4 * _diffY), Occurunce.Value.ToString() + " %"); this.Controls.Add(Occurunce_Value); Occurunce.ValueChanged += (object o, EventArgs EA) => { Occurunce_Value.Text = Occurunce.Value.ToString() + " %"; }; CurvedButtons Vehicles_header = new CurvedButtons(new Size(menu["headerSizeX"], menu["headerSizeY"]), new Point(menu["headerX"], menu["headerY"]), "../../User Interface Recources/Edit_Vehicle_Header.png"); this.Controls.Add(Vehicles_header); /* Slider temp1 = new Slider(new Point(_sliderX, _start + _diff * 4), 0, 100); //sliderDiffY //sliderStart:100 / sliderX:25 //headerSizeX //headerSizeY //headerX //headerY * this.Controls.Add(temp1); * * Slider temp2 = new Slider(new Point(_sliderX, _start + _diff * 3), 0, 100); * this.Controls.Add(temp2); * * Slider temp3 = new Slider(new Point(_sliderX, _start + _diff * 2), 0, 100); * this.Controls.Add(temp3); * * Slider temp4 = new Slider(new Point(_sliderX, _start + _diff), 0, 100); * this.Controls.Add(temp4); * * Slider temp5 = new Slider(new Point(_sliderX, _start), 0, 100); * this.Controls.Add(temp5); * * CurvedButtons Vehicles_header = new CurvedButtons(new Size(menu["headerSizeX"], menu["headerSizeY"]), * new Point(menu["headerX"], menu["headerY"]), "../../User Interface Recources/Edit_Vehicle_Header.png"); * this.Controls.Add(Vehicles_header);*/ }
private void Initialize(Form Form, int Sub_menu_width, FontFamily Dosis_font_family) { Dictionary <string, int> menu = User_Controls.Config.simElementsMenu; int _sliderX = menu["sliderX"]; int _start = menu["sliderStartDriver"]; int _diff = menu["sliderDiffY"]; int _text = menu["textX"]; int _textstart = menu["textStartDriver"]; List <string> _temp = AIController.getStringDriverStats(); Dictionary <string, int> DriverMenu = User_Controls.Config.simDriver; Selection_box = new Selection_box(Form, Dosis_font_family, _temp); if (Form.WindowState == FormWindowState.Maximized) { Selection_box.Location = new Point(User_Controls.Config.standardSubMenu["selectionBoxMaxX"], User_Controls.Config.standardSubMenu["selectionBoxMaxY"]); } else { Selection_box.Location = new Point(User_Controls.Config.standardSubMenu["selectionBoxX"], User_Controls.Config.standardSubMenu["selectionBoxY"]); } this.Controls.Add(Selection_box); Slider Reaction_time = new Slider(new Point(_sliderX, _start + _diff * 4), DriverMenu["reactionTimeMin"], DriverMenu["reactionTimeMax"]); this.Controls.Add(Reaction_time); SliderText Reaction_time_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textstart + _diff * 4), "Reaction time:"); this.Controls.Add(Reaction_time_label); SliderText Reaction_time_Value = new SliderText(Dosis_font_family, new Point(_text, _textstart + _diff * 4), (Reaction_time.Value / 10).ToString() + " s"); this.Controls.Add(Reaction_time_Value); Reaction_time.ValueChanged += (object o, EventArgs EA) => { Reaction_time_Value.Text = (((Reaction_time.Value)) / 10).ToString() + " s"; }; Slider Follow_interval = new Slider(new Point(_sliderX, _start + _diff * 3), DriverMenu["followIntervalMin"], DriverMenu["followIntervalMax"]); this.Controls.Add(Follow_interval); SliderText Follow_interval_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textstart + _diff * 3), "Follow interval:"); this.Controls.Add(Follow_interval_label); SliderText Follow_interval_Value = new SliderText(Dosis_font_family, new Point(_text, _textstart + _diff * 3), (Follow_interval.Value / 10).ToString() + " s"); this.Controls.Add(Follow_interval_Value); Follow_interval.ValueChanged += (object o, EventArgs EA) => { Follow_interval_Value.Text = (((double)(Follow_interval.Value)) / 10).ToString() + " s"; }; Slider Speeding = new Slider(new Point(_sliderX, _start + _diff * 2), DriverMenu["speedingMin"], DriverMenu["speedingMax"]); this.Controls.Add(Speeding); SliderText Speeding_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textstart + _diff * 2), "Speeding:"); this.Controls.Add(Speeding_label); SliderText Speeding_Value = new SliderText(Dosis_font_family, new Point(_text, _textstart + _diff * 2), Speeding.Value.ToString() + " km/h"); this.Controls.Add(Speeding_Value); Speeding.ValueChanged += (object o, EventArgs EA) => { Speeding_Value.Text = Speeding.Value.ToString() + " km/h"; }; Slider Rulebreaking = new Slider(new Point(_sliderX, _start + _diff), DriverMenu["ruleBreakingMin"], DriverMenu["ruleBreakingMax"]); this.Controls.Add(Rulebreaking); SliderText Rulebreaking_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textstart + _diff), "Rulebreaking:"); this.Controls.Add(Rulebreaking_label); SliderText Rulebreaking_Value = new SliderText(Dosis_font_family, new Point(_text, _textstart + _diff), Rulebreaking.Value.ToString() + " %"); this.Controls.Add(Rulebreaking_Value); Rulebreaking.ValueChanged += (object o, EventArgs EA) => { Rulebreaking_Value.Text = Rulebreaking.Value.ToString() + " %"; }; Slider Occurunce = new Slider(new Point(_sliderX, _start), DriverMenu["occurenceMin"], DriverMenu["occurenceMax"]); this.Controls.Add(Occurunce); SliderText Occurunce_label = new SliderText(Dosis_font_family, new Point(_sliderX, _textstart), "Occurunce:"); this.Controls.Add(Occurunce_label); SliderText Occurunce_Value = new SliderText(Dosis_font_family, new Point(_text, _textstart), Occurunce.Value.ToString() + " %"); this.Controls.Add(Occurunce_Value); Occurunce.ValueChanged += (object o, EventArgs EA) => { Occurunce_Value.Text = Occurunce.Value.ToString() + " %"; }; //---------------------------------------------- CurvedButtons Edit_Driver_Header = new CurvedButtons(new Size(menu["headerSizeX"], menu["headerSizeY"]), new Point(menu["headerX"], menu["headerY"]), "../../User Interface Recources/Edit_Driver_Header.png"); this.Controls.Add(Edit_Driver_Header); }
//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; } }; }
//Cleaner but General_form should be just form /*public Simulation_sub_weather_menu(int Sub_menu_width, General_form General_form, FontFamily Dosis_font_family) * { * this.BackColor = Color.FromArgb(255, 255, 255); * this.Size = new Size(Sub_menu_width, General_form.Height - 230 - 135); * this.Location = new Point(General_form.Width - Sub_menu_width, 230); * 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 - 230 - 135); * this.Location = new Point(General_form.Width - Sub_menu_width, 230); * 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.simElementsMenu; int _sliderX = menu["sliderX"]; int _start = menu["sliderStart"]; int _diff = menu["sliderDiffY"]; int _textX = menu["textX"]; int _startText = menu["textStart"]; Slider Slippery = new Slider(new Point(_sliderX, _start + _diff * 3), 0, 100); this.Controls.Add(Slippery); SliderText Slippery_label = new SliderText(Dosis_font_family, new Point(_sliderX, _startText + _diff * 3), "Slipperiness:"); //startText //textX this.Controls.Add(Slippery_label); SliderText Slippery_Value = new SliderText(Dosis_font_family, new Point(_textX, _startText + _diff * 3), Slippery.Value.ToString() + " %"); this.Controls.Add(Slippery_Value); Slippery.ValueChanged += (object o, EventArgs EA) => { Slippery_Value.Text = Slippery.Value.ToString() + " %"; }; Slider Sight = new Slider(new Point(_sliderX, _start + _diff * 2), 0, 100); this.Controls.Add(Sight); SliderText Sight_label = new SliderText(Dosis_font_family, new Point(_sliderX, _startText + _diff * 2), "Sight:"); this.Controls.Add(Sight_label); SliderText Sight_Value = new SliderText(Dosis_font_family, new Point(_textX, _startText + _diff * 2), Sight.Value.ToString() + " m"); this.Controls.Add(Sight_Value); Sight.ValueChanged += (object o, EventArgs EA) => { Sight_Value.Text = Sight.Value.ToString() + " m"; }; Slider Snow = new Slider(new Point(_sliderX, _start + _diff), 0, 50); this.Controls.Add(Snow); SliderText Snow_label = new SliderText(Dosis_font_family, new Point(_sliderX, _startText + _diff), "Snow:"); this.Controls.Add(Snow_label); SliderText Snow_Value = new SliderText(Dosis_font_family, new Point(_textX, _startText + _diff), (Snow.Value / 10).ToString() + " mm"); this.Controls.Add(Snow_Value); Snow.ValueChanged += (object o, EventArgs EA) => { Snow_Value.Text = (((double)(Snow.Value)) / 10).ToString() + " mm"; }; Slider Rainfall = new Slider(new Point(_sliderX, _start), 0, 100); this.Controls.Add(Rainfall); SliderText Rainfall_label = new SliderText(Dosis_font_family, new Point(_sliderX, _startText), "Rainfall:"); this.Controls.Add(Rainfall_label); SliderText Rainfall_Value = new SliderText(Dosis_font_family, new Point(_textX, _startText), (Rainfall.Value / 10).ToString() + " mm/h"); this.Controls.Add(Rainfall_Value); Rainfall.ValueChanged += (object o, EventArgs EA) => { Rainfall_Value.Text = (((double)(Rainfall.Value)) / 10).ToString() + " mm/h"; }; CurvedButtons Weather_header = new CurvedButtons(new Size(menu["headerSizeX"], menu["headerSizeY"]), new Point(menu["headerX"], menu["headerY"]), "../../User Interface Recources/Weather_Header.png"); this.Controls.Add(Weather_header); }