Ejemplo n.º 1
0
        private WritableLayer GetNodeLayer(IEnumerable <Node2> nodes)
        {
            var layer = new WritableLayer();

            foreach (var node in nodes)
            {
                var feature = new Mapsui.Providers.Feature();
                feature.Geometry = ToMapsuiPoint(node);
                layer.Add(feature);
                _nodes.Add(feature, node);
            }
            return(layer);
        }
Ejemplo n.º 2
0
        private async Task Load()
        {
            var service = new EpanetService();

            service.InpPath = @"Samples\INP(Dr-누수량배분-연결요소수정).inp";
            service.Run();

            var nodeLayer = new WritableLayer()
            {
                Style = GetNodeLayerStyle()
            };
            var linkLayer = new WritableLayer()
            {
                Style = GetLinkLayerStyle()
            };

            foreach (var node in service.Nodes)
            {
                var point   = new Mapsui.Geometries.Point(node.X, node.Y);
                var feature = new Mapsui.Providers.Feature();
                feature.Geometry = point;
                nodeLayer.Add(feature);
            }

            foreach (var link in service.Links)
            {
                var vertices = new List <Mapsui.Geometries.Point>();
                vertices.Add(new Mapsui.Geometries.Point(link.Node1.X, link.Node1.Y));
                foreach (var v in link.Vertices)
                {
                    vertices.Add(new Mapsui.Geometries.Point(v.X, v.Y));
                }
                vertices.Add(new Mapsui.Geometries.Point(link.Node2.X, link.Node2.Y));
                var lineString = new Mapsui.Geometries.LineString(vertices);
                var feature    = new Mapsui.Providers.Feature();
                feature.Geometry = lineString;
                linkLayer.Add(feature);
            }

            mapControl.Map.Layers.Add(nodeLayer);
            mapControl.Map.Layers.Add(linkLayer);

            var p = (Mapsui.Geometries.Point)nodeLayer.GetFeatures().First().Geometry;

            mapControl.Navigator.NavigateTo(p, 11);

            await Animation(service, nodeLayer);
        }
Ejemplo n.º 3
0
        private Mapsui.Layers.MemoryLayer GetLabelLayer(Dictionary <MapPinType, MapPinCollection> worldpindata)
        {
            Mapsui.Layers.MemoryLayer _pointlayer = new Mapsui.Layers.MemoryLayer {
                Style = null
            };
            List <Mapsui.Geometries.Point> _points = new List <Mapsui.Geometries.Point>();
            MapPinType pintype        = worldpindata.Keys.ToList().Where(item => item.InternalName == "RoadSign").FirstOrDefault();
            string     path           = Path.Combine(appdir, largeiconpath, pintype.IconFile);
            var        memoryProvider = new Mapsui.Providers.MemoryProvider();

            //Load the image if needed
            if (!IconCache.ContainsKey(path))
            {
                using (FileStream fs = new FileStream(path, FileMode.Open))
                {
                    MemoryStream ms = new MemoryStream();
                    fs.CopyTo(ms);
                    int id = BitmapRegistry.Instance.Register(ms);
                    IconCache[path] = id;
                }
            }

            foreach (MapPin c in worldpindata[pintype].Locations)
            {
                var feature = new Mapsui.Providers.Feature
                {
                    Geometry = CurrentConvertor.ToWorldSpace(c.Location),
                };
                feature.Styles.Add(new LabelStyle
                {
                    Text               = BreakLines(c.Name, 17),
                    ForeColor          = Color.White,
                    BackColor          = new Brush(Color.Gray),
                    Halo               = new Pen(Color.Black, 2),
                    VerticalAlignment  = LabelStyle.VerticalAlignmentEnum.Bottom,
                    Offset             = new Offset(0, 14),
                    CollisionDetection = false
                });
                feature.Styles.Add(new SymbolStyle {
                    BitmapId = IconCache[path]
                });
                memoryProvider.Features.Add(feature);
            }
            _pointlayer.DataSource = memoryProvider;
            return(_pointlayer);
        }
Ejemplo n.º 4
0
        private WritableLayer GetLinkLayer(IEnumerable <Link> links)
        {
            var layer = new WritableLayer();

            foreach (var link in links)
            {
                var vertices = new List <Mapsui.Geometries.Point>();
                vertices.Add(ToMapsuiPoint(link.FirstNode));
                foreach (var v in link.Vertices)
                {
                    vertices.Add(ToMapsuiPoint(v));
                }
                vertices.Add(ToMapsuiPoint(link.SecondNode));
                var lineString = new Mapsui.Geometries.LineString(vertices);
                var feature    = new Mapsui.Providers.Feature();
                feature.Geometry = lineString;
                layer.Add(feature);
                _links.Add(feature, link);
            }
            return(layer);
        }
Ejemplo n.º 5
0
        }     // End Sub Main

        private static Mapsui.Layers.MemoryLayer CreatePointLayer()
        {
            var random   = new System.Random();
            var features = new Mapsui.Providers.Features();

            for (var i = 0; i < 100; i++)
            {
                var feature = new Mapsui.Providers.Feature
                {
                    Geometry = new Mapsui.Geometries.Point(random.Next(100000, 5000000), random.Next(100000, 5000000))
                };
                features.Add(feature);
            } // Next i


            var provider = new Mapsui.Providers.MemoryProvider(features);

            return(new Mapsui.Layers.MemoryLayer {
                DataSource = provider
            });
        }