public WindowShapeFileTest(ShapeFileInfo shapeFileInfo)
        {
            Areas = new List <string>();
            try
            {
                _sf = new ShapeFile(shapeFileInfo.Filename);
                if (_sf.Initialize(shapeFileInfo.TableName,
                                   (ShapeFile.CoordType)Enum.Parse(typeof(ShapeFile.CoordType), shapeFileInfo.TCoord),
                                   (AreaType)Enum.Parse(typeof(AreaType), shapeFileInfo.TArea),
                                   shapeFileInfo.Prefix ?? "",
                                   shapeFileInfo.Encoding))
                {
                    var ail = _sf.AreaInfos;
                    Areas = (from a in ail orderby a.Name select a.Name).ToList();
                }
            }
            catch
            {
            }
            InitializeComponent();
            _browser = new UIControls.WebBrowserControl();
            this.webBrowser.Children.Add(_browser);
            DataContext = this;

            this.Closed += WindowShapeFileTest_Closed;
        }
        public WindowShapefiles()
        {
            InitializeComponent();

            if (Settings.Settings.ApplicationRunning)
            {
                _listData = new ObservableCollection <ShapeFileInfo>();
                var sfls = Settings.Settings.Default.GetShapeFileItems();
                foreach (var si in sfls)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(si.FileName) && System.IO.File.Exists(si.FileName))
                        {
                            var sf = new ShapeFileInfo();
                            sf.Enabled   = si.Enabled != 0;
                            sf.Filename  = si.FileName;
                            sf.TableName = si.TableName;
                            sf.TCoord    = si.CoordType;
                            sf.TArea     = si.AreaType;
                            sf.Prefix    = si.NamePrefix;
                            sf.Encoding  = si.Encoding;

                            using (ShapeFile s = new ShapeFile(sf.Filename))
                            {
                                sf.TableNames = s.GetFields().ToList();
                            }
                            sf.TAreas     = Enum.GetNames(typeof(AreaType)).ToList();
                            sf.TCoords    = Enum.GetNames(typeof(ShapeFile.CoordType)).ToList();
                            sf.TEncodings = new List <string>()
                            {
                                "utf-8", "ISO-8859-1"
                            };

                            _listData.Add(sf);
                        }
                    }
                    catch
                    {
                    }
                }

                DataContext          = this;
                dataGrid.ItemsSource = _listData;
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "";                       // Default file name
            dlg.DefaultExt = ".shp";                   // Default file extension
            dlg.Filter     = "Shapefile (.shp)|*.shp"; // Filter files by extension

            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                var sf = new ShapeFileInfo();
                sf.Enabled    = true;
                sf.Filename   = dlg.FileName;
                sf.TableName  = "";
                sf.TCoord     = ShapeFile.CoordType.WGS84.ToString();
                sf.TArea      = AreaType.Other.ToString();
                sf.Prefix     = "";
                sf.Encoding   = "utf-8";
                sf.TEncodings = new List <string>()
                {
                    "utf-8", "ISO-8859-1"
                };

                using (ShapeFile s = new ShapeFile(sf.Filename))
                {
                    sf.TableNames = s.GetFields().ToList();
                }
                sf.TAreas  = Enum.GetNames(typeof(AreaType)).ToList();
                sf.TCoords = Enum.GetNames(typeof(ShapeFile.CoordType)).ToList();

                _listData.Add(sf);
            }
        }