Наследование: System.Windows.DependencyObject, INotifyPropertyChanged
Пример #1
0
 /// <summary>${WP_mapping_UniqueRender_method_getStyle_D}</summary>
 /// <returns>${WP_mapping_UniqueRender_method_getStyle_return}</returns>
 /// <param name="feature">${WP_mapping_UniqueRender_method_getStyle_param_feature}</param>
 public SuperMap.WindowsPhone.Core.Style GetStyle(Feature feature)
 {
     if (feature != null && !string.IsNullOrEmpty(this.Attribute) && feature.Attributes.ContainsKey(this.Attribute))
     {
         object obj = feature.Attributes[this.Attribute];
         foreach (UniqueItem item in this.Items)
         {
             if ((item.Value == obj) || (((obj != null) && (item.Value != null)) && (obj.GetHashCode() == item.Value.GetHashCode())))
             {
                 if (item.Style != null)
                 {
                     return item.Style;
                 }//设Value了但没有设置Style,返回default
                 else
                 {
                     return DefaultStyle;
                 }
             }
         }
         return DefaultStyle;
     }
     else
     {
         return null;//Attribute属性没有设置,或者设错了。
     }
 }
Пример #2
0
 /// <summary>${WP_mapping_RangeRender_method_getStyle_D}</summary>
 /// <returns>${WP_mapping_RangeRender_method_getStyle_return}</returns>
 /// <param name="feature">${WP_mapping_RangeRender_method_getStyle_param_feature}</param>
 public SuperMap.WindowsPhone.Core.Style GetStyle(Feature feature)
 {
     if (feature != null && !string.IsNullOrEmpty(this.Attribute) && feature.Attributes.ContainsKey(this.Attribute))
     {
         double num;
         object obj = feature.Attributes[this.Attribute];
         if (double.TryParse(string.Format(CultureInfo.InvariantCulture, "{0}", new object[] { obj }), NumberStyles.Any, CultureInfo.InvariantCulture, out num))
         {
             foreach (RangeItem item in this.Items)
             {
                 if ((num >= item.MinimumValue) && (num < item.MaximumValue))
                 {
                     if (item.Style != null)
                     {
                         return item.Style;
                     }
                     else
                     {
                         return DefaultStyle;
                     }
                 }
             }
             return DefaultStyle;
         }
         else
         {
             return null;
         }
     }
     else
     {
         return null;
     }
 }
Пример #3
0
        public FeatureElement(Feature f, IRenderer renderer)
        {
            this.ClipBox = Rectangle2D.Empty;
            this.pathIsInvalid = true;
            if (f == null)
            {
                throw new ArgumentNullException("f");
            }
            this.feature = new WeakReference(f);
            if (renderer != null)
            //if (renderer != null && (f.GetValue(Clusterer.ClusterProperty) == null))
            {
                this.GeoStyle = renderer.GetStyle(f) ?? generateDefaultSyle(f);
            }//renderer的优先级高于Feature自我的
            else
            {
                this.GeoStyle = f.Style ?? generateDefaultSyle(f);
            }
            f.SetBoundedStyle(this.GeoStyle);

            if (this.GeoStyle != null)
            {
                base.Template = this.GeoStyle.ControlTemplate;
            }

            this.Geometry = f.Geometry;
        }
Пример #4
0
 /// <summary>${WP_mapping_UniformRenderer_method_GetStyle_D}</summary>
 /// <returns>${WP_mapping_UniformRenderer_method_GetStyle_return}</returns>
 /// <param name="feature">${WP_mapping_UniformRenderer_method_GetStyle_param_feature}</param>
 public SuperMap.WindowsPhone.Core.Style GetStyle(Feature feature)
 {
     if (feature == null)
     {
         return null;
     }
     if (feature.Geometry is GeoPoint)
     {
         return MarkerStyle;
     }
     else if (feature.Geometry is GeoLine)
     {
         return LineStyle;
     }
     return this.FillStyle;
 }
