コード例 #1
0
        public void AddGeocoder()
        {
            try
            {
                var dlgLayer = new SelectCacheLayerDialog();
                dlgLayer.Owner            = View;
                dlgLayer.ViewModel.Caches = Configuration.MapServices.Where(srvc => !srvc.IsBaseMap);
                dlgLayer.ShowDialog();

                if (dlgLayer.DialogResult == true)
                {
                    var cache = dlgLayer.ViewModel.Caches.FirstOrDefault(cach => cach.URL == dlgLayer.ViewModel.ServiceUrl);
                    var layer = dlgLayer.ViewModel.Layer;

                    var dlgCache = new EditGeocoderDialog();
                    dlgCache.Owner = View;
                    dlgCache.ViewModel.LayerInfo = layer;
                    dlgCache.ViewModel.Configuration.CacheName = cache.Name;
                    dlgCache.ViewModel.Configuration.LayerName = layer.Name;
                    dlgCache.ViewModel.Configuration.LayerID   = layer.ID;
                    dlgCache.ShowDialog();

                    if (dlgCache.DialogResult == true)
                    {
                        Configuration.Geocoders.Add(dlgCache.ViewModel.Configuration);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error adding cache settings", ex);
            }
        }
コード例 #2
0
        public void AddStreetIntersectionFinder()
        {
            try
            {
                var dlgLayer = new SelectCacheLayerDialog();
                dlgLayer.Owner            = View;
                dlgLayer.ViewModel.Caches = Configuration.MapServices.Where(srvc => !srvc.IsBaseMap);
                dlgLayer.ShowDialog();

                if (dlgLayer.DialogResult == true)
                {
                    var cache = dlgLayer.ViewModel.Caches.FirstOrDefault(cach => cach.URL == dlgLayer.ViewModel.ServiceUrl);
                    var layer = dlgLayer.ViewModel.Layer;

                    var dlgField = new SelectFieldDialog();
                    dlgField.Owner           = View;
                    dlgField.ViewModel.Layer = layer;
                    dlgField.ShowDialog();

                    if (dlgField.DialogResult == true)
                    {
                        Configuration.StreetList.Add(new StreetFinderSettings
                        {
                            CacheName       = cache.Name,
                            LayerName       = layer.Name,
                            LayerID         = layer.ID,
                            StreetNameField = dlgField.ViewModel.Field.Name
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, "Error adding cache settings", ex);
            }
        }