public AugmentedPlacemarks()
        {
            Mode          = AugmentedMode.Explorer;
            mapData       = MapDataHandler.FetchGraphData();
            allPlacemarks = new List <GeoPlacemark>();

            foreach (GeoPoint point in mapData["Placemarks"])
            {
                allPlacemarks.Add(new GeoPlacemark(point));
            }

            allPoints = mapData["AllPoints"];

            pointsIndex = new Dictionary <int, int>();
            pointsByID  = new Dictionary <int, GeoGraphPoint>();

            int index = 0;

            foreach (GeoPoint point in mapData["AllPoints"])
            {
                pointsIndex.Add(point.ID, index++);
            }

            foreach (GeoPoint point in allPoints)
            {
                pointsByID.Add(point.ID, new GeoGraphPoint {
                    ID = point.ID, Name = point.Name, Position = point.Position
                });
            }

            currentPosition = new GeoCoordinate();

            PrepareDistanceMatrix();
            //FindShortestPath(pointsByID[-1460], pointsByID[-1508]);
        }
예제 #2
0
 void Start()
 {
     // MapDataHandler.SetID(traveler.nowSpot);
     MapDataHandler.SaveMap(traveler.nowSpot, "./Assets/Resources/Test.xml");
     // traveler.nowSpot = MapDataHandler.CreateMap("Test");
     // MapDataHandler.LoadMap(traveler.nowSpot, "Test");
     // traveler.ChangeSpot(traveler.nowSpot.nextRoutes[0]);
 }
예제 #3
0
        // Update is called once per frame
        void Update()
        {
            if (!readDone && CoreData.Instance.isReadCompleted)
            {
                readDone = true;
                MapDataHandler handler = new MapDataHandler();
                int            mapID   = CoreData.Instance.currentMapID;
                Debug.Log(mapID);
                EventCommandList events
                          = CoreData.Instance.mapDataArray[mapID].GetMapEvent(0).MapEventPageList[0].EventCommands;
                processor = new EventCommandProcessor(text, 0, events);
                return;
            }

            if (readDone)
            {
                processor.Run();
            }
        }
