User Tools

Site Tools


source_code_wpf_desktopeditionsample_mapsuiteusearthquakestatistics_cs_141202.zip

Source Code Wpf DesktopEditionSample MapSuiteUsEarthquakeStatistics CS 141202.zip

MainWindow.xaml.cs

 <Window x:Class="ThinkGeo.MapSuite.EarthquakeStatistics.MainWindow"  
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
         xmlns:sys="clr-namespace:System;assembly=mscorlib"  
         xmlns:local="clr-namespace:ThinkGeo.MapSuite.EarthquakeStatistics"  
         xmlns:wpf="clr-namespace:ThinkGeo.MapSuite.WpfDesktopEdition;assembly=WpfDesktopEdition"  
         Title="US Earthquake Statistics"  
         Height="675"  
         Width="1155"  
         WindowState="Maximized"  
         Loaded="MainWindow_Loaded"  
         Icon="/Image/MapSuite.ico">  
     <Window.Resources>  
         <local:TrackModeToImageUriConverter x:Key="TrackModeToImageUriConverter" />  
         <local:TrackModeToToolTipConverter x:Key="TrackModeToToolTipConverter" />  
         <local:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />  
         <local:NameToImageUriConverter x:Key="NameToImageUriConverter" />  
     </Window.Resources>  
 
     <Grid Style="{StaticResource SampleBody}">  
         <Grid.RowDefinitions>  
             <RowDefinition Height="Auto" />  
             <RowDefinition Height="*" />  
             <RowDefinition Height="Auto" />  
         </Grid.RowDefinitions>  
         <Grid Grid.Row="0">  
             <Border BorderThickness="0,0,0,5" Padding="10" CornerRadius="2" KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2">  
                 <Border.Background>  
                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">  
                         <LinearGradientBrush.GradientStops>  
                             <GradientStop Offset="0" Color="#ffffff" />  
                             <GradientStop Offset="0.4" Color="#fafafa" />  
                             <GradientStop Offset="0.55" Color="#f2f2f2" />  
                             <GradientStop Offset="0.6" Color="#f0f0f0" />  
                             <GradientStop Offset="0.9" Color="#e2e2e2" />  
                         </LinearGradientBrush.GradientStops>  
                     </LinearGradientBrush>  
                 </Border.Background>  
                 <Border.BorderBrush>  
                     <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">  
                         <LinearGradientBrush.GradientStops>  
                             <GradientStop Offset="0.85" Color="#5c707d" />  
                             <GradientStop Offset="1" Color="#305c707d" />  
                         </LinearGradientBrush.GradientStops>  
                     </LinearGradientBrush>  
                 </Border.BorderBrush>  
                 <StackPanel Orientation="Horizontal">  
                     <TextBlock Style="{StaticResource ControlFont}" Margin="{StaticResource TitleMargin}">  
                         <Run FontSize="16">Map Suite</Run>  
                         <Run FontSize="20">US Earthquake Statistics</Run>  
                     </TextBlock>  
                 </StackPanel>  
             </Border>  
         </Grid>  
         <Grid Grid.Row="1">  
             <Grid.ColumnDefinitions>  
                 <ColumnDefinition Width="Auto" />  
                 <ColumnDefinition Width="*" />  
             </Grid.ColumnDefinitions>  
             <Grid Grid.Column="0" Grid.Row="0" Margin="5 0 0 0">  
                 <Grid.ColumnDefinitions>  
                     <ColumnDefinition Width="*" />  
                     <ColumnDefinition Width="Auto" />  
                     <ColumnDefinition Width="5" />  
                 </Grid.ColumnDefinitions>  
                 <Grid x:Name="gridDockPanel" Margin="0 0 0 10">  
                     <Grid.Resources>  
                         <Style TargetType="Grid">  
                             <Style.Triggers>  
                                 <DataTrigger Binding="{Binding ElementName=CollapseToggleButton,Path=IsChecked}" Value="true">  
                                     <Setter Property="Visibility" Value="Collapsed" />  
                                 </DataTrigger>  
                             </Style.Triggers>  
                         </Style>  
                     </Grid.Resources>  
                     <Grid>  
                         <Grid.RowDefinitions>  
                             <RowDefinition Height="Auto" />  
                             <RowDefinition Height="Auto" />  
                             <RowDefinition Height="Auto" />  
                             <RowDefinition Height="Auto" />  
                             <RowDefinition Height="Auto" />  
                         </Grid.RowDefinitions>  
 
                         <TextBlock Style="{StaticResource H4}" Text="Display Type:" HorizontalAlignment="Left" TextWrapping="Wrap" Margin="0 10 0 10"/>  
                         <ListBox Grid.Row="1" BorderThickness="0" ItemsSource="{Binding DisplayTypes}" SelectedItem="{Binding SelectedFeatureLayer,Mode=TwoWay}"  Margin="0 0 0 10">  
                             <ListBox.ItemsPanel>  
                                 <ItemsPanelTemplate>  
                                     <StackPanel Orientation="Horizontal" />  
                                 </ItemsPanelTemplate>  
                             </ListBox.ItemsPanel>  
                             <ListBox.ItemTemplate>  
                                 <DataTemplate>  
                                     <Border CornerRadius="5" Margin="5" BorderThickness="1" BorderBrush="LightGray">  
                                         <RadioButton Template="{StaticResource ImageButtonTemplate}" GroupName="Styles"  
                                             ToolTip="{Binding Name}"  
                                             IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected}"  
                                             Content="{Binding Name,Converter={StaticResource NameToImageUriConverter}}" />  
                                     </Border>  
                                 </DataTemplate>  
                             </ListBox.ItemTemplate>  
                             <ListBox.ItemContainerStyle>  
                                 <Style TargetType="ListBoxItem">  
                                     <Setter Property="Template">  
                                         <Setter.Value>  
                                             <ControlTemplate TargetType="{x:Type ListBoxItem}">  
                                                 <Border x:Name="ItemPanel" Background="Transparent">  
                                                     <ContentPresenter />  
                                                 </Border>  
                                             </ControlTemplate>  
                                         </Setter.Value>  
                                     </Setter>  
                                 </Style>  
                             </ListBox.ItemContainerStyle>  
                         </ListBox>  
                         <Border Grid.Row="2" Style="{StaticResource HeaderBanner}">  
                             <TextBlock Style="{StaticResource HeaderText}" Text="Earthquake Information Explorer"></TextBlock>  
                         </Border>  
 
                         <StackPanel Grid.Row="3"  Width="300">  
                             <TextBlock Style="{StaticResource BodyText}" Text="Query Tool:" Margin="0 0 0 5"></TextBlock>  
                             <Border Style="{StaticResource RoundBorderStyle}">  
                                 <StackPanel Orientation="Horizontal">  
                                     <ListBox x:Name="MapModesListBox" ItemsSource="{Binding MapControlModes}" BorderThickness="0" SelectedItem="{Binding SelectedMapMode,Mode=OneWay}">  
                                         <ListBox.ItemTemplate>  
                                             <DataTemplate>  
                                                 <RadioButton Template="{StaticResource ImageButtonTemplate}" Margin="{StaticResource TitleImageRadioButtonMargin}"  
                                                              IsChecked="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListBoxItem},Path=IsSelected}"  
                                                              Content="{Binding Path=.,Converter={StaticResource TrackModeToImageUriConverter}}" Command="{Binding ElementName=MapModesListBox,Path=DataContext.ChangMapModeCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=Self},Path=DataContext}"  
                                                              ToolTip="{Binding .,Converter={StaticResource TrackModeToToolTipConverter}}" />  
                                             </DataTemplate>  
                                         </ListBox.ItemTemplate>  
                                         <ListBox.ItemsPanel>  
                                             <ItemsPanelTemplate>  
                                                 <StackPanel Orientation="Horizontal" />  
                                             </ItemsPanelTemplate>  
                                         </ListBox.ItemsPanel>  
                                         <ListBox.ItemContainerStyle>  
                                             <Style TargetType="ListBoxItem">  
                                                 <Setter Property="Template">  
                                                     <Setter.Value>  
                                                         <ControlTemplate TargetType="{x:Type ListBoxItem}">  
                                                             <Border x:Name="ItemPanel" Background="Transparent">  
                                                                 <ContentPresenter />  
                                                             </Border>  
                                                         </ControlTemplate>  
                                                     </Setter.Value>  
                                                 </Setter>  
                                             </Style>  
                                         </ListBox.ItemContainerStyle>  
                                     </ListBox>  
                                     <Button Template="{StaticResource ImageButtonTemplate}" Content="/Image/clear.png" Margin="{StaticResource TitleImageRadioButtonMargin}" ToolTip="Clear Selection"  
                                        Command="{Binding ClearAllCommand}" />  
                                 </StackPanel>  
                             </Border>  
                         </StackPanel>  
 
                         <StackPanel Grid.Row="4" >  
                             <TextBlock Style="{StaticResource BodyText}" Text="Query Configuration:" Margin="0 15 0 5"></TextBlock>  
                             <Border Style="{StaticResource RoundBorderStyle}">  
                                 <Grid>  
                                     <Grid.Resources>  
                                         <sys:Int32 x:Key="RangeSliderWidth">213</sys:Int32>  
                                     </Grid.Resources>  
                                     <Grid.RowDefinitions>  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                         <RowDefinition Height="Auto" />  
                                     </Grid.RowDefinitions>  
 
                                     <TextBlock Grid.Row="0" Style="{StaticResource BodyText}" Text="Magnitude:" Margin="0 7 5 5"></TextBlock>  
                                     <StackPanel Grid.Row="1" Margin="0 0 10 10">  
                                         <local:RangeSliderBar StartValue="{Binding QueryFilter.StartMagnitudeRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               EndValue="{Binding QueryFilter.EndMagnitudeRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               Maximum="{Binding QueryFilter.MagnitudeRangeMaximum,Mode=OneTime}"  
                                               Minimum="{Binding QueryFilter.MagnitudeRangeMinimum,Mode=OneTime}"  
                                               SliderWidth="{StaticResource RangeSliderWidth}"  
                                                />  
                                     </StackPanel>  
 
                                     <TextBlock Grid.Row="2" Style="{StaticResource BodyText}" Text="Depth of Hypocenter(Km):" Margin="0 7 5 5"></TextBlock>  
                                     <StackPanel Grid.Row="3" Margin="0 0 10 10">  
                                         <local:RangeSliderBar Minimum="{Binding QueryFilter.DepthRangeMinimum,Mode=OneTime}"  
                                               StartValue="{Binding QueryFilter.StartDepthRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               Maximum="{Binding QueryFilter.DepthRangeMaximum,Mode=OneTime}"  
                                               EndValue="{Binding QueryFilter.EndDepthRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               SliderWidth="{StaticResource RangeSliderWidth}"  
                                               SliderTickFrequency="10" />  
                                     </StackPanel>  
 
                                     <TextBlock Grid.Row="4" Style="{StaticResource BodyText}" Text="Date(Year):" Margin="0 7 5 5"></TextBlock>  
                                     <StackPanel Grid.Row="5" Margin="0 0 10 10">  
                                         <local:RangeSliderBar StartValue="{Binding QueryFilter.StartYearRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               EndValue="{Binding QueryFilter.EndYearRange,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                                               Maximum="{Binding QueryFilter.YearRangeMaximum,Mode=OneTime}"  
                                               Minimum="{Binding QueryFilter.YearRangeMinimum,Mode=OneTime}"  
                                               SliderWidth="{StaticResource RangeSliderWidth}"  
                                               SliderTickFrequency="25" />  
                                     </StackPanel>  
                                 </Grid>  
                             </Border>  
                         </StackPanel>  
                     </Grid>  
                 </Grid>  
                 <ToggleButton x:Name="CollapseToggleButton"  
                         Grid.Row="0"  
                         Grid.Column="1"  
                         VerticalAlignment="Center"  
                         Cursor="Hand" Template="{StaticResource ToggleButtonTemplate}" Background="Transparent" BorderBrush="Transparent" Content="/Image/Collapse.gif" Tag="/Image/Expand.gif" />  
                 <Rectangle Grid.Row="0" Grid.Column="2">  
                     <Rectangle.Fill>  
                         <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">  
                             <GradientStop Color="#5c707d" Offset="0" />  
                             <GradientStop Color="#305c707d" Offset="1" />  
                         </LinearGradientBrush>  
                     </Rectangle.Fill>  
                 </Rectangle>  
             </Grid>  
             <Grid Grid.Column="1">  
                 <Grid.RowDefinitions>  
                     <RowDefinition Height="3*" />  
                     <RowDefinition Height="5" />  
                     <RowDefinition Height="*" />  
                 </Grid.RowDefinitions>  
                 <wpf:WpfMap x:Name="wpfMap" Grid.Row="0" Panel.ZIndex="-1" />  
                 <Grid  Grid.Row="0"  
                     Visibility="{Binding IsBusy,Converter={StaticResource BoolToVisibilityConverter}}"  
                     Background="#30D6D6D6">  
                     <local:LoadingImageUserControl Visibility="{Binding IsBusy,Converter={StaticResource BoolToVisibilityConverter}}" />  
                 </Grid>  
                 <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch">  
                     <GridSplitter.Background>  
                         <LinearGradientBrush StartPoint="0,1" EndPoint="0,0">  
                             <GradientStop Color="#5c707d" Offset="0" />  
                             <GradientStop Color="#305c707d" Offset="1" />  
                         </LinearGradientBrush>  
                     </GridSplitter.Background>  
                 </GridSplitter>  
                 <local:QueryResultUserControl Grid.Row="2" />  
             </Grid>  
         </Grid>  
         <Grid Grid.Row="2">  
             <Border BorderBrush="Gray" BorderThickness="0 1 0 0">  
                 <StatusBar Height="30">  
                     <StatusBarItem  HorizontalContentAlignment="Stretch">  
                         <Grid HorizontalAlignment="Right">  
                             <Grid.ColumnDefinitions>  
                                 <ColumnDefinition Width="Auto" />  
                                 <ColumnDefinition Width="5" />  
                                 <ColumnDefinition Width="Auto" />  
                             </Grid.ColumnDefinitions>  
                             <TextBlock Text="{Binding CoordinateX,StringFormat=X:{0:N2}}" HorizontalAlignment="Right" Width="95" VerticalAlignment="Center" Grid.Column="0" />  
                             <TextBlock Text="{Binding CoordinateY,StringFormat=Y:{0:N2}}" VerticalAlignment="Center" Width="100" Grid.Column="2" />  
                         </Grid>  
                     </StatusBarItem>  
                 </StatusBar>  
             </Border>  
         </Grid>  
     </Grid>  
 </Window>  
 

MainWindow.xaml.cs

 using System.Windows;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     /// <summary>  
     /// Interaction logic for MainWindow.xaml  
     /// </summary>  
     public partial class MainWindow : Window  
     {  
         public MainWindow()  
         {  
             InitializeComponent();  
         }  
 
         private void MainWindow_Loaded(object sender, RoutedEventArgs e)  
         {  
             DataContext = new MainWindowViewModel(wpfMap);  
         }  
     }  
 }  
 

EarthquakeViewModel.cs

 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.EarthquakeStatistics.Properties;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class EarthquakeViewModel : ViewModelBase  
     {  
         private string year;  
         private string latitude;  
         private string location;  
         private string longitude;  
         private string magnitude;  
         private string depthInKilometer;  
 
         private Feature epicenterFeature;  
         private RelayCommand<object> zoomToFeatureCommand;  
 
         public EarthquakeViewModel()  
             : this(null)  
         { }  
 
         public EarthquakeViewModel(Feature epicenterFeature)  
         {  
             EpicenterFeature = epicenterFeature;  
         }  
 
         public string DepthInKilometer  
         {  
             get { return depthInKilometer; }  
             set { depthInKilometer = value; }  
         }  
 
         public string Latitude  
         {  
             get { return latitude; }  
             set { latitude = value; }  
         }  
 
         public string Location  
         {  
             get { return location; }  
             set { location = value; }  
         }  
 
         public string Longitude  
         {  
             get { return longitude; }  
             set { longitude = value; }  
         }  
 
         public string Magnitude  
         {  
             get { return magnitude; }  
             set { magnitude = value; }  
         }  
 
         public string Year  
         {  
             get { return year; }  
             set { year = value; }  
         }  
 
         public Feature EpicenterFeature  
         {  
             get { return epicenterFeature; }  
             set  
             {  
                 epicenterFeature = value;  
                 if (epicenterFeature != null)  
                 {  
                     DepthInKilometer = GetTextFromDoubleTypeColumnValue(epicenterFeature, Resources.DepthColumnName);  
                     Magnitude = GetTextFromDoubleTypeColumnValue(epicenterFeature, Resources.MagnitudeColumnName);  
                     Year = GetTextFromDoubleTypeColumnValue(epicenterFeature, Resources.YearColumnName);  
 
                     Location = GetTextFromColumnValue(epicenterFeature, Resources.LocationColumnName);  
                     Longitude = GetTextFromColumnValue(epicenterFeature, Resources.LongitudeColumnName);  
                     Latitude = GetTextFromColumnValue(epicenterFeature, Resources.LatitudeColumnName);  
                 }  
             }  
         }  
 
         public RelayCommand<object> ZoomToFeatureCommand  
         {  
             get  
             {  
                 return zoomToFeatureCommand ?? (zoomToFeatureCommand = new RelayCommand<object>(dataContext =>  
                 {  
                     MainWindowViewModel mainWindowViewModel = dataContext as MainWindowViewModel;  
                     if (mainWindowViewModel != null)  
                     {  
                         mainWindowViewModel.SelectedEarthquake = this;  
                         PointShape pointShape = epicenterFeature.GetShape() as PointShape;  
                         if (pointShape != null)  
                         {  
                             mainWindowViewModel.MapControl.ZoomTo(pointShape, 288374.8974609375);  
                         }  
                     }  
                 }));  
             }  
         }  
 
         private static string GetTextFromColumnValue(Feature feature, string columnName)  
         {  
             string text = string.Empty;  
             if (feature.ColumnValues.ContainsKey(columnName))  
             {  
                 text = feature.ColumnValues[columnName];  
             }  
             return text;  
         }  
 
         private static string GetTextFromDoubleTypeColumnValue(Feature feature, string columnName)  
         {  
             string text = Resources.UnknownString;  
             if (feature.ColumnValues.ContainsKey(columnName))  
             {  
                 double value;  
                 if (double.TryParse(feature.ColumnValues[columnName], out value))  
                 {  
                     text = value >= 0 ? feature.ColumnValues[columnName] : Resources.UnknownString;  
                 }  
             }  
             return text;  
         }  
     }  
 }  
 

