예제 #1
0
        public MapLayer()
        {
            Features        = new Dictionary <IFeature, Shape>();
            Overlays        = new List <FrameworkElement>();
            LayerStyle      = new VectorStyle();
            LayerLableStyle = new LabelStyle(string.Empty);
            IsLayerVisible  = true;

            //CacheMode = new BitmapCache();
        }
예제 #2
0
        static VectorStyleManager()
        {
            Styles = new Dictionary <string, VectorStyle>();
            foreach (XElement xe in CityGisConfig.XValue.Elements("LayerStyles"))
            {
                foreach (var element in xe.Elements())
                {
                    string layerName = element.AttValue("Layer");

                    VectorStyle vs = new VectorStyle();
                    vs.StrokeWeight = Convert.ToDouble(element.AttValue("StrokeWeight"));
                    vs.SpotSize     = Convert.ToDouble(element.AttValue("SpotSize"));
                    vs.FontSize     = Convert.ToDouble(element.AttValue("FontSize"));

                    var strokeString = element.AttValue("Stroke");
                    if (strokeString.StartsWith("#"))
                    {
                        Color stroke = VectorStyleManager.ParseColor(element.AttValue("Stroke"));
                        vs.Stroke = new SolidColorBrush(stroke);
                    }
                    else if (strokeString == "{ClTheme}")
                    {
                    }
                    var strokeDashString = element.AttValue("StrokeDashArray");
                    if (!string.IsNullOrEmpty(strokeDashString))
                    {
                        vs.StrokeDashArray = new DoubleCollection();
                        strokeDashString.Split(',').ForEach(x => vs.StrokeDashArray.Add(x.TryParseToDouble()));
                    }

                    var fillString = element.AttValue("Fill");
                    if (fillString.StartsWith("#"))
                    {
                        vs.FillTheme = new SingleColorTheme(VectorStyleManager.ParseColor(fillString));
                        Color fill = VectorStyleManager.ParseColor(fillString);
                        vs.Fill = new SolidColorBrush(fill);
                    }
                    else if (fillString == "{MapTheme}")
                    {
                        vs.FillTheme = new MapTheme();
                    }
                    else if (fillString == "{ClTheme}")
                    {
                        vs.FillTheme = new ControlLineTheme();
                    }
                    else if (fillString == "{UnitTheme}")
                    {
                        vs.FillTheme = new UnitTheme();
                    }

                    Color fontbrush = VectorStyleManager.ParseColor(element.AttValue("FontBrush"));
                    vs.FontBrush = new SolidColorBrush(fontbrush);

                    Styles.Add(layerName, vs);
                }
            }

            LabelStyles = new Dictionary <string, LabelStyle>();
            foreach (XElement xe in CityGisConfig.XValue.Elements("LabelStyles"))
            {
                foreach (var element in xe.Elements())
                {
                    string layerName = element.AttValue("Layer");

                    string format = element.AttValue("Format").Replace("\\n", "\n");
                    string linearRepeatInterval = element.AttValue("LinearRepeatInterval");
                    double interval             = 1000;
                    if (linearRepeatInterval != string.Empty)
                    {
                        interval = Convert.ToDouble(linearRepeatInterval);
                    }
                    string     fields = element.AttValue("Fields");
                    LabelStyle ls     = new LabelStyle(format, fields.Split('|'));
                    ls.LinearRepeatInterval = interval;

                    LabelStyles.Add(layerName, ls);
                }
            }
        }