示例#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
        public bool Initialize()
        {
            Clear();

            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
                        {
                            if (bool.Parse(parts[0]))
                            {
                                string encoding = "";
                                if (parts.Length >= 7)
                                {
                                    encoding = parts[6];
                                }
                                ShapeFile sf = new ShapeFile(parts[1]);
                                if (sf.Initialize(parts[2], (ShapeFile.CoordType)Enum.Parse(typeof(ShapeFile.CoordType), parts[3]), (Core.Data.AreaType)Enum.Parse(typeof(Core.Data.AreaType), parts[4]), parts[5], encoding))
                                {
                                    _shapeFiles.Add(sf);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, e);
                        }
                    }
                }
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(""));
            }

            return(true);
        }
示例#5
0
        public bool Initialize()
        {
            Clear();

            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
                        {
                            if (bool.Parse(parts[0]))
                            {
                                string encoding = "";
                                if (parts.Length >= 7)
                                {
                                    encoding = parts[6];
                                }
                                ShapeFile sf = new ShapeFile(parts[1]);
                                if (sf.Initialize(parts[2], (ShapeFile.CoordType)Enum.Parse(typeof(ShapeFile.CoordType), parts[3]), (Core.Data.AreaType)Enum.Parse(typeof(Core.Data.AreaType), parts[4]), parts[5], encoding))
                                {
                                    _shapeFiles.Add(sf);
                                }
                            }
                        }
                        catch(Exception e)
                        {
                            Core.ApplicationData.Instance.Logger.AddLog(this, e);
                        }
                    }
                }
            }

            if (PropertyChanged!=null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(""));
            }

            return true;
        }
示例#6
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);
            }

        }