FeatureLayerViewModel.cs

 using ThinkGeo.MapSuite.Core;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class FeatureLayerViewModel : ViewModelBase  
     {  
         private FeatureLayer featureLayer;  
 
         public FeatureLayerViewModel()  
             : this(null)  
         { }  
 
         public FeatureLayerViewModel(FeatureLayer featureLayer)  
             : this(featureLayer, false)  
         {  
         }  
 
         public FeatureLayerViewModel(FeatureLayer featureLayer, bool isVisible)  
         {  
             FeatureLayer = featureLayer;  
             IsVisible = isVisible;  
         }  
 
         public bool IsVisible  
         {  
             get { return FeatureLayer.IsVisible; }  
             set  
             {  
                 FeatureLayer.IsVisible = value;  
                 RaisePropertyChanged(() => IsVisible);  
             }  
         }  
 
         public FeatureLayer FeatureLayer  
         {  
             get { return featureLayer; }  
             set  
             {  
                 featureLayer = value;  
                 RaisePropertyChanged(() => FeatureLayer);  
             }  
         }  
 
         public string Name  
         {  
             get { return featureLayer != null ? featureLayer.Name : string.Empty; }  
         }  
     }  
 }  
 

MainWindowViewModel.cs

 using System.Collections.ObjectModel;  
 using System.ComponentModel;  
 using System.Globalization;  
 using System.Linq;  
 using System.Windows.Input;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.EarthquakeStatistics.Properties;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class MainWindowViewModel : ViewModelBase  
     {  
         private bool isBusy;  
         private double coordinateX;  
         private double coordinateY;  
         private WpfMap mapControl;  
         private MapModel mapModel;  
         private EarthquakeQueryFilter queryFilter;  
         private EarthquakeViewModel selectedEarthquake;  
         private FeatureLayerViewModel selectedFeatureLayer;  
         private Collection<TrackMode> mapControlModes;  
         private Collection<EarthquakeViewModel> queryResults;  
         private RelayCommand clearAllCommand;  
         private RelayCommand<TrackMode> changMapModeCommand;  
         private ObservableCollection<FeatureLayerViewModel> displayTypes;  
         private ObservableCollection<EarthquakeViewModel> filteredQueryResults;  
 
         public MainWindowViewModel()  
             : this(null)  
         { }  
 
         public MainWindowViewModel(WpfMap wpfMap)  
         {  
             MapControl = wpfMap;  
         }  
 
         public bool IsBusy  
         {  
             get { return isBusy; }  
             set  
             {  
                 isBusy = value;  
                 RaisePropertyChanged(() => IsBusy);  
             }  
         }  
 
         public WpfMap MapControl  
         {  
             get { return mapControl; }  
             set  
             {  
                 mapControl = value;  
                 if (mapControl != null)  
                 {  
                     mapModel = new MapModel(mapControl);  
                     InitializeProperties();  
                     InitializeEvents();  
                 }  
             }  
         }  
 
         public double CoordinateX  
         {  
             get { return coordinateX; }  
             set  
             {  
                 coordinateX = value;  
                 RaisePropertyChanged(() => CoordinateX);  
             }  
         }  
 
         public double CoordinateY  
         {  
             get { return coordinateY; }  
             set  
             {  
                 coordinateY = value;  
                 RaisePropertyChanged(() => CoordinateY);  
             }  
         }  
 
         public TrackMode SelectedMapMode  
         {  
             get { return mapModel.TrackMode; }  
             set  
             {  
                 mapModel.TrackMode = value;  
                 RaisePropertyChanged(() => SelectedMapMode);  
             }  
         }  
 
         public EarthquakeQueryFilter QueryFilter  
         {  
             get { return queryFilter; }  
         }  
 
         public Collection<TrackMode> MapControlModes  
         {  
             get  
             {  
                 return mapControlModes ?? (mapControlModes = new Collection<TrackMode>  
                 {  
                     TrackMode.None,  
                     TrackMode.Polygon,  
                     TrackMode.Rectangle,  
                     TrackMode.Circle  
                 });  
             }  
         }  
 
         public EarthquakeViewModel SelectedEarthquake  
         {  
             get { return selectedEarthquake; }  
             set  
             {  
                 selectedEarthquake = value;  
                 RaisePropertyChanged(() => SelectedEarthquake);  
                 if (selectedEarthquake != null && selectedEarthquake.EpicenterFeature != null)  
                 {  
                     mapModel.UpdateHighlightMarker(selectedEarthquake.EpicenterFeature);  
                 }  
             }  
         }  
 
         public FeatureLayerViewModel SelectedFeatureLayer  
         {  
             get { return selectedFeatureLayer; }  
             set  
             {  
                 if (selectedFeatureLayer != null) selectedFeatureLayer.IsVisible = false;  
 
                 selectedFeatureLayer = value;  
                 selectedFeatureLayer.IsVisible = true;  
 
                 mapModel.SetEarthquakeLegendsVisible(selectedFeatureLayer.FeatureLayer);  
                 mapModel.MapControl.Refresh();  
 
                 RaisePropertyChanged(() => SelectedFeatureLayer);  
             }  
         }  
 
         public ObservableCollection<FeatureLayerViewModel> DisplayTypes  
         {  
             get { return displayTypes; }  
         }  
 
         public ObservableCollection<EarthquakeViewModel> FilteredQueryResults  
         {  
             get { return filteredQueryResults; }  
         }  
 
         public RelayCommand ClearAllCommand  
         {  
             get  
             {  
                 return clearAllCommand ?? (clearAllCommand = new RelayCommand(() =>  
                 {  
                     mapModel.ClearTrackResult();  
                     FilteredQueryResults.Clear();  
                     queryResults.Clear();  
                 }));  
             }  
         }  
 
         public RelayCommand<TrackMode> ChangMapModeCommand  
         {  
             get  
             {  
                 return changMapModeCommand ?? (changMapModeCommand = new RelayCommand<TrackMode>(currentMode =>  
                 {  
                     if (currentMode == SelectedMapMode && currentMode != TrackMode.None) SelectedMapMode = MapControlModes.FirstOrDefault();  
                     else SelectedMapMode = currentMode;  
                 }));  
             }  
         }  
 
         private void MapModel_QueryAreaChanged(object sender, QueryAreaChangedMapModelEventArgs e)  
         {  
             FeatureLayer featureLayer = selectedFeatureLayer.FeatureLayer;  
             featureLayer.Open();  
             Collection<Feature> features = featureLayer.FeatureSource.GetFeaturesWithinDistanceOf(e.QueryFeature, mapModel.MapControl.MapUnit, DistanceUnit.Meter, 0.0001, ReturningColumnsType.AllColumns);  
             queryResults.Clear();  
             foreach (Feature feature in features)  
             {  
                 queryResults.Add(new EarthquakeViewModel(feature));  
             }  
 
             FilterEarthquake();  
         }  
 
         private void StyleLayersOverLay_Drawing(object sender, DrawingOverlayEventArgs e)  
         {  
             if (Mouse.LeftButton == MouseButtonState.Released)  
             {  
                 IsBusy = true;  
             }  
         }  
 
         private void StyleLayersOverLay_Drawn(object sender, DrawnOverlayEventArgs e)  
         {  
             if (Mouse.LeftButton == MouseButtonState.Released)  
             {  
                 IsBusy = false;  
             }  
         }  
 
         private void MapModel_MapMouseCoordinateChanged(object sender, CustomFormattedMouseCoordinateMapToolEventArgs e)  
         {  
             CoordinateX = e.WorldCoordinate.X;  
             CoordinateY = e.WorldCoordinate.Y;  
         }  
 
         private void QueryFilter_PropertyChanged(object sender, PropertyChangedEventArgs e)  
         {  
             FilterEarthquake();  
         }  
 
         private void InitializeProperties()  
         {  
             queryFilter = new EarthquakeQueryFilter();  
             queryResults = new Collection<EarthquakeViewModel>();  
             displayTypes = new ObservableCollection<FeatureLayerViewModel>();  
             filteredQueryResults = new ObservableCollection<EarthquakeViewModel>();  
             SelectedMapMode = MapControlModes.FirstOrDefault();  
 
             foreach (FeatureLayer featureLayer in mapModel.StyleLayerOverlay.Layers.OfType<FeatureLayer>())  
             {  
                 DisplayTypes.Add(new FeatureLayerViewModel(featureLayer));  
             }  
             SelectedFeatureLayer = DisplayTypes.FirstOrDefault();  
         }  
 
         private void InitializeEvents()  
         {  
             mapModel.QueryAreaChanged += MapModel_QueryAreaChanged;  
             mapModel.StyleLayerOverlay.Drawn += StyleLayersOverLay_Drawn;  
             mapModel.StyleLayerOverlay.Drawing += StyleLayersOverLay_Drawing;  
             mapModel.MapControl.MapTools.MouseCoordinate.CustomFormatted += MapModel_MapMouseCoordinateChanged;  
             queryFilter.PropertyChanged += QueryFilter_PropertyChanged;  
         }  
 
         private void FilterEarthquake()  
         {  
             FilteredQueryResults.Clear();  
 
             ManagedProj4Projection mercatorToWgs84Projection = new ManagedProj4Projection();  
             mercatorToWgs84Projection.InternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();  
             mercatorToWgs84Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();  
             mercatorToWgs84Projection.Open();  
 
             for (int i = queryResults.Count - 1; i >= 0; i--)  
             {  
                 EarthquakeViewModel resultItem = queryResults[i];  
 
                 double latitude, longitude;  
                 if (double.TryParse(resultItem.Latitude, out latitude) && double.TryParse(resultItem.Longitude, out longitude))  
                 {  
                     PointShape point = new PointShape(longitude, latitude);  
                     point = (PointShape)mercatorToWgs84Projection.ConvertToExternalProjection(point);  
 
                     EarthquakeViewModel newResultItem = new EarthquakeViewModel(resultItem.EpicenterFeature);  
                     newResultItem.Latitude = point.Y.ToString("f3", CultureInfo.InvariantCulture);  
                     newResultItem.Longitude = point.X.ToString("f3", CultureInfo.InvariantCulture);  
 
                     double year, depth, magnitude;  
                     double.TryParse(newResultItem.Magnitude, out magnitude);  
                     double.TryParse(newResultItem.DepthInKilometer, out depth);  
                     double.TryParse(newResultItem.Year, out year);  
 
                     if ((magnitude >= queryFilter.StartMagnitudeRange && magnitude <= queryFilter.EndMagnitudeRange || newResultItem.Magnitude == Resources.UnknownString)  
                         && (depth <= queryFilter.EndDepthRange && depth >= queryFilter.StartDepthRange || newResultItem.DepthInKilometer == Resources.UnknownString)  
                         && (year >= queryFilter.StartYearRange && year <= queryFilter.EndYearRange) || newResultItem.Year == Resources.UnknownString)  
                     {  
                         FilteredQueryResults.Add(newResultItem);  
                     }  
                 }  
             }  
 
             mercatorToWgs84Projection.Close();  
             mapModel.RefreshMarkersByFeatures(FilteredQueryResults.Select(f => f.EpicenterFeature));  
         }  
     }  
 }  
 

