Exemplo n.º 1
0
 //-------------------------------------------------------------------
 public void MenuCreateComment_Click(object sender, EventArgs e)
 {
     if (_MenuTaxonTreeNode == null)
     {
         return;
     }
     TaxonComments.CommentFileCreate(_MenuTaxonTreeNode);
 }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------------
        private void ButtonCreateComment_Click(object sender, EventArgs e)
        {
            if (Edited == null)
            {
                return;
            }
            if (TaxonComments.CommentFile(Edited) != null)
            {
                return;
            }
            TaxonComments.CommentFileCreateResult result = TaxonComments.CommentFileCreate(Edited);
            if (result == TaxonComments.CommentFileCreateResult.Success)
            {
                splitContainerComments.Visible = false;
                Comments.RefreshContent(true);
                return;
            }

            string message = "Creation failed:\n    ";

            if (result == TaxonComments.CommentFileCreateResult.ExistsAlready)
            {
                message += "a comment file already exists";
            }
            else if (result == TaxonComments.CommentFileCreateResult.NoNameAndID)
            {
                message += "taxon as no name or id, click on ID button to create a new TOL ID";
            }
            else if (result == TaxonComments.CommentFileCreateResult.NoCollection)
            {
                message += "No available collection, edit collections before creating comments";
            }
            else
            {
                message += "unknown reason";
            }
            Loggers.WriteError(LogTags.Comment, message);
        }
