private void CountButton_OnClick(object sender, RoutedEventArgs e) { var text = PcCountTextBox.Text; var mask = MyIp.CountMaskFromNumber(text); CountMaskTextBox.Text = "Маска: " + mask; }
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; }
private void OkButton_OnClick(object sender, RoutedEventArgs e) { var mask = MaskComboBox.SelectedItem as IpMask; if (mask != null && IpTextBox1.Text != string.Empty && IpTextBox2.Text != string.Empty && IpTextBox3.Text != string.Empty && IpTextBox4.Text != string.Empty) { var ipAdress = new MyIp(new[] { Convert.ToByte(IpTextBox1.Text), Convert.ToByte(IpTextBox2.Text), Convert.ToByte(IpTextBox3.Text), Convert.ToByte(IpTextBox4.Text) }); DisplayData(ipAdress, mask); } }
private void DisplayMacAdr() { var mac = MyIp.GetMacAddress(); var physicalAddresses = mac as PhysicalAddress[] ?? mac.ToArray(); if (physicalAddresses.Any()) { var sb = new StringBuilder(); foreach (var adress in physicalAddresses) { sb.Append(adress + Environment.NewLine); } ComputerMacTextBox.Text = sb.ToString().TrimEnd('\r', '\n'); } else { ComputerMacTextBox.Text = "нет"; } }
private void DisplayIpAdr() { var adresses = MyIp.GetLocalIpAddress(); var adressesArray = adresses as string[] ?? adresses.ToArray(); if (adressesArray.Any()) { StringBuilder sb = new StringBuilder(); foreach (var adress in adressesArray) { sb.Append(adress + Environment.NewLine); } ComputerIpTextBox.Text = sb.ToString().TrimEnd('\r', '\n'); } else { ComputerIpTextBox.Text = "нет"; } }