public override void Paint(WriteableBitmap bmp) { cur_y = position.Y; //base.PaintAdditional(g); foreach (Layer layer in mapcontent.layerlist) { if (!layer.visible) { continue; } bmp.DrawString((int)position.X, (int)cur_y, titlecolor, Colors.White, titlefont, layer.Layername); //g.DrawString(layer.Layername, SystemFonts.DefaultFont, Brushes.Black, new Point(position.X, cur_y)); cur_y += 25; GisSmartTools.Support.Style style = layer.style; foreach (RenderRule rule in style.rulelist) { paintRule(bmp, rule, cur_y); cur_y += (20); } if (style.rulelist.Count == 0) { paintRule(bmp, style.defaultRule, cur_y); cur_y += 30; } } }
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); // } //} }
/// <summary> /// 初始化时调用,设置初始的combox的值同时根据styletype初始化对应的styleview /// </summary> /// <param name="type"></param> /// <param name="geotype"></param> /// <param name="style"></param> /// <param name="featuresource"></param> private void SetSelectedStyleType(StyleType type, wkbGeometryType geotype, GisSmartTools.Support.Style style, FeatureSource featuresource) { switch (type) { case StyleType.SIMPLESTYLE: singleRadio.IsChecked = true; break; case StyleType.UNIQUESTYLE: uniqueRadio.IsChecked = true; break; case StyleType.RANKSTYLE: classRadio.IsChecked = true; break; case StyleType.CUSTOMSTYLE: break; } List <RenderRule> rulelist = style.rulelist; if (rulelist.Count != 0) { InitializeList(rulelist); } }
//文本注记 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(); } }
private void end_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e) { ColorPickerDialog picker = new ColorPickerDialog(); Brush brush = end.Fill; picker.StartingColor = GetColor(brush); picker.Owner = this; if (picker.ShowDialog() == true) { end.Fill = new SolidColorBrush(picker.SelectedColor); int classNum = Convert.ToInt32(number.Text); style = GisSmartTools.Support.Style.createRankStyle(featuresource, curField, classNum, GetColor(start.Fill), GetColor(end.Fill)); rulelist = style.rulelist; InitializeList(rulelist); } }
private void btnApply_Click(object sender, RoutedEventArgs e) { GisSmartTools.Support.Style newstyle; if (singleRadio.IsChecked == true) { newstyle = new GisSmartTools.Support.Style(style.name, style.styletype, rulelist[0]); } else { RenderRule defaultrule = style.defaultRule; newstyle = new GisSmartTools.Support.Style(style.name, style.styletype, defaultrule); for (int i = 0; i < list.Count; i++) { RenderRule rule = list[i].rule; newstyle.addRule(rule); } } curLayer.style = newstyle; //if (singleRadio.IsChecked == true) //{ // switch (rulelist[0].geometrysymbolizer.sign) // { // case SymbolizerType.POINT: // break; // case SymbolizerType.LINE: // LineLayer linelayer = (LineLayer)curLayer; // for (int i = 0; i < linelayer.elements.Count; i++) // { // linelayer.elements[i].symbol = (LineSymbol)list[0].symbol; // } // break; // case SymbolizerType.POLYGON: // PolygonLayer polygonlayer = (PolygonLayer)curLayer; // for (int i = 0; i < polygonlayer.elements.Count; i++) // { // polygonlayer.elements[i].symbol = (PolygonSymbol)list[0].symbol; // } // break; // case SymbolizerType.TEXT: // break; // default: // break; // } //} //else if (uniqueRadio.IsChecked == true) //{ // for (int i = 0; i < list.Count; i++) // { // List<int> ids = curLayer.QueryByAttri(curField + "='" + list[i].text + "'"); // curLayer.SetSymbol(ids, list[i].symbol); // } //} //else if (classRadio.IsChecked == true) //{ // for (int i = 0; i < list.Count; i++) // { // string[] values = list[i].text.Split('~'); // List<int> ids = curLayer.QueryByAttri(curField + " >= " + values[0] + " And " + curField + " <= " + values[1]); // curLayer.SetSymbol(ids, list[i].symbol); // } //} map.mapcontrol_refresh(); }
private void fieldList_SelectionChanged(object sender, SelectionChangedEventArgs e) { curField = fieldList.SelectedItem as string; if (singleRadio.IsChecked == true) { style = GisSmartTools.Support.Style.createSimpleStyle(curLayer.featuresource); RenderRule rule = style.defaultRule; rulelist = new List <RenderRule>(); rulelist.Add(rule); InitializeList(rulelist); //list.Clear(); //list.Add(new ColorModel { brush = new SolidColorBrush() , text="All", rule=rule, id = 0}); } else if (uniqueRadio.IsChecked == true) { list.Clear(); style = GisSmartTools.Support.Style.createUniqueValueStyle(featuresource, curField); rulelist = style.rulelist; //List<string> values = curLayer.GetAllValues(curField); InitializeList(rulelist); //for (int i = 0; i < values.Count; i++) //{ // Brush tempBrush = new SolidColorBrush(GetRandomColor()); // PolygonSymbol symbol = new PolygonSymbol(); // symbol.brush = tempBrush; // list.Add(new ColorModel // { // brush = tempBrush, // text = values[i], // symbol = symbol, // id = i // }); //} } else if (classRadio.IsChecked == true) { int classNum = Convert.ToInt32(number.Text); style = GisSmartTools.Support.Style.createRankStyle(featuresource, curField, classNum, new GisSmartTools.Color(255, 254, 240, 217), new GisSmartTools.Color(255, 179, 0, 0)); rulelist = style.rulelist; InitializeList(rulelist); //List<string> values = curLayer.GetAllValues(curField); //List<double> doubles = new List<double>(); //for (int i = 0; i < values.Count; i++) //{ // doubles.Add(Convert.ToDouble(values[i])); //} //double max = doubles.Max(); //double min = doubles.Min(); //double length = (max - min) / classNum; //list.Clear(); //double curValue = min; //for (int i = 0; i < classNum; i++) //{ // Brush tempBrush = new SolidColorBrush(GetRandomColor()); // PolygonSymbol symbol = new PolygonSymbol(); // symbol.brush = tempBrush; // list.Add(new ColorModel // { // brush = tempBrush, // text = curValue.ToString() + "~" + (curValue + length).ToString(), // symbol = symbol, // id = i // }); // curValue += length; //} } }