Пример #5
0
        /// <summary>${WP_mapping_FeaturesClusterer_method_OnCreateFeature_D}</summary>
        /// <param name="cluster">${WP_mapping_FeaturesClusterer_method_OnCreateFeature_param_cluster}</param>
        /// <param name="center">${WP_mapping_FeaturesClusterer_method_OnCreateFeature_param_center}</param>
        /// <param name="maxClusterCount">${WP_mapping_FeaturesClusterer_method_OnCreateFeature_param_maxClusterCount}</param>
        protected override Feature OnCreateFeature(FeatureCollection cluster, GeoPoint center, int maxClusterCount)
        {
            lastFC = cluster;
            lastCenter = center;
            lastMaxClusterCount = maxClusterCount;

            if (cluster.Count == 1)
            {
                return cluster[0];
            }
            Feature feature = null;
            double size = (Math.Log((double)(cluster.Count / 10)) * 10.0) + 20.0;//小于10个,size都是负无穷
            if (size < 12.0)
            {
                size = 12.0;
            }
            if (cluster.Count <= this.MaximumCount)
            {
                if (!this.cache.ContainsKey(cluster.Count))
                {
                    ScatterStyle style = new ScatterStyle(cluster.Count, EnableRotation)
                    {
                        ForeColor = this.Foreground,
                        FillColor = this.Background
                    };
                    this.cache.Add(cluster.Count, style);
                }//如果没有这种 样式,就创建新的样式。 根据Count决定。
                ScatterStyle style3 = this.cache[cluster.Count];
                feature = new Feature
                {
                    Geometry = center,
                    Style = style3
                };
            }
            else
            {
                feature = new ClusterFeature(size)
                {
                    Geometry = center
                };
            }//如果不达到聚合数(太多,比如大于10),则去生成新的样式
            feature.Attributes.Add("Count", cluster.Count);
            feature.Attributes.Add("Size", size);
            feature.Attributes.Add("Color", ClusterUtil.InterpolateColor((double)cluster.Count, maxClusterCount, this.Gradient));
            return feature;
        }
Пример #6
0
 //当线对象时,显示bounds的中心点;
 private void addCenterFeature(Feature feature)
 {
     GeoPoint center = new GeoPoint(feature.Geometry.Bounds.Center.X , feature.Geometry.Bounds.Center.Y);
     hoverCenterFeature = new Feature { Geometry = center , Style = HoverCenterStyle };
     hoverCenterFeature.SetZIndex(3);
     hoverLayer.AddFeature(hoverCenterFeature);
 }
 internal FeatureMouseEventArgs(Feature f, MouseEventArgs args)
 {
     Feature = f;
     source = args;
 }
Пример #8
0
 private void startEdit(Feature feature , bool suppressEvent , Point2D start)
 {
     if (activeFeature != feature)
     {
         StopEdit();
         activeFeature = feature;
         buildHoverLayer(activeFeature);
         if (!suppressEvent)
         {
             OnGeometryEdit(activeFeature , GeometryEditAction.EditStarted);
         }
     }
     else if (activeFeature.Geometry is GeoRegion && !start.IsEmpty)
     {
         prepareMoveLineOrRegionFeature(start);
     }//表明移动整个要素
 }
Пример #9
0
        //添加虚拟线;
        private void addHoverLineSegment(Point2D p0 , Point2D p1 , int index0 , int index1 , Feature feature , Point2DCollection points , int partIndex)
        {
            GeoLine line = new GeoLine();
            line.Parts.Add(new Point2DCollection() { p0 , p1 });
            Feature segment = new Feature() { Geometry = line , Style = hoverLineStyle };
            segment.SetZIndex(1);

            segment.Attributes.Add("Point2DCollection" , points);
            segment.Attributes.Add("Feature" , feature);
            segment.Attributes.Add("Index0" , index0);
            segment.Attributes.Add("Index1" , index1);
            segment.Attributes.Add("PartIndex" , partIndex);

            hoverLayer.Features.Add(segment);
        }
