Exemplo n.º 1
0
        private void TreeView_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var tvw     = sender as TreeView;
            var item    = tvw.SelectedItem as DistributionRegionViewModel;
            var builder = new ContextMenuBuilder(null);

            if (item != null)
            {
                builder.New("Add region").Handler(() => { AddRegion(item); }).End();
                builder.Separator();
                builder.New("Delete region").Handler(() => { DeleteRegion(item); }).End();
                builder.New("Rename region").Handler(() => { RenameRegion(item); }).End();
                builder.Separator();
                builder.New("Expand all").Handler(() => { ExpandAll(item); }).End();
                builder.Separator();
                builder.New("Taxa for Distribution Region").Handler(() => { RunTaxaForDistRegionReport(item); }).End();
            }
            else
            {
                builder.New("Add region").Handler(() => { AddRegion(item); }).End();
                builder.Separator();
                builder.New("Expand all").Handler(() => { ExpandAll(item); }).End();
            }
            tvw.ContextMenu = builder.ContextMenu;
        }
Exemplo n.º 2
0
        void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = lvw.SelectedItem as LabelSetItemViewModel;

            if (selected != null)
            {
                var builder = new ContextMenuBuilder(null);

//                builder.New("Select _material...").Handler(() => { SelectMaterial(); }).End();
                builder.New("Load material by _User ID").Handler(() => { SelectMaterialByUser(); }).End();
                builder.Separator();
                builder.New("Remove item from list").Handler(() => DeleteSelected()).End();
                builder.Separator();
                if (selected.ItemType.Equals("site", StringComparison.CurrentCultureIgnoreCase))
                {
                    builder.New("Edit _Site").Handler(() => EditSite()).End();
                }
                else if (selected.ItemType.Equals("sitevisit", StringComparison.CurrentCultureIgnoreCase))
                {
                    builder.New("Edit _Site").Handler(() => EditSite()).End();
                    builder.New("Edit Site _Visit").Handler(() => EditSiteVisit()).End();
                }
                else if (selected.ItemType.Equals("material", StringComparison.CurrentCultureIgnoreCase))
                {
                    builder.New("Edit _Site").Handler(() => EditSite()).End();
                    builder.New("Edit Site _Visit").Handler(() => EditSiteVisit()).End();
                    builder.New("Edit _Material").Handler(() => EditMaterial()).End();
                }

                builder.Separator();
                builder.New("E_xport Label Set").Handler(() => ExportData()).End();

                lvw.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 3
0
        void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = lvw.SelectedItem as MultimediaLinkViewModel;

            if (selected == null)
            {
                return;
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            builder.New("_Edit details...").Handler(() => { ShowMultimediaProperties(selected); }).End();
            builder.New("_View multimedia...").Handler(() => { ViewMultimedia(selected); }).End();
            builder.New("Save as...").Handler(() => { SaveMultimedia(selected); }).End();
            builder.Separator();
            var filename      = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);
            var verbMenuItems = SystemUtils.GetVerbsAsMenuItems(filename);

            foreach (MenuItem verbItem in verbMenuItems)
            {
                builder.AddMenuItem(verbItem);
            }

            if (selected != null)
            {
                builder.Separator();
                builder.New("Show linked items...").Handler(() => { ShowLinkedItems(selected); }).End();
            }

            builder.Separator();
            builder.New("_Add new...").Handler(() => { AddNew(); }).End();
            builder.New("_Delete").Handler(() => { DeleteSelected(); }).End();

            lvw.ContextMenu = builder.ContextMenu;
        }
        void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var builder = new ContextMenuBuilder(null);

            builder.New("Edit Loan").Handler(() => { EditSelectedLoan(); }).End();
            builder.Separator();
            builder.New("Delete Loan").Handler(() => { DeleteSelectedLoan(); }).End();
            builder.Separator();
            builder.New("Add New Loan").Handler(() => { AddNewLoan(); }).End();

            lvw.ContextMenu = builder.ContextMenu;
        }
        void lstTraitTypes_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = lstTypeData.SelectedItem as TypeDataViewModel;

            if (selected != null)
            {
                ContextMenuBuilder builder = new ContextMenuBuilder(null);
                builder.New("Rename").Handler(() => { RenameTraitType(selected); }).End();
                builder.Separator();
                builder.New("Add new {0} type", _type).Handler(() => { AddNewTypeData(); }).End();
                builder.Separator();
                builder.New("Delete {0} type", _type).Handler(() => { DeleteTypeData(selected); }).End();
                lstTypeData.ContextMenu = builder.ContextMenu;
            }
        }
        private void ShowJournalMenu(ListBox lst)
        {
            var viewModel = lst.SelectedItem as JournalViewModel;

            if (viewModel != null)
            {
                ContextMenuBuilder builder = new ContextMenuBuilder(null);
                builder.New("_Edit journal").Handler(() => { EditJournal(viewModel); }).End();
                builder.Separator();
                builder.New("_Pin to pinboard").Handler(() => { PinSelected(); }).End();
                builder.Separator();
                builder.New("_Add new Journal").Handler(() => { AddNew(); }).End();
                builder.New("_Delete Journal").Handler(() => { DeleteJournal(viewModel); }).End();
                lst.ContextMenu = builder.ContextMenu;
            }
        }
        private void lvwUsers_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = lvwUsers.SelectedItem as UserSearchResultViewModel;

            if (selected != null)
            {
                var builder = new ContextMenuBuilder(null);
                builder.New("Add User").Handler(() => AddNewUser()).End();
                builder.Separator();
                builder.New("Delete " + selected.Username).Handler(() => DeleteSelectedUser()).End();
                builder.Separator();
                builder.New("Properties...").Handler(() => ShowSelectedProperties()).End();

                lvwUsers.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 8
0
        internal ContextMenu BuildFavoritesMenu(HierarchicalViewModelBase node)
        {
            int? favoriteId      = null;
            bool isFavoriteGroup = false;

            if (node is TaxonFavoriteViewModel)
            {
                var fav = node as TaxonFavoriteViewModel;
                favoriteId      = fav.FavoriteID;
                isFavoriteGroup = fav.IsGroup;
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc);

            builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); });

            MenuItem reports = CreateReportMenuItems();

            if (reports != null && reports.HasItems)
            {
                builder.Separator();
                builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                builder.AddMenuItem(reports);
            }

            if (favoriteId != null && favoriteId.HasValue)
            {
                builder.Separator();
                if (isFavoriteGroup)
                {
                    builder.New("Rename group").Handler(() => { Explorer.RenameFavoriteGroup(node as TaxonFavoriteViewModel); });
                    builder.New("Add favorite group").Handler(() => { Explorer.AddFavoriteGroup(node); }).End();
                }

                builder.New("Remove from favorites").Handler(() => { Explorer.RemoveFromFavorites(favoriteId.Value); });
            }

            builder.Separator();
            builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); });
            builder.Separator();
            builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
            builder.Separator();
            builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); });
            builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();

            return(builder.ContextMenu);
        }
        private void ShowGridContextMenu()
        {
            var selected = lstLayers.SelectedItem as GridLayerFileViewModel;

            if (selected != null)
            {
                var builder = new ContextMenuBuilder(null);

                builder.New("Save as _GRD file").Handler(() => { SaveAsGRDFile(new GridLayer(selected.Name)); }).End();
                builder.New("Save as _ASCII Grid file").Handler(() => { SaveAsASCIIFile(new GridLayer(selected.Name)); }).End();
                builder.Separator();
                builder.New("Show in _map").Handler(() => { ShowGridLayerInMap(new GridLayer(selected.Name), _singleModelOptions.Intervals, _singleModelOptions.CutOff, _singleModelOptions); }).End();
                builder.Separator();
                builder.New("Layer _properties").Handler(() => { ShowGridLayerProperties(new GridLayer(selected.Name)); }).End();


                lstLayers.ContextMenu = builder.ContextMenu;
            }
        }
        private void ShowSourceMenu()
        {
            var selected = lvwMappings.SelectedItem as ImportFieldMappingViewModel;

            if (selected != null)
            {
                var  builder = new ContextMenuBuilder(null);
                bool isFixed = selected.Model.IsFixed;
                builder.New("_Add new fixed field...").Handler(() => { AddFixedField(); }).End();
                builder.New("_Edit fixed field...").Handler(() => { EditFixedField(); }).Enabled(isFixed).End();
                builder.New("_Delete fixed field").Handler(() => { DeleteFixedField(); }).Enabled(isFixed).End();
                builder.Separator();
                builder.New("_Set default value").Handler(() => { SetDefaultValue(); }).Enabled(!isFixed).End();
                builder.New("_Clear default value").Handler(() => { ClearDefaultValue(); }).Enabled(!isFixed).End();
                builder.Separator();
                builder.New("Edit transformations").Handler(() => { EditTransformations(); }).End();
                builder.New("Clear transformations").Handler(() => { ClearTransformations(); }).Enabled(selected.Transformer != null).End();

                lvwMappings.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 11
0
        void lvwResults_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            builder.New("Add New").Handler(() => AddNew()).End();
            builder.Separator();
            builder.New("Delete").Handler(() => DeleteSelected()).End();
            builder.Separator();
            MenuItemBuilder b        = new MenuItemBuilder();
            var             selected = lvwResults.SelectedItem as ReferenceSearchResultViewModel;
            var             mnuFav   = b.New("Add to Favorites").MenuItem;

            mnuFav.Items.Add(b.New("User specific").Handler(() => { _favorites.AddToFavorites(selected, false); }).MenuItem);
            mnuFav.Items.Add(b.New("Global").Handler(() => { _favorites.AddToFavorites(selected, true); }).MenuItem);
            builder.AddMenuItem(mnuFav);
            builder.Separator();
            builder.New("Pin to pinboard").Handler(() => { PinSelected(); }).End();
            builder.New("Edit").Handler(() => EditSelected()).End();

            lvwResults.ContextMenu = builder.ContextMenu;
        }
Exemplo n.º 12
0
        public ContextMenu GetContextMenu(HierarchicalViewModelBase selected)
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            int    refId   = -1;
            string refCode = null;

            if (selected is ReferenceFavoriteViewModel)
            {
                var fav = selected as ReferenceFavoriteViewModel;
                if (!fav.IsGroup)
                {
                    refId   = fav.RefID;
                    refCode = fav.RefCode;
                }
                else
                {
                    builder.New("Export favorite group").Handler(() => ExportReferenceFavorite(fav)).End();
                }
            }
            else if (selected is ReferenceSearchResultViewModel)
            {
                var vm = selected as ReferenceSearchResultViewModel;
                refId   = vm.RefID;
                refCode = vm.RefCode;
            }

            builder.New("Add New...").Handler(() => RefManager.Owner.AddNewReference()).End();

            if (refId >= 0)
            {
                builder.Separator();
                builder.New("Delete").Handler(() => RefManager.DeleteReference(refId, refCode)).End();
                builder.Separator();
                builder.New("Edit Details...").Handler(() => RefManager.Owner.EditReference(refId)).End();
            }

            return(builder.ContextMenu);
        }
        void tvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var builder = new ContextMenuBuilder(null);

            var pointSet = tvw.SelectedItem as PointSetViewModel;

            if (pointSet != null)
            {
                builder.New("Add point").Handler(() => { AddNewPoint(); }).End();
                builder.Separator();
                builder.New("Remove point set").Handler(() => { RemoveSelectedPointSet(); }).End();
                builder.New("Load point file").Handler(() => { LoadPointFile(); }).End();
                builder.New("Save point file").Handler(() => { ExportSelected(); }).End();
                builder.Separator();
                builder.New("Plot points").Handler(() => { PlotPointSet(pointSet.Model); }).End();
                builder.Separator();
                builder.New("Clear all points").Handler(() => { ClearPoints(); }).End();
                builder.Separator();
                builder.New("Point options").Handler(() => { EditPointSetOptions(); }).End();

                tvw.ContextMenu = builder.ContextMenu;
                return;
            }

            var point = tvw.SelectedItem as PointViewModel;

            if (point != null)
            {
                builder.New("Add point").Handler(() => { AddNewPoint(); }).End();
                builder.New("Edit point").Handler(() => { EditSelectedPoint(); }).End();
                builder.Separator();
                builder.New("Delete point").Handler(() => { RemoveSelectedPoint(); }).End();
                tvw.ContextMenu = builder.ContextMenu;
                return;
            }
        }
