private void CountyShapeMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MapShape shape = sender as MapShape;

            this.ResetCountyShapeColor();

            this.countyShape = shape;
            shape.Fill = new SolidColorBrush(Color.FromArgb(0xFF, 0xF0, 0xB5, 0x85));
        }
示例#2
0
 private void SetDefaultStyle(MapShape shape)
 {
     if (shape is MapLine)
     {
         shape.Style = this.Resources["defaultLineStyle"] as Style;
     }
     else
     {
         shape.Style = this.Resources["defaultPolylineStyle"] as Style;
     }
 }
示例#3
0
 private void SetSelectedStyle(MapShape shape)
 {
     if (shape is MapLine)
     {
         shape.Style = this.Resources["selectedLineStyle"] as Style;
     }
     else
     {
         shape.Style = this.Resources["selectedPolylineStyle"] as Style;
     }
 }
示例#4
0
        public override bool IsMatch(MapShape mapWay)
        {
            if (mapWay.Tags.TryGetValue("building", out var buildingType) &&
                (string.Equals(buildingType, "house", StringComparison.OrdinalIgnoreCase) ||
                 string.Equals(buildingType, "residential", StringComparison.OrdinalIgnoreCase)))
            {
                return(true);
            }

            return(false);
        }
示例#5
0
        private MapShape GetMapShape(Feature lastTrackingFeature)
        {
            var mapShape = new MapShape(lastTrackingFeature);

            foreach (var item in MeasurementStyle.Styles)
            {
                mapShape.ZoomLevels.ZoomLevel01.CustomStyles.Add(item);
            }
            mapShape.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            return(mapShape);
        }
示例#6
0
        /// <summary>
        /// Converts a MapShape into a Geometry object.
        /// </summary>
        /// <param name="shape">A Bing Maps MapShape object</param>
        /// <returns>A Geometry representation of the MapMultiPoint object</returns>
        public static Geometry ToGeometry(this MapShape shape)
        {
            if (shape is MapPolyline)
            {
                return((shape as MapPolyline).ToGeometry());
            }
            else if (shape is MapPolygon)
            {
                return((shape as MapPolygon).ToGeometry());
            }

            return(null);
        }
示例#7
0
        /// <summary>
        /// Mouse Button up event binded with the view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void shape_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            MapShape shape = sender as MapShape;

            if (shape == null)
            {
                return;
            }
            string country = (string)shape.ExtendedData.GetValue("ISO_2DIGIT");

            SelectorPayload.HeatMapCountryData = country;
            eventAggregator.GetEvent <HeatMapClickEvent>().Publish(SelectorPayload.HeatMapCountryData);
        }
示例#8
0
        public Map <T> CreateMap(MapShape shape, int x, int y = 0)
        {
            switch (shape)
            {
            case MapShape.Circle:
                return(CreateCircleMap(x));

            case MapShape.Rectangle:
                return(CreateRectMap(x, y));

            default:
                throw new InvalidOperationException();
            }
        }
示例#9
0
 public static PolyShape Create(MapShape shape)
 {
     if (shape.Primitive is PrimitiveLine line)
     {
         return(PolyshapeBuilder.Create(line));
     }
     else if (shape.Primitive is PrimitivePolygon polygon)
     {
         return(PolyshapeBuilder.Create(polygon));
     }
     else
     {
         throw new NotImplementedException("Something is missing yo.");
     }
 }
示例#10
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-96.8531, 33.1084, -96.8461, 33.106);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new ThinkGeo.MapSuite.DesktopEdition.WorldMapKitWmsDesktopOverlay();
            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            LineShape lineShape = new LineShape();

            lineShape.Vertices.Add(new Vertex(-96.8511, 33.1089));
            lineShape.Vertices.Add(new Vertex(-96.8504, 33.108));
            lineShape.Vertices.Add(new Vertex(-96.85, 33.1077));
            lineShape.Vertices.Add(new Vertex(-96.8498, 33.1076));
            lineShape.Vertices.Add(new Vertex(-96.8482, 33.1076));

            LineShape lineShape2 = new LineShape();

            lineShape2.Vertices.Add(new Vertex(-96.8497, 33.1084));
            lineShape2.Vertices.Add(new Vertex(-96.8506, 33.1072));

            //MapShapeLayer to display the three features (line to split, splitting line and intersection point).
            MapShapeLayer mapShapeLayer = new MapShapeLayer();

            //For the line to split.
            MapShape lineMapShape1 = new MapShape(new Feature(lineShape));

            lineMapShape1.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Green, 2, true);
            lineMapShape1.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.MapShapes.Add("Line1", lineMapShape1);

            //For the splitting line.
            MapShape lineMapShape2 = new MapShape(new Feature(lineShape2));

            lineMapShape2.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Red, 1, true);
            lineMapShape2.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.MapShapes.Add("Line2", lineMapShape2);

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(mapShapeLayer);

            winformsMap1.Overlays.Add(layerOverlay);

            winformsMap1.Refresh();
        }