예제 #4
0
파일: MapForm.cs 프로젝트: AliDeym/Bifler
        /* Handles loading the map form. */
        private void OnInitialization(object sender, EventArgs e)
        {
            /* Initialize private objects. */
            ProjectsData = new Dictionary <string, Tuple <GMapOverlay, bool, string> > ();
            NodeHandler  = new Dictionary <string, MapDataHandler> ();

            colorRandomizer = new Random();


            excludeList = new ConfigManager("mapExclude");
            colorList   = new ConfigManager("mapColor");


            persianCal = new PersianCalendar();


            if (!Directory.Exists("mapdata"))
            {
                Directory.CreateDirectory("mapdata");
            }

            if (!Directory.Exists("mapimage"))
            {
                Directory.CreateDirectory("mapimage");
            }



            gmap.MapProvider = GoogleMapProvider.Instance;

            GMaps.Instance.Mode = AccessMode.ServerAndCache;

            gmap.CacheLocation = "mapcache";

            gmap.Position = new PointLatLng(35.8, 50.9);

            /* Load marker size from config. if it doesn't exist, then create it using defaults. */
            var markerSize = 10;

            var confMarkerSize = appCore.MainConfigManager.GetConfig("MapMarkerSize");

            if (confMarkerSize != null)
            {
                int.TryParse(confMarkerSize, out markerSize);
            }
            else
            {
                appCore.MainConfigManager.SetConfig("MapMarkerSize", markerSize.ToString());
            }


            /* Load all existing projects data. */

            var dirs = new DirectoryInfo("mapdata").GetDirectories();

            foreach (var dir in dirs)
            {
                var headDir = dir.Name;

                /* HEADER (project name) Node. */
                TreeNode headNode = null;                 //projectsBox.Nodes.Add (headDir);
                //headNode.Checked = true;

                var provinceDirectories = dir.GetDirectories();

                foreach (var provinceDir in provinceDirectories)
                {
                    /* PROVINCE Node. */
                    TreeNode provinceNode = null;                     //headNode.Nodes.Add (provinceDir.Name);
                    //provinceNode.Checked = true;

                    var cityDirectories = provinceDir.GetDirectories();

                    foreach (var cityDir in cityDirectories)
                    {
                        var startAreaDirectories = cityDir.GetDirectories();

                        foreach (var startArea in startAreaDirectories)
                        {
                            var files = startArea.GetFiles();

                            foreach (var finishArea in files)
                            {
                                var fileName = finishArea.Name.Substring(0, finishArea.Name.Length - 8);

                                var mapHandler = new MapDataHandler(headDir, provinceDir.Name, cityDir.Name, startArea.Name, fileName, 0);


                                NodeHandler [mapHandler.GetFriendlyName()] = mapHandler;

                                var excludedNode = excludeList.GetConfig(mapHandler.GetFriendlyName());

                                bool isExcluded = false;

                                if (excludedNode != null && bool.TryParse(excludedNode, out isExcluded))
                                {
                                    // This line of code is set, because we set IsVisible on config, we want IsExcluded, so the project is Excluded only
                                    // when it's not visible. For doing this, we need !IsVisible.
                                    isExcluded = !isExcluded;
                                }

                                // Node is not disabled, so lets load it.
                                if (!isExcluded)
                                {
                                    mapHandler.HandleLoad();
                                }


                                /* Create the un-existing nodes. */
                                if (headNode == null)
                                {
                                    headNode = projectsBox.Nodes.Add(headDir);

                                    headNode.ContextMenuStrip = rightClickMenu;

                                    headNode.Checked = true;
                                }
                                if (provinceNode == null)
                                {
                                    provinceNode = headNode.Nodes.Add(provinceDir.Name + " - " + cityDir.Name);

                                    provinceNode.ContextMenuStrip = rightClickMenu;

                                    provinceNode.Checked = true;
                                }

                                /* CITY Node. */
                                var handlerBox = provinceNode.Nodes.Add(mapHandler.GetFriendlyName(), startArea.Name + " - " + fileName);

                                handlerBox.ContextMenuStrip = rightClickMenu;

                                handlerBox.Checked = !isExcluded;


                                // Create the specific overlay on map.

                                var overlay = new GMapOverlay(mapHandler.GetFriendlyName());

                                // Create the route only in-case of project being enabled.
                                if (mapHandler.IsLoaded)
                                {
                                    var col = colorList.GetConfig(mapHandler.GetFriendlyName());

                                    var selectedCol = default(Color);

                                    /* Load saved color configs. */
                                    if (col != null && int.TryParse(col, out int value))
                                    {
                                        selectedCol = Color.FromArgb(value);
                                    }


                                    handleDataCreation(mapHandler, overlay, selectedCol);
                                }

                                /* Set the node text label color same as Pen color received from first available route. */
                                if (overlay.Routes.Count > 0)
                                {
                                    var strokeColor = overlay.Routes.First().Stroke.Color;

                                    handlerBox.ForeColor = strokeColor;

                                    /* Handle single child nodes and their parents */

                                    if (files.Length <= 1)
                                    {
                                        /* Parent */
                                        if (handlerBox.Parent != null)
                                        {
                                            handlerBox.Parent.ForeColor = strokeColor;

                                            /* Parent of parent. */
                                            if (handlerBox.Parent.Parent != null)
                                            {
                                                handlerBox.Parent.Parent.ForeColor = strokeColor;
                                            }
                                        }
                                    }
                                }


                                /* Create the project data tuple for display on-off functionality. */
                                ProjectsData [mapHandler.GetFriendlyName()] = new Tuple <GMapOverlay, bool, string> (overlay, true, mapHandler.GetFileName());

                                gmap.Overlays.Add(overlay);
                            }
                        }
                    }

                    /* Handle check of Province nodes. */

                    /*if (provinceNode != null && provinceNode.Nodes != null && provinceNode.Nodes.Count >= 1) {
                     *
                     *      var anyEnabled = false;
                     *
                     *      foreach (var node in provinceNode.Nodes) {
                     *
                     *              if (((TreeNode)node).Checked)
                     *                      anyEnabled = true;
                     *
                     *      }
                     *
                     *      provinceNode.Checked = anyEnabled;
                     *
                     * }*/
                }

                /* Check for Head nodes. */

                /*if (headNode != null && headNode.Nodes != null && headNode.Nodes.Count >= 1) {
                 *
                 *      var anyEnabled = false;
                 *
                 *      foreach (var node in headNode.Nodes) {
                 *
                 *              if (((TreeNode)node).Checked)
                 *                      anyEnabled = true;
                 *
                 *      }
                 *
                 *      headNode.Checked = anyEnabled;
                 *
                 * }*/
            }
        }