Exemplo n.º 14
0
        void tvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = tvw.SelectedItem as HierarchicalViewModelBase;

            tvw.ContextMenu = null;
            if (selected != null)
            {
                var builder = new ContextMenuBuilder(null);
                if (selected is ServerViewModel)
                {
                    var server = selected as ServerViewModel;
                    builder.New("Connect...").Handler(() => Connect(server)).Enabled(server.Server == null).End();
                    builder.Separator();
                    builder.New("Disconnect").Handler(() => Disconnect(server)).Enabled(server.Server != null).End();

                    tvw.ContextMenu = builder.ContextMenu;
                }
            }
        }
        private void ShowContextMenu(FrameworkElement sender, ContactViewModel selected)
        {
            var builder = new ContextMenuBuilder(null);

            if (selected != null)
            {
                builder.New("_Contact details...").Handler(() => { EditSelectedContact(); }).End();
                builder.New("_Delete contact").Handler(() => { DeleteContact(selected); }).End();
                builder.New("_Loans...").Handler(() => { ShowLoansForContact(selected); }).End();
            }

            if (builder.HasItems)
            {
                builder.Separator();
            }

            builder.New("Add new contact...").Handler(() => { AddNewContact(); }).End();

            if (builder.HasItems)
            {
                sender.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 16
0
        internal ContextMenu BuildFindResultsMenu()
        {
            var builder = new ContextMenuBuilder(FormatterFunc);

            builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); }).End();

            builder.Separator();

            if (Explorer.IsUnlocked) {
                if (!Taxon.IsRootNode) {
                    builder.New("TaxonExplorer.menu.Delete", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteTaxon(Taxon); });
                    builder.New("TaxonExplorer.menu.DeleteCurrentLevel", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteLevel(Taxon); });
                    builder.New("TaxonExplorer.menu.Rename", Taxon.DisplayLabel).Handler(() => { Explorer.RenameTaxon(Taxon); });
                    builder.Separator();
                    builder.New("TaxonExplorer.menu.ChangeRank", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeRank(Taxon); });
                    if (Taxon.AvailableName == true) {
                        builder.New("TaxonExplorer.menu.ChangeToLiterature", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    } else if (Taxon.LiteratureName == true) {
                        builder.New("TaxonExplorer.menu.ChangeToAvailable", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }
                }

                MenuItem addMenu = BuildAddMenuItems();
                if (addMenu != null && addMenu.Items.Count > 0) {
                    builder.Separator();
                    builder.AddMenuItem(addMenu);
                }

            } else {
                builder.New("TaxonExplorer.menu.Unlock").Handler(() => { Explorer.btnLock.IsChecked = true; });
            }

            MenuItem reports = CreateReportMenuItems();
            if (reports != null && reports.HasItems) {
                if (builder.HasItems) {
                    builder.Separator();
                }
                builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                builder.AddMenuItem(reports);
            }

            builder.Separator();
            builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); }).End();
            builder.Separator();
            builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
            builder.Separator();
            builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); }).End();
            builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();

            return builder.ContextMenu;
        }
 void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
 {
     var selected = lvw.SelectedItem as ViewModelBase;
     if (selected != null) {
         var list = new List<ViewModelBase>();
         list.Add(selected);
         var commands = PluginManager.Instance.SolicitCommandsForObjects(list);
         if (commands.Count > 0) {
             var builder = new ContextMenuBuilder(null);
             foreach (Command loopvar in commands) {
                 Command cmd = loopvar; // include this in the closure scope, loopvar is outside, hence will always point to the last item...
                 if (cmd is CommandSeparator) {
                     builder.Separator();
                 } else {
                     builder.New(cmd.Caption).Handler(() => { cmd.CommandAction(selected); }).End();
                 }
             }
             lvw.ContextMenu = builder.ContextMenu;
         }
     }
 }