Пример #10
0
        private void Init(Point2D firstPoint)
        {
            if (_isInited)
            {
                return;
            }
            Deactivate();
            _line = new Feature();
            GeoLine line = new GeoLine();
            line.Parts = new System.Collections.ObjectModel.ObservableCollection<Point2DCollection>();
            line.Parts.Add(_points);
            PredefinedLineStyle style = new PredefinedLineStyle();
            style.Stroke = new SolidColorBrush(Colors.Red);
            style.StrokeThickness = 2;
            style.Symbol = PredefinedLineStyle.LineSymbol.Solid;
            _line.Geometry = line;
            _line.Style = style;
            _fLayer.AddFeature(_line);

            TextBlock first = new TextBlock();
            _distanceList.Add(first);
            first.FontWeight = FontWeights.ExtraBlack;
            first.Foreground = new SolidColorBrush(Colors.Black);
            first.Text = "起点";
            _eLayer.AddChild(first, firstPoint);
            _points.Add(firstPoint);
            _distances.Add(0);
            _isInited = true;
        }
Пример #11
0
 //添加虚拟顶点;
 private Feature addHoverVertex(Feature feature , GeoPoint p , int index , int partIndex)
 {
     Feature hoverVertex = new Feature() { Geometry = p , Style = HoverVertexStyle };
     hoverVertex.SetZIndex(2);
     hoverLayer.Features.Add(hoverVertex);
     hoverVertex.Attributes.Add("Feature" , feature);
     hoverVertex.Attributes.Add("Index" , index);
     hoverVertex.Attributes.Add("PartIndex" , partIndex);
     hoverVertex.AddDoubleClick((s , e) => { deleteOneVertex(s as Feature); });//双击删除某个顶点,线和面。
     return hoverVertex;
 }
Пример #12
0
 private void CompassButton_Click_1(object sender, RoutedEventArgs e)
 {
     if (_canPan)
     {
         _canPan = false;
         Point2D pointLonLat = new Point2D(102.95, 30.3);
         Point2D pointM = MercatorUtility.LatLonToMeters(pointLonLat);
         MyMap.ZoomToLevel(8, pointM);
         Feature earthquake = new Feature();
         earthquake.Style = App.Current.Resources["MyMarkerStyle"] as MarkerStyle;
         earthquake.Geometry = new GeoPoint(pointM);
         _fLayer.AddFeature(earthquake);
         _addFeature = new DispatcherTimer();
         _addFeature.Interval = new TimeSpan(0, 0, 0, 0, 500);
         _addFeature.Tick += _addFeature_Tick;
         _addFeature.Start();
     }
 }
Пример #13
0
 private void virtualLayer_MouseLeave(object sender , FeatureMouseEventArgs args)
 {
     if (snapVertex != null)
     {
         hoverLayer.Features.Remove(snapVertex);
         snapVertex = null;
     }
 }
Пример #14
0
 private void stopEdit(bool suppressEvent)
 {
     if (hoverLayer != null)
     {
         hoverLayer.ClearFeatures();
         Map.Layers.Remove(hoverLayer);
         hoverLayer.MouseLeftButtonDown -= virtualLayer_MouseLeftButtonDown;
         hoverLayer.MouseMove -= virtualLayer_MouseMove;
         hoverLayer.MouseLeftButtonUp -= virtualLayer_MouseLeftButtonUp;
         hoverLayer.MouseLeave -= virtualLayer_MouseLeave;
         hoverLayer = null;
     }
     stopTracking();
     if (!suppressEvent && activeFeature != null)
     {
         OnGeometryEdit(activeFeature , GeometryEditAction.EditCompleted);
     }
     if (activeFeature != null)
     {
         activeFeature = null;
     }
 }
Пример #15
0
        //public static ServerStyle StyleToServerStyle(SuperMap.WindowsPhone.Core.Style Style)
        //{
        //    return null;
        //}

        /// <summary>${WP_REST_Bridge_method_ToFeature}</summary>
        /// <param name="feature">${WP_REST_Bridge_method_ToFeature_param_feature}</param>
        /// <returns>${WP_REST_Bridge_method_ToFeature_return}</returns>
        public static Feature ToFeature(this ServerFeature feature)
        {
            if (feature != null)
            {
                Feature f = new Feature();
                if (feature.Geometry != null)
                {
                    f.Geometry = feature.Geometry.ToGeometry();
                }
                if (feature.FieldNames != null && feature.FieldNames.Count > 0 && feature.FieldValues != null && feature.FieldValues.Count > 0)
                {

                    for (int i = 0; i < feature.FieldNames.Count; i++)
                    {
                        f.Attributes.Add(feature.FieldNames[i].ToString(), feature.FieldValues[i]);
                    }
                }
                return f;
            }
            return null;
        }
