public TaxaForSiteReportOptions(User user, SiteExplorerNode node)
        {
            InitializeComponent();
            this.User = user;

            txtRegion.BindUser(user, LookupType.SiteOrRegion);
            txtRegion.PreSelect(node.ObjectID, node.Name, MaterialExplorer.GetLookupTypeFromElemType(node.ElemType));

            txtRegion.WatermarkText = "You must select a site or region";
            txtTaxon.BindUser(user, LookupType.Taxon);
            txtTaxon.WatermarkText = "All taxa";
        }
コード例 #2
0
 public DatabaseCommand RenameFavorite(FavoriteViewModel <SiteFavorite> vm, string text)
 {
     if (!vm.IsGroup)
     {
         var fav = vm as SiteFavoriteViewModel;
         SiteExplorerNode model = new SiteExplorerNode();
         model.ElemID   = fav.ElemID;
         model.ElemType = fav.ElemType;
         model.Name     = fav.Name;
         var node   = new SiteExplorerNodeViewModel(model);
         var action = Explorer.GetRenameActionForNode(node);
         if (action != null)
         {
             model.Name = text;
             fav.Name   = text;
             return(action);
         }
     }
     return(null);
 }
コード例 #3
0
        public DatabaseCommand AddNewItem(HierarchicalViewModelBase selectedItem)
        {
            var parent = selectedItem as SiteExplorerNodeViewModel;

            Debug.Assert(parent != null);

            var model = new SiteExplorerNode();

            model.ElemID   = -1;
            model.ElemType = "Region";
            model.Name     = "<New Region>";
            model.ParentID = parent.ElemID;
            model.RegionID = parent.RegionID;

            var viewModel = new SiteExplorerNodeViewModel(model);

            parent.Children.Add(viewModel);

            viewModel.IsSelected = true;
            viewModel.IsRenaming = true;

            return(new InsertRegionCommand(viewModel.Model, viewModel));
        }
コード例 #4
0
        internal SiteExplorerNodeViewModel AddNewNode(HierarchicalViewModelBase parent, SiteExplorerNodeType nodeType, Func <SiteExplorerNodeViewModel, DatabaseCommand> commandFactoryFunction)
        {
            if (parent != null)
            {
                parent.IsExpanded = true;
            }

            var model = new SiteExplorerNode();

            model.Name = string.Format("<New {0}>", nodeType.ToString());
            if (parent is SiteExplorerNodeViewModel)
            {
                model.ParentID = (parent as SiteExplorerNodeViewModel).ElemID;
            }
            model.ElemType = nodeType.ToString();
            model.ElemID   = -1;
            model.RegionID = -1;

            var viewModel = new SiteExplorerNodeViewModel(model);

            if (parent != null)
            {
                viewModel.Parent = parent;
                parent.Children.Add(viewModel);
            }

            viewModel.IsSelected = true;
            viewModel.IsRenaming = true;

            if (commandFactoryFunction != null)
            {
                RegisterPendingChange(commandFactoryFunction(viewModel), this);
            }

            return(viewModel);
        }
コード例 #5
0
 public TaxaForSiteReport(User user, SiteExplorerNode node) : base(user)
 {
     RegisterViewer(new RTFReportViewerSource());
     _node = node;
 }
コード例 #6
0
        private SiteExplorerNodeViewModel ViewModelFromObjectID(SiteExplorerNodeType nodeType, int objectID)
        {
            var service            = new MaterialService(User);
            SiteExplorerNode model = new SiteExplorerNode();

            model.ElemType = nodeType.ToString();
            switch (nodeType)
            {
            case SiteExplorerNodeType.Region:
                var region = service.GetRegion(objectID);
                if (region != null)
                {
                    model.ElemID   = region.PoliticalRegionID;
                    model.Name     = region.Name;
                    model.RegionID = region.PoliticalRegionID;
                    return(new SiteExplorerNodeViewModel(model));
                }
                break;

            case SiteExplorerNodeType.Site:
                var site = service.GetSite(objectID);
                if (site != null)
                {
                    model.ElemID     = site.SiteID;
                    model.Name       = site.SiteName;
                    model.RegionID   = site.PoliticalRegionID;
                    model.IsTemplate = site.IsTemplate;
                    return(new SiteExplorerNodeViewModel(model));
                }
                break;

            case SiteExplorerNodeType.SiteVisit:
                var sitevisit = service.GetSiteVisit(objectID);
                if (sitevisit != null)
                {
                    model.ElemID     = sitevisit.SiteVisitID;
                    model.Name       = sitevisit.SiteVisitName;
                    model.IsTemplate = sitevisit.IsTemplate;
                    return(new SiteExplorerNodeViewModel(model));
                }
                break;

            case SiteExplorerNodeType.Trap:
                var trap = service.GetTrap(objectID);
                if (trap != null)
                {
                    model.ElemID = trap.TrapID;
                    model.Name   = trap.TrapName;
                    return(new SiteExplorerNodeViewModel(model));
                }
                break;

            case SiteExplorerNodeType.Material:
                var material = service.GetMaterial(objectID);
                if (material != null)
                {
                    model.ElemID     = material.MaterialID;
                    model.Name       = material.MaterialName;
                    model.IsTemplate = material.IsTemplate;
                    return(new SiteExplorerNodeViewModel(model));
                }
                break;

            default:
                throw new Exception("Unhandled node type: " + nodeType);
            }
            return(null);
        }
