示例#1
0
        private void SelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
        {
            // User has clicked on a label to change the 'active' person
            if (selectionChangedEventArgs.Selected == null)
            {
                return;
            }
            AdjustMyLength aml = selectionChangedEventArgs.Selected as AdjustMyLength;

            if (aml == null)
            {
                return;
            }

            var val = personSel.SelectedValue as Person;

            if (val == null)
            {
                return;
            }
            if (val.Id == aml.Id) // same as current
            {
                return;
            }

            personSel.SelectedValue = gedtrees.PersonById(aml.Id);
        }
示例#2
0
        private void MakeTrack(Person val, string mark)
        {
            var birt = val.Birth;
            var deat = val.Death;
            var name = val.Name;

            float yrs   = JDN1800_01_01;
            float start = 60.0f;

            // TODO this is looking awkward
            TrackStyle startStyle = TrackStyle.Precise;
            var        bdate      = val.BirthDate;

            if (bdate == null)
            {
                startStyle = TrackStyle.Imprecise;
                yrs        = JDN2017_01_01 - 100 * 365;
                name       = name + "*";
            }
            else if (bdate.Type == GEDDate.Types.Estimated)
            {
                startStyle = TrackStyle.Imprecise;
                yrs        = bdate.JDN;
                name       = name + "*";
            }
            else
            {
                yrs = bdate.JDN;
            }

            yrs = (yrs - JDN1800_01_01) / 365.0f;
            int   yr1  = (int)yrs + 1800;
            float secs = yrs * 6;

            start = 60.0f + secs;

            if (deat == null || val.Indi.Living || deat.GedDate == null)
            {
                yrs = JDN2017_01_01;
            }
            else
            {
                yrs = deat.GedDate.JDN;
            }
            yrs = (yrs - JDN1800_01_01) / 365.0f;
            int yr2 = (int)yrs + 1800;

            secs = yrs * 6;
            float end = 60.0f + secs;

            int?showEnd = null;

            if (deat != null && !val.Indi.Living && deat.GedDate != null)
            {
                showEnd = yr2;
            }

            var outName = string.Format("{0}({1})[{2}-{3}]", name, mark, yr1, showEnd.HasValue ? yr2.ToString() : "");

            var aml = new AdjustMyLength();

            aml.Id         = val.Id;
            aml.StartStyle = startStyle;
            aml.Start      = yr1;
            if (deat != null && !val.Indi.Living && deat.GedDate != null)
            {
                aml.End = yr2;
            }
            aml.Name = outName;

            if (mark == "S") // TODO hack
            {
                aml.Split = true;
            }

            if (mark != "C") // TODO hack
            {
                var onions = val.SpouseIn;
                foreach (var onion in onions)
                {
                    var mdate = onion.MarriageDate;
                    if (mdate != null && mdate.Type != GEDDate.Types.Unknown)
                    {
                        Marker marky = new Marker();
                        marky.Char  = "\u2665";
                        marky.Time  = mdate.Year;
                        marky.Above = true;
                        if (aml.Marks == null)
                        {
                            aml.Marks = new List <Marker>();
                        }
                        aml.Marks.Add(marky);
                    }

                    var divE = onion.GetEvent("DIV");
                    if (divE != null && divE.GedDate != null && divE.GedDate.Type != GEDDate.Types.Unknown)
                    {
                        Marker marky = new Marker();
                        marky.Char  = "D";
                        marky.Time  = divE.GedDate.Year;
                        marky.Above = false;
                        if (aml.Marks == null)
                        {
                            aml.Marks = new List <Marker>();
                        }
                        aml.Marks.Add(marky);
                    }
                }
            }

            timeline1.AddTrack(aml);
        }