Пример #16
0
 private void prepareMovePointFeature(Feature hoverFeature)
 {
     draggingVertex = hoverFeature;
     draggingVertex.Select();
     startTracking();
     startGeoPoint = ( hoverFeature.Geometry as GeoPoint ).Location;
 }
Пример #17
0
        private void addOneVertex(Feature hoverFeature , Point2D pMap)
        {
            GeoLine line = hoverFeature.Geometry as GeoLine;
            Point2DCollection pnts = hoverFeature.Attributes["Point2DCollection"] as Point2DCollection;
            Feature parent = hoverFeature.Attributes["Feature"] as Feature;
            int _partIndex = (int)hoverFeature.Attributes["PartIndex"];
            if (snapVertex != null)
            {
                hoverLayer.Features.Remove(snapVertex);
            }

            Point2D snapPt = FindPointOnLineClosestToPoint(line.Parts[0][0] , line.Parts[0][1] , pMap);
            int index = pnts.IndexOf(line.Parts[0][0]);
            pnts.Insert(index + 1 , snapPt);
            hoverLayer.Features.Remove(hoverFeature);

            rebuildHoverLayer(parent);
            OnGeometryEdit(hoverFeature , GeometryEditAction.VertexAdded);
        }
Пример #18
0
 private void virtualLayer_MouseMove(object sender , FeatureMouseEventArgs args)
 {
     Feature hoverFeature = args.Feature;
     //在虚拟线上,并且没遇到虚拟顶点 ,显示捕捉点
     if (draggingVertex == null && hoverFeature.Geometry is GeoLine)
     {
         GeoLine line = hoverFeature.Geometry as GeoLine;
         Point2D pMap = Map.ScreenToMap(args.GetPosition(Map));
         Point2D snap = FindPointOnLineClosestToPoint(line.Parts[0][0] , line.Parts[0][1] , pMap);
         if (snapVertex == null)
         {
             snapVertex = new Feature() { Style = SnapStyle , Geometry = new GeoPoint(snap) };
             hoverLayer.Features.Add(snapVertex);
         }
         else
         {
             snapVertex.Geometry = new GeoPoint(snap);
         }
     }
 }