示例#11
0
        public override bool IsMatch(MapShape mapWay)
        {
            if (mapWay.Tags.ContainsKey("waterway"))
            {
                return(true);
            }

            string type;

            if (mapWay.Tags.TryGetValue("natural", out type) && string.Equals(type, "water", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
示例#12
0
    void CreateNewMap()
    {
        float posX = 0;
        float posY = 0;
        float imageSpace = imageSize / 100f;

        //fill Arr
        for (int y = 0; y < mapHeigth; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                mapArr[x, y] = new MapShape(prefFloor, new Vector2(posX, posY), imageSize);

                if (x == 0)
                {
                    mapArr[x, y] = new MapShape(prefWall, new Vector2(posX, posY), imageSize, 90);
                }
                if (y == 0)
                {
                    mapArr[x, y] = new MapShape(prefWall, new Vector2(posX, posY), imageSize, 180);
                }
                if (x == mapWidth - 1)
                {
                    mapArr[x, y] = new MapShape(prefWall, new Vector2(posX, posY), imageSize, 270);
                }
                if (y == mapHeigth - 1)
                {
                    mapArr[x, y] = new MapShape(prefWall, new Vector2(posX, posY), imageSize);
                }

                posX += imageSpace;
            }
            posX = 0;
            posY += imageSpace;
        }

        placeWallsDummy();

        for (int y = 0; y < mapHeigth; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                GameObject gObj = (GameObject)Instantiate(mapArr[x, y].Prefab, mapArr[x, y].Position, Quaternion.Euler(0, 0, mapArr[x, y].ImageRotation));
                gObj.transform.parent = prefMapManagerEmptyObj.transform;
            }
        }
    }
        private void StateShapeMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MapShape shape = sender as MapShape;

            if ((bool)this.LoadCountyDataCheckBox.IsChecked)
            {
                this.stateShape = shape;
                (this.Resources["DataContext"] as ExampleViewModel).County = GetExtendedProperty(shape, StateExtendedPropertyName);
            }
            else
            {
                this.ResetStateShapeColor();

                this.stateShape = shape;
                shape.Fill = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xE4, 0xBA));
            }
        }
        private void AddPolyShape(MapShape mapShape)
        {
            mShapeLayer.Shapes.Clear();
            mPinLayer.Children.Clear();

            mShapeLayer.Shapes.Add(mapShape);

            // Add pushpins to the map to make it easy to see how the order of
            // the locations in the LocationCollection affects how the poly shape
            // is drawn.
            for (int i = 0; i < mPolyShapeLocations.Count; i++)
            {
                Pushpin pin = new Pushpin();
                pin.Text = i.ToString();
                mPinLayer.Children.Add(pin);
                MapLayer.SetPosition(pin, mPolyShapeLocations[i]);
            }
        }
