Exemplo n.º 1
0
        private void RestoreFamilyModel(FamilyModel model)
        {
            
            disableChangeRecording = true;
            
            Settings.Instance.Person = new PersonSettings();
            if (model.PersonSettings != null) { Settings.Instance.Person.CopyProperties(model.PersonSettings); }

            Settings.Instance.Relationship = new RelationshipSettings();
            if (model.RelationshipSettings != null) { Settings.Instance.Relationship.CopyProperties(model.RelationshipSettings); }   
                    
            Members.Clear();
            if (model.Members != null)
            {
                foreach (PersonModel personModel in model.Members)
                {
                    PersonView personView = new PersonView(GetNextID());
                    personView.CopyBaseProperties(personModel);
                    Members.Add(personView);                                       
                }
            }

            Relationships.Clear();
            if (model.Relationships != null)
            {
                foreach (RelationshipModel relationshipModel in model.Relationships)
                {
                    RelationshipView relationshipView = new RelationshipView(relationshipModel.Id);
                    relationshipView.CopyBaseProperties(relationshipModel);
                    Relationships.Add(relationshipView);                                     
                }
            }
            Tree = new Tree();
            if (model.Tree != null)
            {
                Tree.CopyProperties(model.Tree);
            }
                 
            SelectedPerson = GetPerson(Tree.SelectedPersonId);
            if (SelectedPerson != null) { SelectedPerson.Selected = true; }

            SelectedRelationship = GetRelationship(Tree.SelectedRelationshipId);
            if (SelectedRelationship != null) { SelectedRelationship.Selected = true; }
            
            RefreshTreeLayout();
            SubscribeToEvents();
            CurrentFamilyModel = GetCurrentFamilyModel();            
            Undo.RaiseCanExecuteChanged();
            Redo.RaiseCanExecuteChanged();
            lastChangeTime = DateTime.Now;
            disableChangeRecording = false;

            FamilyTreeCursor = Cursors.Arrow;
            SelectCommandInProgressType = 0;
        }
Exemplo n.º 2
0
        public void CreateRelationship(int type, PersonView personSource, PersonView personDestination, DateTime? startDate, DateTime? endDate)
        {

            if (personSource == personDestination) { return; }
            int Id = type * (int)Math.Pow(10, 6) + personSource.Id * (int)Math.Pow(10, 3) + personDestination.Id;

            RelationshipView relationship = FamilyView.Instance.GetRelationship(Id);
            if (relationship != null)
            {
                relationship.Refresh();
            }
            else
            {
                RelationshipView newRelationship = new RelationshipView(Id, startDate, endDate);
                FamilyView.Instance.Relationships.Add(newRelationship);
                newRelationship.PropertyChanged += RelationshipPropertyChangedHandler;
                newRelationship.BasePropertyChanged += BasePropertyChangedHandler;

            }
        }
Exemplo n.º 3
0
 private bool IsNewRelationship(RelationshipView relationship)
 {
     bool IsNew = true;
     if (MotherRelationship != null)
     {
         if (relationship.Id == MotherRelationship.Id) { IsNew = false; }
     }
     if (FatherRelationship != null)
     {
         if (relationship.Id == FatherRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in SiblingRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in FriendRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in PartnerRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in ChildRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in AbuserRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     foreach (RelationshipView currentRelationship in VictimRelationships)
     {
         if (relationship.Id == currentRelationship.Id) { IsNew = false; }
     }
     return IsNew;
 }
Exemplo n.º 4
0
 public void SelectRelationship(RelationshipView relationship)
 {
     if (SelectedRelationship != null)
     {
         SelectedRelationship.Selected = false;                
     }
     if (relationship != null)
     {
         SelectedRelationship = relationship;
         SelectedRelationship.Selected = true;
     }
     else
     {
         SelectedRelationship = null;
     }
 }
Exemplo n.º 5
0
        public void AddRelationship(RelationshipView relationship)
        {
            if (!IsNewRelationship(relationship)) { return; }

            switch (relationship.Type)
            {
                case 1:
                    if (this == relationship.PersonSource) { ChildRelationships.Add(relationship); }
                    else { MotherRelationship = relationship; }                  
                    break;
                case 2:
                    if (this == relationship.PersonSource) { ChildRelationships.Add(relationship); }
                    else { FatherRelationship = relationship; }
                    break;
                case 3:
                    SiblingRelationships.Add(relationship);
                    break;
                case 4:
                    FriendRelationships.Add(relationship);
                    break;
                case 5:
                    PartnerRelationships.Add(relationship);
                    break;
                case 6:
                    if (this == relationship.PersonSource)
                    {
                        VictimRelationships.Add(relationship);
                    }
                    else
                    {
                        AbuserRelationships.Add(relationship);
                    }
                    break;                    
            }
        }