RangeSliderBar.xaml

 <UserControl x:Class="ThinkGeo.MapSuite.EarthquakeStatistics.RangeSliderBar"  
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
              Name="UC_Arrange" Loaded="UC_Arrange_Loaded">  
     <StackPanel Orientation="Horizontal" Height="{Binding ElementName=UC_Arrange,Path=SilderHeight}" Width="Auto" >  
         <TextBlock Text="{Binding ElementName=SL_Bat1,Path=Value}" Width="25" Margin="0,3" />  
         <Canvas Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}" Margin="0,0,5,0">  
             <Slider x:Name="SL_Bat1"  
                 Value="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 Minimum="{Binding ElementName=UC_Arrange,Path=Minimum}"  
                 Maximum="{Binding ElementName=UC_Arrange,Path=Maximum}"  
                 SelectionStart="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 SelectionEnd="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}"  
                 TickFrequency="{Binding ElementName=UC_Arrange,Path=SliderTickFrequency}"  
                 FocusVisualStyle="{x:Null}"  
                 CacheMode="BitmapCache"  
                 IsSelectionRangeEnabled="True"  
                 TickPlacement="BottomRight"  
                 IsSnapToTickEnabled="True"  
                 VerticalAlignment="Center"  
                 Margin="2"  
                 ValueChanged="SL_Bat1_ValueChanged"  
                 Thumb.DragCompleted="SL_DragCompleted"  
                 ButtonBase.Click="SL_Click" >  
                 <Slider.Clip>  
                     <RectangleGeometry Rect="{Binding ElementName=UC_Arrange,Path=StartRect}" />  
                 </Slider.Clip>  
             </Slider>  
             <Slider x:Name="SL_Bat2"  
                 Value="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Minimum="{Binding ElementName=UC_Arrange,Path=Minimum}"  
                 Maximum="{Binding ElementName=UC_Arrange,Path=Maximum}"  
                 SelectionStart="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 SelectionEnd="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}"  
                 TickFrequency="{Binding ElementName=UC_Arrange,Path=SliderTickFrequency}"  
                 FocusVisualStyle="{x:Null}"  
                 CacheMode="BitmapCache"  
                 IsSelectionRangeEnabled="True"  
                 TickPlacement="BottomRight"  
                 IsSnapToTickEnabled="True"  
                 VerticalAlignment="Center"  
                 Margin="2"  
                 ValueChanged="SL_Bat2_ValueChanged"  
                     Thumb.DragCompleted="SL_DragCompleted"  
                     ButtonBase.Click="SL_Click">  
                 <Slider.Clip>  
                     <RectangleGeometry Rect="{Binding ElementName=UC_Arrange,Path=EndRect}" />  
                 </Slider.Clip>  
             </Slider>  
         </Canvas>  
         <TextBlock Text="{Binding ElementName=SL_Bat2,Path=Value}" Width="25" Margin="0,3" />  
     </StackPanel>  
 </UserControl>  
 