コード例 #7
0
 public InsertSiteCommand(SiteExplorerNode model, SiteExplorerNodeViewModel viewModel, int templateId = 0) : base(model, viewModel)
 {
     this.TemplateID = templateId;
 }
コード例 #8
0
 public InsertSiteVisitCommand(SiteExplorerNode model, SiteExplorerNodeViewModel viewModel, int templateId = -1) : base(model, viewModel)
 {
     TemplateID = templateId;
 }
コード例 #9
0
 public InsertSiteGroupCommand(SiteExplorerNode model, SiteExplorerNodeViewModel viewModel) : base(model, viewModel)
 {
 }
コード例 #10
0
        public static ContextMenu BuildForFavorite(SiteFavoriteViewModel fav, MaterialExplorer explorer)
        {
            if (fav == null)
            {
                return(null);
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            builder.New("Refresh").Handler(() => { explorer.Refresh(); }).End();

            if (!fav.IsGroup)
            {
                builder.Separator();

                builder.New("Rename").Handler(() => { fav.IsRenaming = true; }).End();

                // A little bit of a hack to reuse the edit code...simulate a site explorer node, although its not really there...
                SiteExplorerNode model = new SiteExplorerNode();
                model.ElemID   = fav.ElemID;
                model.ElemType = fav.ElemType;
                model.Name     = fav.Name;
                var node = new SiteExplorerNodeViewModel(model);

                var pinnable = explorer.CreatePinnable(node);
                if (pinnable != null)
                {
                    builder.Separator();
                    builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(pinnable); });
                }

                var mnuReports = CreateReportMenuItems(node, explorer);
                if (mnuReports.HasItems)
                {
                    builder.Separator();
                    builder.AddMenuItem(mnuReports);
                }



                SiteExplorerNodeType type = (SiteExplorerNodeType)Enum.Parse(typeof(SiteExplorerNodeType), fav.ElemType);
                if (type != SiteExplorerNodeType.SiteGroup)
                {
                    builder.Separator();
                    builder.New("Edit Details...").Handler(() => {
                        switch (type)
                        {
                        case SiteExplorerNodeType.Region: explorer.EditRegion(node);
                            break;

                        case SiteExplorerNodeType.Site: explorer.EditSite(node);
                            break;

                        case SiteExplorerNodeType.SiteVisit: explorer.EditSiteVisit(node);
                            break;

                        case SiteExplorerNodeType.Trap: explorer.EditTrap(node);
                            break;

                        case SiteExplorerNodeType.Material: explorer.EditMaterial(node);
                            break;

                        default:
                            throw new Exception("[Details] Unhandled site explorer element type: " + node.ElemType);
                        }
                    }).End();
                    var rdeNodeTypes = new List <SiteExplorerNodeType>(new SiteExplorerNodeType[] { SiteExplorerNodeType.Material, SiteExplorerNodeType.Site, SiteExplorerNodeType.SiteVisit });
                    if (node != null && rdeNodeTypes.Contains(node.NodeType))
                    {
                        builder.New("Open in Rapid Data Entry...").Handler(() => { explorer.EditRDE(node); }).End();
                    }
                    else
                    {
                        builder.New("Rapid Data Entry...").Handler(() => { explorer.EditRDE(node); }).End();
                    }
                }
            }

            return(builder.ContextMenu);
        }