Exemplo n.º 18
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;
        }
Exemplo n.º 19
0
        private void thumbList_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = thumbList.SelectedItem as MultimediaLinkViewModel;
            if (selected != null) {
                var builder = new ContextMenuBuilder(null);
                string filename = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);

                var verbMenuItems = SystemUtils.GetVerbsAsMenuItems(filename);
                foreach (MenuItem verbItem in verbMenuItems) {
                    builder.AddMenuItem(verbItem);
                }

                builder.Separator();
                builder.New("Show linked items...").Handler(() => ShowLinkedItems(selected)).End();
                builder.Separator();
                builder.New("Save as...").Handler(() => SaveAs(selected)).End();
                builder.Separator();
                builder.New("Open in system editor...").Handler(() => OpenSelected()).End();
                builder.Separator();
                builder.New("Properties...").Handler(() => ShowMultimediaProperties(selected)).End();

                thumbList.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 20
0
        internal ContextMenu BuildFindResultsMenu()
        {
            var builder = new ContextMenuBuilder(FormatterFunc);

            builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); }).End();

            builder.Separator();

            if (Explorer.IsUnlocked)
            {
                if (!Taxon.IsRootNode)
                {
                    builder.New("TaxonExplorer.menu.Delete", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteTaxon(Taxon); });
                    builder.New("TaxonExplorer.menu.DeleteCurrentLevel", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteLevel(Taxon); });
                    builder.New("TaxonExplorer.menu.Rename", Taxon.DisplayLabel).Handler(() => { Explorer.RenameTaxon(Taxon); });
                    builder.Separator();
                    builder.New("TaxonExplorer.menu.ChangeRank", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeRank(Taxon); });
                    if (Taxon.AvailableName == true)
                    {
                        builder.New("TaxonExplorer.menu.ChangeToLiterature", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }
                    else if (Taxon.LiteratureName == true)
                    {
                        builder.New("TaxonExplorer.menu.ChangeToAvailable", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }
                }

                MenuItem addMenu = BuildAddMenuItems();
                if (addMenu != null && addMenu.Items.Count > 0)
                {
                    builder.Separator();
                    builder.AddMenuItem(addMenu);
                }
            }
            else
            {
                builder.New("TaxonExplorer.menu.Unlock").Handler(() => { Explorer.btnLock.IsChecked = true; });
            }

            MenuItem reports = CreateReportMenuItems();

            if (reports != null && reports.HasItems)
            {
                if (builder.HasItems)
                {
                    builder.Separator();
                }
                builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                builder.AddMenuItem(reports);
            }

            builder.Separator();
            builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); }).End();
            builder.Separator();
            builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
            builder.Separator();
            builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); }).End();
            builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();

            return(builder.ContextMenu);
        }