RangeSliderBar.cs

 using System.Windows;  
 using System.Windows.Controls;  
 using System.Windows.Controls.Primitives;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public partial class RangeSliderBar : UserControl  
     {  
         private static int frequency = 1;  
         private static int sliderHeight = 30;  
         private static int maximum = 100;  
         private static int minimum = 0;  
         private static int sliderWidth = 150;  
 
         private bool isSliderClicked;  
 
         public static readonly DependencyProperty EndValueProperty =  
                     DependencyProperty.Register("EndValue", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(maximum));  
 
         public static readonly DependencyProperty MaximumProperty =  
                     DependencyProperty.Register("Maximum", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(maximum));  
 
         public static readonly DependencyProperty MinimumProperty =  
                     DependencyProperty.Register("Minimum", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(minimum));  
 
         public static readonly DependencyProperty SliderHeightProperty =  
                     DependencyProperty.Register("SilderHeight", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(sliderHeight));  
 
         public static readonly DependencyProperty SliderWidthProperty =  
                     DependencyProperty.Register("SilderWidth", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(sliderWidth));  
 
         public static readonly DependencyProperty SliderTickFrequencyProperty =  
                     DependencyProperty.Register("SliderTickFrequency", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(frequency));  
 
         public static readonly DependencyProperty StartValueProperty =  
                     DependencyProperty.Register("StartValue", typeof(int), typeof(RangeSliderBar));  
 
         private static readonly DependencyProperty EndRectProperty =  
                     DependencyProperty.Register("EndRect", typeof(Rect), typeof(RangeSliderBar));  
 
         private static readonly DependencyProperty StartRectProperty =  
                     DependencyProperty.Register("StartRect", typeof(Rect), typeof(RangeSliderBar));  
 
         public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<double>), typeof(RangeSliderBar));  
 
         public RangeSliderBar()  
         {  
             InitializeComponent();  
             isSliderClicked = false;  
         }  
 
         public event RoutedPropertyChangedEventHandler<double> ValueChanged  
         {  
             add { AddHandler(ValueChangedEvent, value); }  
             remove { RemoveHandler(ValueChangedEvent, value); }  
         }  
 
         public int EndValue  
         {  
             get { return (int)GetValue(EndValueProperty); }  
             set { SetValue(EndValueProperty, value); }  
         }  
 
         public int Maximum  
         {  
             get { return (int)GetValue(MaximumProperty); }  
             set { SetValue(MaximumProperty, value); }  
         }  
 
         public int Minimum  
         {  
             get { return (int)GetValue(MinimumProperty); }  
             set { SetValue(MinimumProperty, value); }  
         }  
 
         public int SliderHeight  
         {  
             get { return (int)GetValue(SliderHeightProperty); }  
             set { SetValue(SliderHeightProperty, value); }  
         }  
 
         public int SliderWidth  
         {  
             get { return (int)GetValue(SliderWidthProperty); }  
             set { SetValue(SliderWidthProperty, value); }  
         }  
 
         public int SliderTickFrequency  
         {  
             get { return (int)GetValue(SliderTickFrequencyProperty); }  
             set { SetValue(SliderTickFrequencyProperty, value); }  
         }  
 
         public int StartValue  
         {  
             get { return (int)GetValue(StartValueProperty); }  
             set { SetValue(StartValueProperty, value); }  
         }  
 
         private Rect EndRect  
         {  
             get { return (Rect)GetValue(EndRectProperty); }  
             set { SetValue(EndRectProperty, value); }  
         }  
 
         private Rect StartRect  
         {  
             get { return (Rect)GetValue(StartRectProperty); }  
             set { SetValue(StartRectProperty, value); }  
         }  
 
         protected void OnValueChanged(double oldValue, double newValue)  
         {  
             RoutedPropertyChangedEventArgs<double> args = new RoutedPropertyChangedEventArgs<double>(oldValue, newValue);  
             args.RoutedEvent = ValueChangedEvent;  
             RaiseEvent(args);  
         }  
 
         private void ClipSilder()  
         {  
             int selectedValue = EndValue - StartValue;  
             int totalValue = Maximum - Minimum;  
             double sliderClipWidth = SliderWidth * (StartValue - Minimum + selectedValue * 0.5) / totalValue;  
             StartRect = new Rect(0, 0, sliderClipWidth, SliderHeight);  
             EndRect = new Rect(sliderClipWidth, 0, SliderWidth, SliderHeight);  
         }  
 
         private void SL_Bat1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)  
         {  
             if (e.NewValue > EndValue)  
                 StartValue = EndValue;  
             ClipSilder();  
             if (isSliderClicked)  
             {  
                 OnValueChanged(e.OldValue, e.NewValue);  
                 isSliderClicked = false;  
             }  
         }  
 
         private void SL_Bat2_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)  
         {  
             if (e.NewValue < StartValue)  
                 EndValue = StartValue;  
             ClipSilder();  
 
             if (isSliderClicked)  
             {  
                 OnValueChanged(e.OldValue, e.NewValue);  
                 isSliderClicked = false;  
             }  
         }  
 
         private void UC_Arrange_Loaded(object sender, RoutedEventArgs e)  
         {  
             ClipSilder();  
         }  
 
         private void SL_DragCompleted(object sender, DragCompletedEventArgs e)  
         {  
             OnValueChanged(-9999, ((Slider)sender).Value);  
         }  
 
         private void SL_Click(object sender, RoutedEventArgs e)  
         {  
             isSliderClicked = true;  
         }  
     }  
 }  
 

QueryResultUserControl.xaml

 <UserControl x:Class="ThinkGeo.MapSuite.EarthquakeStatistics.QueryResultUserControl"  
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
              xmlns:local="clr-namespace:ThinkGeo.MapSuite.EarthquakeStatistics"  
              mc:Ignorable="d" Background="Transparent"  
              d:DesignHeight="500" d:DesignWidth="300">  
     <Border BorderThickness="0 1 0 0" VerticalAlignment="Stretch">  
         <Grid Margin="5">  
             <Grid.RowDefinitions>  
                 <RowDefinition Height="Auto" />  
                 <RowDefinition Height="*" />  
             </Grid.RowDefinitions>  
             <TextBlock Grid.Row="0" Style="{StaticResource BodyText}" Text="Query Result" Margin="0 15 0 5" />  
             <ListView x:Name="ResultListView" ItemsSource="{Binding FilteredQueryResults}" SelectedItem="{Binding SelectedEarthquake,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  
                       SelectionMode="Single" VerticalAlignment="Stretch" Grid.Row="1">  
                 <ListView.View>  
                     <GridView>  
                         <GridViewColumn Width="36"  
                                         Header="">  
                             <GridViewColumn.CellTemplate>  
                                 <DataTemplate>  
                                     <Button Template="{StaticResource ImageButtonTemplate}" Command="{Binding ZoomToFeatureCommand}" CommandParameter="{Binding ElementName=ResultListView,Path=DataContext}"  
                                                        Margin="{StaticResource ImageButtonMargin}" Content="/Image/find.png" />  
                                 </DataTemplate>  
                             </GridViewColumn.CellTemplate>  
                         </GridViewColumn>  
                         <GridViewColumn Width="100"  
                                         DisplayMemberBinding="{Binding Year}"  
                                         Header="Year" />  
                         <GridViewColumn Width="100"  
                                         DisplayMemberBinding="{Binding Longitude}"  
                                         Header="Longitude" />  
                         <GridViewColumn Width="100"  
                                         DisplayMemberBinding="{Binding Latitude}"  
                                         Header="Latitude" />  
                         <GridViewColumn Width="100"  
                                         DisplayMemberBinding="{Binding DepthInKilometer}"  
                                         Header="Depth(KM)" />  
                         <GridViewColumn Width="150"  
                                         DisplayMemberBinding="{Binding Magnitude}"  
                                         Header="Magnitude" />  
                         <GridViewColumn Width="500"  
                                         DisplayMemberBinding="{Binding Location}"  
                                         Header="Location" />  
                     </GridView>  
                 </ListView.View>  
             </ListView>  
         </Grid>  
     </Border>  
 </UserControl>  
 

