${WP_core_PredefinedMarkerStyle_Title}

${WP_core_PredefinedMarkerStyle_Description}

Inheritance: MarkerStyle
示例#1
0
 private void SetDefaultStyle( )
 {
     HoverVertexStyle = new PredefinedMarkerStyle() { Size = 10 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Square , Color = new SolidColorBrush(Colors.Green) };
     SnapStyle = new PredefinedMarkerStyle() { Size = 12 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Circle , Color = new SolidColorBrush(Colors.LightGray) };
     HoverCenterStyle = new PredefinedMarkerStyle() { Size = 20 , Symbol = PredefinedMarkerStyle.MarkerSymbol.Star , Color = new SolidColorBrush(Colors.Red) };
     hoverLineStyle = new PredefinedLineStyle() { Stroke = new SolidColorBrush(Colors.Transparent) , StrokeThickness = 10 };//Colors.Transparent
 }
        //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);
        }
        //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;
            }
        }