Exemplo n.º 21
0
        private void ShowContextMenu(TreeView tvw)
        {
            var selected = tvw.SelectedItem as SiteExplorerNodeViewModel;
            var builder = new ContextMenuBuilder(null);
            if (selected != null) {
                tvw.ContextMenu = SiteExplorerMenuBuilder.Build(selected, this);
            } else if (tvw.SelectedItem == this.regionsNode) {
                builder.New("Add _Region").Handler(() => {
                    var newNode = AddRegion(null);
                    RegionsModel.Insert(0, newNode);
                }).End();
                builder.Separator();
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                builder.Separator();
                builder.New("Refresh").Handler(() => { Refresh(); }).End();
                tvw.ContextMenu = builder.ContextMenu;
            } else if (tvw.SelectedItem == unplacedNode) {
                builder.New("Add Site _Group").Handler(() => {
                    var newNode = AddSiteGroup(null);
                    UnplacedModel.Insert(0, newNode);
                }).End();

                MenuItemBuilder b = new MenuItemBuilder();
                MenuItem addSite = b.New("Add Site").MenuItem;
                addSite.Items.Add(b.New("Blank").Handler(() => {
                    var newNode = AddSite(null);
                    UnplacedModel.Insert(0, newNode);
                }).MenuItem);

                addSite.Items.Add(b.New("From _Template").Handler(() => {
                    int? templateId = ChooseTemplate(SiteExplorerNodeType.Site);
                    if (templateId != null && templateId.HasValue) {
                        var newNode = AddSite(null, templateId.Value);
                        UnplacedModel.Insert(0, newNode);
                    }
                }).MenuItem);

                builder.AddMenuItem(addSite);

                builder.Separator();
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                builder.Separator();
                builder.New("Refresh").Handler(() => { Refresh(); }).End();
                tvw.ContextMenu = builder.ContextMenu;
            } else if (tvw.SelectedItem is ViewModelPlaceholder) {
                var ph = tvw.SelectedItem as ViewModelPlaceholder;
                switch (ph.DisplayLabel.ToLower()) {
                    case "site templates":
                        builder.New("Add new _Site Template").Handler(() => { AddSiteTemplate(); }).End();
                        break;
                    case "site visit templates":
                        builder.New("Add new Site _Visit Template").Handler(() => { AddSiteVisitTemplate(); }).End();
                        break;
                    case "material templates":
                        builder.New("Add new _Material Template").Handler(() => { AddMaterialTemplate(); }).End();
                        break;
                }

                tvw.ContextMenu = builder.ContextMenu;
            } else if (tvw.SelectedItem == templatesNode) {
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                tvw.ContextMenu = builder.ContextMenu;
            } else {
                tvw.ContextMenu = null;
            }
        }
Exemplo n.º 22
0
 private void AddMapItems(ContextMenuBuilder builder, params string[] colAliases)
 {
     foreach (string colpair in colAliases) {
         var bits = colpair.Split(',');
         if (bits.Length == 2) {
             if (Data.ContainsColumn(bits[0]) && Data.ContainsColumn(bits[1])) {
                 var latColName = bits[0];
                 var longColName = bits[1];
                 if (!string.IsNullOrEmpty(longColName) && !string.IsNullOrEmpty(latColName)) {
                     if (builder.ContextMenu.HasItems) {
                         builder.Separator();
                     }
                     builder.New("Plot selected rows on Map").Handler(() => { PlotSelected(longColName, latColName); }).End();
                     builder.New("Plot all rows on Map").Handler(() => { PlotAll(longColName, latColName); }).End();
                 }
                 break;
             }
         }
     }
 }