RangeSliderBar.xaml

 <UserControl x:Class="ThinkGeo.MapSuite.EarthquakeStatistics.RangeSliderBar"  
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
              Name="UC_Arrange" Loaded="UC_Arrange_Loaded">  
     <StackPanel Orientation="Horizontal" Height="{Binding ElementName=UC_Arrange,Path=SilderHeight}" Width="Auto" >  
         <TextBlock Text="{Binding ElementName=SL_Bat1,Path=Value}" Width="25" Margin="0,3" />  
         <Canvas Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}" Margin="0,0,5,0">  
             <Slider x:Name="SL_Bat1"  
                 Value="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 Minimum="{Binding ElementName=UC_Arrange,Path=Minimum}"  
                 Maximum="{Binding ElementName=UC_Arrange,Path=Maximum}"  
                 SelectionStart="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 SelectionEnd="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}"  
                 TickFrequency="{Binding ElementName=UC_Arrange,Path=SliderTickFrequency}"  
                 FocusVisualStyle="{x:Null}"  
                 CacheMode="BitmapCache"  
                 IsSelectionRangeEnabled="True"  
                 TickPlacement="BottomRight"  
                 IsSnapToTickEnabled="True"  
                 VerticalAlignment="Center"  
                 Margin="2"  
                 ValueChanged="SL_Bat1_ValueChanged"  
                 Thumb.DragCompleted="SL_DragCompleted"  
                 ButtonBase.Click="SL_Click" >  
                 <Slider.Clip>  
                     <RectangleGeometry Rect="{Binding ElementName=UC_Arrange,Path=StartRect}" />  
                 </Slider.Clip>  
             </Slider>  
             <Slider x:Name="SL_Bat2"  
                 Value="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Minimum="{Binding ElementName=UC_Arrange,Path=Minimum}"  
                 Maximum="{Binding ElementName=UC_Arrange,Path=Maximum}"  
                 SelectionStart="{Binding ElementName=UC_Arrange,Path=StartValue}"  
                 SelectionEnd="{Binding ElementName=UC_Arrange,Path=EndValue}"  
                 Width="{Binding ElementName=UC_Arrange,Path=SilderWidth}"  
                 TickFrequency="{Binding ElementName=UC_Arrange,Path=SliderTickFrequency}"  
                 FocusVisualStyle="{x:Null}"  
                 CacheMode="BitmapCache"  
                 IsSelectionRangeEnabled="True"  
                 TickPlacement="BottomRight"  
                 IsSnapToTickEnabled="True"  
                 VerticalAlignment="Center"  
                 Margin="2"  
                 ValueChanged="SL_Bat2_ValueChanged"  
                     Thumb.DragCompleted="SL_DragCompleted"  
                     ButtonBase.Click="SL_Click">  
                 <Slider.Clip>  
                     <RectangleGeometry Rect="{Binding ElementName=UC_Arrange,Path=EndRect}" />  
                 </Slider.Clip>  
             </Slider>  
         </Canvas>  
         <TextBlock Text="{Binding ElementName=SL_Bat2,Path=Value}" Width="25" Margin="0,3" />  
     </StackPanel>  
 </UserControl>  
 

RangeSliderBar.xaml.cs

 using System.Windows;  
 using System.Windows.Controls;  
 using System.Windows.Controls.Primitives;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public partial class RangeSliderBar : UserControl  
     {  
         private static int frequency = 1;  
         private static int sliderHeight = 30;  
         private static int maximum = 100;  
         private static int minimum = 0;  
         private static int sliderWidth = 150;  
 
         private bool isSliderClicked;  
 
         public static readonly DependencyProperty EndValueProperty =  
                     DependencyProperty.Register("EndValue", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(maximum));  
 
         public static readonly DependencyProperty MaximumProperty =  
                     DependencyProperty.Register("Maximum", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(maximum));  
 
         public static readonly DependencyProperty MinimumProperty =  
                     DependencyProperty.Register("Minimum", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(minimum));  
 
         public static readonly DependencyProperty SliderHeightProperty =  
                     DependencyProperty.Register("SilderHeight", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(sliderHeight));  
 
         public static readonly DependencyProperty SliderWidthProperty =  
                     DependencyProperty.Register("SilderWidth", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(sliderWidth));  
 
         public static readonly DependencyProperty SliderTickFrequencyProperty =  
                     DependencyProperty.Register("SliderTickFrequency", typeof(int), typeof(RangeSliderBar), new PropertyMetadata(frequency));  
 
         public static readonly DependencyProperty StartValueProperty =  
                     DependencyProperty.Register("StartValue", typeof(int), typeof(RangeSliderBar));  
 
         private static readonly DependencyProperty EndRectProperty =  
                     DependencyProperty.Register("EndRect", typeof(Rect), typeof(RangeSliderBar));  
 
         private static readonly DependencyProperty StartRectProperty =  
                     DependencyProperty.Register("StartRect", typeof(Rect), typeof(RangeSliderBar));  
 
         public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<double>), typeof(RangeSliderBar));  
 
         public RangeSliderBar()  
         {  
             InitializeComponent();  
             isSliderClicked = false;  
         }  
 
         public event RoutedPropertyChangedEventHandler<double> ValueChanged  
         {  
             add { AddHandler(ValueChangedEvent, value); }  
             remove { RemoveHandler(ValueChangedEvent, value); }  
         }  
 
         public int EndValue  
         {  
             get { return (int)GetValue(EndValueProperty); }  
             set { SetValue(EndValueProperty, value); }  
         }  
 
         public int Maximum  
         {  
             get { return (int)GetValue(MaximumProperty); }  
             set { SetValue(MaximumProperty, value); }  
         }  
 
         public int Minimum  
         {  
             get { return (int)GetValue(MinimumProperty); }  
             set { SetValue(MinimumProperty, value); }  
         }  
 
         public int SliderHeight  
         {  
             get { return (int)GetValue(SliderHeightProperty); }  
             set { SetValue(SliderHeightProperty, value); }  
         }  
 
         public int SliderWidth  
         {  
             get { return (int)GetValue(SliderWidthProperty); }  
             set { SetValue(SliderWidthProperty, value); }  
         }  
 
         public int SliderTickFrequency  
         {  
             get { return (int)GetValue(SliderTickFrequencyProperty); }  
             set { SetValue(SliderTickFrequencyProperty, value); }  
         }  
 
         public int StartValue  
         {  
             get { return (int)GetValue(StartValueProperty); }  
             set { SetValue(StartValueProperty, value); }  
         }  
 
         private Rect EndRect  
         {  
             get { return (Rect)GetValue(EndRectProperty); }  
             set { SetValue(EndRectProperty, value); }  
         }  
 
         private Rect StartRect  
         {  
             get { return (Rect)GetValue(StartRectProperty); }  
             set { SetValue(StartRectProperty, value); }  
         }  
 
         protected void OnValueChanged(double oldValue, double newValue)  
         {  
             RoutedPropertyChangedEventArgs<double> args = new RoutedPropertyChangedEventArgs<double>(oldValue, newValue);  
             args.RoutedEvent = ValueChangedEvent;  
             RaiseEvent(args);  
         }  
 
         private void ClipSilder()  
         {  
             int selectedValue = EndValue - StartValue;  
             int totalValue = Maximum - Minimum;  
             double sliderClipWidth = SliderWidth * (StartValue - Minimum + selectedValue * 0.5) / totalValue;  
             StartRect = new Rect(0, 0, sliderClipWidth, SliderHeight);  
             EndRect = new Rect(sliderClipWidth, 0, SliderWidth, SliderHeight);  
         }  
 
         private void SL_Bat1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)  
         {  
             if (e.NewValue > EndValue)  
                 StartValue = EndValue;  
             ClipSilder();  
             if (isSliderClicked)  
             {  
                 OnValueChanged(e.OldValue, e.NewValue);  
                 isSliderClicked = false;  
             }  
         }  
 
         private void SL_Bat2_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)  
         {  
             if (e.NewValue < StartValue)  
                 EndValue = StartValue;  
             ClipSilder();  
 
             if (isSliderClicked)  
             {  
                 OnValueChanged(e.OldValue, e.NewValue);  
                 isSliderClicked = false;  
             }  
         }  
 
         private void UC_Arrange_Loaded(object sender, RoutedEventArgs e)  
         {  
             ClipSilder();  
         }  
 
         private void SL_DragCompleted(object sender, DragCompletedEventArgs e)  
         {  
             OnValueChanged(-9999, ((Slider)sender).Value);  
         }  
 
         private void SL_Click(object sender, RoutedEventArgs e)  
         {  
             isSliderClicked = true;  
         }  
     }  
 }  
 

