Ejemplo n.º 1
0
        public void Show(Draw D, Rectangle Rect)
        {
            float Zoom       = 0.35f;
            int   Width      = 0;
            int   StartX     = Rect.X + Rect.Width / 2;
            int   dx         = 20;
            int   dy         = 75;
            bool  MouseOver  = false;
            int   Offset     = Common_Ancestor.Generation;
            int   FullHeight = (FamilyTree.Count + 2) * dy;
            int   Outside    = FullHeight - Rect.Height;
            int   Top        = dy - (int)(Outside * ScrollValue);

            for (int i = Offset; i < FamilyTree.Count + Offset; i++)
            {
                int FamId = i - Offset;
                int Y     = dy * (i - Offset) + Top;

                int NextY      = Y + dy;
                int NextWidth  = 0;
                int NextStartX = 0;
                int Nextdx     = 0;

                if (FamId + 1 < FamilyTree.Count)
                {
                    NextWidth  = (int)(Rect.Width * (1 - 5 / (FamilyTree[FamId + 1].Count + 4f)));
                    NextStartX = Rect.X + (Rect.Width - NextWidth) / 2;
                    if (FamilyTree[FamId + 1].Count > 1)
                    {
                        Nextdx = NextWidth / (FamilyTree[FamId + 1].Count - 1);
                    }
                    else
                    {
                        Nextdx = 0;
                    }
                }

                D.Graphics.DrawString(i.ToString(), D.Font, Brushes.Black, StartX - 50, Y, D.SF);

                for (int j = 0; j < FamilyTree[FamId].Count; j++)
                {
                    int          X             = StartX + j * dx;
                    FamilyMember Current       = FamilyTree[FamId][j];
                    bool         inHoverFamily = false;
                    if (HoverFamily != null && i - Offset < HoverFamily.Count)
                    {
                        inHoverFamily = HoverFamily[FamId].FamilyPos == j;
                    }
                    for (int k = 0; k < Current.Children.Count; k++)
                    {
                        int   X2            = NextStartX + Current.Children[k].FamilyPos * Nextdx;
                        int   Y2            = NextY;
                        Color Col           = Color.LightGray;
                        bool  HoverChildren = false;
                        if (inHoverFamily && i - Offset < HoverFamily.Count - 1)
                        {
                            if (HoverFamily[FamId + 1].FamilyPos == Current.Children[k].FamilyPos)
                            {
                                Col           = Color.Green;
                                HoverChildren = true;
                            }
                        }
                        D.Graphics.DrawLine(new Pen(Col, HoverChildren? 4:2), X, Y, X2, Y2);
                    }
                    if (!Current.Dead || inHoverFamily || Current.Selected)
                    {
                        float R   = CircleRadius * Zoom * 1.5f;
                        Color Col = Color.DarkOrange;
                        if (inHoverFamily)
                        {
                            Col = Color.Green;
                        }
                        if (Current.Selected)
                        {
                            D.Graphics.FillEllipse(Brushes.DarkGreen, X - R, Y - R, R * 2, R * 2);
                        }
                        else
                        {
                            D.Graphics.DrawEllipse(new Pen(Col, 2), X - R, Y - R, R * 2, R * 2);
                        }
                    }
                    //if (Current.IsEgg != null)
                    //{
                    //    Current.IsEgg.Show(D, X, Y, Zoom);
                    //}
                    //else
                    //{
                    Current.Show(D, X, Y, Zoom);
                    //}
                    if (Intersect(X, Y, CircleRadius * Zoom * 1.5f) && Current.Name.Length > 0)
                    {
                        Hover     = Current;
                        MouseOver = true;
                    }
                    D.Graphics.DrawString(Current.Name, D.Font, Brushes.Black, X, Y - CircleRadius * Zoom * 1.5f, D.SF);
                }
                Width  = NextWidth;
                StartX = NextStartX;
                dx     = Nextdx;
            }
            if (!MouseOver)
            {
                Hover       = null;
                HoverFamily = null;
            }
            else
            {
                HoverFamily = new List <FamilyMember>()
                {
                    Hover
                };
                int CurrentGen = Hover.Generation - Common_Ancestor.Generation;
                int CurrentPos = Hover.FamilyPos;
                while (CurrentGen > 0 && FamilyTree[CurrentGen][CurrentPos].Parents.Count > 0)
                {
                    CurrentPos = FamilyTree[CurrentGen][CurrentPos].Parents[0].FamilyPos;
                    CurrentGen--;
                    HoverFamily.Insert(0, FamilyTree[CurrentGen][CurrentPos]);
                }
                if (Form1.MouseHold)
                {
                    Draw.Selected = Hover;
                }
            }
            ShowScroll(D);
        }