Пример #19
0
        //public FeatureElement(Feature f, IRenderer renderer, bool _ignoreMouseEvent)
        //{
        //    this.ClipBox = Rectangle2D.Empty;
        //    this.pathIsInvalid = true;
        //    if (f == null)
        //    {
        //        throw new ArgumentNullException("f");
        //    }
        //    this.feature = new WeakReference(f);

        //    if (renderer != null && (f.GetValue(Clusterer.ClusterProperty) == null))
        //    {
        //        this.GeoStyle = renderer.GetStyle(f) ?? generateDefaultSyle(f);
        //    }//renderer的优先级高于Feature自我的
        //    else
        //    {
        //        this.GeoStyle = f.Style ?? generateDefaultSyle(f);
        //    }
        //    f.SetBoundedStyle(this.GeoStyle);

        //    if (this.GeoStyle != null)
        //    {
        //        base.Template = this.GeoStyle.ControlTemplate;
        //    }
        //    this.ignoreMouseEvents = _ignoreMouseEvent;

        //    this.Geometry = f.Geometry;
        //}

        //internal static FeatureElement DrawShape(Feature feature, IRenderer renderer)
        //{
        //    SuperMap.WindowsPhone.Core.Geometry geometry = feature.Geometry;
        //    FeatureElement element = new FeatureElement(feature, renderer);
        //    if (geometry is GeoPoint && element.GeoStyle is MarkerStyle)
        //    {
        //        MarkerStyle style = (MarkerStyle)(element.GeoStyle);
        //        element.RenderTransform = new TranslateTransform { X = -style.OffsetX, Y = -style.OffsetY };
        //    }
        //    else if (geometry is GeoLine && element.GeoStyle is LineStyle)
        //    {
        //        element.SetPath();
        //    }
        //    else if (geometry is GeoRegion && element.GeoStyle is FillStyle)
        //    {
        //        element.SetPath();
        //    }
        //    else
        //    {
        //        throw new ArgumentException(ExceptionStrings.InvalidSupportGeometry);
        //    }
        //    return element;
        //}

        private static Style generateDefaultSyle(Feature f)
        {
            if (f.Geometry is GeoPoint)
            {
                Style pmstyle = null;
                if (f.Layer.Map.Theme == null)
                {
                    pmstyle = new PredefinedMarkerStyle() { Color = new SolidColorBrush(Colors.Red), Size = 10 };
                }
                else
                {
                    pmstyle = new PredefinedMarkerStyle() { Color = f.Layer.Map.Theme.Color, Size = f.Layer.Map.Theme.Size };
                }
                return pmstyle;
            }
            else if (f.Geometry is GeoLine)
            {
                Style plstyle = null;
                if (f.Layer.Map.Theme == null)
                {
                    plstyle = new PredefinedLineStyle() { Stroke = new SolidColorBrush(Color.FromArgb(99, 255, 0, 0)), StrokeThickness = 2 };
                }
                else
                {
                    plstyle = new PredefinedLineStyle() { Stroke = f.Layer.Map.Theme.Stroke, StrokeThickness = f.Layer.Map.Theme.StrokeThickness };
                }
                return plstyle;
            }
            else
            {
                Style pfstyle = null;
                if (f.Layer.Map.Theme == null)
                {
                    pfstyle = new FillStyle() { Fill = new SolidColorBrush(Color.FromArgb(99, 255, 0, 0)) };
                }
                else
                {
                    pfstyle = new FillStyle() { Fill = f.Layer.Map.Theme.Fill, Stroke = f.Layer.Map.Theme.Stroke };
                }
                return pfstyle;
            }
        }
Пример #20
0
        //private void Button_Click_3(object sender, RoutedEventArgs e)
        //{
        //    DrawLine line = new DrawLine(this.MyMap);
        //    this.MyMap.Action = line;
        //   // this.featuresLayer.ClearFeatures();
        //    line.DrawCompleted += new EventHandler<DrawEventArgs>(line_DrawCompleted);
        //}

        //private void line_DrawCompleted(object sender, DrawEventArgs e)
        //{
        //    this.featuresLayer.ClearFeatures();
        //    Feature feature = new Feature { Geometry=e.Geometry};
        //    //this.elementLayer.Children.Add(e.Element);
        //    this.featuresLayer.AddFeature(feature);
        //}

        //private void Button_Click_4(object sender, RoutedEventArgs e)
        //{
        //    DrawPolygon polygon = new DrawPolygon(this.MyMap);
        //    this.MyMap.Action = polygon;
        //    polygon.DrawCompleted += new EventHandler<DrawEventArgs>(polygon_DrawCompleted);

        //}

        //private void polygon_DrawCompleted(object sender, DrawEventArgs e)
        //{
        //    this.featuresLayer.ClearFeatures();
        //    Feature feature = new Feature { Geometry=e.Geometry};
        //    this.featuresLayer.AddFeature(feature);
        //}

        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            Feature f = new Feature();
            //f.Tap += f_Tap;
            //f.MouseEnter += f_MouseEnter;
            //f.MouseLeave += f_MouseLeave;
            //f.MouseLeftButtonDown += f_MouseLeftButtonDown;
            //f.MouseLeftButtonUp += f_MouseLeftButtonUp;
            //f.MouseMove+=f_MouseMove;   
            GeoPoint point = new GeoPoint(0, 0);
            PredefinedMarkerStyle style = new PredefinedMarkerStyle();
            style.Color = new SolidColorBrush(Colors.Red);
            style.Size = 80;
            style.Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle;
            f.Geometry = point;
            f.Style = style;
            this.featuresLayer.AddFeature(f);
        }