EarthquakeHeatFeatureLayer.cs

 using System;  
 using System.Collections.ObjectModel;  
 using System.Diagnostics;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class EarthquakeHeatFeatureLayer : FeatureLayer  
     {  
         private HeatLayer heatLayer;  
 
         public EarthquakeHeatFeatureLayer()  
             : this(null)  
         { }  
 
         public EarthquakeHeatFeatureLayer(FeatureSource featureSource)  
             : base()  
         {  
             FeatureSource = featureSource;  
         }  
 
         public new FeatureSource FeatureSource  
         {  
             get { return base.FeatureSource; }  
             set  
             {  
                 base.FeatureSource = value;  
                 heatLayer = new HeatLayer(value);  
             }  
         }  
 
         public HeatStyle HeatStyle  
         {  
             get { return heatLayer.HeatStyle; }  
             set { heatLayer.HeatStyle = value; }  
         }  
 
         protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             try  
             {  
                 heatLayer.Draw(canvas, labelsInAllLayers);  
             }  
             catch (Exception ex)  
             {  
                 Debug.WriteLine(ex.Message);  
             }  
         }  
     }  
 }  
 

EarthquakeIsoLineFeatureLayer.cs

 using System.Collections.Generic;  
 using System.Collections.ObjectModel;  
 using System.Globalization;  
 using System.Linq;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.EarthquakeStatistics.Properties;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class EarthquakeIsoLineFeatureLayer : FeatureLayer  
     {  
         private DynamicIsoLineLayer isoLineLayer;  
         private ClassBreakStyle levelClassBreakStyle;  
 
         public EarthquakeIsoLineFeatureLayer()  
             : this(null)  
         { }  
 
         public EarthquakeIsoLineFeatureLayer(ShapeFileFeatureSource featureSource)  
         {  
             FeatureSource = featureSource;  
         }  
 
         public new FeatureSource FeatureSource  
         {  
             get { return base.FeatureSource; }  
             set  
             {  
                 base.FeatureSource = value;  
                 Initialize();  
             }  
         }  
 
         public Collection<double> IsoLineLevels  
         {  
             get { return isoLineLayer.IsoLineLevels; }  
         }  
 
         public ClassBreakStyle LevelClassBreakStyle  
         {  
             get { return levelClassBreakStyle; }  
         }  
 
         protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)  
         {  
             isoLineLayer.Draw(canvas, labelsInAllLayers);  
         }  
 
         private void Initialize()  
         {  
             Collection<GeoColor> levelAreaColors = new Collection<GeoColor>();  
             levelAreaColors.Add(GeoColor.FromHtml("#FFFFBE"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDFF9E"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDFF37"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FDDA04"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FFA701"));  
             levelAreaColors.Add(GeoColor.FromHtml("#FF6F02"));  
             levelAreaColors.Add(GeoColor.FromHtml("#EC0000"));  
             levelAreaColors.Add(GeoColor.FromHtml("#B90000"));  
             levelAreaColors.Add(GeoColor.FromHtml("#850100"));  
             levelAreaColors.Add(GeoColor.FromHtml("#620001"));  
             levelAreaColors.Add(GeoColor.FromHtml("#450005"));  
             levelAreaColors.Add(GeoColor.FromHtml("#2B0804"));  
 
             FeatureSource.Open();  
 
             Dictionary<PointShape, double> dataPoints = GetDataPoints();  
             GridInterpolationModel interpolationModel = new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue);  
             isoLineLayer = new DynamicIsoLineLayer(dataPoints, GetClassBreakValues(dataPoints.Values, 12), interpolationModel, IsoLineType.ClosedLinesAsPolygons);  
 
             levelClassBreakStyle = new ClassBreakStyle(isoLineLayer.DataValueColumnName);  
             levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[0])))));  
             for (int i = 0; i < IsoLineLevels.Count - 1; i++)  
             {  
                 levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(IsoLineLevels[i|+ 1], new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[i|+ 1])))));  
             }  
             isoLineLayer.CustomStyles.Add(levelClassBreakStyle);  
 
             TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);  
             textStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);  
             textStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;  
             textStyle.SplineType = SplineType.StandardSplining;  
             textStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels;  
             textStyle.TextLineSegmentRatio = 9999999;  
             textStyle.FittingLineInScreen = true;  
             textStyle.SuppressPartialLabels = true;  
             textStyle.NumericFormat = "{0:0.00}";  
             isoLineLayer.CustomStyles.Add(textStyle);  
         }  
 
         private Dictionary<PointShape, double> GetDataPoints()  
         {  
             return (from feature in FeatureSource.GetAllFeatures(GetReturningColumns())  
                     where double.Parse(feature.ColumnValues[Resources.MagnitudeColumnName]) > 0  
                     select new PointShape  
                     {  
                         X = double.Parse(feature.ColumnValues[Resources.LongitudeColumnName], CultureInfo.InvariantCulture),  
                         Y = double.Parse(feature.ColumnValues[Resources.LatitudeColumnName], CultureInfo.InvariantCulture),  
                         Z = double.Parse(feature.ColumnValues[Resources.MagnitudeColumnName], CultureInfo.InvariantCulture)  
                     }).ToDictionary(point => point, point => point.Z);  
         }  
 
         private static IEnumerable<double> GetClassBreakValues(IEnumerable<double> values, int count)  
         {  
             Collection<double> result = new Collection<double>();  
             double[] sortedValues = values.OrderBy(v => v).ToArray();  
             int classCount = sortedValues.Length / count;  
             for (int i = 1; i < count; i++)  
             {  
                 result.Add(sortedValues[i|* classCount]);  
             }  
 
             return result;  
         }  
 
         private static IEnumerable<string> GetReturningColumns()  
         {  
             yield return Resources.LongitudeColumnName;  
             yield return Resources.LatitudeColumnName;  
             yield return Resources.MagnitudeColumnName;  
         }  
     }  
 }  
 

EarthquakeQueryFilter.cs

 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class EarthquakeQueryFilter : ViewModelBase  
     {  
         private double endYearRange;  
         private double endDepthRange;  
         private double startYearRange;  
         private double startDepthRange;  
         private double yearRangeMinimum;  
         private double yearRangeMaximum;  
         private double depthRangeMaximum;  
         private double depthRangeMinimum;  
         private double endMagnitudeRange;  
         private double startMagnitudeRange;  
         private double magnitudeRangeMaximum;  
         private double magnitudeRangeMinimum;  
 
         public EarthquakeQueryFilter()  
         {  
             MagnitudeRangeMinimum = 0;  
             MagnitudeRangeMaximum = 12;  
             DepthRangeMinimum = 0;  
             DepthRangeMaximum = 300;  
             YearRangeMinimum = 1568;  
             YearRangeMaximum = 2010;  
 
             endDepthRange = 300;  
             startDepthRange = 0;  
             endMagnitudeRange = 12;  
             startMagnitudeRange = 0;  
             endYearRange = 2010;  
             startYearRange = 1568;  
         }  
 
         public double DepthRangeMaximum  
         {  
             get { return depthRangeMaximum; }  
             set { depthRangeMaximum = value; }  
         }  
 
         public double DepthRangeMinimum  
         {  
             get { return depthRangeMinimum; }  
             set { depthRangeMinimum = value; }  
         }  
 
         public double EndDepthRange  
         {  
             get { return endDepthRange; }  
             set  
             {  
                 endDepthRange = value;  
                 RaisePropertyChanged(() => EndDepthRange);  
             }  
         }  
 
         public double StartDepthRange  
         {  
             get { return startDepthRange; }  
             set  
             {  
                 startDepthRange = value;  
                 RaisePropertyChanged(() => StartDepthRange);  
             }  
         }  
 
         public double EndMagnitudeRange  
         {  
             get { return endMagnitudeRange; }  
             set  
             {  
                 endMagnitudeRange = value;  
                 RaisePropertyChanged(() => EndMagnitudeRange);  
             }  
         }  
 
         public double StartMagnitudeRange  
         {  
             get { return startMagnitudeRange; }  
             set  
             {  
                 startMagnitudeRange = value;  
                 RaisePropertyChanged(() => StartMagnitudeRange);  
             }  
         }  
 
         public double EndYearRange  
         {  
             get { return endYearRange; }  
             set  
             {  
                 endYearRange = value;  
                 RaisePropertyChanged(() => EndYearRange);  
             }  
         }  
 
         public double StartYearRange  
         {  
             get { return startYearRange; }  
             set  
             {  
                 startYearRange = value;  
                 RaisePropertyChanged(() => StartYearRange);  
             }  
         }  
 
         public double MagnitudeRangeMaximum  
         {  
             get { return magnitudeRangeMaximum; }  
             set { magnitudeRangeMaximum = value; }  
         }  
 
         public double MagnitudeRangeMinimum  
         {  
             get { return magnitudeRangeMinimum; }  
             set { magnitudeRangeMinimum = value; }  
         }  
 
         public double YearRangeMaximum  
         {  
             get { return yearRangeMaximum; }  
             set { yearRangeMaximum = value; }  
         }  
 
         public double YearRangeMinimum  
         {  
             get { return yearRangeMinimum; }  
             set { yearRangeMinimum = value; }  
         }  
     }  
 }  
 

