static TaxonTreeNode LoadBin(string _fileName) { TaxonTreeNode result = null; _LoadCanceled = false; LoadCounterInit(); try { using (FileStream fs = File.Open(_fileName, FileMode.Open, FileAccess.Read)) { using (DeflateStream deflateStream = new DeflateStream(fs, CompressionMode.Decompress)) { using (BinaryReader r = new BinaryReader(deflateStream)) { uint version = r.ReadUInt32(); result = LoadBin(r, version); r.Close(); deflateStream.Close(); fs.Close(); } } } } catch { } return(result); }
//--------------------------------------------------------------------------------- private void Picture_SetSpeciesAndSubSpecies(TaxonTreeNode _species, int _previousImageIndex) { _CurrentTaxonIsSpecies = true; TaxonBigVignette.Visible = true; TaxonBigVignette.CurrentTaxon = _species; TaxonBigVignette.Tag = _species; List <TaxonTreeNode> speciesList = new List <TaxonTreeNode>(); _species.GetAllChildrenWithImageRecursively(speciesList); //if (TaxonUtils.CurrentFilters.HasFilter(TaxonFilters.FilterAlive)) // speciesList = speciesList.Where(node => node.Desc.IsExtinct).ToList(); if (speciesList.Contains(_species)) { speciesList.Remove(_species); } else { _species = null; } _MultiImages.SetLists(speciesList, _species); _MultiImages.ScrollMode_UpdateOutputImages(); _MultiImages.Visible = true; }
//------------------------------------------------------------------- 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 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 static CommentFileCreateResult CommentFileCreate(TaxonTreeNode _node) { if (_node == null) { return(CommentFileCreateResult.Failed); } if (TaxonComments.Manager.AvailableCollections.Count == 0) { return(CommentFileCreateResult.NoCollection); } CommentsCollection collection = TaxonComments.Manager.AvailableCollections[0]; string name = CommentFilename(_node.Desc); if (string.IsNullOrEmpty(name)) { return(CommentFileCreateResult.NoNameAndID); } string path = CommentFileDesc.BuildHtlmName(collection, name); if (File.Exists(path)) { return(CommentFileCreateResult.ExistsAlready); } Manager.CreateHtmlComment(path, name); Manager.CleanCommentInMemory(0); return(CommentFileCreateResult.Success); }
//------------------------------------------------------------------- protected override void OnMouseDown(MouseEventArgs e) { if (Root == null) { return; } if (e.Button == MouseButtons.Right) { TaxonTreeNode pick = PickTaxon(Root, ClientToGraph(e.Location))?.GetMain(); if (pick != Selected) { Selected = pick; } return; } mouseDown = true; mouseX = e.Location.X; mouseY = e.Location.Y; moveX = Origin.X; moveY = Origin.Y; _InertiaMove.Stop(); }
//------------------------------------------------------------------- private void TextBoxSearch_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return) { e.Handled = true; if (textBoxSearch.Text.Length < 2) { TaxonSearchAsync.Search(_Root, textBoxSearch.Text); } if (listBoxResult.Items.Count > 0) { TaxonTreeNode taxon = listBoxResult.GetAt(0); if (taxon != null) { TaxonUtils.GotoTaxon(taxon); TaxonUtils.SelectTaxon(taxon); } } } if (e.KeyCode == Keys.Down) { if (listBoxResult.Items.Count > 0) { e.Handled = true; listBoxResult.Focus(); if (listBoxResult.SelectedIndex == -1) { listBoxResult.SelectedIndex = 0; } } } }
//méthode pour retourner la liste des parents public void GetAllParents(List <TaxonTreeNode> _list, bool _includeFirst = true, bool _fromFatherToChild = true, bool _includeUnnamed = true) { TaxonTreeNode current = this; if (!_includeFirst) { current = current.Father; } if (_includeUnnamed) { while (current != null) { _list.Add(current); current = current._Father; } } else { while (current != null) { if (!current.Desc.IsUnnamed) { _list.Add(current); } current = current._Father; } } if (_fromFatherToChild) { _list.Reverse(); } }
//--------------------------------------------------------------------------------- private void createNewTreeToolStripMenuItem_Click(object sender, EventArgs e) { TaxonTreeNode root = new TaxonTreeNode(new TaxonDesc("root")); TaxonUtils.Save(root, true, true); TaxonUtils.SetOriginalRoot(root); }
//------------------------------------------ private TaxonTreeNode FindTaxonByFullNameRecursive(string _fullname) { int index = _fullname.IndexOf('|'); if (index == -1) { foreach (TaxonTreeNode child in _Children) { if (child.Desc.RefMultiName.Main == _fullname) { return(child); } } } else { string name = _fullname.Substring(0, index); foreach (TaxonTreeNode child in _Children) { if (child.Desc.RefMultiName.Main == name) { TaxonTreeNode result = child.FindTaxonByFullNameRecursive(_fullname.Substring(index + 1)); if (result != null) { return(result); } } } } return(null); }
//--------------------------------------------------------------------------------------- public static CommentFileDesc CommentFile(TaxonTreeNode _node) { if (_node == null) { return(null); } string filename = CommentFilename(_node.Desc); CommentFileDesc result; foreach (CommentsCollection collection in TaxonComments.Manager.AvailableCollections) { if (filename != null && collection.IsDistant() && collection.DistantReferences.ContainsKey(filename)) { result = new CommentFileDesc(collection, filename); } else { result = CommentFileDesc.CreateOnlyIfFileExists(collection, filename); } if (result != null) { return(result); } } return(null); }
//--------------------------------------------------------------------------------- public static int Compare(TaxonTreeNode t1, TaxonTreeNode t2) { if (t1 == t2) { return(0); } if (t1.Father == t2.Father) { return((t1.Father.Children.IndexOf(t1) < t2.Father.Children.IndexOf(t2)) ? -1 : 1); } int level1 = t1.GetGeneration(); int level2 = t2.GetGeneration(); if (level1 < level2) { return(Compare(t1, t2.Father)); } if (level2 < level1) { return(Compare(t1.Father, t2)); } return(Compare(t1.Father, t2.Father)); }
void PasteClipboard(TaxonTreeNode _to) { if (Clipboard.ContainsData("TaxonTreeNodeXmlMemoryStream")) { object o = Clipboard.GetData("TaxonTreeNodeXmlMemoryStream"); if (o is System.IO.MemoryStream ms) { TaxonTreeNode node = TaxonTreeNode.LoadXMLFromMemory(ms); if (node != null) { ImportNode(_to, node); } } } else if (Clipboard.ContainsData(DataFormats.Text)) { string name = Clipboard.GetText(); if (name == null) { return; } TaxonTreeNode node = Root.FindTaxonByFullName(name); if (node != null) { TaxonUtils.GotoTaxon(node); TaxonUtils.SelectTaxon(node); } } }
//--------------------------------------------------------------------------------- // Display Image of taxon private void Pictures_Display(TaxonTreeNode _taxon, TaxonTreeNode _previousSelectedTaxon = null, List <TaxonTreeNode> _previousDisplayedTaxons = null, int _previousImageIndex = -1) { if (_taxon == null) { return; } if (!_taxon.HasChildren) { Pictures_SetSpecies(_taxon, _previousImageIndex); // display taxon image } else if (_taxon.Desc.ClassicRank == ClassicRankEnum.Espece) { Picture_SetSpeciesAndSubSpecies(_taxon, _previousImageIndex); } else { Pictures_SetFamily(_taxon, _previousSelectedTaxon, _previousDisplayedTaxons); } UpdateCheckBoxes(); if (_CurrentTaxonIsSpecies) { TaxonBigVignette.Width = _MultiImages.Width; } else { TaxonBigVignette.Width = _MultiImages.Width - 32; } }
//------------------------------------------------------------------- public void Goto(TaxonTreeNode _taxon) { if (_taxon == null) { return; } if (!_taxon.Visible) { return; } // get taxon center; Point pt; /* Removing CircleDisplayMode * if (Options.DisplayMode == GraphOptions.DisplayModeEnum.Circle) * pt = new Point((int)_taxon.CircularInfo.X, (int) _taxon.CircularInfo.Y); * else*/ pt = new Point(_taxon.R.Left + Options.ZoomedWidth / 2, _taxon.R.Top + _taxon.R.Height / 2); // in Client space pt = GraphToClient(pt); // compute delta to move pt to client middle (Width/2, Height/2); // pt.X + deltaX = Width / 2 // pt.Y + deltaY = Height / 2 OffsetOrigin(Width / 2 - pt.X, Height / 2 - pt.Y); ConstraintGraphInClient(); Invalidate(); }
//========================================================================================= // PICKING // //------------------------------------------------------------------- public static TaxonTreeNode PickTaxonRectangularStatic(TaxonTreeNode _in, int X, int Y) { if (X < _in.R.Left) { return(null); } if (Y < _in.R.Top) { return(null); } if (Y > _in.R.Bottom) { return(null); } if (_in.R.Contains(X, Y)) { return(_in); } foreach (TaxonTreeNode child in _in.Children) { TaxonTreeNode result = PickTaxonRectangularStatic(child, X, Y); if (result != null) { return(result); } } return(null); }
//--------------------------------------------------------------------------------- // debut de database //Database.SQL DataBase = new Database.SQL(); //--------------------------------------------------------------------------------- public Form1(string[] args) { //----- tip manager TipManager.Start(); //----- menu InitializeComponent(); ApplyTheme(); UpdateUI(); //----- args if (args.Length > 0 && File.Exists(args[0])) { FileInfo fi = new FileInfo(args[0]); TaxonUtils.MyConfig.TaxonPath = fi.Directory.FullName; TaxonUtils.MyConfig.TaxonFileName = fi.Name; } //----- load DateTime startLoad = DateTime.Now; TaxonTreeNode loadedNode = null; if (TaxonUtils.Exists()) { loadedNode = TaxonTreeNode.Load(TaxonUtils.GetTaxonFileName()); } if (loadedNode == null) { if (!TaxonTreeNode.LoadHasBeenCanceled() && !TaxonUtils.MyConfig.emptyTreeAtStartup) { Loggers.WriteError(LogTags.Data, "Cannot open taxon file data : \n\n " + TaxonUtils.GetTaxonFileName()); } } else { string message = "open " + TaxonUtils.GetTaxonFileName() + " successful"; message += "\n " + loadedNode.Count() + " taxon loaded"; message += "\n " + loadedNode.Count(ClassicRankEnum.Espece) + " " + VinceToolbox.Helpers.enumHelper.GetEnumDescription(ClassicRankEnum.Espece); message += "," + loadedNode.Count(ClassicRankEnum.SousEspece) + " " + VinceToolbox.Helpers.enumHelper.GetEnumDescription(ClassicRankEnum.SousEspece); Loggers.WriteInformation(LogTags.Data, message); } FormAbout.SetSplashScreenMessage(".. End initialization ..."); TaxonUtils.SetOriginalRoot(loadedNode); TaxonUtils.MainWindow = this; DateTime endLoad = DateTime.Now; TaxonControlList.OnRegisterTaxonControl += TaxonControlList_OnRegisterTaxonControl; TaxonControlList.OnInitTaxonControlAfterLoad += TaxonControlList_OnInitTaxonControlAfterLoad; TaxonControlList.OnUnregisterTaxonControl += TaxonControlList_OnUnregisterTaxonControl; SystemConfig.OnRunningModeChanged += SystemConfig_OnRunningModeChanged; SystemConfig_OnRunningModeChanged(null, EventArgs.Empty); TaxonUtils.MyConfig.ToUI(); taxonGraph_AddOneIfNone(); Loggers.WriteInformation(LogTags.Data, "Total loading time: " + (int)((endLoad - startLoad).TotalMilliseconds)); }
public virtual TaxonTreeNode GetFiltered(TaxonTreeNode _root) { if (_root == null) { return(null); } return(_root.FindTaxon(Desc)); }
//--------------------------------------------------------------------------------- private void HighlightFrenchName(TaxonTreeNode _node) { _node.Highlight = _node.Desc.HasFrenchName; foreach (TaxonTreeNode child in _node.Children) { HighlightFrenchName(child); } }
//--------------------------------------------------------------------------------- public override void OnSelectTaxon(TaxonTreeNode _taxon) { if (checkBoxLock.Checked) { return; } Edited = _taxon; }
void RegisterTaxon(TaxonTreeNode _node) { if (_node.Desc.IsUnnamed) { return; } Add(_node.Desc.RefMultiName.Main, _node); }
public TaxonSearch(TaxonTreeNode _root, bool _init = true, bool _useAlternativeNames = false) { _Root = _root; if (_init) { Init(_useAlternativeNames); } }
bool CanPasteClipboard(TaxonTreeNode _to) { if (Selected == null || Selected.IsFiltered()) { return(false); } return(Clipboard.ContainsData("TaxonTreeNodeXmlMemoryStream")); }
public TaxonTreeNode Duplicate() { MemoryStream s = SaveXMLInMemory(); TaxonTreeNode duplicata = LoadXMLFromMemory(s); s.Dispose(); return(duplicata); }
public int GetLastFullVisibleGeneration(TaxonTreeNode _origin) { List <TaxonTreeNode> list = new List <TaxonTreeNode> { _origin }; return(GetLastFullVisibleGeneration(_origin, list)); }
public static TaxonIds Compute(TaxonTreeNode _node) { TaxonIds Data = new TaxonIds(); _node.ParseNodeDesc(CheckIds, Data); Data.BuildRanges(); return(Data); }
public Synonyms(TaxonTreeNode _root) { _root.ParseNodeDesc((d) => { if (d.RefMultiName.HasSynonym) { this.Add(new Synonym(d)); } }); }
//--------------------------------------------------------------------------------- private void HighlightImage(TaxonTreeNode _node) { _node.Highlight = _node.Desc.HasImage; foreach (TaxonTreeNode child in _node.Children) { HighlightImage(child); } }
//--------------------------------------------------------------------------------- private void HighlightSound(TaxonTreeNode _node) { _node.Highlight = _node.Desc.HasSound; foreach (TaxonTreeNode child in _node.Children) { HighlightSound(child); } }
//--------------------------------------------------------------------------------- private void HighlightClassikRank(TaxonTreeNode _node) { _node.Highlight = _node.Desc.ClassicRank != ClassicRankEnum.None; //_node.Highlight = _node.Desc.ClassicRank == ClassicRankEnum.Classe; foreach (TaxonTreeNode child in _node.Children) { HighlightClassikRank(child); } }