Esempio n. 1
0
        private void SearchShowPath(NavigatorPath path, HotspotLocation location, List <string> searchPaths)
        {
            // show points
            for (int i = 0; i < path.Points.Count; i++)
            {
                NavigatorPoint point = path.Points[i];

                SearchShowPoint(point, path.Id);

                // if current point is the one looking for
                if (point.Id == location.GetNavigatorPoint().Id)
                {
                    // TODO: turn and show as given in HotspotLocation
                    return;
                }
            }

            // connent to another path
            List <JunctionPoint> junctionPoints = path.Points[path.Points.Count - 1].JunctionPoints;

            if (junctionPoints != null)
            {
                foreach (JunctionPoint junctionPoint in junctionPoints)
                {
                    if (searchPaths.Contains(junctionPoint.Path.Id))
                    {
                        SearchShowPath(junctionPoint.Path, location, searchPaths);
                    }
                }
            }
        }
Esempio n. 2
0
        private static List <string> SearchHotspot(NavigatorPath path, NavigatorPoint endpoint)
        {
            List <string> idsList = new List <string>();

            bool endpointExists = false;
            List <JunctionPoint> junctionPoints = path.Points[path.Points.Count - 1].JunctionPoints;

            if (junctionPoints != null)
            {
                foreach (JunctionPoint junctionPoint in junctionPoints)
                {
                    if (junctionPoint.Path.Points.Contains(endpoint))
                    {
                        break;
                    }
                    else
                    {
                        List <string> pathIds = SearchHotspot(junctionPoint.Path, endpoint);
                        foreach (string paths in pathIds)
                        {
                            idsList.Add(path.Id + "#" + paths);
                        }
                    }
                }
            }

            // if it is last node
            if (idsList.Count == 0)
            {
                idsList.Add(path.Id + (endpointExists ? "@" : "")); // current path id
            }

            return(idsList);
        }
Esempio n. 3
0
        private NavigatorPoint GetNextPrevPoint(NavigatorPoint curPoint, NavigatorPath curPath, bool next)
        {
            int nextOrPrev = next ? 1 : -1;

            if (curPath.Points.Contains(curPoint))
            {
                int curIndex  = curPath.Points.IndexOf(curPoint);
                int nextIndex = -1;
                if (currentAngle == 0)
                {
                    nextIndex = curIndex + nextOrPrev;
                }
                else if (currentAngle == 180)
                {
                    nextIndex = curIndex - nextOrPrev;
                }

                if (nextIndex >= 0 && nextIndex < curPath.Points.Count)
                {
                    currentIndex = nextIndex;
                    return(curPath.Points[nextIndex]);
                }
            }

            return(curPoint);
        }
Esempio n. 4
0
        private NavigatorPoint GetPrevPoint(NavigatorPoint curPoint, NavigatorPath curPath)
        {
            // Get prev point in current path
            NavigatorPoint prevPoint = GetNextPrevPoint(curPoint, curPath, false);

            if (PositionChanged != null)
            {
                PositionChanged(this, new NavigatorPositionChangedEventArgs(prevPoint, curPath));
            }

            return(prevPoint);
        }
Esempio n. 5
0
        private void btnCreatePath_Click(object sender, EventArgs e)
        {
            NavigatorPath path = new NvnNavigator.Common.NavigatorPath();

            place.Paths.Add(path);
            lstPaths.Items.Add(path);

            string pathDir = Globals.ImagesDir + "\\" + path.Id;

            if (Directory.Exists(pathDir))
            {
                Directory.Move(pathDir, Globals.ImagesDir + "\\_" + path.Id);
            }

            Directory.CreateDirectory(pathDir);
        }
Esempio n. 6
0
        private void btnLoadProject_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                currentPlace = LoadSave.Load(dlg.FileName);
                imagePath    = Path.GetDirectoryName(dlg.FileName) + "\\images";

                currentPath  = currentPlace.Paths[0];
                currentPoint = currentPath.Points[0];
                currentAngle = 0;

                LoadImage();
            }
        }
Esempio n. 7
0
        public static List <string> Search(NavigatorPath currentPath, NavigatorPoint endpoint)
        {
            List <string> pathIds = SearchHotspot(currentPath, endpoint);

            string selectedPathIds = string.Empty;

            foreach (string pathIdList in pathIds)
            {
                if (pathIdList.Contains("@"))
                {
                    selectedPathIds = pathIdList;
                    break;
                }
            }

            return(new List <string>());
        }
Esempio n. 8
0
        // Get next point... either in current path or go to next path
        private NavigatorPoint GetNextPoint(NavigatorPoint curPoint, NavigatorPath curPath)
        {
            NavigatorPoint nextPoint = null;

            if (curPoint.JunctionPoints != null && curPoint.JunctionPoints.Count > 0)
            {
                foreach (JunctionPoint junctionPoint in curPoint.JunctionPoints)
                {
                    if (junctionPoint.PathAngle == currentAngle)
                    {
                        // change current path to point next path linked with junction point
                        currentPath = junctionPoint.Path;

                        if (junctionPoint.StartOrEnd == StartOrEnd.Start)
                        {
                            nextPoint    = currentPath.Points[0];
                            currentAngle = 0;
                            currentIndex = 0;
                        }
                        else if (junctionPoint.StartOrEnd == StartOrEnd.End)
                        {
                            nextPoint    = currentPath.Points[currentPath.Points.Count - 1];
                            currentAngle = 180;
                            currentIndex = currentPath.Points.Count - 1;
                        }

                        break;
                    }
                }
            }

            if (nextPoint == null)
            {
                // Get next point in current path
                nextPoint = GetNextPrevPoint(curPoint, curPath, true);
            }

            if (nextPoint != null && PositionChanged != null)
            {
                PositionChanged(this, new NavigatorPositionChangedEventArgs(nextPoint, currentPath));
            }

            return(nextPoint);
        }
Esempio n. 9
0
 public NavigatorPositionChangedEventArgs(NavigatorPoint point, NavigatorPath path)
 {
     this.point = point;
     this.path  = path;
 }