예제 #1
0
        private void Solve()
        {
            if (fRec1 == null)
            {
                Lab1.Text  = @"XXX1";
                Edit1.Text = "";
            }
            else
            {
                Lab1.Text  = fRec1.XRef;
                Edit1.Text = GKUtils.GetNameString(fRec1, true, false);
            }

            if (fRec2 == null)
            {
                Lab2.Text  = @"XXX2";
                Edit2.Text = "";
            }
            else
            {
                Lab2.Text  = fRec2.XRef;
                Edit2.Text = GKUtils.GetNameString(fRec2, true, false);
            }

            if (fRec1 != null && fRec2 != null)
            {
                txtResult.Text = "???";

                using (KinshipsGraph kinsGraph = TreeTools.SearchKinshipsGraph(fBase.Context, fRec1)) {
                    if (kinsGraph.IsEmpty())
                    {
                        txtResult.Text = "Empty graph.";
                        return;
                    }

                    if (kinsGraph.FindVertex(fRec2.XRef) == null)
                    {
                        txtResult.Text = "These individuals have no common relatives.";
                        return;
                    }

                    kinsGraph.SetTreeRoot(fRec1);
                    txtResult.Text = kinsGraph.GetRelationship(fRec2, true);

                    #if DEBUG_SOLVE
                    txtResult.Text += "\r\n" + kinsGraph.IndividualsPath;
                    #endif
                }
            }
        }