示例#1
0
        public void UpdateGraph(Wrapper.SDesc sdsc, Wrapper.ExtFamilyTies famt)
        {
            this.BeginUpdate();
            if (Parent != null)
            {
                this.Width  = Parent.ClientRectangle.Width;
                this.Height = Parent.ClientRectangle.Height;
            }
            bool run = WaitingScreen.Running;

            WaitingScreen.Wait();
            try
            {
                this.SaveBounds = false;
                this.AutoSize   = true;
                this.Clear();
                baseip = null;

                if (famt == null || sdsc == null)
                {
                    this.EndUpdate();
                    if (!run)
                    {
                        WaitingScreen.Stop();
                    }
                    return;
                }

                FamilyTieSim    tie      = famt.FindTies(sdsc);
                Wrapper.SDesc[] parents  = famt.ParentSims(sdsc);
                Wrapper.SDesc[] siblings = famt.SiblingSims(sdsc);
                Wrapper.SDesc[] childs   = famt.ChildSims(sdsc);

                int maxct = parents.Length + siblings.Length + childs.Length;
                if (maxct < 4)
                {
                    this.LinearUpdateGraph(sdsc, famt);
                    if (!run)
                    {
                        WaitingScreen.Stop();
                    }
                    return;
                }

                double r      = GraphPanel.GetPinCircleRadius(this.ItemSize, this.ItemSize, maxct);
                Point  center = new Point(
                    Math.Max(Width / 2, (int)r + 16 + ItemSize.Width / 2),
                    Math.Max(Height / 2, (int)r + ItemSize.Height / 2)
                    );

                baseip               = CreateItem(sdsc, 0, 0);
                baseip.Location      = GraphPanel.GetCenterLocationOnPinCircle(center, r, ItemSize);
                baseip.Parent        = this;
                this.SelectedElement = baseip;
                baseip.PanelColor    = Color.Black;
                baseip.ForeColor     = Color.White;
                baseip.EndUpdate();

                int ct = 0;

                if (tie != null)
                {
                    foreach (SDesc s in childs)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }

                    foreach (SDesc s in siblings)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }

                    foreach (SDesc s in parents)
                    {
                        ImagePanel ip = AddTieToGraph(s, 0, 0, tie.FindTie(s).Type, false);
                        ip.Location = GraphPanel.GetItemLocationOnPinCricle(center, r, ct++, maxct, ItemSize);
                        ip.EndUpdate();
                    }
                }


                this.EndUpdate();
            }
            finally { if (!run)
                      {
                          WaitingScreen.Stop();
                      }
            }
        }
示例#2
0
        public void LinearUpdateGraph(Wrapper.SDesc sdsc, Wrapper.ExtFamilyTies famt)
        {
            this.BeginUpdate();

            this.Clear();
            baseip = null;

            if (famt == null || sdsc == null)
            {
                this.EndUpdate();
                return;
            }

            FamilyTieSim tie = famt.FindTies(sdsc);


            Wrapper.SDesc[] parents  = famt.ParentSims(sdsc);
            Wrapper.SDesc[] siblings = famt.SiblingSims(sdsc);
            Wrapper.SDesc[] childs   = famt.ChildSims(sdsc);

            Size prect = new Size((parents.Length - 1) * (ItemSize.Width + 8), ItemSize.Height + 60);
            Size srect = new Size(siblings.Length * (ItemSize.Width + 24) + 140, ItemSize.Height + 60 + ((siblings.Length / 2) - 1) * 4 + 24);
            Size crect = new Size((childs.Length - 1) * (ItemSize.Width + 8), ItemSize.Height);
            int  maxw  = Math.Max(Math.Max(prect.Width, srect.Width), crect.Width);
            int  top   = prect.Height + (srect.Height - ItemSize.Height) / 2;
            int  left  = (maxw - ItemSize.Width) / 2 + 32;


            baseip               = CreateItem(sdsc, left, top);
            baseip.Parent        = this;
            this.SelectedElement = baseip;
            baseip.PanelColor    = Color.Black;
            baseip.ForeColor     = Color.White;
            baseip.EndUpdate();

            if (tie != null)
            {
                left = (maxw - prect.Width) / 2 + 16;
                top  = 0;
                foreach (SDesc s in parents)
                {
                    ImagePanel ip = AddTieToGraph(s, left, top, tie.FindTie(s).Type, true);
                    left += ip.Width + 8;
                }

                left = (maxw - srect.Width) / 2 + 16;
                int ct = 0;
                top = prect.Height;
                foreach (SDesc s in siblings)
                {
                    ImagePanel ip = AddTieToGraph(s, left, top, tie.FindTie(s).Type, true);
                    left += ip.Width + 24;

                    ct++;
                    if (ct == siblings.Length / 2 || siblings.Length == 1)
                    {
                        left += 70;
                        baseip.SetBounds(left, top + 24, baseip.Width, baseip.Height);
                        left += ip.Width + 94;
                    }
                    else if (ct > siblings.Length / 2)
                    {
                        top -= 4;
                    }
                    else
                    {
                        top += 4;
                    }
                }

                left = (maxw - crect.Width) / 2 + 16;
                top  = prect.Height + srect.Height;
                foreach (SDesc s in childs)
                {
                    ImagePanel ip = AddTieToGraph(s, left, top, tie.FindTie(s).Type, true);
                    left += ip.Width + 8;
                }
            }


            this.EndUpdate();
        }