Exemplo n.º 3
0
        //---------------------------------------------------------------------------------
        private void CheckBoxFlagUseID_CheckedChanged(object sender, EventArgs e)
        {
            if (Edited == null)
            {
                return;
            }
            if (Edited.Desc.HasFlag(FlagsEnum.IncludeIdInFilenames) == checkBoxFlagUseID.Checked)
            {
                return;
            }

            if (checkBoxFlagUseID.Checked && Edited.Desc.OTTID == 0)
            {
                string message = "You have to create a new ID first";
                MessageBox.Show(message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                checkBoxFlagUseID.Checked = Edited.Desc.HasFlag(FlagsEnum.IncludeIdInFilenames);
                return;
            }

            bool hasFile = (Edited.Desc.Images != null && Edited.Desc.Images.Count != 0) || (TaxonComments.CommentFile(Edited) != null);

            if (hasFile)
            {
                string message = "Taxon have already some associated files";
                message += "\nchanging that flag may result in loosing these association";
                message += "\n\nContinue anyway ?";
                if (MessageBox.Show(message, "Continue ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    checkBoxFlagUseID.Checked = Edited.Desc.HasFlag(FlagsEnum.IncludeIdInFilenames);
                    return;
                }
            }

            Edited.Desc.SetFlagValue(FlagsEnum.IncludeIdInFilenames, checkBoxFlagUseID.Checked);
            TaxonComments.Manager.CleanCommentInMemory(0);
            ShowInfo();
            CallOnEditedTaxonChanged();
        }
Exemplo n.º 4
0
        ToolStripMenuItem BuildAdvancedMenu()
        {
            if (_MenuTaxonTreeNode == null)
            {
                return(null);
            }
            if (SystemConfig.IsInUserMode)
            {
                return(null);
            }

            ToolStripMenuItem advanced = new ToolStripMenuItem("Advanced")
            {
                Name = "Advanced"
            };
            int countLastSeparator = 0;

            if (Root.IsFiltered())
            {
                // Import / export
                advanced.DropDownItems.Add(new ToolStripMenuItem("Export", null, MenuExport_Click)
                {
                    Name = "Export"
                });
                advanced.DropDownItems.Add(new ToolStripMenuItem("Export full", null, MenuExportFull_Click)
                {
                    Name = "ExportFull"
                });
            }
            else
            {
                bool isRoot = _MenuTaxonTreeNode == Root;

                if (MenuAdminCreateHtml)
                {
                    if (TaxonComments.CommentFile(_MenuTaxonTreeNode) == null)
                    {
                        advanced.DropDownItems.Add(new ToolStripMenuItem("create HTML comment", null, MenuCreateComment_Click)
                        {
                            Name = "CreateHTMLComment"
                        });
                    }
                }

                // Edition
                {
                    if (advanced.DropDownItems.Count > countLastSeparator)
                    {
                        advanced.DropDownItems.Add(new ToolStripSeparator());
                    }
                    countLastSeparator = advanced.DropDownItems.Count;

                    if (!isRoot)
                    {
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Delete", null, MenuDelete_Click)
                        {
                            Name = "Delete"
                        });
                        if (_MenuTaxonTreeNode.HasChildren)
                        {
                            advanced.DropDownItems.Add(new ToolStripMenuItem("Delete but keep children (moved in father)", null, MenuDeleteKeepChildren_Click)
                            {
                                Name = "DeleteKeepChildren"
                            });
                        }
                    }
                    if (_MenuTaxonTreeNode.HasChildren)
                    {
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Remove all children", null, MenuRemoveChildren_Click)
                        {
                            Name = "RemoveAllChild"
                        });
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Sort all children", null, MenuSortChildren_Click)
                        {
                            Name = "SortAllChildren"
                        });
                    }

                    if (advanced.DropDownItems.Count > countLastSeparator)
                    {
                        advanced.DropDownItems.Add(new ToolStripSeparator());
                    }
                    countLastSeparator = advanced.DropDownItems.Count;

                    if (!isRoot && _MenuTaxonTreeNode.Father.Children.Count > 1)
                    {
                        int index = _MenuTaxonTreeNode.Father.Children.IndexOf(_MenuTaxonTreeNode);
                        if (index > 0)
                        {
                            advanced.DropDownItems.Add(new ToolStripMenuItem("Move top", null, MenuMoveTop_Click)
                            {
                                Name = "MoveTop"
                            });
                            advanced.DropDownItems.Add(new ToolStripMenuItem("Move up", null, MenuMoveUp_Click)
                            {
                                Name = "MoveUp"
                            });
                        }
                        if (index < _MenuTaxonTreeNode.Father.Children.Count - 1)
                        {
                            advanced.DropDownItems.Add(new ToolStripMenuItem("Move down", null, MenuMoveDown_Click)
                            {
                                Name = "MoveDown"
                            });
                            advanced.DropDownItems.Add(new ToolStripMenuItem("Move bottom", null, MenuMoveBottom_Click)
                            {
                                Name = "MoveBottom"
                            });
                        }
                    }

                    if (advanced.DropDownItems.Count > countLastSeparator)
                    {
                        advanced.DropDownItems.Add(new ToolStripSeparator());
                    }
                    countLastSeparator = advanced.DropDownItems.Count;

                    if (!isRoot)
                    {
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Add Father", null, MenuAddFather_Click)
                        {
                            Name = "AddFather"
                        });
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Add Father (for all siblings)", null, MenuAddFatherAll_Click)
                        {
                            Name = "AddFatherAllSiblings"
                        });
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Add sibling above", null, MenuAddSiblingAbove_Click)
                        {
                            Name = "AddSiblingAbove"
                        });
                        advanced.DropDownItems.Add(new ToolStripMenuItem("Add sibling below", null, MenuAddSiblingBelow_Click)
                        {
                            Name = "AddSiblingBelow"
                        });
                    }
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Add child", null, MenuAddChild_Click)
                    {
                        Name = "AddChild"
                    });

                    /*ToolStripMenuItem flags = new ToolStripMenuItem("Flags") { Name = "Flags" };
                     * flags.DropDownItems.Add(new ToolStripMenuItem("Add extinct (taxon and sub tree)", null, MenuAddEctinctFlag_Click) { Name = "AddExtinct" });
                     * flags.DropDownItems.Add(new ToolStripMenuItem("Remove extinct (taxon and sub tree)", null, MenuRemoveEctinctFlag_Click) { Name = "RemoveExtinct" });
                     * advanced.DropDownItems.Add(new ToolStripSeparator());
                     * advanced.DropDownItems.Add(flags);*/
                }

                // Copy / paste
                {
                    if (advanced.DropDownItems.Count > 0)
                    {
                        advanced.DropDownItems.Add(new ToolStripSeparator());
                    }
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Copy", null, MenuCopy_Click)
                    {
                        Name = "Copy", ShortcutKeys = Keys.Control | Keys.C
                    });
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Cut", null, MenuCut_Click)
                    {
                        Name = "Cut", Enabled = _MenuTaxonTreeNode.Father != null, ShortcutKeys = Keys.Control | Keys.X
                    });
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Paste", null, MenuPaste_Click)
                    {
                        Name = "Paste", Enabled = CanPasteClipboard(_MenuTaxonTreeNode), ShortcutKeys = Keys.Control | Keys.V
                    });
                }

                // Import / export
                {
                    if (advanced.DropDownItems.Count > 0)
                    {
                        advanced.DropDownItems.Add(new ToolStripSeparator());
                    }
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Import", null, MenuImport_Click)
                    {
                        Name = "Import"
                    });
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Export", null, MenuExport_Click)
                    {
                        Name = "Export"
                    });
                    advanced.DropDownItems.Add(new ToolStripMenuItem("Export full", null, MenuExportFull_Click)
                    {
                        Name = "ExportFull"
                    });
                }
            }

            if (advanced.DropDownItems.Count == 0)
            {
                return(null);
            }
            Localization.Manager.DoMenuItem("ContextMenu.Graph", advanced);
            return(advanced);
        }