private void calculate() { byte[] octets= text2byte(); //InternetProtocolAddress ip = new InternetProtocolAddress(octets[0], octets[1], octets[2], octets[3]); InternetProtocolAddress ip = new InternetProtocolAddress(192,168,178,222); IPCalculation ipc = new IPCalculation(ip, byte.Parse(Hostbits.SelectedItem.ToString())); updateDecimalLabels(ipc); updateBinaryLabels(ipc); }
private void updateBinaryLabels(IPCalculation ipc) { lNetmaskBinary.Content = ipc.getNetmask().ToBinaryString(); lNetworkBinary.Content = ipc.getNetworkAddress().ToBinaryString(); lStartAddressBinary.Content = ipc.getfirstAddress().ToBinaryString(); lEndAddressBinary.Content = ipc.getLastAddress().ToBinaryString(); lBroadcastAddressBinary.Content = ipc.getBroadcastAddress().ToBinaryString(); }
private void TextBox_TextChanged(object sender, TextChangedEventArgs e) { TextBox textbox = (TextBox)sender; byte octet; if(!byte.TryParse(textbox.Text,out octet)) { textbox.Text = ""; } else { if (textbox.Text.Length == 3) { TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next); request.Wrapped = true; textbox.MoveFocus(request); } } if(firstOctet.Text!="" && secondOctet.Text!="" && thirdOctet.Text!="" && fourthOctet.Text != "") { calculate(); } IPCalculation ipc = new IPCalculation(null, 1); }
private void updateDecimalLabels(IPCalculation ipc) { lNetmask.Content = ipc.getNetmask(); lNetwork.Content = ipc.getNetworkAddress(); lHostNumber.Content = ipc.getHostnumber(); lHostAddressSize.Content= ipc.getHostBits()+" Bits"; lNetworkAddressSize.Content = ipc.getNetworkBits()+" Bits"; lStartAddress.Content = ipc.getfirstAddress(); lEndAddress.Content = ipc.getLastAddress(); lBroadcastAddress.Content = ipc.getBroadcastAddress(); }