示例#1
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);
        }
示例#2
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;
        }