コード例 #1
0
        protected void ResetPanel(Wrapper.FamilyTies famt)
        {
            form.cballtieablesims.Items.Clear();
            form.cballtieablesims.Sorted = false;
            Interfaces.Files.IPackedFileDescriptor[] pfds = famt.Package.FindFiles(Data.MetaData.SIM_DESCRIPTION_FILE);
            Wrapper.SDesc sdesc = new SimPe.PackedFiles.Wrapper.SDesc(famt.NameProvider, null, null);
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                Wrapper.Supporting.FamilyTieSim fts = new FamilyTieSim((ushort)pfd.Instance, null, famt);
                form.cballtieablesims.Items.Add(fts);
            }

            form.cballtieablesims.Sorted = true;

            form.cbtietype.Items.Clear();
            form.cbtietype.Items.Add(new LocalizedFamilyTieTypes(Data.MetaData.FamilyTieTypes.MyMotherIs));
            form.cbtietype.Items.Add(new LocalizedFamilyTieTypes(Data.MetaData.FamilyTieTypes.MyFatherIs));
            form.cbtietype.Items.Add(new LocalizedFamilyTieTypes(Data.MetaData.FamilyTieTypes.ImMarriedTo));
            form.cbtietype.Items.Add(new LocalizedFamilyTieTypes(Data.MetaData.FamilyTieTypes.MySiblingIs));
            form.cbtietype.Items.Add(new LocalizedFamilyTieTypes(Data.MetaData.FamilyTieTypes.MyChildIs));
            form.cbtietype.SelectedIndex = 2;

            form.btaddtie.Enabled    = false;
            form.btdeletetie.Enabled = false;
            form.btnewtie.Enabled    = false;

            form.lbties.Items.Clear();
        }
コード例 #2
0
        protected override void Unserialize(System.IO.BinaryReader reader)
        {
            uint id = reader.ReadUInt32();

            if (id != 0x00000001)
            {
                throw new Exception("File is not Recognized by the Family Ties Wrapper!");
            }
            int count = reader.ReadInt32();

            sims = new ArrayList(count);

            for (int i = 0; i < count; i++)
            {
                ushort          instance = reader.ReadUInt16();
                int             blockdel = reader.ReadInt32();
                FamilyTieItem[] items    = new FamilyTieItem[reader.ReadInt32()];
                for (int k = 0; k < items.Length; k++)
                {
                    MetaData.FamilyTieTypes type = (MetaData.FamilyTieTypes)reader.ReadUInt32();
                    ushort tinstance             = reader.ReadUInt16();
                    items[k] = new FamilyTieItem(type, tinstance, this);
                }
                FamilyTieSim simtie = new FamilyTieSim(instance, items, this);
                simtie.BlockDelimiter = blockdel;
                sims.Add(simtie);
            }
        }
コード例 #3
0
        /// <summary>
        /// Returns the available <see cref="FamilyTieSim"/> for the Sim, or creates a new One
        /// </summary>
        /// <param name="sdsc"></param>
        /// <returns>the <see cref="FamilyTieSim"/> for the passed Sim</returns>
        public FamilyTieSim CreateTie(SDesc sdsc)
        {
            FamilyTieSim s = FindTies(sdsc);

            if (s == null)
            {
                s = new FamilyTieSim(sdsc.Instance, new FamilyTieItem[0], this);
                sims.Add(s);
            }
            return(s);
        }
コード例 #4
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();
                      }
            }
        }
コード例 #5
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();
        }