示例#15
0
        /// <summary>
        /// Registers Properties for Heat Map
        /// </summary>
        /// <param name="shape">Map Shape</param>
        private void SetAdditionalData(MapShape shape)
        {
            ExtendedData data = shape.ExtendedData;

            if (data != null)
            {
                if (!data.PropertySet.ContainsKey(COUNTRY_PERFORMANCE_FIELD))
                {
                    data.PropertySet.RegisterProperty(COUNTRY_PERFORMANCE_FIELD, "CountryPerformance", typeof(int), 0);
                }
                if (!data.PropertySet.ContainsKey(COUNTRY_YTD_FIELD))
                {
                    data.PropertySet.RegisterProperty(COUNTRY_YTD_FIELD, "CountryYTD", typeof(Decimal), Convert.ToDecimal(0));
                }
                if (!data.PropertySet.ContainsKey(BENCHMARK_YTD_FIELD))
                {
                    data.PropertySet.RegisterProperty(BENCHMARK_YTD_FIELD, "BenchmarkYTD", typeof(Decimal), Convert.ToDecimal(0));
                }

                if (heatMapInfo != null)
                {
                    string      countryID     = (string)shape.ExtendedData.GetValue("ISO_2DIGIT");
                    HeatMapData countryRecord = heatMapInfo.Where(r => r.CountryID == countryID).FirstOrDefault();

                    if (countryRecord != null)
                    {
                        shape.ExtendedData.SetValue(COUNTRY_PERFORMANCE_FIELD, (int)(countryRecord.CountryPerformance));
                        shape.ExtendedData.SetValue(COUNTRY_YTD_FIELD, countryRecord.CountryYTD);
                        shape.ExtendedData.SetValue(BENCHMARK_YTD_FIELD, countryRecord.BenchmarkYTD);
                        AddColorizerToInformationLayer(shape, countryRecord);
                    }
                    else
                    {
                        shape.ExtendedData.SetValue(COUNTRY_PERFORMANCE_FIELD, null);
                        shape.ExtendedData.SetValue(COUNTRY_YTD_FIELD, null);
                        shape.ExtendedData.SetValue(BENCHMARK_YTD_FIELD, null);
                        AddTransparentColorizerToInformationLayer(shape);
                    }
                }
            }
        }
示例#16
0
        /// <summary>
        /// Apply a style to a MapShape (MapPolygon, MapPolyline).
        /// </summary>
        /// <param name="element">MapShape to apply style to.</param>
        /// <param name="style">Style to apply to MapShape.</param>
        public static void ApplyStyle(MapShape polyShape, ShapeStyle style)
        {
            if (polyShape != null && style != null)
            {
                if (polyShape is MapPolyline)
                {
                    var polyline = polyShape as MapPolyline;

                    if (style.StrokeColor.HasValue)
                    {
                        polyline.Color = style.StrokeColor.Value.ToColor();
                    }
                    else
                    {
                        polyline.Color = DefaultPolylineColor;
                    }

                    if (!double.IsNaN(style.StrokeThickness) && style.StrokeThickness > 0)
                    {
                        polyline.Width = style.StrokeThickness;
                    }
                    else
                    {
                        polyline.Width = DefaultPolylineThickness;
                    }
                }
                else if (polyShape is MapPolygon)
                {
                    var polygon = polyShape as MapPolygon;

                    if (style.FillColor.HasValue)
                    {
                        polygon.FillColor = style.FillColor.Value.ToColor();
                    }
                    else
                    {
                        polygon.FillColor = DefaultPolygonFillColor;
                    }
                }
            }
        }
示例#17
0
        private void btnSplitLine_Click(object sender, EventArgs e)
        {
            LayerOverlay  layerOverLay  = (LayerOverlay)winformsMap1.Overlays[1];
            MapShapeLayer mapShapeLayer = (MapShapeLayer)layerOverLay.Layers[0];

            LineShape lineShape  = (LineShape)mapShapeLayer.MapShapes["Line1"].Feature.GetShape();
            LineShape lineShape2 = (LineShape)mapShapeLayer.MapShapes["Line2"].Feature.GetShape();

            //Gets the crossing MultipointShape with the PointShape that will be used to calculate the two split lines.
            MultipointShape multipointShape = lineShape.GetCrossing(lineShape2);

            //Uses the GetLineOnLine (Dynamic Segmentation) to get the two split lines from the intersection point.
            LineShape splitLineShape1 = (LineShape)lineShape.GetLineOnALine(StartingPoint.FirstPoint, multipointShape.Points[0]);
            LineShape splitLineShape2 = (LineShape)lineShape.GetLineOnALine(StartingPoint.LastPoint, multipointShape.Points[0]);

            //Displays the two split lines with different colors to distinguish them.
            MapShape splitMapShape1 = new MapShape(new Feature(splitLineShape1));

            splitMapShape1.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Orange, 3, true);
            splitMapShape1.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.MapShapes.Add("SplitLine1", splitMapShape1);

            MapShape splitMapShape2 = new MapShape(new Feature(splitLineShape2));

            splitMapShape2.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Turquoise, 3, true);
            splitMapShape2.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.MapShapes.Add("SplitLine2", splitMapShape2);

            //Displays the intersection point as a reference.
            MapShape pointMapShape = new MapShape(new Feature(multipointShape.Points[0]));

            pointMapShape.ZoomLevels.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimplePointStyle(PointSymbolType.Circle,
                                                                                                        GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 1, 9);
            pointMapShape.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            mapShapeLayer.MapShapes.Add("Point", pointMapShape);

            winformsMap1.Refresh(layerOverLay);

            btnSplitLine.Enabled = false;
        }
