示例#1
0
        private void DisplayData(MyIp ip, IpMask mask)
        {
            var brAdr  = ip.GetBroadcastAdress(mask);
            var netAdr = ip.GetNetworkAdress(mask);
            var l      = new ObservableCollection <Representation>
            {
                new Representation {
                    Name = "Ip adress", BinaryValue = ip.BinaryView(), Value = ip.ToString()
                },
                new Representation {
                    Name = "Mask", BinaryValue = mask.BinaryView(), Value = mask.ToString()
                },
                new Representation {
                    Name = "Broadcast adress", BinaryValue = brAdr.BinaryView(), Value = brAdr.ToString()
                },
                new Representation {
                    Name = "Network adress", BinaryValue = netAdr.BinaryView(), Value = netAdr.ToString()
                },
            };

            IpRepresentationListView.ItemsSource = l;
            IpClassTextBox.Text      = ip.GetIpClass();
            IpClassTextBox.IsEnabled = true;
            CountTextBox.Text        = mask.GetNetworkCapacity().ToString();
            CountTextBox.IsEnabled   = true;
        }
示例#2
0
        public IpRepresentation GetBroadcastAdress(IpMask mask)
        {
            var network    = new byte[4];
            var ipOctets   = base.GetAddressBytes();
            var maskOctets = mask.GetAddressBytes();

            for (var i = 0; i < 4; i++)
            {
                network[i] = (byte)(ipOctets[i] | (255 - maskOctets[i]));
            }
            return(new IpRepresentation(network));
        }
示例#3
0
        public IpRepresentation GetNetworkAdress(IpMask mask)
        {
            var network    = new byte[4];
            var ipOctets   = GetAddressBytes();
            var maskOctets = mask.GetAddressBytes();

            for (var i = 0; i < 4; i++)
            {
                network[i] = (byte)(ipOctets[i] & maskOctets[i]);
            }
            return(new IpRepresentation(network));
        }
示例#4
0
        public MainWindow()
        {
            InitializeComponent();
            byte mask = 255;

            byte[] result = new byte[4];
            for (var i = 3; i >= 0; i--)
            {
                result[i] = 255;
            }
            for (var j = 3; j >= 0; j--)
            {
                for (int i = 0; i < 8; i++)
                {
                    mask      = (byte)(mask << 1);
                    result[j] = mask;
                    var msk = new IpMask(result);
                    MaskComboBox.Items.Add(msk);
                }
                mask = 255;
            }
            DisplayIpAdr();
            DisplayMacAdr();
        }