public void CalculateMinimalHostIp(IP_address sub, TextBox MinIpTextBox) { string valmin = String.Format("{0}.{1}.{2}.{3}", sub.first_octet, sub.second_octet, sub.third_octet, sub.fourth_octet + 1); MinIpTextBox.Text = valmin; }
private void Button_Click(object sender, RoutedEventArgs e) { if (IP_address.Text == "" && DNS_Name.Text == "" && Description.Text == "") { var da = new DoubleAnimation(); da.From = 1; da.To = 0; da.Duration = new TimeSpan(0, 0, 0, 0, 200); da.AutoReverse = true; IP_address.BeginAnimation(TextBox.OpacityProperty, da); DNS_Name.BeginAnimation(TextBox.OpacityProperty, da); Description.BeginAnimation(TextBox.OpacityProperty, da); } else { DialogResult = true; } }
public void CalculateBinarySubnetMask(IP_address subnet) { subnetMaskBinary = String.Format("{0}{1}{2}{3}", Convert.ToString(subnet.first_octet, 2).PadLeft(8, '0'), Convert.ToString(subnet.second_octet, 2).PadLeft(8, '0'), Convert.ToString(subnet.third_octet, 2).PadLeft(8, '0'), Convert.ToString(subnet.fourth_octet, 2).PadLeft(8, '0')); subnetMaskBinaryChar = subnetMaskBinary.ToCharArray(); for (int i = 0; i < subnetMaskBinaryChar.Length; i++) { for (int j = 0; j < maskFlags.Length; j++) { if (maskFlags[i] == false) { subnetMaskBinaryChar[i] = '1'; } } } }
public static IP_address get_Subnet(IP_address ip, int cidr) { IP_address temp; byte[] bit_decimal = new byte[] { 0, 128, 192, 224, 240, 248, 252, 254, 255 }; if (cidr <= 8) { byte first = bit_decimal[cidr]; temp = new IP_address(first, 0, 0, 0); } else if (cidr > 8 && cidr <= 16) { int pwr = cidr - 8; byte second = bit_decimal[pwr]; temp = new IP_address(255, second, 0, 0); } else if (cidr > 16 && cidr <= 24) { int pwr = cidr - 16; byte third = bit_decimal[pwr]; temp = new IP_address(255, 255, third, 0); } else if (cidr > 24 && cidr <= 32) { int pwr = cidr - 24; byte fourth = bit_decimal[pwr]; temp = new IP_address(255, 255, 255, fourth); } else { temp = new IP_address(0, 0, 0, 0); } IP_address sub = new IP_address((byte)(temp.first_octet & ip.first_octet), (byte)(temp.second_octet & ip.second_octet), (byte)(temp.third_octet & ip.third_octet), (byte)(temp.fourth_octet & ip.fourth_octet)); return(sub); }
public RedirectResult UpdateAddress(IP_address ip) { var add = db.AllAddress.Where(i => i.Address == ip.Address && i.Network == ip.Network).FirstOrDefault(); if (add != null) { db.AllAddress.Remove(add); } if (ip.Name == null) { db.SaveChanges(); } else { IP_address newAdd = new IP_address() { Address = ip.Address, Network = ip.Network, Name = ip.Name, Information = ip.Information }; db.AllAddress.Add(newAdd); } return(Redirect("/Main/ViewIP?net=" + ip.Network)); }
public RedirectResult AddAddress(IP_address ip) { db.AllAddress.Add(ip); db.SaveChanges(); return(Redirect("/Main/ViewIP?net=" + ip.Network)); }
private void Window_Loaded(object sender, RoutedEventArgs e) { IP_address.Focus(); }