Пример #1
0
        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)
            {
                ShapeFileInfo sf = new ShapeFileInfo();
                sf.Enabled   = true;
                sf.Filename  = dlg.FileName;
                sf.TableName = "";
                sf.TCoord    = ShapeFile.CoordType.WGS84.ToString();
                sf.TArea     = Core.Data.AreaType.Other.ToString();
                sf.Prefix    = "";
                sf.Encoding  = "";

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

                _listData.Add(sf);
            }
        }
Пример #2
0
        public SettingsWindow()
        {
            InitializeComponent();

            _listData = new ObservableCollection<ShapeFileInfo>();

            if (!string.IsNullOrEmpty(Core.Settings.Default.ShapeFiles))
            {
                string[] lines = Core.Settings.Default.ShapeFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string shpFile in lines)
                {
                    //enabled
                    //file name
                    //table name for name of area
                    //Coord type
                    //Area type
                    //name prefix
                    string[] parts = shpFile.Split(new char[] { '|' }, 7);
                    if (parts.Length >= 6)
                    {
                        try
                        {
                            ShapeFileInfo sf = new ShapeFileInfo();
                            sf.Enabled = bool.Parse(parts[0]);
                            sf.Filename = parts[1];
                            sf.TableName = parts[2];
                            sf.TCoord = parts[3];
                            sf.TArea = parts[4];
                            sf.Prefix = parts[5];
                            if (parts.Length>6)
                            {
                                sf.Encoding = parts[6];
                            }
                            else
                            {
                                sf.Encoding = "";
                            }

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

                            _listData.Add(sf);
                        }
                        catch(Exception e)
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, e);
                        }
                    }
                }
            }

            dataGrid.ItemsSource = _listData;
        }
Пример #3
0
        public SettingsWindow()
        {
            InitializeComponent();

            _listData = new ObservableCollection <ShapeFileInfo>();

            if (!string.IsNullOrEmpty(Core.Settings.Default.ShapeFiles))
            {
                string[] lines = Core.Settings.Default.ShapeFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string shpFile in lines)
                {
                    //enabled
                    //file name
                    //table name for name of area
                    //Coord type
                    //Area type
                    //name prefix
                    string[] parts = shpFile.Split(new char[] { '|' }, 7);
                    if (parts.Length >= 6)
                    {
                        try
                        {
                            ShapeFileInfo sf = new ShapeFileInfo();
                            sf.Enabled   = bool.Parse(parts[0]);
                            sf.Filename  = parts[1];
                            sf.TableName = parts[2];
                            sf.TCoord    = parts[3];
                            sf.TArea     = parts[4];
                            sf.Prefix    = parts[5];
                            if (parts.Length > 6)
                            {
                                sf.Encoding = parts[6];
                            }
                            else
                            {
                                sf.Encoding = "";
                            }

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

                            _listData.Add(sf);
                        }
                        catch (Exception e)
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, e);
                        }
                    }
                }
            }

            dataGrid.ItemsSource = _listData;
        }
Пример #4
0
        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)
            {
                ShapeFileInfo sf = new ShapeFileInfo();
                sf.Enabled = true;
                sf.Filename = dlg.FileName;
                sf.TableName = "";
                sf.TCoord = ShapeFile.CoordType.WGS84.ToString();
                sf.TArea = Core.Data.AreaType.Other.ToString();
                sf.Prefix = "";
                sf.Encoding = "";

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

                _listData.Add(sf);
            }

        }