Ejemplo n.º 1
0
        public bool Equals(Nation p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (nation == p.nation);
        }
Ejemplo n.º 2
0
        private void checkedListBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (selectedRelative != null)
            {
                if (checkedListBox2.CheckedItems.Contains(checkedListBox2.SelectedItem))
                {
                    List<int> descedants = new List<int>();
                    descedants.Add(selectedRelative.relativeID);
                    selectedRelative.owningFHx.GetDescendants(selectedRelative.relativeID, ref descedants);
                    foreach (int i in descedants)
                    {
                        Person p = selectedRelative.owningFHx.getRelative(i);
                        if (p != null)
                        {
                            Nation n = new Nation(p.Nationality);
                            n.nation = checkedListBox2.SelectedItem.ToString();
                            if (p.Nationality.IsLoaded)
                            {
                                p.Nationality.AddToList(n, new HraModelChangedEventArgs(this));
                            }
                            else
                            {
                                p.Nationality.BackgroundListLoad();
                                p.Nationality.AddToList(n, new HraModelChangedEventArgs(this));
                            }
                        }
                    }
                }
                else
                {
                    Nation doomed = null;
                    foreach (Nation n in selectedRelative.Nationality)
                    {
                        if (string.Compare(checkedListBox2.SelectedItem.ToString(), n.nation, true) == 0)
                        {
                            doomed = n;
                            break;
                        }

                    }
                    if (doomed != null)
                    {
                        selectedRelative.Nationality.RemoveFromList(doomed, SessionManager.Instance.securityContext);
                    }
                }
            }
        }