示例#18
0
 /// <summary>
 /// Adding Colour to Each Shape
 /// </summary>
 /// <param name="shape">Shape</param>
 /// <param name="countryRecord">Country record of type heat map data</param>
 private void AddColorizerToInformationLayer(MapShape shape, HeatMapData countryRecord)
 {
     if ((int)(countryRecord.CountryPerformance) == 3)
     {
         shape.Fill = new SolidColorBrush(Colors.Green);
     }
     else
     if ((int)(countryRecord.CountryPerformance) == 1)
     {
         shape.Fill = new SolidColorBrush(Colors.Red);
     }
     else
     if ((int)(countryRecord.CountryPerformance) == 2)
     {
         shape.Fill = new SolidColorBrush(Colors.Gray);
     }
     else
     if ((int)(countryRecord.CountryPerformance) == 0)
     {
         shape.Fill = new SolidColorBrush(Colors.White);
     }
 }
示例#19
0
 /// <summary>
 /// Adding default Colour to  Shape with no values
 /// </summary>
 /// <param name="shape">Shape</param>
 private void AddTransparentColorizerToInformationLayer(MapShape shape)
 {
     shape.Fill = new SolidColorBrush(Colors.Transparent);
 }
示例#20
0
 public static void ColorShape(MapShape shape, Color color)
 {
     shape.Fill = new SolidColorBrush(color);
 }
        private void btnCalculate_Click(object sender, RoutedEventArgs e)
        {
            //Get a reference to the results MapShapeLayer and clear it so we can display our new results.
            MapShapeLayer results = (MapShapeLayer)((LayerOverlay)mapView.Overlays["layerOverlay"]).Layers["Results"];

            results.MapShapes.Clear();

            //Get a reference to the test data layer.
            InMemoryFeatureLayer testDataLayer = (InMemoryFeatureLayer)((LayerOverlay)mapView.Overlays["layerOverlay"]).Layers["TestData"];

            //Check to see if the test data has been edited.
            if (mapView.EditOverlay.EditShapesLayer.InternalFeatures.Count > 0)
            {
                //Loop through the edited test data and update the test data layer.
                testDataLayer.EditTools.BeginTransaction();
                foreach (Feature feature in mapView.EditOverlay.EditShapesLayer.InternalFeatures)
                {
                    testDataLayer.EditTools.Update(feature.CloneDeep());
                }
                testDataLayer.EditTools.CommitTransaction();
                //Clear out the EditOverlay since we are done editing.
                mapView.EditOverlay.EditShapesLayer.InternalFeatures.Clear();
                //Since we are done editing, turn visibility back on the for the layer overlay so we can see our test data again.
                mapView.Overlays["layerOverlay"].IsVisible = true;
            }

            //Get the test point feature from the test data layer.
            Feature testPointFeature = testDataLayer.QueryTools.GetFeaturesByColumnValue("Name", "TestPoint", ReturningColumnsType.AllColumns)[0];
            //Get the test line feature from the test data layer.
            Feature testLineFeature = testDataLayer.QueryTools.GetFeaturesByColumnValue("Name", "TestLine", ReturningColumnsType.AllColumns)[0];
            //Take the test line feature and create a line shape so we can use line-specific APIs for finding the shortest line and line-on-line.
            LineShape testLine = new MultilineShape(testLineFeature.GetWellKnownText()).Lines[0];

            //Calculate the shortest line between our test line and test point.
            LineShape shortestLineResult = testLine.GetShortestLineTo(testPointFeature.GetShape(), GeographyUnit.Meter).Lines[0];
            //Take the result and create a MapShape so we can display the shortest line on the map in a blue color.
            MapShape shortestLine = new MapShape(new Feature(shortestLineResult));

            shortestLine.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyle.CreateSimpleLineStyle(GeoColors.Blue, 4, false);
            shortestLine.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            results.MapShapes.Add("ShortestLine", shortestLine);
            string message = "Length of Blue Line is: " + shortestLineResult.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer).ToString() + " KM" + '\n';

            //Split the test line from the left side based on where the shortest line touches it.
            LineBaseShape leftSideOfLineResult = testLine.GetLineOnALine(new PointShape(testLine.Vertices[0]), new PointShape(shortestLineResult.Vertices[0]));

            //Make sure the split was valid and the closest point wasn't at the beginning or end of the line.
            if (leftSideOfLineResult.Validate(ShapeValidationMode.Simple).IsValid)
            {
                MapShape leftSideOfLine = new MapShape(new Feature(leftSideOfLineResult));
                leftSideOfLine.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyle.CreateSimpleLineStyle(GeoColors.Green, 2, false);
                leftSideOfLine.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                results.MapShapes.Add("LeftSideofLine", leftSideOfLine);
                message += "Length of Green Line is: " + leftSideOfLineResult.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer).ToString() + " KM" + '\n';
            }

            //Split the test line from the right side based on where the shortest line touches it.
            LineBaseShape rightSideOfLineResult = testLine.GetLineOnALine(new PointShape(shortestLineResult.Vertices[0]), new PointShape(testLine.Vertices[testLine.Vertices.Count - 1]));

            //Make sure the split was valid and the closest point wasn't at the beginning or end of the line.
            if (rightSideOfLineResult.Validate(ShapeValidationMode.Simple).IsValid)
            {
                MapShape rightSideOfLine = new MapShape(new Feature(rightSideOfLineResult));
                rightSideOfLine.ZoomLevels.ZoomLevel01.DefaultLineStyle    = LineStyle.CreateSimpleLineStyle(GeoColors.Yellow, 2, false);
                rightSideOfLine.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                results.MapShapes.Add("RightSideofLine", rightSideOfLine);
                message += "Length of Yellow Line is: " + rightSideOfLineResult.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer).ToString() + " KM" + '\n';
            }
            //Display the length of each line in kilometers.
            message += "Length of Red Line is: " + testLine.GetLength(GeographyUnit.Meter, DistanceUnit.Kilometer).ToString() + " KM";
            mapView.Refresh();
            MessageBox.Show(message, "Results");
        }
