public FindNearestNamePlace(GazetterPlugin plugin) { InitializeComponent(); this.Plugin = plugin; if (plugin == null || plugin.CurrentGazetteer == null) { ErrorMessage.Show("Please select a gazeeteer file before using this tool."); this.Loaded += new RoutedEventHandler((source, e) => { this.Close(); }); return; } lblGaz.Content = "Using " + Service.FileName; cmbPlaceType.IsEnabled = false; chkRestrictPlaceType.Checked += new RoutedEventHandler(chkRestrictPlaceType_Checked); chkRestrictPlaceType.Unchecked += new RoutedEventHandler(chkRestrictPlaceType_Unchecked); if (plugin.CurrentSelectedPlace != null) { var selected = plugin.CurrentSelectedPlace; ctlPosition.Latitude = selected.Latitude; ctlPosition.Longitude = selected.Longitude; } ListViewDragHelper.Bind(lstResults, CreateDragData); var lastMode = Config.GetUser <LatLongMode>(PluginManager.Instance.User, "Gazetteer.NearestNamePlace.LatLongMode", LatLongMode.DegreesMinutesSeconds); SetLatLongMode(lastMode); SetDistanceUnits(Config.GetUser <DistanceUnits>(PluginManager.Instance.User, "Gazetteer.NearestNamePlace.DistanceUnits", DistanceUnits.Kilometers)); }
public Gazetteer(GazetterPlugin owner) { InitializeComponent(); _searchModel = new ObservableCollection <PlaceNameViewModel>(); lstResults.ItemsSource = _searchModel; _owner = owner; btnDataInfo.IsEnabled = false; List <string> list = Config.GetUser(_owner.User, "gazetteer.recentlyUsedFiles", new List <string>()); _fileMRU = new ObservableCollection <GazetteerFile>(list.ConvertAll((path) => { return(new GazetteerFile(path)); })); cmbFile.ItemsSource = _fileMRU; cmbFile.SelectionChanged += new SelectionChangedEventHandler(cmbFile_SelectionChanged); _offsetControl = new OffsetControl(); _offsetControl.SelectedPlaceNameChanged += new Action <PlaceName>((place) => { UpdateMap(); }); _dirDistControl = new DistanceDirectionControl(); lstResults.SelectionChanged += new SelectionChangedEventHandler(lstResults_SelectionChanged); optFindDistDir.Checked += new RoutedEventHandler(optFindDistDir_Checked); optFindLatLong.Checked += new RoutedEventHandler(optFindLatLong_Checked); optFindLatLong.IsChecked = true; Loaded += new RoutedEventHandler(Gazetteer_Loaded); ListBoxDragHelper.Bind(lstResults, CreateDragData); _mapUpdateTimer = new Timer((state) => { // Disable the timer... _mapUpdateTimer.Change(Timeout.Infinite, Timeout.Infinite); UpdateMapAsync(); }, null, Timeout.Infinite, Timeout.Infinite); }