MapModel.cs

 using System;  
 using System.Collections.Generic;  
 using System.Configuration;  
 using System.Diagnostics;  
 using System.IO;  
 using System.Linq;  
 using System.Windows;  
 using System.Windows.Input;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.EarthquakeStatistics.Properties;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class MapModel  
     {  
         private static readonly RectangleShape defaultExtent = new RectangleShape(-19062735.6816748, 9273256.52450252, -5746827.16371793, 2673516.56066139);  
         private static Cursor handCursor = new Cursor(MapSuiteSampleHelper.GetImageStream("/Image/cursor_hand.cur"));  
 
         private WpfMap mapControl;  
         private InMemoryFeatureLayer markerMemoryLayer;  
         private InMemoryFeatureLayer markerMemoryHighlightLayer;  
 
         public event EventHandler<QueryAreaChangedMapModelEventArgs> QueryAreaChanged;  
 
         public MapModel()  
             : this(null)  
         { }  
 
         public MapModel(WpfMap map)  
         {  
             MapControl = map;  
         }  
 
         public WpfMap MapControl  
         {  
             get { return mapControl; }  
             set  
             {  
                 mapControl = value;  
                 InitializeMap();  
             }  
         }  
 
         public TrackMode TrackMode  
         {  
             get { return mapControl.TrackOverlay.TrackMode; }  
             set  
             {  
                 mapControl.TrackOverlay.TrackMode = value;  
                 mapControl.Cursor = value == TrackMode.None ? handCursor : Cursors.Arrow;  
             }  
         }  
 
         public LayerOverlay StyleLayerOverlay  
         {  
             get { return (LayerOverlay)mapControl.Overlays[Resources.StyleLayerOverLayKey]; }  
         }  
 
         public void ClearTrackResult()  
         {  
             mapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();  
             markerMemoryLayer.InternalFeatures.Clear();  
             markerMemoryHighlightLayer.InternalFeatures.Clear();  
 
             mapControl.Refresh(mapControl.TrackOverlay);  
             mapControl.Refresh(mapControl.Overlays[Resources.MarkerOverlayKey]);  
         }  
 
         public void UpdateHighlightMarker(Feature epicenterFeature)  
         {  
             markerMemoryHighlightLayer.InternalFeatures.Clear();  
             markerMemoryHighlightLayer.InternalFeatures.Add(epicenterFeature);  
 
             mapControl.Refresh(mapControl.Overlays[Resources.MarkerOverlayKey]);  
             mapControl.CenterAt(epicenterFeature);  
         }  
 
         public void SetEarthquakeLegendsVisible(Layer currentLayer)  
         {  
             EarthquakeIsoLineFeatureLayer earthquakeFeatureLayer = currentLayer as EarthquakeIsoLineFeatureLayer;  
             LegendAdornmentLayer earthquakeLegendLayer = GetEarthquakeLegendLayer(earthquakeFeatureLayer);  
             if (earthquakeLegendLayer != null)  
             {  
                 earthquakeLegendLayer.IsVisible = earthquakeFeatureLayer != null;  
             }  
         }  
 
         public void RefreshMarkersByFeatures(IEnumerable<Feature> features)  
         {  
             markerMemoryLayer.InternalFeatures.Clear();  
             markerMemoryHighlightLayer.InternalFeatures.Clear();  
 
             if (features != null)  
             {  
                 foreach (Feature item in features)  
                 {  
                     markerMemoryLayer.InternalFeatures.Add(item);  
                 }  
             }  
 
             mapControl.Overlays[Resources.MarkerOverlayKey].Refresh();  
         }  
 
         protected void OnQueryAreaChanged(BaseShape queringArea)  
         {  
             EventHandler<QueryAreaChangedMapModelEventArgs> handler = QueryAreaChanged;  
             if (handler != null) handler(this, new QueryAreaChangedMapModelEventArgs(new Feature(queringArea)));  
         }  
 
         private void TrackOverlay_TrackEnded(object sender, TrackEndedTrackInteractiveOverlayEventArgs e)  
         {  
             try  
             {  
                 PolygonShape[] allPolygonFeatures = mapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Select(f => f.GetShape()).OfType<PolygonShape>().ToArray();  
                 BaseShape trackedShape = SqlTypesGeometryHelper.Union(allPolygonFeatures);  
                 if (trackedShape != null)  
                 {  
                     OnQueryAreaChanged(trackedShape);  
                 }  
             }  
             catch (Exception ex)  
             {  
                 Debug.WriteLine(ex.Message);  
             }  
         }  
 
         private void InitializeMap()  
         {  
             mapControl.MapUnit = GeographyUnit.Meter;  
             mapControl.CurrentExtent = defaultExtent;  
             mapControl.MapTools.Logo.IsEnabled = false;  
             mapControl.MapTools.MouseCoordinate.IsEnabled = true;  
             mapControl.MapTools.MouseCoordinate.MouseCoordinateType = MouseCoordinateType.Custom;  
             mapControl.MapTools.MouseCoordinate.Visibility = Visibility.Hidden;  
             mapControl.MapTools.PanZoomBar.GlobeButtonClick += (s, e) => e.NewExtent = defaultExtent;  
 
             OverlaySwitcher overlaySwitcher = new OverlaySwitcher();  
             overlaySwitcher.Initialize(mapControl);  
             overlaySwitcher.OverlayChanged += OverlaySwitcherOverlayChanged;  
             mapControl.MapTools.Add(overlaySwitcher);  
 
             InitializeOverlays();  
         }  
 
         private void OverlaySwitcherOverlayChanged(object sender, OverlayChangedOverlaySwitcherEventArgs e)  
         {  
             BingMapsOverlay bingMapsOverlay = e.Overlay as BingMapsOverlay;  
             if (bingMapsOverlay != null)  
             {  
                 e.Cancel = ApplyBingMapsKey();  
             }  
         }  
 
         private bool ApplyBingMapsKey()  
         {  
             bool cancel = false;  
             string bingMapsKey = MapSuiteSampleHelper.GetBingMapsKey();  
             if (!string.IsNullOrEmpty(bingMapsKey))  
             {  
                 foreach (BingMapsOverlay bingOverlay in MapControl.Overlays.OfType<BingMapsOverlay>())  
                 {  
                     bingOverlay.ApplicationId = bingMapsKey;  
                 }  
             }  
             else  
             {  
                 cancel = true;  
             }  
 
             return cancel;  
         }  
 
         private void InitializeOverlays()  
         {  
             string cacheFolder = Path.Combine(Path.GetTempPath(), "TileCache");  
 
             WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();  
             worldMapKitOverlay.Name = Resources.WorldMapKitOverlayName;  
             worldMapKitOverlay.TileHeight = 512;  
             worldMapKitOverlay.TileWidth = 512;  
             worldMapKitOverlay.Projection = WorldMapKitProjection.SphericalMercator;  
             worldMapKitOverlay.IsVisible = true;  
             worldMapKitOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.WorldMapKitOverlayName);  
             mapControl.Overlays.Add(worldMapKitOverlay);  
 
             OpenStreetMapOverlay openStreetMapOverlay = new OpenStreetMapOverlay();  
             openStreetMapOverlay.Name = Resources.OSMOverlayName;  
             openStreetMapOverlay.TileHeight = 512;  
             openStreetMapOverlay.TileWidth = 512;  
             openStreetMapOverlay.IsVisible = false;  
             openStreetMapOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.OSMOverlayName);  
             mapControl.Overlays.Add(openStreetMapOverlay);  
 
             BingMapsOverlay bingMapsAerialOverlay = new BingMapsOverlay();  
             bingMapsAerialOverlay.Name = Resources.BingMapsAerialOverlayName;  
             bingMapsAerialOverlay.TileHeight = 512;  
             bingMapsAerialOverlay.TileWidth = 512;  
             bingMapsAerialOverlay.MapType = BingMapsMapType.Aerial;  
             bingMapsAerialOverlay.IsVisible = false;  
             bingMapsAerialOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsAerialOverlayName);  
             mapControl.Overlays.Add(bingMapsAerialOverlay);  
 
             BingMapsOverlay bingMapsRoadOverlay = new BingMapsOverlay();  
             bingMapsRoadOverlay.Name = Resources.BingMapsRoadOverlayName;  
             bingMapsRoadOverlay.TileHeight = 512;  
             bingMapsRoadOverlay.TileWidth = 512;  
             bingMapsRoadOverlay.MapType = BingMapsMapType.Road;  
             bingMapsRoadOverlay.IsVisible = false;  
             bingMapsRoadOverlay.TileCache = new FileBitmapTileCache(cacheFolder, Resources.BingMapsRoadOverlayName);  
             mapControl.Overlays.Add(bingMapsRoadOverlay);  
 
             LayerOverlay styleLayersOverLay = new LayerOverlay();  
             styleLayersOverLay.TileType = TileType.SingleTile;  
             mapControl.Overlays.Add(Resources.StyleLayerOverLayKey, styleLayersOverLay);  
 
             ManagedProj4Projection wgs84ToMercatorProjection = new ManagedProj4Projection();  
             wgs84ToMercatorProjection.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();  
             wgs84ToMercatorProjection.ExternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();  
 
             EarthquakeHeatFeatureLayer heatLayer = new EarthquakeHeatFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));  
             heatLayer.HeatStyle = new HeatStyle(10, 100, Resources.MagnitudeColumnName, 0, 12, 100, DistanceUnit.Kilometer);  
             heatLayer.FeatureSource.Projection = wgs84ToMercatorProjection;  
             heatLayer.Name = Resources.HeatStyleLayerName;  
             styleLayersOverLay.Layers.Add(heatLayer);  
 
             ShapeFileFeatureLayer pointLayer = new ShapeFileFeatureLayer(ConfigurationManager.AppSettings["DataShapefileFileName"]);  
             pointLayer.FeatureSource.Projection = wgs84ToMercatorProjection;  
             pointLayer.Name = Resources.PointStyleLayerName;  
             pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 6, GeoColor.StandardColors.White, 1);  
             pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             styleLayersOverLay.Layers.Add(pointLayer);  
 
             EarthquakeIsoLineFeatureLayer isoLineLayer = new EarthquakeIsoLineFeatureLayer(new ShapeFileFeatureSource(ConfigurationManager.AppSettings["DataShapefileFileName"]));  
             isoLineLayer.FeatureSource.Projection = wgs84ToMercatorProjection;  
             isoLineLayer.Name = Resources.IsolineStyleLayerName;  
             styleLayersOverLay.Layers.Add(isoLineLayer);  
 
             //Setup TarckOverlay.  
             mapControl.TrackOverlay = new RadiusMearsureTrackInteractiveOverlay(DistanceUnit.Mile, mapControl.MapUnit);  
             mapControl.TrackOverlay.TrackEnded += TrackOverlay_TrackEnded;  
 
             LayerOverlay markerOverlay = new LayerOverlay();  
             mapControl.Overlays.Add(Resources.MarkerOverlayKey, markerOverlay);  
 
             PointStyle highLightStyle = new PointStyle();  
             highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(50, GeoColor.SimpleColors.Blue), 20, GeoColor.SimpleColors.LightBlue, 1));  
             highLightStyle.CustomPointStyles.Add(PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.LightBlue, 9, GeoColor.SimpleColors.Blue, 1));  
 
             markerMemoryLayer = new InMemoryFeatureLayer();  
             markerMemoryLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.Orange, 8, GeoColor.SimpleColors.White, 1);  
             markerMemoryLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             markerOverlay.Layers.Add(markerMemoryLayer);  
 
             markerMemoryHighlightLayer = new InMemoryFeatureLayer();  
             markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = highLightStyle;  
             markerMemoryHighlightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
             markerOverlay.Layers.Add(markerMemoryHighlightLayer);  
 
             ScaleBarAdornmentLayer scaleBarAdornmentLayer = new ScaleBarAdornmentLayer();  
             scaleBarAdornmentLayer.UnitFamily = UnitSystem.Imperial;  
             mapControl.AdornmentOverlay.Layers.Add(scaleBarAdornmentLayer);  
         }  
 
         private LegendAdornmentLayer GetEarthquakeLegendLayer(EarthquakeIsoLineFeatureLayer earthquakeFeatureLayer)  
         {  
             LegendAdornmentLayer isoLevelLegendLayer = null;  
             if (mapControl.AdornmentOverlay.Layers.Contains(Resources.IsoLineLevelLegendLayerName))  
             {  
                 isoLevelLegendLayer = (LegendAdornmentLayer)mapControl.AdornmentOverlay.Layers[Resources.IsoLineLevelLegendLayerName];  
             }  
             else if (earthquakeFeatureLayer != null)  
             {  
                 isoLevelLegendLayer = new LegendAdornmentLayer();  
                 isoLevelLegendLayer.Width = 85;  
                 isoLevelLegendLayer.Height = 320;  
                 isoLevelLegendLayer.Location = AdornmentLocation.LowerRight;  
                 isoLevelLegendLayer.ContentResizeMode = LegendContentResizeMode.Fixed;  
                 mapControl.AdornmentOverlay.Layers.Add(Resources.IsoLineLevelLegendLayerName, isoLevelLegendLayer);  
 
                 LegendItem flagLegendItem = new LegendItem();  
                 flagLegendItem.TextStyle = new TextStyle("Magnitude", new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.StandardColors.Black));  
                 flagLegendItem.TextLeftPadding = -20;  
                 isoLevelLegendLayer.LegendItems.Add(flagLegendItem);  
 
                 for (int i = 0; i < earthquakeFeatureLayer.IsoLineLevels.Count; i++)  
                 {  
                     LegendItem legendItem = new LegendItem();  
                     legendItem.TextStyle = new TextStyle(earthquakeFeatureLayer.IsoLineLevels[i].ToString("f2"), new GeoFont("Arial", 10), new GeoSolidBrush(GeoColor.StandardColors.Black));  
                     legendItem.ImageStyle = earthquakeFeatureLayer.LevelClassBreakStyle.ClassBreaks[i].DefaultAreaStyle;  
                     legendItem.ImageWidth = 25;  
 
                     isoLevelLegendLayer.LegendItems.Add(legendItem);  
                 }  
             }  
 
             return isoLevelLegendLayer;  
         }  
     }  
 }  
 

