示例#1
0
 public InfoGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map, EnhancedMapLayer layer)
     : base(geometry, styleSpecification, map, layer)
 {
     //must have at least one EnhancedMapPoint to show label and launch balloon.
     foreach (var mapObject in mapObjects)
     {
         if (mapObject is EnhancedMapPoint)
         {
             var mapPoint = (EnhancedMapPoint)mapObject;
             if (mainPoint == null)
             {
                 mainPoint = mapPoint;
             }
             mapPoint.Balloon += (o, e) => Balloon(this, new BalloonEventArgs {
                 LayerID = layer.ID, ItemID = ItemID
             });
         }
     }
     if (mainPoint == null)
     {
         //TODO: create one, invisible at centre of first object
         var point = geometry.Centroid;
         mainPoint          = createPoint(point, layer);
         mainPoint.Balloon += (o, e) => Balloon(this, new BalloonEventArgs {
             LayerID = layer.ID, ItemID = ItemID
         });
     }
     Selected += InfoGeometry_Selected;
 }
示例#2
0
 public BaseGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map, EnhancedMapLayer layer)
 {
     Geometry           = geometry;
     StyleSpecification = styleSpecification;
     mapInstance        = map;
     mapLayer           = layer;
     mapObjects         = new ObservableCollection <Control>();
     if (mapLayer != null)
     {
         createGeometry(mapLayer, Geometry);
     }
 }
示例#3
0
 private void setStyleOnMapObjects(StyleSpecification styleSpecification)
 {
     foreach (Control mapObject in mapObjects)
     {
         if (mapObject is EnhancedMapPoint)
         {
             ((EnhancedMapPoint)mapObject).GeometryStyle = styleSpecification;
         }
         if (mapObject is EnhancedMapPolyline)
         {
             ((EnhancedMapPolyline)mapObject).GeometryStyle = styleSpecification;
         }
         if (mapObject is EnhancedMapPolygon)
         {
             ((EnhancedMapPolygon)mapObject).GeometryStyle = styleSpecification;
         }
     }
 }
示例#4
0
        public SelectGeometry(IGeometry geometry, StyleSpecification styleSpecification, MapCore map,
                              EnhancedMapLayer layer)
            : base(geometry, styleSpecification, map, layer)
        {
            //default is the inverse of the style colours + 50% larger icon.
            SelectedSpecification                = styleSpecification.Clone();
            SelectedSpecification.IconScale      = styleSpecification.IconScale * 1.5;
            SelectedSpecification.LineColour     = Utilities.InvertColorFromHexString(styleSpecification.LineColour);
            SelectedSpecification.PolyFillColour = Utilities.InvertColorFromHexString(styleSpecification.PolyFillColour);

            foreach (Control mapObject in mapObjects)
            {
                mapObject.MouseLeftButtonDown += SelectGeometry_MouseLeftButtonDown;
                mapObject.MouseEnter          += SelectGeometry_MouseEnter;
                mapObject.MouseLeave          += SelectGeometry_MouseLeave;
            }

            mapObjects.CollectionChanged += mapObjects_CollectionChanged;

            EnableSelection = true;
        }
        private void dataAddedWorker_DoWork(object sender, DoWorkEventArgs args)
        {
            var worker = sender as BackgroundWorker;

            //going to modify the list so can't use a foreach.
            while (true)
            {
                if (layerDataToProcess.Count == 0)
                {
                    break;
                }

                VectorLayerData vectorLayerData = layerDataToProcess[0];
                if (worker != null && worker.CancellationPending)
                {
                    args.Cancel = true;
                    break;
                }

                StyleSpecification style   = Styles[cDefaultStyleID];
                string             styleID = (!string.IsNullOrEmpty(vectorLayerData.Style))
                                     ? vectorLayerData.Style
                                     : LayerDefinition.LayerStyleName;
                if (Styles.ContainsKey(styleID))
                {
                    style = Styles[styleID];
                }
                var wkbReader = new WKBReader(new GeometryFactory(new PrecisionModel(), 4326));
                try
                {
                    IGeometry       geo  = wkbReader.Read(vectorLayerData.Geo);
                    VectorLayerData data = vectorLayerData;
                    Dispatcher.BeginInvoke(delegate
                    {
                        var infogeo = new InfoGeometry(geo, style, MapInstance, this)
                        {
                            Label           = data.Label,
                            LabelVisibility =
                                (LayerDefinition.LabelOn)
                                    ? Visibility.Visible
                                    : Visibility.Collapsed,
                            ItemID          = data.ID,
                            EnableBalloon   = EnableBalloon,
                            EnableSelection = EnableSelection,
                            TimeStamp       = data.TimeStamp,
                        };
                        infogeo.Balloon += (o, e) =>
                        {
                            if (
                                ((InfoGeometry)o).BalloonData.Count ==
                                0)
                            {
                                Commands.LoadBalloonDataCommand.Execute(e, o);
                            }
                        };
                        infogeo.Selected += (o, e) => Commands.ItemSelectedCommand.Execute(o);
                        if (LayerDefinition.PermissionToEdit)
                        {
                            infogeo.Selected += (o, e) => Commands.EditVectorCommand.Execute(o);
                        }
                        mapLayerGeometries.Add(infogeo);
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
                layerDataToProcess.Remove(vectorLayerData);
            }
        }