Exemplo n.º 1
0
 private void OpenCompletedHandler(object sender, OpenRequestedEventArgs e)
 {
     for (int i = 1; i < generationManager.generationList.Count; i++)
     {
         ConnectChildrenToParents((object)generationManager.generationList[i], new GenerationChangedEventArgs());
     }
 }
Exemplo n.º 2
0
        private void ClearGrid(object sender, OpenRequestedEventArgs e)
        {
            for (int i = 0; i < treeGrid.Children.Count; i++)
            {
                treeGrid.Children.Remove(treeGrid.Children[i]);
                i--;
            }

            for (int i = 1; i < ConnectionsGrid.Children.Count; i++)
            {
                ConnectionsGrid.Children.Remove(ConnectionsGrid.Children[i]);
            }
        }
Exemplo n.º 3
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.DefaultExt = ".bin";
            openFileDialog.Filter     = "Genealogy tree binary files (.bin)|*.bin";
            Nullable <bool> result = openFileDialog.ShowDialog();

            if (result == true)
            {
                FileName = openFileDialog.FileName;
                OpenRequestedEventArgs eventArgs = new OpenRequestedEventArgs();
                eventArgs.filename = FileName;
                OpenRequested?.Invoke(this, eventArgs);
            }
        }
        public void Open(object sender, OpenRequestedEventArgs e)
        {
            OpenRequestedEvent?.Invoke(this, new OpenRequestedEventArgs());

            BinaryFormatter formatter = new BinaryFormatter();
            Node <Person>   tempTree;

            using (Stream stream = File.Open(e.filename, FileMode.Open))
            {
                stream.Position = 0;
                tempTree        = (Node <Person>)formatter.Deserialize(stream);
            }

            generationList.Clear();

            PersonTree.Tree = new Node <Person>(new Person(), null);

            PersonTree.Tree.Value.Name             = tempTree.Value.Name;
            PersonTree.Tree.Value.Partner          = tempTree.Value.Partner;
            PersonTree.Tree.Value.BirthDate        = tempTree.Value.BirthDate;
            PersonTree.Tree.Value.DeathDate        = tempTree.Value.DeathDate;
            PersonTree.Tree.Value.PartnerBirthDate = tempTree.Value.PartnerBirthDate;
            PersonTree.Tree.Value.PartnerDeathDate = tempTree.Value.PartnerDeathDate;
            PersonTree.Tree.SubscribeToNewChildAdded(PersonTree.NewChildAdded);

            this.AddGeneration(new Generation(null));
            this.generationList[generationList.Count - 1].GenerationID = tempTree.Value.GenerationID;
            PersonTree.Tree.Value.GenerationID = this.generationList[0].GenerationID;
            this.generationList[generationList.Count - 1].AddPerson(PersonTree.Tree);

            Action <Person, Node <Person> > action = LoadTree;

            tempTree.Traverse(tempTree, action);

            OpenCompletedEvent?.Invoke(this, new OpenRequestedEventArgs());
        }