Exemplo n.º 23
0
        void lvw_MouseRightButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            var row = lvw.SelectedItem as MatrixRow;
            if (row != null) {
                var builder = new ContextMenuBuilder(null);

                AddLookupItem(builder, LookupType.Site, "SiteID", "intSiteID", "Site Identifier");
                AddLookupItem(builder, LookupType.SiteVisit, "SiteVisitID", "intSiteVisitID", "Visit Identifier");
                AddLookupItem(builder, LookupType.Material, "MaterialID", "intMaterialID", "Material Identifier");
                AddLookupItem(builder, LookupType.Taxon, "BiotaID", "intBiotaID", "Taxon Identifier", "TaxonID");
                AddLookupItem(builder, LookupType.Reference, "RefID", "intRefID", "ReferenceID", "Reference Identifier");
                AddLookupItem(builder, LookupType.Journal, "JournalID", "intJournalID", "Journal Identifier");

                string latColName = null;
                string longColName = null;

                foreach (MatrixColumn col in Data.Columns) {
                    if (latColName == null && col.Name.Contains("Lat")) {
                        latColName = col.Name;
                    }

                    if (longColName == null && col.Name.Contains("Long")) {
                        longColName = col.Name;
                    }
                }

                AddMapItems(builder, "Lat,Long", "Latitude,Longitude", "Y,X", "Y1,X1", "decimalLatitude,decimalLongitude");
                AddMaterialItems(builder, "materialID", "intMaterialID");

                if (builder.ContextMenu.HasItems) {
                    builder.Separator();
                }

                if (ContextMenuHandler != null) {
                    ContextMenuHandler(builder, row);
                    if (builder.ContextMenu.HasItems) {
                        builder.Separator();
                    }
                }

                builder.New("Export data...").Handler(() => { Export(); }).End();
                builder.Separator();
                builder.New("Copy All (including column names)").Handler(() => CopyAll(true)).End();
                builder.New("Copy All (excluding column names)").Handler(() => CopyAll(false)).End();
                builder.Separator();
                builder.New("Copy Selected (including column names)").Handler(() => CopySelected(true)).End();
                builder.New("Copy Selected (excluding column names)").Handler(() => CopySelected(false)).End();

                lvw.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 24
0
        void tvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = tvw.SelectedItem as HierarchicalViewModelBase;
            tvw.ContextMenu = null;
            if (selected != null) {
                var builder = new ContextMenuBuilder(null);
                if (selected is ServerViewModel) {
                    var server = selected as ServerViewModel;
                    builder.New("Connect...").Handler(() => Connect(server)).Enabled(server.Server == null).End();
                    builder.Separator();
                    builder.New("Disconnect").Handler(() => Disconnect(server)).Enabled(server.Server != null).End();

                    tvw.ContextMenu = builder.ContextMenu;
                }
            }
        }
Exemplo n.º 25
0
 private void ShowJournalMenu(ListBox lst)
 {
     var viewModel = lst.SelectedItem as JournalViewModel;
     if (viewModel != null) {
         ContextMenuBuilder builder = new ContextMenuBuilder(null);
         builder.New("_Edit journal").Handler(() => { EditJournal(viewModel); }).End();
         builder.Separator();
         builder.New("_Pin to pinboard").Handler(() => { PinSelected(); }).End();
         builder.Separator();
         builder.New("_Add new Journal").Handler(() => { AddNew(); }).End();
         builder.New("_Delete Journal").Handler(() => { DeleteJournal(viewModel); }).End();
         lst.ContextMenu = builder.ContextMenu;
     }
 }
Exemplo n.º 26
0
 void lstTypeData_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
 {
     var selected = lstTypeData.SelectedItem as TypeDataViewModel;
     if (selected != null) {
         ContextMenuBuilder builder = new ContextMenuBuilder(null);
         builder.New("Rename").Handler(() => { RenameTraitType(selected); }).End();
         builder.Separator();
         builder.New("Add new {0} type", TypeName).Handler(() => { AddNewTypeData(); }).End();
         builder.Separator();
         builder.New("Delete {0} type", TypeName).Handler(() => { DeleteTypeData(selected); }).End();
         lstTypeData.ContextMenu = builder.ContextMenu;
     }
 }
Exemplo n.º 27
0
        private void ShowSourceMenu()
        {
            var selected = lvwMappings.SelectedItem as ImportFieldMappingViewModel;
            if (selected != null) {
                var builder = new ContextMenuBuilder(null);
                bool isFixed = selected.Model.IsFixed;
                builder.New("_Add new fixed field...").Handler(() => { AddFixedField(); }).End();
                builder.New("_Edit fixed field...").Handler(() => { EditFixedField(); }).Enabled(isFixed).End();
                builder.New("_Delete fixed field").Handler(() => { DeleteFixedField(); }).Enabled(isFixed).End();
                builder.Separator();
                builder.New("_Set default value").Handler(() => { SetDefaultValue(); }).Enabled(!isFixed).End();
                builder.New("_Clear default value").Handler(() => { ClearDefaultValue(); }).Enabled(!isFixed).End();
                builder.Separator();
                builder.New("Edit transformations").Handler(() => { EditTransformations(); }).End();
                builder.New("Clear transformations").Handler(() => { ClearTransformations(); }).Enabled(selected.Transformer != null).End();

                lvwMappings.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 28
0
        internal ContextMenu BuildFavoritesMenu(HierarchicalViewModelBase node)
        {
            int? favoriteId = null;
            bool isFavoriteGroup = false;
            if (node is TaxonFavoriteViewModel) {
                var fav = node as TaxonFavoriteViewModel;
                favoriteId = fav.FavoriteID;
                isFavoriteGroup = fav.IsGroup;
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc);
            builder.New("TaxonExplorer.menu.ShowInContents").Handler(() => { Explorer.ShowInExplorer(Taxon.TaxaID); });

            MenuItem reports = CreateReportMenuItems();
            if (reports != null && reports.HasItems) {
                builder.Separator();
                builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                builder.AddMenuItem(reports);
            }

            if (favoriteId != null && favoriteId.HasValue) {
                builder.Separator();
                if (isFavoriteGroup) {
                    builder.New("Rename group").Handler(() => { Explorer.RenameFavoriteGroup(node as TaxonFavoriteViewModel); });
                    builder.New("Add favorite group").Handler(() => { Explorer.AddFavoriteGroup(node); }).End();
                }

                builder.New("Remove from favorites").Handler(() => { Explorer.RemoveFromFavorites(favoriteId.Value); });
            }

            builder.Separator();
            builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(new PinnableObject(TaxaPlugin.TAXA_PLUGIN_NAME, LookupType.Taxon, Taxon.TaxaID.Value)); });
            builder.Separator();
            builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
            builder.Separator();
            builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); });
            builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();

            return builder.ContextMenu;
        }
