Пример #1
0
        public void NewNodeToolShouldWorkWithoutSnapRules()
        {
            // Create map and map control
            Map map = new Map();
            var nodeList = new List<Node>();

            var nodeLayer = new VectorLayer
                {
                    DataSource = new FeatureCollection(nodeList, typeof (Node)),
                    Visible = true,
                    Style = new VectorStyle
                        {
                            Fill = new SolidBrush(Color.Tomato),
                            Symbol = null,
                            Line = new Pen(Color.Turquoise, 3)
                        }
                };
            map.Layers.Add(nodeLayer);

            var mapControl = new MapControl {Map = map};
            mapControl.Resize += delegate { mapControl.Refresh(); };
            mapControl.Dock = DockStyle.Fill;

            var newNodeTool = new NewNetworkFeatureTool(l => true, "new node");
            mapControl.Tools.Add(newNodeTool);

            var args = new MouseEventArgs(MouseButtons.Left, 1, -1, -1, -1);

            newNodeTool.OnMouseDown(new Coordinate(0, 20), args);
            newNodeTool.OnMouseMove(new Coordinate(0, 20), args);
            newNodeTool.OnMouseUp(new Coordinate(0, 20), args);

            Assert.IsFalse(newNodeTool.IsBusy);
            Assert.AreEqual(1, nodeList.Count);
        }
Пример #2
0
        private void AddNetworkCoverageAndTool()
        {
            INetworkCoverage networkCoverage = new NetworkCoverage { Network = network };
            networkCoverageGroupLayer.NetworkCoverage = networkCoverage;

            ((FeatureCollection)networkCoverageGroupLayer.LocationLayer.DataSource).AddNewFeatureFromGeometryDelegate =
                AddFeatureFromGeometryDelegate;

/* no references to DeltaShell, TODO: move LayerPropertiesEditor into SharpMap.UI
            mapControl.MouseDoubleClick += delegate
            {
                var dialog = new LayerPropertiesEditorDialog(networkCoverageLayer.SegmentLayer);
                dialog.Show(mapControl);
            };
*/

            mapControl.Map.Layers.Add(networkCoverageGroupLayer);

            var networkCoverageTool = new NewNetworkFeatureTool(l => l.Equals(networkCoverageGroupLayer.LocationLayer), "new location");
            mapControl.Tools.Add(networkCoverageTool);
            
            networkCoverageGroupLayer.LocationLayer.FeatureEditor.SnapRules.Add(new SnapRule
            {
                SnapRole = SnapRole.FreeAtObject,
                Obligatory = true,
                PixelGravity = 40
            });
            return;
        }
Пример #3
0
        private void ADdNewFeature()
        {
            
            var features = new EventedList<TestBranchFeature>(); // ?!?!
            featuresLayer.DataSource = new FeatureCollection {Features = features};
            //featuresLayer.VectorLayer.Name = "culverts"; 
            featuresLayer.Visible = true;
            featuresLayer.Style = new VectorStyle();
            featuresLayer.Style.Fill = new SolidBrush(Color.Tomato);
            featuresLayer.Style.Symbol = null;
            featuresLayer.Style.Line = new Pen(Color.Turquoise, 3);
            mapControl.Map.Layers.Insert(0, featuresLayer);

            //mapControl.SnappingStrategiesByLayer[featuresLayer].Add(
            //    new SnapStrategy(branchLayer, SnapRole.FreeAtObject, 40));

            var newNodeTool = new NewNetworkFeatureTool(l => l.DataSource.FeatureType.IsSubclassOf(typeof(TestBranchFeature)), "add new feature");
            mapControl.Tools.Add(newNodeTool);
        }