Пример #21
0
        private void stopTracking( )
        {
            Map.Cursor = Cursors.Arrow;
            startGeoPoint = Point2D.Empty;
            startPoint = Point2D.Empty;
            lastPostion = Point2D.Empty;

            if (draggingVertex != null)
            {
                draggingVertex.UnSelect();
                draggingVertex = null;
                if (activeFeature != null && activeFeature.Geometry is GeoPoint)
                {
                    StopEdit();
                }
            }
        }
Пример #22
0
 //重新构建整个虚拟图层,比如添加或删除一个顶点时
 private void rebuildHoverLayer(Feature feature)
 {
     stopEdit(true);
     startEdit(feature , true);
 }
 internal FeatureMouseButtonEventArgs(Feature f, MouseButtonEventArgs e)
     : base(f, e)
 {
     this.source = e;
 }
Пример #24
0
        private void deleteOneVertex(Feature hoverVertex)
        {
            Feature parent = hoverVertex.Attributes["Feature"] as Feature;
            Point2DCollection points = hoverVertex.Attributes["Point2DCollection"] as Point2DCollection;
            int index = (int)hoverVertex.Attributes["Index"];
            if (parent.Geometry is GeoRegion && points.Count < 5)
            {
                return;
            }
            if (parent.Geometry is GeoLine && points.Count < 3)
            {
                return;
            }
            if (parent.Geometry is GeoRegion && index == 0)
            {
                points.RemoveAt(points.Count - 1);
                points.Add(points[1]);
            }//特殊处理下第1个/最后1个点删除
            points.RemoveAt(index);

            rebuildHoverLayer(parent);
            OnGeometryEdit(hoverVertex , GeometryEditAction.VertexRemoved);
        }
Пример #25
0
        /// <summary>${WP_core_Feature_method_Clone_D}</summary>
        public Feature Clone()
        {
            Feature fClone = new Feature();
            fClone.Geometry = this.Geometry.Clone();
            fClone.Style = this.Style;
            fClone.ToolTip = this.ToolTip;
            fClone.DisableToolTip = this.DisableToolTip;
            fClone.Attributes = this.Attributes;

            return fClone;
        }
Пример #26
0
 private void OnGeometryEdit(Feature f , GeometryEditAction action)
 {
     if (GeometryEdit != null)
     {
         GeometryEdit(this , new GeometryEditEventArgs(f , action));
     }
 }
Пример #27
0
 void MyMap_ViewBoundsChanged(object sender, ViewBoundsEventArgs e)
 {
     if (!_mapInited && !Rectangle2D.IsNullOrEmpty(e.NewViewBounds))
     {
         _mapInited = true;
         MyMap.ZoomToLevel(8, new Point2D(12969134.4929308, 4863396.19924929));
         _compassFeature = new Feature();
         _compassFeature.Geometry = new GeoPoint(Point2D.Empty);
         CompassMarkerStyle style = new CompassMarkerStyle();
         style.Height = 40;
         style.Width = 30;
         style.Rotation = 0;
         _compassFeature.Style = style;
         _fLayer.AddFeature(_compassFeature);
         _needPan = true;
         _watcher.Start();
     }
 }
Пример #28
0
 internal GeometryEditEventArgs(Feature feature , GeometryEditAction action)
 {
     Feature = feature;
     Action = action;
 }
Пример #29
0
 public override void Deactivate()
 {
     if (_distanceList != null && _distanceList.Count > 0)
     {
         foreach (TextBlock text in _distanceList)
         {
             if (_eLayer.Children.Contains(text))
             {
                 _eLayer.Children.Remove(text);
             }
         }
         _distanceList.Clear();
     }
     if (_line != null)
     {
         if (_fLayer.Features.Contains(_line))
         {
             _fLayer.Features.Remove(_line);
         }
         _line = null;
     }
     if (_points != null && _points.Count > 0)
     {
         _points.Clear();
     }
     _distances.Clear();
 }
Пример #30
0
 private void startEdit(Feature feature , bool suppressEvent)
 {
     startEdit(feature , suppressEvent , Point2D.Empty);
 }