示例#1
0
        void AddPersonToListView(IndividualClass person)
        {
            string birthAddress          = "";
            string deathAddress          = "";
            IndividualEventClass birthEv = person.GetEvent(IndividualEventClass.EventType.Birth);

            if (birthEv != null)
            {
                AddressClass address = birthEv.GetAddress();
                if (address != null)
                {
                    birthAddress = address.ToString();
                }
            }
            IndividualEventClass deathEv = person.GetEvent(IndividualEventClass.EventType.Death);

            if (deathEv != null)
            {
                AddressClass address = deathEv.GetAddress();
                if (address != null)
                {
                    deathAddress = address.ToString();
                }
            }

            ListViewItem item = new ListViewItem(person.GetName());

            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), birthAddress, person.GetDate(IndividualEventClass.EventType.Death).ToString(), deathAddress });
            item.Tag = person.GetXrefName();

            resultList.Items.Add(item);
        }
示例#2
0
        private string CreateToolString()
        {
            string str = xref + "\n";

            if (family != null)
            {
                IndividualEventClass ev = family.GetEvent(IndividualEventClass.EventType.FamMarriage);

                if (ev != null)
                {
                    str += "Married ";

                    FamilyDateTimeClass date = ev.GetDate();

                    if ((date != null) && (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown))
                    {
                        str += date.ToString();
                    }
                    AddressClass address = ev.GetAddress();
                    if (address != null)
                    {
                        str += " in " + address.ToString();
                    }
                    else
                    {
                        PlaceStructureClass place = ev.GetPlace();

                        if (place != null)
                        {
                            str += " in " + place.ToString();
                        }
                    }
                    str += "\n";
                }
                IList <IndividualXrefClass> childList = family.GetChildList();
                int children = 0;

                if (childList != null)
                {
                    children = childList.Count;
                }
                IList <IndividualXrefClass> parentList = family.GetParentList();
                int parents = 0;

                if (parentList != null)
                {
                    parents = parentList.Count;
                }
                str += parents + " parents and " + children + " children";
            }

            return(str);
        }
        /// <summary>
        /// Uses the ammount of bits bowrowed to determine the subnetmask
        /// </summary>
        /// <returns></returns>
        private SubnetMask GetSubnetAddress(AddressClass AddrClass, int BitsBorrowed, int AddressBits)
        {
            // Use the address class to determine what the defaul subnet mask is
            byte[] BaseAddress;

            // Builts a base subnet with the address class
            switch (AddrClass)
            {
                case AddressClass.A:
                    BaseAddress = new byte[] { 255, 0, 0, 0 };
                    break;
                case AddressClass.B:
                    BaseAddress = new byte[] { 255, 255, 0, 0 };
                    break;
                case AddressClass.C:
                    BaseAddress = new byte[] { 255, 255, 255, 0 };
                    break;
                default:
                    BaseAddress = new byte[] { 255, 255, 255, 0 };
                    break;
            }

            int FirstIndexOfZero = Array.IndexOf(BaseAddress, 0);

            // Get local resource dictionary
            var assembly = typeof(IpAddress).GetTypeInfo().Assembly;
            string[] Resources = assembly.GetManifestResourceNames();

            // Load resources based on address class
            Stream fileStream = assembly.GetManifestResourceStream("Network.SubnetData." + AddrClass.ToString() + ".json");
            StreamReader Reader = new StreamReader(fileStream);

            // Parse json from resources
            string contents = Reader.ReadToEnd();
            dynamic JsonData = JsonConvert.DeserializeObject(contents);

            // Determine Address class
            string AddressString = "";
            AddressString = JsonData[BitsBorrowed.ToString()];

            // Build the subnet mask object that will contain the nessecary information to build the addressing scheme
            SubnetMask ReturnAddress = new SubnetMask(AddressString);
            ReturnAddress.BitsBorrowed = BitsBorrowed;
            ReturnAddress.UsableHostsPerSubnet = AddressesPerSubnet(AddressBits);
            ReturnAddress.AddressesPerSubnet = IntPow(2, BitsBorrowed);

            return ReturnAddress;
        }
示例#4
0
        /// <summary>
        /// Uses the ammount of bits bowrowed to determine the subnetmask
        /// </summary>
        /// <returns></returns>
        private SubnetMask GetSubnetAddress(AddressClass AddrClass, int BitsBorrowed, int AddressBits)
        {
            // Use the address class to determine what the defaul subnet mask is
            byte[] BaseAddress;

            // Builts a base subnet with the address class
            switch (AddrClass)
            {
            case AddressClass.A:
                BaseAddress = new byte[] { 255, 0, 0, 0 };
                break;

            case AddressClass.B:
                BaseAddress = new byte[] { 255, 255, 0, 0 };
                break;

            case AddressClass.C:
                BaseAddress = new byte[] { 255, 255, 255, 0 };
                break;

            default:
                BaseAddress = new byte[] { 255, 255, 255, 0 };
                break;
            }

            int FirstIndexOfZero = Array.IndexOf(BaseAddress, 0);

            // Get local resource dictionary
            var assembly = typeof(IpAddress).GetTypeInfo().Assembly;

            string[] Resources = assembly.GetManifestResourceNames();

            // Load resources based on address class
            Stream       fileStream = assembly.GetManifestResourceStream("Network.SubnetData." + AddrClass.ToString() + ".json");
            StreamReader Reader     = new StreamReader(fileStream);

            // Parse json from resources
            string  contents = Reader.ReadToEnd();
            dynamic JsonData = JsonConvert.DeserializeObject(contents);

            // Determine Address class
            string AddressString = "";

            AddressString = JsonData[BitsBorrowed.ToString()];

            // Build the subnet mask object that will contain the nessecary information to build the addressing scheme
            SubnetMask ReturnAddress = new SubnetMask(AddressString);

            ReturnAddress.BitsBorrowed         = BitsBorrowed;
            ReturnAddress.UsableHostsPerSubnet = AddressesPerSubnet(AddressBits);
            ReturnAddress.AddressesPerSubnet   = IntPow(2, BitsBorrowed);

            return(ReturnAddress);
        }