public void LoadProperties() { txtPathAngle.Text = junctionPoint.PathAngle.ToString(); txtPathId.Text = junctionPoint.Path.Id; chkStartOrEnd.Checked = junctionPoint.StartOrEnd == StartOrEnd.Start ? true : false; // Load Images NavigatorPoint point = null; if (junctionPoint.StartOrEnd == StartOrEnd.Start) { point = junctionPoint.Path.Points[0]; } else { point = junctionPoint.Path.Points[junctionPoint.Path.Points.Count - 1]; } if (point != null) { string pathDir = Globals.ImagesDir + "\\" + junctionPoint.Path.Id + "\\"; pbStraight.Image = ImageLoader.GetImageFromFile(pathDir + point.Img1, pbStraight.Width, pbStraight.Height); pbLeft.Image = ImageLoader.GetImageFromFile(pathDir + point.Img2, pbLeft.Width, pbLeft.Height); pbBehind.Image = ImageLoader.GetImageFromFile(pathDir + point.Img3, pbBehind.Width, pbBehind.Height); pbRight.Image = ImageLoader.GetImageFromFile(pathDir + point.Img4, pbRight.Width, pbRight.Height); lbl1.Text = point.Img1; lbl2.Text = point.Img2; lbl3.Text = point.Img3; lbl4.Text = point.Img4; } }
private void btnDeletePoint_Click(object sender, EventArgs e) { if (lstPaths.SelectedItem != null && lstPoints.SelectedItem != null) { NavigatorPoint selectedPoint = (NavigatorPoint)lstPoints.SelectedItem; NavigatorPath selectedPath = (NavigatorPath)lstPaths.SelectedItem; lstPoints.Items.Remove(selectedPoint); if (selectedPath.Points.Contains(selectedPoint)) { selectedPath.Points.Remove(selectedPoint); } // remove all corresponding images string pathDir = Globals.ImagesDir + "\\" + selectedPath.Id; if (File.Exists(pathDir + "\\" + selectedPoint.Img1)) { File.Move(pathDir + "\\" + selectedPoint.Img1, pathDir + "\\_" + selectedPoint.Img1); } if (File.Exists(pathDir + "\\" + selectedPoint.Img2)) { File.Move(pathDir + "\\" + selectedPoint.Img2, pathDir + "\\_" + selectedPoint.Img2); } if (File.Exists(pathDir + "\\" + selectedPoint.Img3)) { File.Move(pathDir + "\\" + selectedPoint.Img3, pathDir + "\\_" + selectedPoint.Img3); } if (File.Exists(pathDir + "\\" + selectedPoint.Img4)) { File.Move(pathDir + "\\" + selectedPoint.Img4, pathDir + "\\_" + selectedPoint.Img4); } } }
void junctionPointControl_JunctionPointDeleted(object sender, EventArgs e) { if (lstPoints.SelectedItem != null) { // delete this junction point NavigatorPoint selectedPoint = (NavigatorPoint)lstPoints.SelectedItem; JunctionPointItemControl itemControl = (JunctionPointItemControl)sender; if (selectedPoint.JunctionPoints.Contains(itemControl.JunctionPoint)) { selectedPoint.JunctionPoints.Remove(itemControl.JunctionPoint); } // Load selected point again LoadSelectedPoint(); } }
private void lnkAddJunctionPoint_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (lstPoints.SelectedItem != null && lstPaths.SelectedItem != null) { JunctionPointForm newJunctionPointForm = new JunctionPointForm(); if (newJunctionPointForm.ShowDialog() == DialogResult.OK) { NavigatorPoint selectedPoint = (NavigatorPoint)lstPoints.SelectedItem; NavigatorPath selectedPath = (NavigatorPath)lstPaths.SelectedItem; if (newJunctionPointForm.JunctionPoint.Path.Id != selectedPath.Id) { JunctionPoint junctionPoint = newJunctionPointForm.JunctionPoint; selectedPoint.JunctionPoints.Add(junctionPoint); // Add junction point to the path connecting to it JunctionPoint newJunctionPoint = new JunctionPoint(); newJunctionPoint.Path = selectedPath; newJunctionPoint.PathAngle = ((360 - junctionPoint.PathAngle) + 180) % 360; if (junctionPoint.StartOrEnd == StartOrEnd.Start) { newJunctionPoint.StartOrEnd = StartOrEnd.End; junctionPoint.Path.Points[0].JunctionPoints.Add(newJunctionPoint); } else { newJunctionPoint.StartOrEnd = StartOrEnd.Start; junctionPoint.Path.Points[junctionPoint.Path.Points.Count - 1].JunctionPoints.Add(newJunctionPoint); } // Reload selected point LoadSelectedPoint(); } else { MessageBox.Show("You selected same path to join. It should be different"); } } } }
private void LoadSelectedPoint() { if (lstPoints.SelectedItem != null && lstPaths.SelectedItem != null) { NavigatorPoint selectedPoint = (NavigatorPoint)lstPoints.SelectedItem; if (selectedPoint != null) { // Set point control values txtPointId.Text = selectedPoint.Id; txtNextPointAngle.Text = selectedPoint.NextPointAngle.ToString(); // Load Images pointImages.Point = selectedPoint; pointImages.NavigatorPath = (NavigatorPath)lstPaths.SelectedItem; pointImages.LoadPointImages(); // Load Junction Points pnlJunctionPoints.Controls.Clear(); if (selectedPoint.JunctionPoints != null) { foreach (JunctionPoint junctionPoint in selectedPoint.JunctionPoints) { JunctionPointItemControl junctionPointControl = new JunctionPointItemControl(); junctionPointControl.JunctionPointSaved += new EventHandler(junctionPointControl_JunctionPointSaved); junctionPointControl.JunctionPointDeleted += new EventHandler(junctionPointControl_JunctionPointDeleted); junctionPointControl.JunctionPoint = junctionPoint; junctionPointControl.LoadProperties(); pnlJunctionPoints.Controls.Add(junctionPointControl); } } // Load Images in Image capture control imageCaptureControl1.NavigatorPoint = selectedPoint; imageCaptureControl1.NavigatorPath = (NavigatorPath)lstPaths.SelectedItem; imageCaptureControl1.LoadPointImages(); } } }
private void btnPointInfoSave_Click(object sender, EventArgs e) { if (lstPoints.SelectedItem != null && lstPaths.SelectedItem != null) { NavigatorPath selectedPath = (NavigatorPath)lstPaths.SelectedItem; NavigatorPoint selectedPoint = (NavigatorPoint)lstPoints.SelectedItem; // change all associated image file names string[] files = Directory.GetFiles(Globals.ImagesDir + selectedPath.Id, selectedPoint.Id + "*.*"); foreach (string file in files) { string[] pointFileNameParts = Path.GetFileName(file).Split("-".ToCharArray()); if (pointFileNameParts.Length != 2) { throw new Exception("File name is not in proper format"); } IOSupport.RenameFile(file, Globals.ImagesDir + selectedPath.Id + "\\" + txtPointId.Text + "-" + pointFileNameParts[1]); } // Update selected point info if (String.IsNullOrEmpty(txtNextPointAngle.Text) == false) { selectedPoint.NextPointAngle = Int32.Parse(txtNextPointAngle.Text); } if (String.IsNullOrEmpty(txtPointId.Text) == false) { selectedPoint.Id = txtPointId.Text; } // sav e project file if (place != null) { LoadSave.Save(Globals.ProjectFile, place); } } }