示例#22
0
 /// <summary>
 /// Gets if this is a match.
 /// </summary>
 /// <param name="mapWay">The shape.</param>
 /// <returns>If it is a match.</returns>
 public abstract bool IsMatch(MapShape mapWay);
示例#23
0
 public static void UnSelectShape(MapShape shape)
 {
     shape.StrokeThickness = 0;
 }
示例#24
0
    public static Map GenerateMap(int size, float radius, MapShape shape, TileGeneration generation, int seed)
    {
        Dictionary <string, Location> locations = new Dictionary <string, Location>();
        Dictionary <(int, int), Path> paths     = new Dictionary <(int, int), Path>();
        List <Tile> tiles             = new List <Tile>();
        int         currentLocationId = 0;
        int         currentPathId     = 0;
        int         currentTileId     = 0;

        UnityEngine.Random.InitState(seed);

        // Generate tiles with given map shape
        Vector3[] tileLocations = GenerateTilesOfShape(shape, size, radius);

        // Generate all tiles, locations, and paths
        foreach (Vector3 l in tileLocations)
        {
            // Initialize tile
            Tile tile = new Tile()
            {
                id       = currentTileId,
                position = l,
                value    = UnityEngine.Random.Range(2, 11), // Random number in [2, 10]
            };
            currentTileId++;

            Vector3[] surroundingPoints = MapUtil.HexagonFromPoint(new Vector2(l.x, l.z), radius);
            tile.locations = new Location[surroundingPoints.Length];
            Location startLocation = null;
            Location prevLocation  = null;
            for (int i = 0; i < surroundingPoints.Length; i++)
            {
                Vector3  point    = surroundingPoints[i];
                Location location = null;
                String   pointKey = point.x.ToString("0.000") + "_" + point.z.ToString("0.000");
                if (!locations.ContainsKey(pointKey))
                {
                    // Locatino does not already exist, add it to the dictionary
                    location = new Location()
                    {
                        id       = currentLocationId,
                        position = point,
                        type     = LocationType.Available,
                    };
                    locations.Add(pointKey, location);
                    currentLocationId++;
                }
                else
                {
                    // Location already exist, extract it from the dictionary
                    location = locations[pointKey];
                }

                // Check if the location is the first location of the tile
                if (startLocation == null)
                {
                    startLocation = location;
                }

                // Add path between the previous location
                if (prevLocation != null)
                {
                    // Check if there already is an existing path between the locations
                    if (!paths.ContainsKey((location.id, prevLocation.id)) && !paths.ContainsKey((prevLocation.id, location.id)))
                    {
                        paths.Add((location.id, prevLocation.id), new Path()
                        {
                            id      = currentPathId,
                            between = new Tuple <Location, Location>(location, prevLocation)
                        });
                        currentPathId++;
                    }
                }
                prevLocation      = location;
                tile.locations[i] = location;
            }

            // Add a path between the previous location and the start location
            // Check if there already is an existing path between the locations
            if (!paths.ContainsKey((startLocation.id, prevLocation.id)) && !paths.ContainsKey((prevLocation.id, startLocation.id)))
            {
                paths.Add((startLocation.id, prevLocation.id), new Path()
                {
                    id      = currentPathId,
                    between = new Tuple <Location, Location>(startLocation, prevLocation)
                });
                currentPathId++;
            }
            // Reset the locations
            prevLocation  = null;
            startLocation = null;

            tiles.Add(tile);
        }

        // Generate map tile types
        tiles = GenerateTileTypes(generation, tiles, seed);

        // Convert map attributes to
        Map map = new Map();

        map.AddLocations(locations.Values);
        map.AddTiles(tiles);
        map.AddPaths(paths.Values);
        return(map);
    }
