//CLEAR all the created crossing private void buttonclear_Click(object sender, EventArgs e) { this.controller.Design.allcreatedcrossings.Clear(); this.workpanel.Invalidate(); //this.controller.C = new Crossing(new Point(0, 0), null, this.workpanel.Width / this.controller.lines); this.controller.C = null; selectedimage = null; selectedCrossinginpanel = null; }
//needs to fix and work better //REMOVE seletedCrossing; private void buttonremove_Click(object sender, EventArgs e) { if (selectedCrossinginpanel != null) { Crossing cross = controller.Design.allcreatedcrossings.Find(x => x.StartPoint == selectedCrossinginpanel.StartPoint); controller.Design.allcreatedcrossings.Remove(cross); this.workpanel.Invalidate(); selectedCrossinginpanel = null; } else { StatuslistBox.Items.Add("Select a crossing on the grid first..😅"); } }
//When user selects a crossing , stores all the information in selectedCrossing; private void workpanel_MouseClick(object sender, MouseEventArgs e) { if(this.controller != null) { Point p = workpanel.PointToClient(new Point(e.X, e.Y)); Point cellstartpoint = controller.findcell(new Point(e.X, e.Y)); if (controller.isTakenCell(cellstartpoint) == true) { foreach (var crossing in controller.Design.allcreatedcrossings) { if (crossing.StartPoint == controller.findcell(cellstartpoint)) { selectedCrossinginpanel = crossing; workpanel.Invalidate(); } } } } }
private void gridbutton_Click(object sender, EventArgs e) { OverviewlistBox.Items.Clear(); object obj = gridcomboBox.SelectedItem; string name = tbname.Text; DateTime time = dateTimePicker1.Value; if (obj != null && name != "") { string grid = gridcomboBox.SelectedItem.ToString(); WorkspaceDesign D = new WorkspaceDesign(grid, name, time); this.controller = Controller.getController(); this.controller.setSettings(this.workpanel.Width, this.workpanel.Height, D); if (D.Grid == "Small") { //4*4 this.controller.lines = 4; } else if (D.Grid == "Medium") { //3*3 this.controller.lines = 3; } else if (D.Grid == "Large") { //2*2 this.controller.lines = 2; } selectedimage = null; selectedCrossinginpanel = null; showgrid = true; this.workpanel.Invalidate(); StatuslistBox.Items.Clear(); PBtype1.Enabled = true; PBtype2.Enabled = true; cursorbutton.Enabled = true; buttonremove.Enabled = true; buttonclear.Enabled = true; setbutton.Enabled = true; IsSet = false; } else { string s = "😜"; StatuslistBox.Items.Add("First:Choose the Grid & Name & Time. " + s); } }
private void cursorbutton_Click(object sender, EventArgs e) { selectedCrossinginpanel = null; workpanel.Invalidate(); }
public void SetTheLights(Crossing C /*List<int> Group,*/) { int lightIndex = 0; //make sure it doesnt return null Crossing crossing = Design.allcreatedcrossings.Find(x => x == C); for (int i = 0; i < crossing.Lanes.Count; i++) { if (!(crossing.Lanes[i] is EmptyLane)) { lightIndex++; crossing.Lanes[i].Light.LightID = lightIndex; } } }
public void SetTheLaneGroupsT(Crossing C) { if (C.CType == 1) { C.Group = GroupType.GroupLightsForCrossingType1; } else { C.Group = GroupType.GroupLightsForCrossingType2; } }
/// <summary> /// draw one crossing in a chosen cell and crossing type picture /// user click and drag the crossing type to the workspace area /// </summary> /// <param name="gr"></param> /// <param name="clickedpoint"></param> /// <param name="C"></param> public void drawcrossing(Graphics gr, Point position, Crossing C) { try { int size = Convert.ToInt32(panelw / lines); Rectangle reg = new Rectangle(position.X - 1, position.Y - 1, Convert.ToInt32(panelw / lines), Convert.ToInt32(panelh / lines)); gr.DrawImage(C.image, reg); } catch (Exception ex) { MessageBox.Show(ex.Message); } }