private void sldr_Direction_ValueChanged(object sender, EventArgs e) { PipeEnd p = (PipeEnd)lstbx_Pipes.SelectedItem; p.Direction = (sldr_Direction.Value <= 180 ? 180 - sldr_Direction.Value : 360 + 180 - sldr_Direction.Value); DrawStructure(); }
private void btn_EditPipe_Click(object sender, EventArgs e) { PipeEnd p = (PipeEnd)lstbx_Pipes.SelectedItem; EnterPipeInfo enterPipeInfo = new EnterPipeInfo(structure, false, p); this.Hide(); enterPipeInfo.Show(); enterPipeInfo.Parent = this; }
public static void LoadFile(string fileName) { using (StreamReader reader = new StreamReader(fileName)) { Program.CurrentJob = new Job(Path.GetFileNameWithoutExtension(fileName)); string line; while ((line = reader.ReadLine()) != null) { if (line == "***") { break; } Structure sc = new Structure(); Program.CurrentJob.Structures.Add(sc); string[] arr = line.Split(','); sc.Shot = arr[0]; sc.Label = arr[1]; sc.Type = (StructureType)Enum.Parse(typeof(StructureType), arr[2]); sc.Northing = float.Parse(arr[3]); sc.Easting = float.Parse(arr[4]); sc.Elevation = float.Parse(arr[5]); int n = Convert.ToInt32(arr[6]); for (int i = 0; i < n; i++) { PipeEnd p = new PipeEnd(sc); sc.Pipes.Add(p); line = reader.ReadLine(); arr = line.Split(','); p.ID = ((char)(i + 'A')).ToString(); p.Invert = float.Parse(arr[0]); p.Flow = (Flow)Enum.Parse(typeof(Flow), arr[1]); p.Direction = float.Parse(arr[2]); p.Diameter = float.Parse(arr[3]); p.Type = (PipeType)Enum.Parse(typeof(PipeType), arr[4]); } } while ((line = reader.ReadLine()) != null) { string[] arr = line.Split(','); Connection c = new Connection(); c.upperStructure = Program.CurrentJob.Structures.Find(x => x.Shot == arr[0]); c.lowerStructure = Program.CurrentJob.Structures.Find(x => x.Shot == arr[1]); c.upperEnd = c.upperStructure.Pipes.Find(x => x.ID == arr[2]); c.lowerEnd = c.lowerStructure.Pipes.Find(x => x.ID == arr[3]); Program.Connections.Add(c); } } }
private void btn_ConnectNew_Click(object sender, EventArgs e) { PipeEnd p = (PipeEnd)lstbx_Pipes.SelectedItem; Structure s = new Structure(); Program.CurrentJob.Structures.Add(s); EnterStructInfo enterStructInfo = new EnterStructInfo(s); if (enterStructInfo.ShowDialog() == DialogResult.Cancel) { Program.CurrentJob.Structures.Remove(s); } }
public void Connect(PipeEnd pipe1, PipeEnd pipe2) { Connection c = new Connection(); if (pipe1.Flow == Flow.In) { c.lowerEnd = pipe1; c.lowerStructure = pipe1.ParentStructure; c.upperStructure = pipe2.ParentStructure; c.upperEnd = pipe2; } else if (pipe1.Flow == Flow.Out) { c.upperEnd = pipe1; c.upperStructure = pipe1.ParentStructure; c.lowerStructure = pipe2.ParentStructure; c.lowerEnd = pipe2; } this.Add(c); //still need to allow picking of other pipe }
private void lstbx_Pipes_SelectedIndexChanged(object sender, EventArgs e) { if (lstbx_Pipes.SelectedIndex != -1) { btn_EditPipe.Enabled = true; sldr_Direction.Enabled = true; btn_ConnectExisting.Enabled = true; btn_ConnectNew.Enabled = true; PipeEnd p = (PipeEnd)lstbx_Pipes.SelectedItem; sldr_Direction.Value = (p.Direction <= 180 ? 180 - (int)p.Direction : 360 + 180 - (int)p.Direction); btn_ConnectToSelected.Enabled = true; sketchArea.Refresh(); } else { btn_ConnectNew.Enabled = false; btn_ConnectExisting.Enabled = false; sldr_Direction.Enabled = false; btn_EditPipe.Enabled = false; btn_ConnectToSelected.Enabled = false; } }
public EnterPipeInfo(Structure s, bool add = true, PipeEnd pipe = null) { InitializeComponent(); currentStructure = s; if (add) { CurrentPipe = new PipeEnd(currentStructure); currentStructure.Pipes.Add(CurrentPipe); } else { CurrentPipe = pipe; } this.add = add; CurrentPipe.ID = ((char)(currentStructure.Pipes.IndexOf(CurrentPipe) + 'A')).ToString(); txt_Diameter.Text = (add ? "0" : CurrentPipe.Diameter.ToString()); txt_Direction.Text = (add ? "0" : CurrentPipe.Direction.ToString()); txt_Invert.Text = (add ? "0" : CurrentPipe.Invert.ToString()); cmb_PipeType.SelectedItem = (add ? PipeType.unknown : CurrentPipe.Type); cmb_PipeType.Text = (add ? "unknown" : CurrentPipe.Type.ToString()); if (add) { CurrentPipe.Flow = Flow.unknown; } if (CurrentPipe.Flow == Flow.In) { rd_In.Checked = true; } if (CurrentPipe.Flow == Flow.Out) { rd_Out.Checked = true; } this.cmb_PipeType.DataSource = Enum.GetNames(typeof(PipeType)); cmb_PipeType.Text = (add ? "unknown" : CurrentPipe.Type.ToString()); }