예제 #5
0
파일: MapForm.cs 프로젝트: AliDeym/Bifler
        /* Handles data creation on map for the Data Handler. this function creates routes and points. also tooltips. */
        private void handleDataCreation(MapDataHandler nodeHandler, GMapOverlay overlay, Color selectionColor = default(Color))
        {
            if (selectionColor == default(Color))
            {
                selectionColor = Color.DarkGreen;
            }

            var points = new List <PointLatLng> ();

            /* Get all the points from data. */
            foreach (var data in nodeHandler.Data)
            {
                points.Add(new PointLatLng(data.Latitude, data.Longitude));
            }


            /* We need two points for tooltips. */
            if (points.Count > 1)
            {
                var startPoint  = new GMarkerGoogle(points.First(), GMarkerGoogleType.white_small);
                var finishPoint = new GMarkerGoogle(points.Last(), GMarkerGoogleType.black_small);



                finishPoint.ToolTipText = startPoint.ToolTipText = Language.ProjectName + ": " + nodeHandler.ProjectName + "\n" +
                                                                   Language.ProjectCode + ": " + nodeHandler.ProjectCode + "\n" +
                                                                   Language.GrabCount + ": " + nodeHandler.TriggerCount + " " + Language.Meter + "\n\n" +
                                                                   Language.ProjectStartTime + ": " + displayPersianTime(nodeHandler.ProjectStartTime) + "\n" +
                                                                   Language.ProjectFinishTime + ": " + displayPersianTime(nodeHandler.ProjectFinishTime) + "";



                startPoint.ToolTip.Font = finishPoint.ToolTip.Font = new Font("B Nazanin", 14f);

                startPoint.ToolTipText  = Language.StartArea + "\n\n" + startPoint.ToolTipText;
                finishPoint.ToolTipText = Language.FinishArea + "\n\n" + finishPoint.ToolTipText;



                /* White pin's tooltip (Start point). */
                startPoint.ToolTip.Fill        = Brushes.Black;
                startPoint.ToolTip.Foreground  = Brushes.White;
                startPoint.ToolTip.Stroke      = Pens.Black;
                startPoint.ToolTip.TextPadding = new Size(20, 20);



                /* Black pin's tooltip (Finish point). */

                finishPoint.ToolTip.Fill        = Brushes.White;
                finishPoint.ToolTip.Foreground  = Brushes.Black;
                finishPoint.ToolTip.Stroke      = Pens.White;
                finishPoint.ToolTip.TextPadding = new Size(20, 20);


                overlay.Markers.Add(startPoint);
                overlay.Markers.Add(finishPoint);
            }

            /* Create the pen and route. */
            var route = new GMapRoute(points, nodeHandler.GetFriendlyName());


            /* Load marker size from config. if it doesn't exist, then create it using defaults. */
            var markerSize = 10;

            var confMarkerSize = appCore.MainConfigManager.GetConfig("MapMarkerSize");

            if (confMarkerSize != null)
            {
                int.TryParse(confMarkerSize, out markerSize);
            }
            else
            {
                appCore.MainConfigManager.SetConfig("MapMarkerSize", markerSize.ToString());
            }



            var penColor = selectionColor;

            // Set random pen color.
            if (selectionColor == default(Color))
            {
                penColor = Color.FromArgb(255,
                                          colorRandomizer.Next(256),
                                          colorRandomizer.Next(256),
                                          colorRandomizer.Next(256));
            }

            colorList.SetConfig(nodeHandler.GetFriendlyName(), penColor.ToArgb().ToString());


            route.Stroke = new Pen(penColor, markerSize);



            overlay.Routes.Add(route);
        }
예제 #6
0
 public MapDataController(MapDataHandler mapDataHandler,
                          WorldEntityManager entityManager)
 {
     _mapDataHandler = mapDataHandler;
     _entityManager  = entityManager;
 }