示例#1
0
        private void layerList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            curLayer = layerList.SelectedItem as GisSmartTools.Support.Layer;
            if (curLayer.style != null)
            {
                rulelist = curLayer.style.rulelist;
            }
            else
            {
                GisSmartTools.Support.Style newsimplestyle = GisSmartTools.Support.Style.createSimpleStyle(curLayer.featuresource);
                rulelist = newsimplestyle.rulelist;
            }
            featuresource = curLayer.featuresource;
            Schema schema = featuresource.schema;

            this.geotype = schema.geometryType;
            SetSelectedStyleType(curLayer.style.styletype, this.geotype, curLayer.style, curLayer.featuresource);

            //fieldList.ItemsSource = curLayer.GetFields();
            fieldList.ItemsSource = schema.fields.Keys.ToList();

            //foreach (string attributename in schema.fields.Keys)
            //{
            //    FieldDefn field = null;
            //    if (schema.fields.TryGetValue(attributename, out field))
            //    {
            //        if (field.GetFieldType() == FieldType.OFTReal || field.GetFieldType() == FieldType.OFTInteger)
            //            fieldList.Items.Add(attributename);
            //    }

            //}
        }
示例#2
0
        //文本注记
        private void btnMapLable_Click(object sender, RoutedEventArgs e)
        {
            GisSmartTools.Support.Layer curLayer = mapControl.focuslayer;
            if (curLayer == null)
            {
                curLayer = mapControl.mapcontent.layerlist[0];
            }
            SelectField form = new SelectField(curLayer.featuresource.schema.fields.Keys.ToList());

            if (form.ShowDialog() == true)
            {
                GisSmartTools.Support.Style style = curLayer.style;
                PortableFontDesc            font  = new PortableFontDesc();
                if (form.font != null)
                {
                    double size     = form.font.Size;
                    string fontname = form.font.Family.Source;
                    bool   italic   = false;
                    bool   bold     = false;
                    if (form.font.Style != FontStyles.Normal)
                    {
                        italic = true;
                    }
                    if (form.font.Weight != FontWeights.Normal)
                    {
                        bold = true;
                    }
                    font = new PortableFontDesc(name: fontname, emsize: (int)size, isbold: bold, isitalic: italic, cleartype: false);
                }

                foreach (var rule in style.rulelist)
                {
                    textsymbolizer sym = (textsymbolizer)rule.textsymbolizer;
                    sym.visible       = form.Checked;
                    sym.attributename = form.field;
                    if (form.font != null)
                    {
                        sym.color = form.font.BrushColor.Color;
                        sym.font  = font;
                    }
                }
                if (style.rulelist.Count == 0)
                {
                    var            rule = style.defaultRule;
                    textsymbolizer sym  = (textsymbolizer)rule.textsymbolizer;
                    sym.visible       = form.Checked;
                    sym.attributename = form.field;
                    if (form.font != null)
                    {
                        sym.color = form.font.BrushColor.Color;
                        sym.font  = font;
                    }
                }
                mapControl.mapcontrol_refresh();
                //curLayer.IsLabelShown = true;
                //curLayer.LabelField = form.field;
                //mapControl.Refresh();
            }
        }