ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
ThinkGeo Cloud
ThinkGeo UI Controls
ThinkGeo Open Source
Help and Support
External Resources
using System; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Threading.Tasks; using System.Windows; namespace FilterStyleSample { /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { } }
using System; using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; using ThinkGeo.MapSuite.Core; using ThinkGeo.MapSuite.WpfDesktopEdition; namespace FilterStyleSample { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private FilterStyle filterStyle; public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { //Initialization the wpf map wpfMap1.CurrentExtent = new RectangleShape(-130.5615234375, 63.193359375, -44.0771484375, 11.337890625); wpfMap1.Overlays.Add(new WorldMapKitWmsWpfOverlay()); LayerOverlay layerOverlay = new LayerOverlay(); wpfMap1.Overlays.Add(layerOverlay); //create a shapefilefeaturelayer from usstate ShapeFileFeatureLayer shpLayer = new ShapeFileFeatureLayer(@"..\..\App_Data\USStates.shp"); layerOverlay.Layers.Add(shpLayer); //add shape file columns to combobox AddColumnItemsFormShapeFile(shpLayer); //add the filter style to wpfmap filterStyle = new FilterStyle(); filterStyle.Conditions.Add(CreateNewFilterCondition()); filterStyle.Styles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(120, GeoColor.StandardColors.Red), GeoColor.SimpleColors.White)); //reset shapefile display style shpLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(filterStyle); shpLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; wpfMap1.Refresh(); } private void btnApply_Click(object sender, RoutedEventArgs e) { //change filterstyle and refresh wpfmap. filterStyle.Conditions.Clear(); filterStyle.Conditions.Add(CreateNewFilterCondition()); wpfMap1.Refresh(); } private FilterCondition CreateNewFilterCondition() { FilterCondition filterCondition = new FilterCondition(); filterCondition.ColumnName = cmbFilterColumnName.SelectedItem.ToString(); filterCondition.Expression = string.Format("{0} {1}", ((ComboBoxItem)cmbFilterCondition.SelectedItem).Content.ToString(), txtFilterValue.Text); return filterCondition; } private void AddColumnItemsFormShapeFile(ShapeFileFeatureLayer shpLayer) { shpLayer.Open(); Collection<FeatureSourceColumn> columns = shpLayer.FeatureSource.GetColumns(); Feature feature = shpLayer.FeatureSource.GetFeatureById("2", ReturningColumnsType.AllColumns); foreach (var column in columns) { double value = 0; if (double.TryParse(feature.ColumnValues[column.ColumnName], out value)) { cmbFilterColumnName.Items.Add(column.ColumnName); } } cmbFilterColumnName.SelectedItem = "POP1990"; } } }