Exemplo n.º 29
0
        void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var selected = lvw.SelectedItem as MultimediaLinkViewModel;
            if (selected == null) {
                return;
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            builder.New("_Edit details...").Handler(() => { ShowMultimediaProperties(selected); }).End();
            builder.New("_View multimedia...").Handler(() => { ViewMultimedia(selected); }).End();
            builder.New("Save as...").Handler(() => { SaveMultimedia(selected); }).End();
            builder.Separator();
            var filename = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);
            var verbMenuItems = SystemUtils.GetVerbsAsMenuItems(filename);
            foreach (MenuItem verbItem in verbMenuItems) {
                builder.AddMenuItem(verbItem);
            }

            if (selected != null) {
                builder.Separator();
                builder.New("Show linked items...").Handler(() => { ShowLinkedItems(selected); }).End();
            }

            builder.Separator();
            builder.New("_Add new...").Handler(() => { AddNew(); }).End();
            builder.New("_Delete").Handler(() => { DeleteSelected(); }).End();

            lvw.ContextMenu = builder.ContextMenu;
        }
Exemplo n.º 30
0
        public ContextMenu BuildExplorerMenu()
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc);


            if (Explorer.IsUnlocked)
            {
                if (!Taxon.IsRootNode)
                {
                    builder.New("TaxonExplorer.menu.Delete", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteTaxon(Taxon); });
                    builder.New("TaxonExplorer.menu.DeleteCurrentLevel", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteLevel(Taxon); });
                    builder.New("TaxonExplorer.menu.Rename", Taxon.DisplayLabel).Handler(() => { Explorer.RenameTaxon(Taxon); });
                    builder.Separator();
                    builder.New("TaxonExplorer.menu.ChangeRank", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeRank(Taxon); });
                    if (Taxon.AvailableName == true)
                    {
                        builder.New("TaxonExplorer.menu.ChangeToLiterature", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }
                    else if (Taxon.LiteratureName == true)
                    {
                        builder.New("TaxonExplorer.menu.ChangeToAvailable", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }
                }

                MenuItem addMenu = BuildAddMenuItems();
                if (addMenu != null && addMenu.Items.Count > 0)
                {
                    builder.Separator();
                    builder.AddMenuItem(addMenu);
                }
            }
            else
            {
                builder.New("TaxonExplorer.menu.Unlock").Handler(() => { Explorer.btnLock.IsChecked = true; });
            }

            builder.Separator();

            builder.New("TaxonExplorer.menu.ExpandAll").Handler(() => {
                JobExecutor.QueueJob(() => {
                    Explorer.tvwAllTaxa.InvokeIfRequired(() => {
                        try {
                            using (new OverrideCursor(Cursors.Wait)) {
                                Explorer.ExpandChildren(Taxon);
                            }
                        } catch (Exception ex) {
                            GlobalExceptionHandler.Handle(ex);
                        }
                    });
                });
            });

            MenuItem sortMenu = BuildSortMenuItems();

            if (sortMenu != null && sortMenu.HasItems)
            {
                builder.Separator();
                builder.AddMenuItem(sortMenu);
            }

            builder.Separator();
            builder.AddMenuItem(CreateFavoriteMenuItems());

            if (!Explorer.IsUnlocked)
            {
                builder.Separator();
                builder.New("TaxonExplorer.menu.Refresh").Handler(() => Explorer.Refresh()).End();
            }

            if (!Taxon.IsRootNode)
            {
                MenuItem reports = CreateReportMenuItems();
                if (reports != null && reports.HasItems)
                {
                    builder.Separator();
                    builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                    builder.AddMenuItem(reports);
                }

                builder.Separator();
                builder.New("Export (XML)").Handler(() => { Explorer.XMLIOExport(Taxon.TaxaID.Value); }).End();

                builder.Separator();
                var pinnable = Explorer.Owner.CreatePinnableTaxon(Taxon.TaxaID.Value);
                builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(pinnable); }).End();
                builder.Separator();
                builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
                builder.Separator();
                builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); });
                builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();
            }

            return(builder.ContextMenu);
        }
        private void ShowContextMenu(TreeView tvw)
        {
            var selected = tvw.SelectedItem as SiteExplorerNodeViewModel;
            var builder  = new ContextMenuBuilder(null);

            if (selected != null)
            {
                tvw.ContextMenu = SiteExplorerMenuBuilder.Build(selected, this);
            }
            else if (tvw.SelectedItem == this.regionsNode)
            {
                builder.New("Add _Region").Handler(() => {
                    var newNode = AddRegion(null);
                    RegionsModel.Insert(0, newNode);
                }).End();
                builder.Separator();
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                builder.Separator();
                builder.New("Refresh").Handler(() => { Refresh(); }).End();
                tvw.ContextMenu = builder.ContextMenu;
            }
            else if (tvw.SelectedItem == unplacedNode)
            {
                builder.New("Add Site _Group").Handler(() => {
                    var newNode = AddSiteGroup(null);
                    UnplacedModel.Insert(0, newNode);
                }).End();

                MenuItemBuilder b       = new MenuItemBuilder();
                MenuItem        addSite = b.New("Add Site").MenuItem;
                addSite.Items.Add(b.New("Blank").Handler(() => {
                    var newNode = AddSite(null);
                    UnplacedModel.Insert(0, newNode);
                }).MenuItem);

                addSite.Items.Add(b.New("From _Template").Handler(() => {
                    int?templateId = ChooseTemplate(SiteExplorerNodeType.Site);
                    if (templateId != null && templateId.HasValue)
                    {
                        var newNode = AddSite(null, templateId.Value);
                        UnplacedModel.Insert(0, newNode);
                    }
                }).MenuItem);


                builder.AddMenuItem(addSite);

                builder.Separator();
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                builder.Separator();
                builder.New("Refresh").Handler(() => { Refresh(); }).End();
                tvw.ContextMenu = builder.ContextMenu;
            }
            else if (tvw.SelectedItem is ViewModelPlaceholder)
            {
                var ph = tvw.SelectedItem as ViewModelPlaceholder;
                switch (ph.DisplayLabel.ToLower())
                {
                case "site templates":
                    builder.New("Add new _Site Template").Handler(() => { AddSiteTemplate(); }).End();
                    break;

                case "site visit templates":
                    builder.New("Add new Site _Visit Template").Handler(() => { AddSiteVisitTemplate(); }).End();
                    break;

                case "material templates":
                    builder.New("Add new _Material Template").Handler(() => { AddMaterialTemplate(); }).End();
                    break;
                }

                tvw.ContextMenu = builder.ContextMenu;
            }
            else if (tvw.SelectedItem == templatesNode)
            {
                builder.AddMenuItem(SiteExplorerMenuBuilder.CreateTemplateItems(this));
                tvw.ContextMenu = builder.ContextMenu;
            }
            else
            {
                tvw.ContextMenu = null;
            }
        }
