//------------------------------------------------------------------- public void AddFatherAll(TaxonTreeNode _taxon) { if (_taxon == null) { return; } TaxonDialog.NewTaxon dlg = new TaxonDialog.NewTaxon { TopMost = true, CheckNameUsage = true }; dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) { return; } TaxonDesc newTaxon = new TaxonDesc(dlg.TaxonName); TaxonTreeNode newNode = new TaxonTreeNode(newTaxon); TaxonTreeNode OldFather = _taxon.Father; foreach (TaxonTreeNode child in OldFather.Children) { newNode.AddChild(child); } OldFather.Children.Clear(); OldFather.AddChild(newNode); OldFather.Expand(); newNode.Expand(); RefreshGraph(); }
//------------------------------------------------------------------- public void AddFather(TaxonTreeNode _taxon) { if (_taxon == null) { return; } TaxonDialog.NewTaxon dlg = new TaxonDialog.NewTaxon { TopMost = true, CheckNameUsage = true }; dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) { return; } TaxonDesc newTaxon = new TaxonDesc(dlg.TaxonName); TaxonTreeNode newNode = new TaxonTreeNode(newTaxon); TaxonTreeNode OldFather = _taxon.Father; OldFather.ReplaceChild(_taxon, newNode); newNode.AddChild(_taxon); OldFather.Expand(); newNode.Expand(); RefreshGraph(); }
public bool ChangeIndexAndRenameFile(TaxonDesc _taxon, int _newIndex) { if (IsALink) { return(false); } string oldPath = GetPath(_taxon); int saveIndex = Index; Index = _newIndex; string newPath = GetPath(_taxon); Index = saveIndex; if (File.Exists(newPath)) { Loggers.WriteError(LogTags.Image, "Can't reindex image " + oldPath + ",\n file " + newPath + " already exists"); return(false); } try { File.Move(oldPath, newPath); } catch (Exception e) { Loggers.WriteError(LogTags.Image, "Error renaming " + oldPath + " to " + newPath + ":\n" + e.Message); return(false); } Index = _newIndex; return(true); }
public string GetPath(TaxonDesc _taxon) { if (IsALink) { return(null); } return(TaxonImages.Manager.CollectionPath(CollectionId) + "\\" + GetName(_taxon)); }
public void FillForNewFile(TaxonDesc _taxon) { Index = 0; while (Exists(_taxon)) { Index++; } }
public bool Exists(TaxonDesc _taxon) { if (IsALink) { return(false); } return(File.Exists(GetPath(_taxon))); }
public void EndUseTempName_ChangeIndex(int _newIndex) { if (IsALink) { return; } Index = _newIndex; File.Move(_TempPath, GetPath(_TaxonForTempName)); _TaxonForTempName = null; }
private static void LastTolIds(TaxonDesc _desc, object _data) { if (_desc.OTTID >= FirstTolID) { TaxonIds Data = _data as TaxonIds; if (_desc.OTTID > Data.MaxTolId) { Data.MaxTolId = _desc.OTTID; } } }
//------------------------------------------ public TaxonTreeNode FindTaxon(TaxonDesc _desc) { if (_Desc == _desc) { return(this); } foreach (TaxonTreeNode child in _Children) { TaxonTreeNode result = child.FindTaxon(_desc); if (result != null) { return(result); } } return(null); }
private static void CheckIds(TaxonDesc _desc, object _data) { if (_desc.OTTID == 0) { (_data as TaxonIds).NoIds.Add(_desc); return; } TaxonIds Data = _data as TaxonIds; if (_desc.OTTID >= FirstTolID) { if (Data.TolIds.ContainsKey(_desc.OTTID)) { Data.Duplicates.Add(new Tuple <TaxonDesc, TaxonDesc>(Data.TolIds[_desc.OTTID], _desc)); return; } Data.TolIds[_desc.OTTID] = _desc; if (_desc.OTTID > Data.MaxTolId) { Data.MaxTolId = _desc.OTTID; } if (_desc.OTTID < Data.MinTolId) { Data.MinTolId = _desc.OTTID; } } else { if (Data.Ids.ContainsKey(_desc.OTTID)) { Data.Duplicates.Add(new Tuple <TaxonDesc, TaxonDesc>(Data.Ids[_desc.OTTID], _desc)); return; } Data.Ids[_desc.OTTID] = _desc; if (_desc.OTTID > Data.MaxId) { Data.MaxId = _desc.OTTID; } if (_desc.OTTID < Data.MinId) { Data.MinId = _desc.OTTID; } } }
private void addButton_Click(object sender, EventArgs e) { if (classicRankCB.Text == string.Empty) { errorLabel.Text = "Please select a classic rank value"; return; } if (RedListCategory.Text == string.Empty) { errorLabel.Text = "Please select a red list category"; return; } string nameString = nameTextBox.Text; if (nameString == string.Empty) { nameString = "Unnamed"; } Helpers.MultiName name = new Helpers.MultiName(nameString); Helpers.MultiName frenchName = new Helpers.MultiName(frenchNameTextBox.Text); ClassicRankEnum classicRank = ClassicRankEnum.None; Enum.TryParse <ClassicRankEnum>(classicRankCB.Text, out classicRank); RedListCategoryEnum redListCategory = RedListCategoryEnum.NotEvaluated; Enum.TryParse <RedListCategoryEnum>(RedListCategoryCB.Text, out redListCategory); TaxonDesc desc = new TaxonDesc { RefMultiName = name, ClassicRank = classicRank, RedListCategory = redListCategory, FrenchMultiName = frenchName }; node = new TaxonTreeNode { Desc = desc }; Close(); }
public void StartUseTempName(TaxonDesc _taxon) { if (_TaxonForTempName != null) { return; } if (_taxon == null) { return; } if (IsALink) { return; } _TaxonForTempName = _taxon; _TempPath = GetTempPath(_taxon); File.Move(GetPath(_taxon), _TempPath); }
public string GetName(TaxonDesc _taxon) { string name = _taxon.RefMultiName.Main; if (Secondary) { name += "_s"; if (Index != -1) { name += Index.ToString(); } } else if (Index != -1) { name += "_" + Index.ToString(); } name += ".jpg"; return(name); }
//--------------------------------------------------------------------------------------- public static string CommentFilename(TaxonDesc _desc) { if (_desc.IsUnnamed) { if (_desc.OTTID == 0) { return(null); } return("Unnamed_" + _desc.OTTID.ToString()); } string name = _desc.RefMultiName.Main; if (_desc.HasFlag(FlagsEnum.IncludeIdInFilenames)) { name += "_" + _desc.OTTID.ToString(); } return(name); }
//------------------------------------------------------------------- public void AddChild(TaxonTreeNode _taxon) { if (_taxon == null) { return; } string firstName = null; if (_taxon.Desc.ClassicRank == ClassicRankEnum.Genre) { firstName = _taxon.Desc.RefMainName; } TaxonDialog.NewTaxon dlg = new TaxonDialog.NewTaxon(firstName) { TopMost = true, CheckNameUsage = true }; dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) { return; } TaxonDesc newTaxon = new TaxonDesc(dlg.TaxonName); if (_taxon.Desc.ClassicRank == ClassicRankEnum.Genre) { newTaxon.ClassicRank = ClassicRankEnum.Espece; } else if (_taxon.Desc.ClassicRank == ClassicRankEnum.Espece) { newTaxon.ClassicRank = ClassicRankEnum.SousEspece; } TaxonTreeNode newNode = new TaxonTreeNode(newTaxon); _taxon.AddChild(newNode); _taxon.SortChildren(); _taxon.Expand(); RefreshGraph(); }
//========================================================================================= // convert to new data // public TaxonTreeNode ConvertToDescAndNodeTree() { TaxonDesc desc = new TaxonDesc(Name); desc.ClassicRank = ClassicRank; desc.FrenchName = FrenchName; desc.HasImage = HasImage; TaxonTreeNode node = new TaxonTreeNode(desc); node.Visible = Visible; foreach (Taxon child in Children) { TaxonTreeNode nodeChild = child.ConvertToDescAndNodeTree(); nodeChild.Father = node; node.Children.Add(nodeChild); } return(node); }
//------------------------------------------------------------------- public void AddSiblingAbove(TaxonTreeNode _taxon) { if (_taxon == null) { return; } string firstName = null; if (_taxon.Desc.ClassicRank == ClassicRankEnum.Espece) { string[] parts = _taxon.Desc.RefMainName.Split(' '); if (parts.Length >= 2) { firstName = parts[0]; } } NewTaxon dlg = new TaxonDialog.NewTaxon(firstName) { TopMost = true, CheckNameUsage = true }; dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) { return; } TaxonDesc newTaxon = new TaxonDesc(dlg.TaxonName) { ClassicRank = _taxon.Desc.ClassicRank }; TaxonTreeNode newNode = new TaxonTreeNode(newTaxon); _taxon.AddSiblingBefore(newNode); _taxon.Father.Expand(); RefreshGraph(); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { TaxonDialog.NewTaxon dlg = new TaxonDialog.NewTaxon(null) { TopMost = true, CheckNameUsage = true }; dlg.ShowDialog(); if (dlg.DialogResult != DialogResult.OK) { return; } TaxonDesc desc = new TaxonDesc(dlg.TaxonName); TaxonTreeNode root = new TaxonTreeNode(desc); TaxonUtils.SetOriginalRoot(root); TaxonUtils.MyConfig.TaxonFileName = ""; TaxonUtils.MyConfig.saved = false; TaxonUtils.MainGraph.Root = root; TaxonUtils.MainGraph.ResetView(); }
static TaxonTreeNode LoadBin(BinaryReader _r, uint _version) { LoadCounterInc(); if (_LoadCanceled) { return(null); } TaxonTreeNode node = new TaxonTreeNode() { Desc = TaxonDesc.LoadBin(_r, _version) }; int count = _r.ReadInt32(); for (int i = 0; i < count; i++) { TaxonTreeNode child = LoadBin(_r, _version); if (child == null) { return(null); } node.AddChild(child); } return(node); }
public Synonym(TaxonDesc _desc) { _Desc = _desc; AllSynonyms = string.Join(Helpers.MultiName.SeparatorAsString, _desc.RefMultiName.GetSynonymsArray()); }
public TaxonTreeNodeFilter() : base() { Desc = new TaxonDesc("Null graph"); _NodeInOriginal = null; }
public static TaxonDesc LoadBin(BinaryReader _br, uint _version) { if (_version == 1) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString(), HasSound = _br.ReadBoolean(), FrenchName = _br.ReadString(), ClassicRank = (ClassicRankEnum)_br.ReadUInt32(), Age = _br.ReadUInt32(), RelativeGeneticDistance = _br.ReadSingle(), OTTID = _br.ReadUInt32() }; uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } if (_version == 2) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString(), Flags = _br.ReadUInt32(), HasSound = _br.ReadBoolean(), FrenchName = _br.ReadString(), ClassicRank = (ClassicRankEnum)_br.ReadUInt32(), Age = _br.ReadUInt32(), RelativeGeneticDistance = _br.ReadSingle(), OTTID = _br.ReadUInt32() }; uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } if (_version == 3) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString() }; if (_br.ReadUInt32() != 0) { /*taxon.AlternativeNames = */ _br.ReadString(); } taxon.Flags = _br.ReadUInt32(); taxon.HasSound = _br.ReadBoolean(); taxon.FrenchName = _br.ReadString(); taxon.ClassicRank = (ClassicRankEnum)_br.ReadUInt32(); taxon.Age = _br.ReadUInt32(); taxon.RelativeGeneticDistance = _br.ReadSingle(); taxon.OTTID = _br.ReadUInt32(); uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } if (_version == 4) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString(), Flags = _br.ReadUInt32(), HasSound = _br.ReadBoolean(), FrenchName = _br.ReadString(), ClassicRank = (ClassicRankEnum)_br.ReadUInt32(), Age = _br.ReadUInt32(), RelativeGeneticDistance = _br.ReadSingle(), OTTID = _br.ReadUInt32() }; uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } if (_version == 5) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString(), Flags = _br.ReadUInt32(), HasSound = _br.ReadBoolean(), FrenchName = _br.ReadString(), ClassicRank = (ClassicRankEnum)_br.ReadUInt32(), Age = _br.ReadUInt32(), RelativeGeneticDistance = _br.ReadSingle(), OTTID = _br.ReadUInt32() }; uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32(), LinksId = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } if (_version == 6) { TaxonDesc taxon = new TaxonDesc { Name = _br.ReadString(), Flags = _br.ReadUInt32(), HasSound = _br.ReadBoolean(), FrenchName = _br.ReadString(), ClassicRank = (ClassicRankEnum)_br.ReadUInt32(), Age = _br.ReadUInt32(), RelativeGeneticDistance = _br.ReadSingle(), OTTID = _br.ReadUInt32(), RedListCategory = (RedListCategoryEnum)_br.ReadByte() }; uint imageNumber = _br.ReadUInt32(); if (imageNumber != 0) { taxon.Images = new List <TaxonImageDesc>((int)imageNumber); for (uint i = 0; i < imageNumber; i++) { TaxonImageDesc image = new TaxonImageDesc { CollectionId = _br.ReadInt32(), Secondary = _br.ReadBoolean(), Index = _br.ReadInt32(), LinksId = _br.ReadInt32() }; taxon.Images.Add(image); } } return(taxon); } return(null); }
public string getDistantImageCacheFile(TaxonDesc _desc) { return(Path.Combine(TaxonUtils.GetImageCachePath(), "distant_" + CollectionId.ToString() + "_" + _desc.RefMultiName.Main + "-" + Index.ToString() + ".jpg")); }
public TaxonTreeNode(TaxonDesc _taxonDesc) : this() { _Desc = _taxonDesc; }
public string GetTempName(TaxonDesc _taxon) { string name = GetName(_taxon); return(name.Substring(0, name.Length - 4) + "_temp.jpg"); }
public string GetTempPath(TaxonDesc _taxon) { return(TaxonImages.Manager.CollectionPath(CollectionId) + "\\" + GetTempName(_taxon)); }