コード例 #1
0
        //=========================================================================================
        // Generation functions
        //

        // méthode pour retourner la génération d'un taxon
        public int getGeneration()
        {
            int   level   = 0;
            Taxon current = this;

            while (current != null)
            {
                level++;
                current = current._Father;
            }
            return(level);
        }
コード例 #2
0
        //---------------------------------------------------------------------------------
        public string getFullName()
        {
            string fullName = Name;

            Taxon current = _Father;

            while (current != null)
            {
                fullName = current.Name + "|" + fullName;
                current  = current._Father;
            }
            return(fullName);
        }
コード例 #3
0
        //------------------------------------------
        public Taxon FindTaxonByFullName(string _fullname)
        {
            if (_fullname == null)
            {
                return(null);
            }
            string[] separate = _fullname.ToLower().Split(new char[] { '|' });
            if (separate == null || separate.Count() < 1)
            {
                return(null);
            }

            if (separate[0] != Name.ToLower())
            {
                return(null);
            }
            if (separate.Count() == 1)
            {
                return(this);
            }

            Taxon current = this;
            int   index   = 1;

            while (index < separate.Count())
            {
                bool found = false;
                foreach (Taxon child in current._Children)
                {
                    if (child.Name.ToLower() == separate[index])
                    {
                        index++;
                        if (index == separate.Count())
                        {
                            return(current);
                        }
                        current = child;
                        found   = true;
                        break;
                    }
                }
                if (!found)
                {
                    return(null);
                }
            }
            return(null);
        }
コード例 #4
0
        //=========================================================================================
        // Children functions
        //

        //------------------------------------------
        public Taxon FindTaxonByName(string _name)
        {
            if (Name.ToLower() == _name)
            {
                return(this);
            }
            foreach (Taxon child in _Children)
            {
                Taxon result = child.FindTaxonByName(_name);
                if (result != null)
                {
                    return(result);
                }
            }
            return(null);
        }
コード例 #5
0
        //méthode pour retourner la liste des parents

        public void getAllParents(List <Taxon> _list, bool _includeFirst = true, bool _fromFatherToChild = true)
        {
            Taxon current = this;

            if (!_includeFirst)
            {
                current = current.Father;
            }
            while (current != null)
            {
                _list.Add(current);
                current = current._Father;
            }
            if (_fromFatherToChild)
            {
                _list.Reverse();
            }
        }
コード例 #6
0
        //--------------------------------------------------------------------------------------
        void ContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (SelectedItem == null || !(SelectedItem is Taxon))
            {
                e.Cancel = true;
                return;
            }

            Taxon taxon = SelectedItem as Taxon;

            ToolStripMenuItem menuItem;

            ContextMenuStrip.Items.Clear();
            menuItem = new ToolStripMenuItem("Goto " + taxon.DisplayName, null, new System.EventHandler(onGoto));
            ContextMenuStrip.Items.Add(menuItem);
            menuItem = new ToolStripMenuItem("Select " + taxon.DisplayName, null, new System.EventHandler(onSelect));
            ContextMenuStrip.Items.Add(menuItem);
            menuItem = new ToolStripMenuItem("Add " + taxon.DisplayName + " to favorite", null, new System.EventHandler(onAddFavorite));
            ContextMenuStrip.Items.Add(menuItem);
            e.Cancel = false;
        }
コード例 #7
0
        //--------------------------------------------------------------------------------------
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Taxon taxon = null;

            if (e.Index >= 0 && e.Index < Items.Count)
            {
                taxon = Items[e.Index] as Taxon;
            }
            if (taxon == null)
            {
                base.OnDrawItem(e);
                return;
            }

            //Brush b = (e.Index & 1) == 0 ? Brushes.PapayaWhip : Brushes.PeachPuff;
            Brush b = Brushes.LightYellow;

            if ((e.State & DrawItemState.Selected) != 0)
            {
                b = Brushes.Gold;
            }
            else if (e.Index == MouseIndex)
            {
                b = Brushes.Khaki;
            }

            e.Graphics.FillRectangle(b, e.Bounds);
            e.Graphics.DrawString(taxon.DisplayName, Font, Brushes.Black, e.Bounds);

            Image image = TaxonImages.Manager.GetSmallImage(taxon);

            if (image != null)
            {
                Rectangle imageRect = e.Bounds;
                imageRect.X     = imageRect.Right - imageRect.Height;
                imageRect.Width = imageRect.Height;
                e.Graphics.DrawImage(image, imageRect);
            }
        }
コード例 #8
0
 //--------------------------------------------------------------------------------------
 public int IndexOf(Taxon _taxon)
 {
     return(Items.IndexOf(_taxon));
 }
コード例 #9
0
 public FilterResult filterNonNommé(Taxon _taxon)
 {
     return((_taxon.Name == "non nommé") ? FilterResult.Yes : FilterResult.No);
 }
コード例 #10
0
 //------------------------------------------
 //méthode qui rajoute un taxon à la liste des enfants (_children)
 public void AddChild(Taxon _child)
 {
     _child.Father = this;
     _Children.Add(_child);
 }