Exemplo n.º 32
0
        private void ShowContextMenu(HierarchicalViewModelBase selected, FrameworkElement control)
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(null);
            if (_content.CanAddNewItem) {
                builder.New("Add new").Handler(() => { AddNewItem(selected); }).End();
            }

            if (_content.CanRenameItem) {
                builder.Separator();
                builder.New("Rename").Handler(() => { RenameItem(selected); }).End();
            }

            if (_content.CanDeleteItem) {
                builder.Separator();
                builder.New("Delete").Handler(() => { DeleteItem(selected); }).End();
            }

            if (builder.HasItems) {
                control.ContextMenu = builder.ContextMenu;
            }
        }
Exemplo n.º 33
0
        public static ContextMenu Build(SiteExplorerNodeViewModel node, MaterialExplorer explorer)
        {
            if (node == null)
            {
                return(null);
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            if (explorer.tabMaterial.SelectedIndex != 0)
            {
                builder.New("Show in Contents").Handler(() => {
                    explorer.ShowInContents(node);
                }).End();
                builder.Separator();
            }

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

            builder.Separator();

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

            if (!node.IsTemplate)
            {
                var addMenu = CreateAddMenu(node, explorer);
                builder.AddMenuItem(addMenu);

                builder.Separator();
            }

            var type = NodeType(node);

            builder.New("Delete").Handler(() => {
                switch (type)
                {
                case SiteExplorerNodeType.Region: explorer.DeleteRegion(node);
                    break;

                case SiteExplorerNodeType.SiteGroup: explorer.DeleteSiteGroup(node);
                    break;

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

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

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

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

                default:
                    throw new Exception("[Delete] Unhandled site explorer element type: " + node.ElemType);
                }
            });

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

                builder.Separator();
                builder.AddMenuItem(CreateFavoriteMenuItems(explorer, node));

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

                builder.Separator();
                builder.AddMenuItem(CreateTemplateItems(explorer));
            }


            if (type != SiteExplorerNodeType.SiteGroup)
            {
                builder.Separator();
                builder.New("Edit Details...").Handler(() => {
                    explorer.EditNode(node);
                }).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); }).Enabled(!node.IsTemplate).End();
                }
                else
                {
                    builder.New("Rapid Data Entry...").Handler(() => { explorer.EditRDE(node); }).End();
                }
            }

            return(builder.ContextMenu);
        }
Exemplo n.º 34
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);
        }
Exemplo n.º 35
0
 private void AddMaterialItems(ContextMenuBuilder builder, params string[] colAliases)
 {
     foreach (string col in colAliases) {
         if (Data.ContainsColumn(col)) {
             if (builder.ContextMenu.HasItems) {
                 builder.Separator();
             }
         }
     }
 }
