Exemplo n.º 1
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.º 2
0
        private void CreateItem()
        {
            string itemName = _path + NameTextBox.Text;

            if ((DirectoryRadioButton.IsChecked ?? false))
            {
                Directory.CreateDirectory(itemName);

                _curretnItem.Items.Add(new TreeViewItemBuilder(NameTextBox.Text)
                                       .SetTag(itemName)
                                       .SetOnSelectedHandler(TreeViewBuilder.SelectedEventHandler)
                                       .AddContextMenu(new ContextMenuBuilder()
                                                       .AddMenuItem("Delete", TreeViewBuilder.DeleteEventHandler)
                                                       .AddMenuItem("Create new...")
                                                       .Build())
                                       .Build());
            }
            else
            {
                var attr = (FileAttributes)0;
                if (ReadOnlyCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.ReadOnly;
                }
                if (ArchiveCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.Archive;
                }
                if (SystemCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.System;
                }
                if (HiddenCheckbox.IsChecked ?? false)
                {
                    attr |= FileAttributes.Hidden;
                }

                File.Create(itemName);
                File.SetAttributes(itemName, attr);

                var cmb = new ContextMenuBuilder().AddMenuItem("Delete", TreeViewBuilder.DeleteEventHandler);
                if (NameTextBox.Text.EndsWith(".txt"))
                {
                    cmb.AddMenuItem("Open", TreeViewBuilder.OpenEventHandler);
                }

                _curretnItem.Items.Add(new TreeViewItemBuilder(NameTextBox.Text)
                                       .SetTag(itemName)
                                       .SetOnSelectedHandler(TreeViewBuilder.SelectedEventHandler)
                                       .AddContextMenu(cmb.Build())
                                       .Build());
            }
        }
Exemplo n.º 3
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.º 4
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.º 5
0
        private void AddLookupItem(ContextMenuBuilder builder, LookupType lookupType, params String[] aliases)
        {
            int index = -1;
            foreach (string alias in aliases) {
                var field = alias;

                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {
                var row = lvw.SelectedItem as MatrixRow;

                int objectId = 0;
                var enabled = false;
                if (row[index] != null) {
                    if (Int32.TryParse(row[index].ToString(), out objectId) && objectId > 0) {
                        enabled = true;
                    }
                }

                var pinnable = PluginManager.Instance.GetPinnableForLookupType(lookupType, objectId);

                var commands = new List<Command>();

                if (pinnable != null) {
                    var vm = PluginManager.Instance.GetViewModel(pinnable);
                    if (vm != null) {
                        var selected = new List<ViewModelBase>();
                        selected.Add(vm);
                        commands.AddRange(PluginManager.Instance.SolicitCommandsForObjects(selected));
                    }
                }

                if (commands.Count > 0) {

                    MenuItemBuilder b = new MenuItemBuilder();

                    var typeItem = b.New(lookupType.ToString()).MenuItem;

                    typeItem.Items.Add(b.New("Pin {0} to pinboard", lookupType).Handler(() => {
                        PluginManager.Instance.PinObject(pinnable);
                    }).Enabled(enabled).MenuItem);
                    typeItem.Items.Add(new Separator());

                    commands.ForEach((cmd) => {
                        if (cmd is CommandSeparator) {
                            typeItem.Items.Add(new Separator());
                        } else {
                            typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                cmd.CommandAction(pinnable);
                            }).Enabled(enabled).MenuItem);
                        }
                    });

                    builder.AddMenuItem(typeItem);
                } else {
                    builder.New("Edit " + lookupType.ToString()).Handler(() => {
                        PluginManager.Instance.EditLookupObject(lookupType, objectId);
                    }).Enabled(enabled).End();
                }
            }

            addSetOperations(builder, lookupType, aliases);
        }
Exemplo n.º 6
0
        private void addSetOperations(ContextMenuBuilder builder, LookupType type, params string[] idColAliases)
        {
            int index = -1;
            foreach (string alias in idColAliases) {
                var field = alias;
                for (int i = 0; i < Data.Columns.Count; ++i) {
                    var col = Data.Columns[i];
                    if (col.Name.Contains(alias)) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    break;
                }
            }

            if (index > -1) {

                List<int> idSet = new List<int>();

                if (lvw.SelectedItems.Count > 1) {
                    foreach (object selected in lvw.SelectedItems) {
                        var row = selected as MatrixRow;
                        var selectedRow = Data.Rows.IndexOf(row);
                        idSet.Add((int)row[selectedRow]);
                    }
                } else {
                    Data.Rows.ForEach(row => {
                        var objectIndex = row[index];
                        if (objectIndex is int) {
                            idSet.Add((int)row[index]);
                        }
                    });
                }

                if (idSet.Count > 0) {
                    var commands = PluginManager.Instance.SolicitCommandsForObjectSet(idSet, type);
                    if (commands != null && commands.Count > 0) {
                        MenuItemBuilder b = new MenuItemBuilder();

                        var typeItem = b.New(type.ToString() + String.Format(" Set ({0} items)", idSet.Count)).MenuItem;

                        commands.ForEach((cmd) => {
                            if (cmd is CommandSeparator) {
                                typeItem.Items.Add(new Separator());
                            } else {
                                typeItem.Items.Add(b.New(cmd.Caption).Handler(() => {
                                    cmd.CommandAction(idSet);
                                }).MenuItem);
                            }
                        });
                        builder.AddMenuItem(typeItem);
                    }
                }
            }
        }
Exemplo n.º 7
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;
            }
        }
        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.º 9
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.º 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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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.º 13
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.º 14
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.º 15
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;
        }
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;
        }
Exemplo n.º 17
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.º 18
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.º 19
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;
        }