コード例 #1
0
        private void ShowRegionMap()
        {
            var regions = new List<RegionDescriptor>();

            foreach (HierarchicalViewModelBase vm in _model) {
                vm.Traverse((item) => {
                    if (item is DistributionViewModel) {
                        var model = item as DistributionViewModel;
                        regions.Add(new RegionDescriptor(model.DistRegionFullPath, model.ThroughoutRegion));
                    }
                });
            }

            PluginManager.Instance.ShowRegionSelector(regions, (selectedRegions) => {

                if (!IsReadOnly) {
                    var newModel = new ObservableCollection<HierarchicalViewModelBase>();

                    // rebuild the model from the new list of regions...
                    foreach (RegionDescriptor region in selectedRegions) {
                        var existing = FindDistributionByPath(region.Path);
                        TaxonDistribution model = null;
                        if (existing != null) {
                            model = existing.Model;
                        } else {
                            model = new TaxonDistribution();
                            model.DistRegionFullPath = region.Path;
                            model.BiotaDistID = -1;
                            model.ThroughoutRegion = region.IsThroughoutRegion;
                        }
                        AddViewModelByPath(newModel, model);
                    }

                    _model.Clear();
                    foreach (HierarchicalViewModelBase item in newModel) {
                        _model.Add(item);
                    }
                    RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model));
                    ExpandAll(_model);
                }
            });
        }
コード例 #2
0
 private void ShowRegionExplorer()
 {
     Plugin.ShowRegionExplorer((selectionResult) => {
         var region = selectionResult.DataObject as DistributionRegionViewModel;
         if (region != null) {
             var dist = new TaxonDistribution { DistRegionID = region.DistRegionID, TaxonID = Taxon.TaxaID.Value, BiotaDistID = -1, DistRegionFullPath = region.GetFullPath() };
             AddViewModelByPath(_model, dist);
             RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model));
         }
     });
 }
コード例 #3
0
 void DistributionControl_Drop(object sender, DragEventArgs e)
 {
     var pinnable = e.Data.GetData(PinnableObject.DRAG_FORMAT_NAME) as PinnableObject;
     e.Effects = DragDropEffects.None;
     if (pinnable != null && pinnable.LookupType == LookupType.DistributionRegion) {
         var service = new SupportService(User);
         var parentage = service.GetDistributionFullPath(pinnable.ObjectID);
         if (!string.IsNullOrEmpty(parentage)) {
             var dist = new TaxonDistribution { BiotaDistID = -1, DistRegionFullPath = parentage, TaxonID = Taxon.TaxaID.Value, DistRegionID = pinnable.ObjectID };
             AddViewModelByPath(_model, dist);
             RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model));
         }
     }
 }
コード例 #4
0
 private void AddViewModelByPath(ObservableCollection<HierarchicalViewModelBase> collection, TaxonDistribution model)
 {
     String[] bits = model.DistRegionFullPath.Split('\\');
     var pCol = collection;
     HierarchicalViewModelBase parent = null;
     for (int i = 0; i < bits.Length; ++i) {
         string bit = bits[i];
         var current = pCol.FirstOrDefault((candidate) => { return candidate.DisplayLabel == bit; });
         if (current == null) {
             if (i == bits.Length - 1) {
                 current = new DistributionViewModel(model, bit);
                 current.Parent = parent;
                 current.DataChanged += new DataChangedHandler((d) => {
                     RegisterUniquePendingChange(new SaveDistributionRegionsCommand(Taxon.Taxon, _model));
                 });
             } else {
                 current = new DistributionPlaceholder(bit);
                 current.Parent = parent;
                 parent = current;
             }
             pCol.Add(current);
         } else {
             parent = current;
             if (i == bits.Length - 1) {
                 // This region exists already, but will be overridden by this one...
                 (current as DistributionViewModel).Model = model;
             }
         }
         pCol = current.Children;
     }
     // return result;
 }
コード例 #5
0
ファイル: DistributionViewModel.cs プロジェクト: kehh/biolink
 public DistributionViewModel(TaxonDistribution model, string label)
     : base(label)
 {
     Model = model;
 }
コード例 #6
0
ファイル: TaxaService.cs プロジェクト: kehh/biolink
        public int InsertBiotaDist(int? TaxonID, TaxonDistribution dist)
        {
            var retval = ReturnParam("identity");

            StoredProcUpdate("spBiotaDistInsert",
                _P("intBiotaID", TaxonID.Value),
                _P("txtRegionFullPath", dist.DistRegionFullPath),
                _P("bitIntroduced", dist.Introduced),
                _P("bitUncertain", dist.Uncertain),
                _P("bitThroughoutRegion", dist.ThroughoutRegion),
                _P("txtQual", dist.Qual),
                retval
            );

            return (int)retval.Value;
        }