QueryAreaChangedMapModelEventArgs.cs

 using System;  
 using ThinkGeo.MapSuite.Core;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class QueryAreaChangedMapModelEventArgs : EventArgs  
     {  
         private Feature queryFeature;  
 
         public QueryAreaChangedMapModelEventArgs()  
             : this(null)  
         {  
         }  
 
         public QueryAreaChangedMapModelEventArgs(Feature queryFeature)  
         {  
             this.queryFeature = queryFeature;  
         }  
 
         public Feature QueryFeature  
         {  
             get { return queryFeature; }  
             set { queryFeature = value; }  
         }  
     }  
 }  
 

RadiusMearsureTrackInteractiveOverlay.cs

 using System.Globalization;  
 using System.Windows;  
 using System.Windows.Controls;  
 using ThinkGeo.MapSuite.Core;  
 using ThinkGeo.MapSuite.EarthquakeStatistics.Properties;  
 using ThinkGeo.MapSuite.WpfDesktopEdition;  
 
 namespace ThinkGeo.MapSuite.EarthquakeStatistics  
 {  
     public class RadiusMearsureTrackInteractiveOverlay : TrackInteractiveOverlay  
     {  
         private AreaStyle areaStyle;  
         private LineStyle lineStyle;  
         private PointStyle pointStyle;  
         private Vertex circleCenterVertex;  
         private LineShape radiusLine;  
         private TextBlock textBlock;  
 
         public RadiusMearsureTrackInteractiveOverlay()  
             : this(DistanceUnit.Mile, GeographyUnit.DecimalDegree)  
         {  
         }  
 
         public RadiusMearsureTrackInteractiveOverlay(DistanceUnit distanceUnit, GeographyUnit mapUnit)  
         {  
             DistanceUnit = distanceUnit;  
             MapUnit = mapUnit;  
 
             textBlock = new TextBlock();  
             textBlock.Visibility = Visibility.Collapsed;  
             OverlayCanvas.Children.Add(textBlock);  
 
             PolygonTrackMode = PolygonTrackMode.LineWithFill;  
             RenderMode = RenderMode.DrawingVisual;  
 
             areaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(80, GeoColor.SimpleColors.LightGreen), GeoColor.SimpleColors.White, 2);  
             pointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.SimpleColors.DarkBlue, 8);  
             lineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.White, 3, true);  
 
             SetStylesForInMemoryFeatureLayer(TrackShapeLayer);  
             SetStylesForInMemoryFeatureLayer(TrackShapesInProcessLayer);  
         }  
 
         public DistanceUnit DistanceUnit { get; set; }  
 
         public GeographyUnit MapUnit { get; set; }  
 
         protected override RectangleShape GetBoundingBoxCore()  
         {  
             return ExtentHelper.GetBoundingBoxOfItems(TrackShapeLayer.InternalFeatures);  
         }  
 
         protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments)  
         {  
             if (TrackMode == TrackMode.Circle)  
             {  
                 circleCenterVertex = new Vertex(interactionArguments.WorldX, interactionArguments.WorldY);  
                 TrackShapeLayer.InternalFeatures.Add(Resources.CenterFeatureKey, new Feature(circleCenterVertex));  
             }  
 
             return base.MouseDownCore(interactionArguments);  
         }  
 
         protected override InteractiveResult MouseMoveCore(InteractionArguments interactionArguments)  
         {  
             InteractiveResult arguments = base.MouseMoveCore(interactionArguments);  
             if (Vertices.Count == 0)  
             {  
                 textBlock.Visibility = Visibility.Collapsed;  
             }  
             else if (TrackMode == TrackMode.Circle && interactionArguments.MouseButton == MapMouseButton.Left)  
             {  
                 Vertex currentVertex = new Vertex(interactionArguments.WorldX, interactionArguments.WorldY);  
                 radiusLine = new LineShape(new[] { circleCenterVertex, currentVertex });  
                 TrackShapeLayer.InternalFeatures[Resources.RadiusFeatureKey] = new Feature(radiusLine);  
 
                 Canvas.SetLeft(textBlock, interactionArguments.ScreenX + 10);  
                 Canvas.SetTop(textBlock, interactionArguments.ScreenY + 10);  
             }  
 
             return arguments;  
         }  
 
         protected override void OnDrawing(DrawingOverlayEventArgs e)  
         {  
             MeasureRadius();  
             base.OnDrawing(e);  
         }  
 
         protected override void OnMapMouseUp(MapMouseUpInteractiveOverlayEventArgs e)  
         {  
             base.OnMapMouseUp(e);  
 
             if (TrackMode == TrackMode.Circle)  
             {  
                 if (TrackShapeLayer.InternalFeatures.Contains(Resources.CenterFeatureKey))  
                 {  
                     TrackShapeLayer.InternalFeatures.Remove(Resources.CenterFeatureKey);  
                 }  
 
                 if (TrackShapeLayer.InternalFeatures.Contains(Resources.RadiusFeatureKey))  
                 {  
                     TrackShapeLayer.InternalFeatures.Remove(Resources.RadiusFeatureKey);  
                 }  
             }  
         }  
 
         protected override void OnTrackEnded(TrackEndedTrackInteractiveOverlayEventArgs e)  
         {  
             textBlock.Visibility = Visibility.Collapsed;  
             base.OnTrackEnded(e);  
         }  
 
         protected override void OnTrackStarting(TrackStartingTrackInteractiveOverlayEventArgs e)  
         {  
             if (TrackMode == TrackMode.Circle)  
             {  
                 textBlock.Visibility = Visibility.Visible;  
             }  
             base.OnTrackStarting(e);  
         }  
 
         private static string GetAbbreviateDistanceUnit(DistanceUnit unit)  
         {  
             switch (unit)  
             {  
                 case DistanceUnit.Mile:  
                     return "mi";  
                 case DistanceUnit.Kilometer:  
                     return "km";  
                 case DistanceUnit.Meter:  
                     return "m";  
                 case DistanceUnit.Inch:  
                     return "in";  
                 default:  
                     return ".";  
             }  
         }  
 
         private void MeasureRadius()  
         {  
             if (TrackMode == TrackMode.Circle)  
             {  
                 if (TrackShapeLayer.InternalFeatures.Count > 0 && radiusLine != null)  
                 {  
                     double radius = radiusLine.GetLength(MapUnit, DistanceUnit);  
                     textBlock.Text = string.Format(CultureInfo.InvariantCulture, "{0:N3} {1}", radius, GetAbbreviateDistanceUnit(DistanceUnit));  
                 }  
             }  
         }  
 
         private void SetStylesForInMemoryFeatureLayer(FeatureLayer featureLayer)  
         {  
             featureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = areaStyle;  
             featureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = lineStyle;  
             featureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = pointStyle;  
 
             featureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
         }  
     }  
 }  
 
source_code_wpf_desktopeditionsample_mapsuiteusearthquakestatistics_cs_141202.zip.txt · Last modified: 2015/09/09 03:39 by admin