public void Init() { var folder = AppState.Config.Get("ShapeLayer.Folder", ""); if (String.IsNullOrEmpty(folder)) return; _folder = folder; var groupName = AppState.Config.Get("ShapeLayer.GroupName", "Shapes"); var layer = new GroupLayer {ID = groupName}; layer.Initialize(); layer.Visible = true; _gl = layer; _bgWorker = new BackgroundWorker(); _bgWorker.DoWork += _bgWorker_DoWork; _bgWorker.RunWorkerCompleted += _bgWorker_RunWorkerCompleted; _bgWorker.RunWorkerAsync(); }
/// <summary> /// Reads the folder that is configured in the settings and creates layers for the files in the folders. /// </summary> public void ReadFolder(string path, GroupLayer curGrLayer) { //Canvas cnvs = new Canvas(); //dispatcher = cnvs.Dispatcher; //string path = @"D:\Projects\TNO\bitBucket\apps\ufData\Forest2000"; Execute.OnUIThread(() => { foreach (var file in Directory.EnumerateFiles(path)) { if (file.ToLower().EndsWith(".shp")) { AddShapefile(file, curGrLayer); // Hier wordt de locale shape geladen. } if(file.ToLower().EndsWith(".kml")) { AddKmlFile(file, curGrLayer); } } foreach (var folder in Directory.EnumerateDirectories(path)) { // Add Subfolders as new grouplayers var di = new DirectoryInfo(folder); var newGl = new GroupLayer {ID = di.Name}; newGl.Initialize(); curGrLayer.ChildLayers.Add(newGl); ReadFolder(folder, newGl); } }); }