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); }
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); }
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); } } } }
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); } }
private void SearchShowPoint(NavigatorPoint point, string pathId) { Image img = GetImage(point.Img1, pathId); pbNavigationImage.Image = img; //TODO: draw direction pbNavigationImage.Refresh(); }
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); }
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(); } }
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>()); }
// 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); }
public void UpdateLocation(NavigatorPoint point, MapLocationImageType imageType) { if (imageType == MapLocationImageType.CurrentLocation) { currentPositionPoint = point; } else if (imageType == MapLocationImageType.Search) { searchPositionPoint = point; } else if (imageType == MapLocationImageType.YouAreHere) { youareHerePoint = point; } if (selectedMap != null) { LoadSelectedMap(selectedMap); } }
//private MapPoint IsMouseOnTheLine(int x, int y) { // foreach (MapPath mapPath in currentMapPaths) { // foreach (MapPoint mapPoint in mapPath.Points) { // float mapx = mapPoint.X * ((float)(pbMap.Width + (zoomIndex * zoomIncrement)) / actualMapImage.Width); // float mapy = mapPoint.Y * ((float)(pbMap.Height + (zoomIndex * zoomIncrement)) / actualMapImage.Height); // if ((mapx <= (x + 5) && mapx >= (x - 5)) && (mapy <= (y + 5) && mapy >= (y - 5))) { // return mapPoint; // } // } // } // return null; //} //private NavigatorPath GetNavigatorPath(string id) { // if (NavigatorPlace.Place != null) { // foreach (NavigatorPath path in NavigatorPlace.Place.Paths) { // if (path.Id == id) { // return path; // } // } // } // return null; //} private Point?GetMapPointForNaviatorPoint(NavigatorPoint navigatorPoint) { foreach (NavigatorPath path in currentNavigatorPaths.Values) { if (path.Points.Contains(navigatorPoint)) { foreach (MapPath mapPath in currentMapPaths) { if (mapPath.Id == path.Id) { int index = path.Points.IndexOf(navigatorPoint) * (int)Math.Floor((decimal)mapPath.Points.Count / (path.Points.Count - 1)); index += path.Points.IndexOf(navigatorPoint) == path.Points.Count - 1 ? -1 : 0; return(new Point(mapPath.Points[index].X, mapPath.Points[index].Y)); } } } } return(null); }
private void Navigate(NavigateDirection direction) { if (direction == NavigateDirection.Left) { currentAngle = GetNextAngle(currentAngle, currentPoint); } else if (direction == NavigateDirection.Right) { currentAngle = GetPrevAngle(currentAngle, currentPoint); } else if (direction == NavigateDirection.Forward) { currentPoint = GetNextPoint(currentPoint, currentPath); } else if (direction == NavigateDirection.Backward) { currentPoint = GetPrevPoint(currentPoint, currentPath); } LoadImage(); }
private int GetNextAngle(int curAngle, NavigatorPoint curPoint) { int angle = -1; if (curPoint.JunctionPoints != null && curPoint.JunctionPoints.Count > 0) { foreach (JunctionPoint junctionPoint in curPoint.JunctionPoints) { if (junctionPoint.PathAngle > curAngle && junctionPoint.PathAngle < GetNextQuadrantAngle(curAngle)) { angle = junctionPoint.PathAngle; break; } } } if (angle == -1) { angle = GetNextQuadrantAngle(curAngle); } return(angle % 360); }
public NavigatorPositionChangedEventArgs(NavigatorPoint point, NavigatorPath path) { this.point = point; this.path = path; }
// Display image based on current point, direction or next path first point image private void LoadImage() { Image img = null; string imageName = string.Empty; NavigatorPoint point = currentPoint; if (currentPoint.JunctionPoints != null) { foreach (JunctionPoint junctionPoint in currentPoint.JunctionPoints) { if (currentAngle == junctionPoint.PathAngle && currentAngle % 90 != 0) { // use next path first image and show if (junctionPoint.StartOrEnd == StartOrEnd.Start) { imageName = junctionPoint.Path.Points[0].Img1; } else { imageName = junctionPoint.Path.Points[junctionPoint.Path.Points.Count - 1].Img1; } img = GetImage(imageName, junctionPoint.Path.Id); break; } } } // if no juction point image assigned (show next path first point image) if (img == null) { imageName = string.Empty; switch (currentAngle) { case 0: imageName = point.Img1; break; case 90: imageName = point.Img2; break; case 180: imageName = point.Img3; break; case 270: imageName = point.Img4; break; } img = GetImage(imageName, currentPath.Id); } // Display image lblImageName.Text = imageName; lblPath.Text = currentPath.Id; lblCurrentAngle.Text = "" + currentAngle; currentImagePath = imagePath + "\\" + currentPath.Id + "\\" + imageName; pbNavigationImage.Image = img; // Draw navigation direction DrawNavigationDirection(); pbNavigationImage.Refresh(); // Notify that image changed if (ImageChanged != null) { ImageChanged(this, null); } }