Пример #1
0
        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);
                }
            }
        }
Пример #2
0
 private void AddPoint()
 {
     if (lstPaths.SelectedItem != null)
     {
         NavigatorPoint newPoint     = new NvnNavigator.Common.NavigatorPoint();
         NavigatorPath  selectedPath = (NavigatorPath)lstPaths.SelectedItem;
         selectedPath.Points.Add(newPoint);
         lstPoints.Items.Add(newPoint);
     }
 }
Пример #3
0
        private void lstPaths_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Load all points assigned to this path
            if (lstPaths.SelectedItem != null)
            {
                lstPoints.Items.Clear();
                NavigatorPath selectedPath = (NavigatorPath)lstPaths.SelectedItem;
                lstPoints.Items.AddRange(selectedPath.Points.ToArray());
                txtPathId.Text = selectedPath.Id;

                markControl1.SetSelectedNavigatorPath(selectedPath);
            }
        }
Пример #4
0
 private void btnPathIdSave_Click(object sender, EventArgs e)
 {
     if (lstPaths.SelectedItem != null)
     {
         NavigatorPath selectedPath = (NavigatorPath)lstPaths.SelectedItem;
         if (Directory.Exists(Globals.ImagesDir + "\\" + selectedPath.Id) && Directory.Exists(Globals.ImagesDir + "\\" + txtPathId.Text) == false)
         {
             // change directory name
             Directory.Move(Globals.ImagesDir + "\\" + selectedPath.Id, Globals.ImagesDir + "\\" + txtPathId.Text);
             // change path id
             selectedPath.Id = txtPathId.Text;
             int selectedIndex = lstPaths.SelectedIndex;
             lstPaths.Items.Clear();
             lstPaths.Items.AddRange(place.Paths.ToArray());
         }
     }
 }
Пример #5
0
        private void btnDeletePath_Click(object sender, EventArgs e)
        {
            // Delete selected path
            if (lstPaths.SelectedItem != null)
            {
                NavigatorPath path = (NavigatorPath)lstPaths.SelectedItem;
                if (place.Paths.Contains(path))
                {
                    place.Paths.Remove(path);
                    lstPaths.Items.Remove(path);

                    string pathDir = Globals.ImagesDir + "\\" + path.Id;
                    if (Directory.Exists(pathDir))
                    {
                        Directory.Move(pathDir, Globals.ImagesDir + "\\_" + path.Id);
                    }
                }
            }
        }
Пример #6
0
        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");
                    }
                }
            }
        }
Пример #7
0
        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);
                }
            }
        }
Пример #8
0
 public void SetSelectedNavigatorPath(NavigatorPath navigatorPath)
 {
     selectedNavigatorPath = navigatorPath;
     LoadMapPaths();
 }