private static void OnLimitsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { IPAddressControl control = obj as IPAddressControl; if (control.MinimumIPAddress == IPAddress.None) { control.MinimumIPAddress = IPAddress.Parse("0.0.0.0"); } if (control.MaximumIPAddress == IPAddress.None) { control.MaximumIPAddress = IPAddress.Parse("255.255.255.255"); } byte[] minimumBytes = control.MinimumIPAddress.GetAddressBytes(); byte[] maximumBytes = control.MaximumIPAddress.GetAddressBytes(); for (int i = 0; i <= 3; i++) { if (minimumBytes[i] > maximumBytes[i]) { minimumBytes[i] = maximumBytes[i]; IPAddress updatedMinimum = IPAddress.Parse(string.Format("{0}.{1}.{2}.{3}", minimumBytes[0], minimumBytes[1], minimumBytes[2], minimumBytes[3])); control.MinimumIPAddress = updatedMinimum; return; } } control.UpdateToolTips(); }
private static void OnValueChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { IPAddressControl control = obj as IPAddressControl; IPAddress newValue = (IPAddress)e.NewValue; byte[] bytes = newValue.GetAddressBytes(); control.ByteA = bytes[0]; control.ByteB = bytes[1]; control.ByteC = bytes[2]; control.ByteD = bytes[3]; }