Exemplo n.º 36
0
        public static ContextMenu Build(SiteExplorerNodeViewModel node, MaterialExplorer explorer)
        {
            if (node == null) {
                return null;
            }

            ContextMenuBuilder builder = new ContextMenuBuilder(null);

            if (explorer.tabMaterial.SelectedIndex != 0) {
                builder.New("Show in Contents").Handler(() => {
                    explorer.ShowInContents(node);
                }).End();
                builder.Separator();
            }

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

            builder.Separator();

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

            if (!node.IsTemplate) {
                var addMenu = CreateAddMenu(node, explorer);
                builder.AddMenuItem(addMenu);

                builder.Separator();
            }

            var type = NodeType(node);

            builder.New("Delete").Handler(() => {
                switch (type) {
                    case SiteExplorerNodeType.Region: explorer.DeleteRegion(node);
                        break;
                    case SiteExplorerNodeType.SiteGroup: explorer.DeleteSiteGroup(node);
                        break;
                    case SiteExplorerNodeType.Site: explorer.DeleteSite(node);
                        break;
                    case SiteExplorerNodeType.SiteVisit: explorer.DeleteSiteVisit(node);
                        break;
                    case SiteExplorerNodeType.Trap: explorer.DeleteTrap(node);
                        break;
                    case SiteExplorerNodeType.Material: explorer.DeleteMaterial(node);
                        break;
                    default:
                        throw new Exception("[Delete] Unhandled site explorer element type: " + node.ElemType);
                }
            });

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

                builder.Separator();
                builder.AddMenuItem(CreateFavoriteMenuItems(explorer, node));

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

                builder.Separator();
                builder.AddMenuItem(CreateTemplateItems(explorer));
            }

            if (type != SiteExplorerNodeType.SiteGroup) {
                builder.Separator();
                builder.New("Edit Details...").Handler(() => {
                    explorer.EditNode(node);
                }).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); }).Enabled(!node.IsTemplate).End();
                } else {
                    builder.New("Rapid Data Entry...").Handler(() => { explorer.EditRDE(node); }).End();
                }

            }

            return builder.ContextMenu;
        }
Exemplo n.º 37
0
        void lvw_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var builder = new ContextMenuBuilder(null);

            builder.New("Edit Loan").Handler(() => { EditSelectedLoan(); }).End();
            builder.Separator();
            builder.New("Delete Loan").Handler(() => { DeleteSelectedLoan(); }).End();
            builder.Separator();
            builder.New("Add New Loan").Handler(() => { AddNewLoan(); }).End();

            lvw.ContextMenu = builder.ContextMenu;
        }
Exemplo n.º 38
0
        public ContextMenu BuildExplorerMenu()
        {
            ContextMenuBuilder builder = new ContextMenuBuilder(FormatterFunc);

            if (Explorer.IsUnlocked) {
                if (!Taxon.IsRootNode) {
                    builder.New("TaxonExplorer.menu.Delete", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteTaxon(Taxon); });
                    builder.New("TaxonExplorer.menu.DeleteCurrentLevel", Taxon.DisplayLabel).Handler(() => { Explorer.DeleteLevel(Taxon); });
                    builder.New("TaxonExplorer.menu.Rename", Taxon.DisplayLabel).Handler(() => { Explorer.RenameTaxon(Taxon); });
                    builder.Separator();
                    builder.New("TaxonExplorer.menu.ChangeRank", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeRank(Taxon); });
                    if (Taxon.AvailableName == true) {
                        builder.New("TaxonExplorer.menu.ChangeToLiterature", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    } else if (Taxon.LiteratureName == true) {
                        builder.New("TaxonExplorer.menu.ChangeToAvailable", Taxon.DisplayLabel).Handler(() => { Explorer.ChangeAvailable(Taxon); });
                    }

                }

                MenuItem addMenu = BuildAddMenuItems();
                if (addMenu != null && addMenu.Items.Count > 0) {
                    builder.Separator();
                    builder.AddMenuItem(addMenu);
                }

            } else {
                builder.New("TaxonExplorer.menu.Unlock").Handler(() => { Explorer.btnLock.IsChecked = true; });
            }

            builder.Separator();

            builder.New("TaxonExplorer.menu.ExpandAll").Handler(() => {
                JobExecutor.QueueJob(() => {
                    Explorer.tvwAllTaxa.InvokeIfRequired(() => {
                        try {
                            using (new OverrideCursor(Cursors.Wait)) {
                                Explorer.ExpandChildren(Taxon);
                            }
                        } catch (Exception ex) {
                            GlobalExceptionHandler.Handle(ex);
                        }
                    });
                });
            });

            MenuItem sortMenu = BuildSortMenuItems();
            if (sortMenu != null && sortMenu.HasItems) {
                builder.Separator();
                builder.AddMenuItem(sortMenu);
            }

            builder.Separator();
            builder.AddMenuItem(CreateFavoriteMenuItems());

            if (!Explorer.IsUnlocked) {
                builder.Separator();
                builder.New("TaxonExplorer.menu.Refresh").Handler(() => Explorer.Refresh()).End();
            }

            if (!Taxon.IsRootNode) {
                MenuItem reports = CreateReportMenuItems();
                if (reports != null && reports.HasItems) {
                    builder.Separator();
                    builder.New("Distribution _Map").Handler(() => { Explorer.DistributionMap(Taxon); }).End();
                    builder.AddMenuItem(reports);
                }

                builder.Separator();
                builder.New("Export (XML)").Handler(() => { Explorer.XMLIOExport(Taxon.TaxaID.Value); }).End();

                builder.Separator();
                var pinnable = Explorer.Owner.CreatePinnableTaxon(Taxon.TaxaID.Value);
                builder.New("_Pin to pin board").Handler(() => { PluginManager.Instance.PinObject(pinnable); }).End();
                builder.Separator();
                builder.New("_Permissions...").Handler(() => Explorer.EditBiotaPermissions(Taxon)).End();
                builder.Separator();
                builder.New("_Edit Name...").Handler(() => { Explorer.EditTaxonName(Taxon); });
                builder.New("_Edit Details...").Handler(() => { Explorer.EditTaxonDetails(Taxon.TaxaID); }).End();
            }

            return builder.ContextMenu;
        }