//private void UnregisterViewModel(IWorkList workList) //{ // SelectionWorkListVm vm = GetObserverByWorklistName(workList.Name) as SelectionWorkListVm; // if (vm != null) // { // UnregisterObserver(vm); // } //} private async Task OnProjectOpendedAsync(ProjectEventArgs e) { // todo daro: // 1) Check all existing project items. // 2) Add a work list factory to registry for every work list project item found in custom project items // (Use work list factory because we do not want to create a work list for EVERY work list project item. // Only create a work list (from a work list factory / work list custom project item) if a layer requests a work // list as a data source // order of method calls: // 1. Module.Initialize // 2. OnProjectOpenedAsync // 3. OnProjectOpened // 4. Pluggable Datasource Open() // todo daro: later this is replaced with custom project items // todo daro QueuedTask needed? await QueuedTask.Run(() => { // todo daro: use ConfigurationUtils? // todo daro: revise! foreach (string path in GetDefinitionFiles()) //foreach (var path in ProjectRepository.Current.GetProjectFileItems(ProjectItemType.WorkListDefinition)) { string workListName = WorkListUtils.GetName(path); var factory = new XmlBasedWorkListFactory(path, workListName); Assert.True(_registry.TryAdd(factory), $"work list {factory.Name} already added"); } }); }
public override void Open([NotNull] Uri connectionPath) // "open workspace" { Assert.ArgumentNotNull(connectionPath, nameof(connectionPath)); _msg.Debug($"Try to open {connectionPath}"); // Empirical: when opening a project (.aprx) with a saved layer // using our Plugin Datasource, the connectionPath will be // prepended with the project file's directory path and // two times URL encoded (e.g., ' ' => %20 => %2520)! var path = connectionPath.IsAbsoluteUri ? connectionPath.LocalPath : connectionPath.ToString(); path = HttpUtility.UrlDecode(path); path = HttpUtility.UrlDecode(path); string name = WorkListUtils.GetName(path); _tableNames = new ReadOnlyCollection <string>( new List <string> { FormatTableName(name) }); }
public string ShowWorklist([NotNull] WorkEnvironmentBase environment, [NotNull] string path) { Assert.ArgumentNotNull(environment, nameof(environment)); Assert.ArgumentNotNullOrEmpty(path, nameof(path)); IWorkList worklist; string name = WorkListUtils.GetName(path).ToLower(); if (_registry.Exists(name)) { worklist = _registry.Get(name); } else { var factory = new XmlBasedWorkListFactory(path, name); if (_registry.TryAdd(factory)) { _msg.Debug($"Add work list {name} from file {path}"); } worklist = _registry.Get(name); } Assert.NotNull(worklist); if (!_viewsByWorklistName.ContainsKey(worklist.Name)) { var item = ProjectItemUtils.Get <WorklistItem>(Path.GetFileName(path)); if (item == null) { Assert.True(ProjectItemUtils.TryAdd(path, out item), $"Cannot add item {path}"); Assert.NotNull(item); } _viewsByWorklistName.Add(worklist.Name, new WorkListObserver(worklist, item)); Uri uri = WorkListUtils.GetDatasource(GetProject().HomeFolderPath, name, environment.FileSuffix); FeatureLayer layer = AddLayer(uri, name, item.Name); // use item name as layer name (and as view display name as well) LayerUtils.ApplyRenderer(layer, environment.GetLayerDocument()); } return(Assert.NotNullOrEmpty(worklist.Name)); }
public override Item CreateItem(string name, string path, string containerType, string data) { var item = ItemFactory.Instance.Create(path) as WorklistItem; if (item == null) { // todo daro remove items from project if they can't be restored, e.g. deleted on file system? return(null); } item.IncludeInPackages(true); item.WorklistName = WorkListUtils.GetName(path); Add(item); return(item); }
private async Task OnProjectItemRemoving(ProjectItemRemovingEventArgs e) { await ViewUtils.TryAsync(QueuedTask.Run(() => { foreach (var item in e.ProjectItems.OfType <WorklistItem>()) { string name = WorkListUtils.GetName(item.Path); Assert.NotNullOrEmpty(name); //Item container = Project.Current.GetProjectItemContainer(WorklistsContainer.ContainerTypeName); //var worklistsContainer = container as WorklistsContainer; //worklistsContainer?.Refresh(); //foreach (Item cont in Project.Current.ProjectItemContainers) //{ // string contType = cont.Type; // string contTypeID = cont.TypeID; //} if (_layersByWorklistName.TryGetValue(name, out FeatureLayer worklistLayer)) { // this does NOT call the OnLayerRemovingAsync event handler!!o // OnLayerRemovingAsync is called when the layer is removes manually MapView.Active.Map.RemoveLayer(worklistLayer); foreach (IWorkList worklist in GetAssociatedWorklists( new Layer[] { worklistLayer })) { // no need to persist work list state, work list gets deleted Unload(worklist); Assert.True(_registry.Remove(worklist), $"Cannot remove work list {worklist.Name} from registry"); } } } }), _msg); // NOTE collapses Worklists folder, refresh of folder would be better //var projectItem = ProjectItemUtils.Get<MapProjectItem>().ToList(); //List<Item> items = projectItem?.GetItems()?.ToList(); //string folderName = "Worklists"; //Item firstOrDefault = items?.FirstOrDefault(i => string.Equals(folderName, i.Name)); }