示例#25
0
 /// <summary>
 /// Adds the way to the tree.
 /// </summary>
 /// <param name="mapWay">The map way.</param>
 public void Add(MapShape mapWay)
 {
     this.ways.AddItem(mapWay);
 }
 private void SetDefaultStyle(MapShape shape)
 {
     if (shape is MapLine)
     {
         shape.Style = this.Resources["selectedLineStyle"] as Style;
     }
     else
     {
         shape.Style = this.Resources["defaultPolylineStyle"] as Style;
     }
 }
 private void BringIntoView(MapShape shape)
 {
     LocationRect bestView = this.StateLayer.GetBestView(new object[] { shape });
     RadMap1.SetView(bestView);
 }
        private static Color GetSeatColor(MapShape shape)
        {
            byte red = byte.Parse(shape.ExtendedData.GetValue("RGB0").ToString(), CultureInfo.InvariantCulture);
            byte green = byte.Parse(shape.ExtendedData.GetValue("RGB1").ToString(), CultureInfo.InvariantCulture);
            byte blue = byte.Parse(shape.ExtendedData.GetValue("RGB2").ToString(), CultureInfo.InvariantCulture);

            return Color.FromArgb(255, red, green, blue);
        }
        private void UnselectSeat(MapShape shape, TheatreSeatInfo seatInfo)
        {
            this.selectedSeats.Remove(seatInfo);

            shape.StrokeThickness = 0;
            shape.Stroke = null;
            shape.HighlightFill = null;

            this.ViewModel.IsBuyButtonEnabled = this.selectedSeats.Count > 0;
        }
        private void SelectSeat(MapShape shape, TheatreSeatInfo seatInfo)
        {
            this.selectedSeats.Add(seatInfo);

            shape.StrokeThickness = 1;
            shape.Stroke = ColorizationHelper.SelectedBrush;

            this.ViewModel.IsBuyButtonEnabled = this.selectedSeats.Count > 0;
        }
        private SeatAvailability GetSeatAvailability(MapShape shape)
        {
            int seatId = int.Parse(shape.ExtendedData.GetValue("ID").ToString(), CultureInfo.InvariantCulture);

            return this.ViewModel.GetSeatAvailability(seatId);
        }
        object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            MapShape shape = value as MapShape;

            return(shape != null?Math.Round(GeoUtils.CalculateStrokeLength(shape), 3) + " m" : string.Empty);
        }
 private void SetStyle(MapShape shape,string source)
 {
     shape.Style = Resources[source] as Style;
 }
 private string GetExtendedProperty(MapShape shape, string propertyName)
 {
     return shape.ExtendedData.GetValue(propertyName).ToString();
 }