void RedListCategoryInit() { RedListCategoryCheckBoxes = new List <CheckBox>(); checkBoxNE.Tag = RedListCategoryEnum.NotEvaluated; RedListCategoryCheckBoxes.Add(checkBoxNE); checkBoxDD.Tag = RedListCategoryEnum.DataDeficient; RedListCategoryCheckBoxes.Add(checkBoxDD); checkBoxLC.Tag = RedListCategoryEnum.LeastConcern; RedListCategoryCheckBoxes.Add(checkBoxLC); checkBoxNT.Tag = RedListCategoryEnum.NearThreatened; RedListCategoryCheckBoxes.Add(checkBoxNT); checkBoxVU.Tag = RedListCategoryEnum.Vulnerable; RedListCategoryCheckBoxes.Add(checkBoxVU); checkBoxEN.Tag = RedListCategoryEnum.Endangered; RedListCategoryCheckBoxes.Add(checkBoxEN); checkBoxCR.Tag = RedListCategoryEnum.CriticallyEndangered; RedListCategoryCheckBoxes.Add(checkBoxCR); checkBoxEW.Tag = RedListCategoryEnum.ExtinctInTheWild; RedListCategoryCheckBoxes.Add(checkBoxEW); checkBoxEX.Tag = RedListCategoryEnum.Extinct; RedListCategoryCheckBoxes.Add(checkBoxEX); foreach (CheckBox cb in RedListCategoryCheckBoxes) { RedListCategoryExt.SetupToggleButton((RedListCategoryEnum)cb.Tag, cb); } }
void RedListCategoryUpdate() { foreach (CheckBox cb in RedListCategoryCheckBoxes) { cb.Checked = Edited == null ? false : ((RedListCategoryEnum)cb.Tag == Edited.Desc.RedListCategory); RedListCategoryExt.SetupToggleButton((RedListCategoryEnum)cb.Tag, cb); } }
//========================================================================================= // Jac File load // static TaxonTreeNode LoadJacFile(string _filename) { try { using (StreamReader sr = new StreamReader(_filename)) { TaxonTreeNode root = new TaxonTreeNode(new TaxonDesc("__ignore__")); TaxonTreeNode currentNode = root; int currentTab = 0; int currentLine = 0; string line; // read header line while ((line = sr.ReadLine()) != null) { currentLine++; int tab = 0; while (line.StartsWith("\t")) { tab++; line = line.Substring(1); } if (tab > currentTab) { if (tab - currentTab > 1 || currentNode.Children.Count == 0) { Loggers.WriteError(LogTags.Data, _filename + "(" + currentLine.ToString() + ") too many tabs"); return(null); } currentTab = tab; currentNode = currentNode.Children[currentNode.Children.Count - 1]; } else if (tab < currentTab) { while (currentTab != tab) { if (currentNode == root) { Loggers.WriteError(LogTags.Data, _filename + "(" + currentLine.ToString() + ") tabulation error"); return(null); } currentTab--; currentNode = currentNode.Father; } } string[] parts = line.Split('>'); TaxonTreeNode newNode = new TaxonTreeNode(new TaxonDesc() { RefMultiName = new Helpers.MultiName(parts[0]), FrenchMultiName = parts.Length < 2 || String.IsNullOrWhiteSpace(parts[1]) ? null : new Helpers.MultiName(parts[1]), ClassicRank = parts.Length < 3 || String.IsNullOrWhiteSpace(parts[2]) ? ClassicRankEnum.None : ClassicRankEnumExt.FromString(parts[2]), Flags = (parts.Length < 4 || String.IsNullOrWhiteSpace(parts[3])) ? 0 : FlagsEnumExt.FromString(parts[3]), RedListCategory = (parts.Length < 5 || String.IsNullOrWhiteSpace(parts[4])) ? RedListCategoryEnum.NotEvaluated : RedListCategoryExt.FromString(parts[4]), } ); currentNode.AddChild(newNode); } return(root); } } catch (Exception e) { Loggers.WriteError(LogTags.Data, "Exception raised while reading file " + _filename + "\n " + e.Message); return(null); } }