Ejemplo n.º 1
0
        public void Flush()
        {
            var lineString = newArrowLineGeometry;

            if (null == lineString)
            {
                return;
            }

            FeatureProvider.Add(lineString);

            StopDrawing();

            IFeature feature = FeatureProvider.GetFeature(FeatureProvider.GetFeatureCount() - 1);

            // hack? sourceLayer doesn't have to be part of a network; thus we are
            // required to force repaint. DataSource has no knowledge of layer.
            Layer.RenderRequired = true;

            if (null != feature)
            {
                MapControl.SelectTool.Select(Layer, feature, 0);
            }

            newArrowLineGeometry = null;
        }
Ejemplo n.º 2
0
        public override void OnMouseUp(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (!isBusy)
            {
                return;
            }
            if (null == snapResult)
            {
                MapControl.SelectTool.Clear();
            }
            else
            {
                GeometryHelper.SetCoordinate(newNode, 0, snapResult.Location);
                FeatureProvider.Add(newNode);

                IFeature feature = FeatureProvider.GetFeature(FeatureProvider.GetFeatureCount() - 1);


                IFeatureEditor featureEditor = MapControl.SelectTool.GetFeatureEditor(Layer, feature);
//if (null != featureEditor)
//{only when move
//    featureEditor.Start();
//    featureEditor.Stop(snapResult);
//}

                Layer.RenderRequired = true;
                MapControl.SelectTool.Select(Layer, feature, 0);
            }
            isBusy = false;
            StopDrawing();
            MapControl.Refresh();
        }
Ejemplo n.º 3
0
        public void Flush()
        {
            ILineString lineString = (ILineString)newLineGeometry[0];

            if (null == lineString)
            {
                return;
            }
            // MouseDoubleClick has added 2 points at the end of the line; remove the last point.
            lineString = RemoveDuplicatePoints(lineString);
            if (null != lineString)
            {
                FeatureProvider.Add(lineString);
            }
            StopDrawing();
            IFeature feature = FeatureProvider.GetFeature(FeatureProvider.GetFeatureCount() - 1);

            // hack? sourceLayer doesn't have to be part of a network; thus we are
            // required to force repaint. DataSource has no knowledge of layer.
            Layer.RenderRequired = true;

            if (null != feature)
            {
                MapControl.SelectTool.Select(Layer, feature, 0);
            }
            newLineGeometry.Clear();
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            Console.WriteLine("What feature is active?");
            IFlagResolver    flagResolver    = new FlagResolver();
            IFeatureProvider featureProvider = new FeatureProvider(flagResolver, "app3");
            var feature = featureProvider.GetFeature();

            feature.Execute();
        }
Ejemplo n.º 5
0
        public override void OnMouseUp(ICoordinate worldPosition, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (newLineGeometry.Count == 0)
            {
                return;
            }

            ISnapResult snapResult = MapControl.SnapTool.ExecuteLayerSnapRules(Layer, null, adding ? newLineGeometry[0] : null,
                                                                               worldPosition,
                                                                               adding ? newLineGeometry[0].Coordinates.Length - 1 : -1);
            IGeometry      defaultGeometry = null;
            IFeatureEditor featureEditor   = MapControl.SelectTool.GetFeatureEditor(Layer, null);

            if (null != featureEditor)
            {
                defaultGeometry = featureEditor.CreateDefaultGeometry(Layer, newLineGeometry[0],
                                                                      (null != snapResult) ? snapResult.NearestTarget : null,
                                                                      (null != snapResult) ? snapResult.Location : null);
                if (null != defaultGeometry)
                {
                    newLineGeometry.Clear();
                    newLineGeometry.Add(defaultGeometry);
                }
            }
            ILineString lineString = (ILineString)newLineGeometry[0];

            if (null == lineString)
            {
                isBusy = false;
                return;
            }
            if (ActualAutoCurve)
            {
                if (null == defaultGeometry)
                {
                    snapResult = Snap(worldPosition);
                    if (null == snapResult)
                    {
                        // hack if obligatory snapping failed mimic result. This is not valid for NewNodeTool
                        // Think of solution within snaprule
                        snapResult = new SnapResult(worldPosition, null, null, -1, -1);
                    }
                    if (TemporalEnd)
                    {
                        GeometryHelper.SetCoordinate(lineString, lineString.Coordinates.Length - 1, snapResult.Location);
                    }
                    else
                    {
                        lineString = AppendCurvePoint(lineString, snapResult.Location);
                    }
                    lineString = RemoveDuplicatePoints(lineString);
                }
                adding             = false;
                newLineGeometry[0] = lineString;
                //Flush();
                SelectTool selectTool = MapControl.SelectTool;

                if (null != lineString && snapResult != null)
                {
                    // TODO: call editor here instead of feature provider
                    int count = FeatureProvider.GetFeatureCount();

                    try
                    {
                        FeatureProvider.Add(lineString); // will add Cross Section and call ConnectCrossSectionToBranch
                    }
                    catch (Exception exception)
                    {
                        // an exception during add operation can fail; for example when adding a branch feature
                        log.Warn(exception.Message);
                        adding = false;
                        StopDrawing();
                        newLineGeometry.Clear();
                        return;
                    }

                    // was adding succesfull?
                    if ((1 + count) == FeatureProvider.GetFeatureCount())
                    {
                        IFeature feature = FeatureProvider.GetFeature(count);
                        //Layer.RenderRequired = true;
                        MapControl.SelectTool.Select(Layer, feature, 0);
                    }
                }
                else
                {
                    // do not add a linestring with zero length
                    selectTool.Clear();
                }
                adding = false;
                StopDrawing();
                newLineGeometry.Clear();
            }
            Layer.RenderRequired = true;
            MapControl.Refresh();
            isBusy = false;
        }