/Mimoza/Plugins/System Settings/NetworkPlugin/IPAddressTextBox.cs
C# | 2435 lines | 2007 code | 69 blank | 359 comment | 221 complexity | 04a746774845ade17d6d327012278f4a MD5 | raw file
Possible License(s): GPL-2.0
Large files files are truncated, but you can click here to view the full file
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Text.RegularExpressions;
-
- namespace Mimoza.Plugin.Forms
- {
- [
- DefaultProperty("Text"),
- DefaultEvent("TextChanged"),
- ]
- /// <summary>
- /// IPAddressTextBox
- /// Control to enter IP-Addresses manually
- /// Supports Binary and Decimal Notation
- /// Supports input of CIDR Notation (appending of Bitmask of Subnetmask devided by Slash)
- /// Support input of IP-Address in IPv6 format
- /// </summary>
- public class IPAddressTextBox : System.Windows.Forms.TextBox
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
-
- private IPNotation m_ipNotation = IPNotation.IPv4Decimal;
- private IPNotation m_newIPNotation = IPNotation.IPv4Decimal;
- private bool m_bOverwrite = true;
- private bool m_bPreventLeave = true;
- private System.Windows.Forms.ErrorProvider error;
- private Regex m_regexValidNumbers = new Regex("[0-9]");
- private ArrayList m_arlDelimeter = new ArrayList(new char[]{'.'});
-
-
- public enum IPNotation
- {
- IPv4Decimal, //192.168.000.001
- IPv4Binary, //11000000.10101000.00000000.00000001
- IPv4DecimalCIDR, //192.168.000.001/16
- IPv4BinaryCIDR, //11000000.10101000.00000000.00000001/16
- IPv6Hexadecimal, //0000:0000:0000:0000:00c0:00a8:0000:0001
- IPv6Binary, //0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000011000000:0000000010101000:0000000000000000:0000000000000001
- IPv6HexadecimalCIDR, //0000:0000:0000:0000:00c0:00a8:0000:0001/16
- IPv6BinaryCIDR, //0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000011000000:0000000010101000:0000000000000000:0000000000000001/16
- IPv6IPv4Decimal, //::192.168.000.001
- IPv6IPv4Binary, //::11000000.10101000.00000000.00000001
- IPv6IPv4DecimalCIDR, //::192.168.000.001/16
- IPv6IPv4BinaryCIDR //::11000000.10101000.00000000.00000001/16
- }
- /*
- switch(arg_value)
- {
- case IPNotation.IPv4Decimal:
- break;
- case IPNotation.IPv4DecimalCIDR:
- break;
- case IPNotation.IPv4Binary:
- break;
- case IPNotation.IPv4BinaryCIDR:
- break;
- case IPNotation.IPv6Hexadecimal:
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- break;
- case IPNotation.IPv6Binary:
- break;
- case IPNotation.IPv6BinaryCIDR:
- break;
- case IPNotation.IPv6IPv4Decimal:
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- break;
- case IPNotation.IPv6IPv4Binary:
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- break;
- default:
- break;
- }
- */
-
- /// <summary>
- /// Constructor
- /// </summary>
- public IPAddressTextBox():base()
- {
- this.InitializeComponent();
-
- this.ResetText();
- }
-
- private void InitializeComponent()
- {
- this.error = new System.Windows.Forms.ErrorProvider();
- }
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if( components != null )
- components.Dispose();
- }
- base.Dispose( disposing );
- }
-
- #region Properties
- #region Not allowed Properties from BaseClass
- /// <summary>
- /// Multiline is not allowed
- /// </summary>
- [
- Category("Behavior"),
- Description("Multiline is not allowed"),
- DefaultValue(false),
- Browsable(false)
- ]
- public override bool Multiline
- {
- get
- {
- return base.Multiline;
- }
- set
- {
- //base.Multiline = value;
- base.Multiline = false;
- }
- }
- [
- Category("Behavior"),
- Description("AllowDrop is not allowed"),
- DefaultValue(false),
- Browsable(false)
- ]
- public override bool AllowDrop
- {
- get
- {
- return base.AllowDrop;
- }
- set
- {
- //base.AllowDrop = value;
- base.AllowDrop = false;
- }
- }
- [
- Category("Behavior"),
- Description("AcceptsReturn is not allowed"),
- DefaultValue(false),
- Browsable(false)
- ]
- public new bool AcceptsReturn
- {
- get
- {
- return base.AcceptsReturn;
- }
- set
- {
- //base.AcceptsReturn = value;
- base.AcceptsReturn = false;
- }
- }
- [
- Category("Behavior"),
- Description("AcceptsTab is not allowed"),
- DefaultValue(false),
- Browsable(false)
- ]
- public new bool AcceptsTab
- {
- get
- {
- return base.AcceptsTab;
- }
- set
- {
- //base.AcceptTab = value;
- base.AcceptsTab = false;
- }
- }
- [
- Category("Behavior"),
- Description("CharacterCasing is not allowed"),
- DefaultValue(CharacterCasing.Normal),
- Browsable(false)
- ]
- public new CharacterCasing CharacterCasing
- {
- get
- {
- return base.CharacterCasing;
- }
- set
- {
- //base.CharacterCasing = value;
- base.CharacterCasing = CharacterCasing.Normal;
- }
- }
- [
- Category("Behavior"),
- Description("WordWrap is not allowed"),
- DefaultValue(true),
- Browsable(false)
- ]
- public new bool WordWrap
- {
- get
- {
- return base.WordWrap;
- }
- set
- {
- //base.WordWrap = value;
- base.WordWrap = true;
- }
- }
-
- /// <summary>
- /// Maxlength must not be changed by user
- /// </summary>
- [
- Category("Behavior"),
- Description("Specifies maximum length of a String. Change is not allowed"),
- DefaultValue(15),
- Browsable(false)
- ]
- public override int MaxLength
- {
- get
- {
- return base.MaxLength;
- }
- set
- {
- //base.MaxLength = value;
- base.MaxLength = this.Text.Length;
- }
- }
-
- #endregion // Not allowed Properties from BaseClass
-
- /// <summary>
- /// Specifies if IP-Address
- /// </summary>
- [
- Category("Appearance"),
- Description("Specifies the IP-Address"),
- DefaultValue(" . . . ")
- ]
- public override string Text
- {
- get
- {
- return base.Text;
- }
- set
- {
- try
- {
- if(IPAddressTextBox.ValidateIP(value, this.m_newIPNotation, this.m_arlDelimeter))
- base.Text = IPAddressTextBox.MakeValidSpaces(value, this.m_newIPNotation, this.m_arlDelimeter);
- }
- catch
- {
-
- }
- }
- }
-
- /// <summary>
- /// Specifies if Numbers should be overwritten
- /// </summary>
- [
- Category("Behavior"),
- Description("Specifies if Numbers should be overwritten"),
- DefaultValue(true)
- ]
- public bool OverWriteMode
- {
- get
- {
- return this.m_bOverwrite;
- }
- set
- {
- if(value!=this.m_bOverwrite)
- {
- this.m_bOverwrite = value;
- this.OnOverWriteChanged(value);
- }
- }
- }
-
- /// <summary>
- /// Prevents leaving of Control if there is an input-error
- /// </summary>
- [
- Category("Behavior"),
- Description("Prevents leaving of Control if there is an input-error"),
- DefaultValue(true)
- ]
- public bool PreventLeaveAtError
- {
- get
- {
- return this.m_bPreventLeave;
- }
- set
- {
- if(value!=this.m_bPreventLeave)
- {
- this.m_bPreventLeave = value;
- this.OnPreventLeaveChanged(value);
- }
- }
- }
-
- /// <summary>
- /// Specifies if IP-Address Notation (IPv4, IPv6, Binary, Decimal, CIDR
- /// </summary>
- [
- Category("Appearance"),
- Description("Specifies if IP-Address Notation (IPv4, IPv6, Binary, Decimal, CIDR"),
- DefaultValue(IPNotation.IPv4Decimal)
- ]
- public IPNotation Notation
- {
- get
- {
- return this.m_ipNotation;
- }
- set
- {
- if(value!=this.m_ipNotation)
- {
- try
- {
- this.m_newIPNotation = value;
- this.ChangeNotation(this.m_ipNotation, this.m_newIPNotation);
- this.m_ipNotation = this.m_newIPNotation;
- this.OnNotationChanged(this.m_newIPNotation);
- }
- catch(Exception LastError)
- {
- System.Diagnostics.Debug.WriteLine(LastError.Message);
- throw LastError;
- }
- }
- }
- }
-
- /// <summary>
- /// Specifies the Errorprovider that appears at invalid IPs
- /// </summary>
- [
- Category("Appearance"),
- Description("Specifies the Errorprovider that appears at invalid IPs"),
- DefaultValue(false)
- ]
- public ErrorProvider IPError
- {
- get
- {
- return this.error;
- }
- }
-
-
- #endregion //Properties
-
- #region Eventhandling
-
- /// <summary>
- /// Delegate for Notation-Events
- /// </summary>
- public delegate void NotationChangedEventHandler(IPNotation arg_newValue);
- /// <summary>
- /// Event called if AppearanceMode Notation is changed
- /// </summary>
- public event NotationChangedEventHandler NotationChanged;
- /// <summary>
- /// Delegate for Bool-Properties-Events
- /// </summary>
- public delegate void BoolPropertyChangedEventHandler(bool arg_bNewValue);
- /// <summary>
- /// Event called if BehaviorMode OverWriteMode is changed
- /// </summary>
- public event BoolPropertyChangedEventHandler OverWriteModeChanged;
- /// <summary>
- /// Event called if BehaviorMode PreventLeave is changed
- /// </summary>
- public event BoolPropertyChangedEventHandler PreventLeaveChanged;
-
- /// <summary>
- /// Occures when Appearance-Mode Notation was changed
- /// </summary>
- /// <param name="arg_Value">Value, Input IP-Address notation</param>
- protected virtual void OnNotationChanged(IPNotation arg_Value)
- {
- if(this.NotationChanged!=null)
- this.NotationChanged(arg_Value);
- }
-
- private void ChangeNotation(IPNotation arg_oldValue, IPNotation arg_newValue)
- {
- string sTo = "";
- ArrayList arlFrom = new ArrayList(this.Text.Replace(" ","").Split((char[])this.m_arlDelimeter.ToArray(typeof(char))));
-
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- this.m_regexValidNumbers = new Regex("[0-9]");
- this.m_arlDelimeter = new ArrayList(new char[]{'.'});
- break;
- case IPNotation.IPv4DecimalCIDR:
- this.m_regexValidNumbers = new Regex("[0-9]");
- this.m_arlDelimeter = new ArrayList(new char[]{'.','/'});
- break;
- case IPNotation.IPv4Binary:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{'.'});
- break;
- case IPNotation.IPv4BinaryCIDR:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{'.','/'});
- break;
- case IPNotation.IPv6Hexadecimal:
- this.m_regexValidNumbers = new Regex("[0-9a-fA-F]");
- this.m_arlDelimeter = new ArrayList(new char[]{':'});
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- this.m_regexValidNumbers = new Regex("[0-9a-fA-F]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','/'});
- break;
- case IPNotation.IPv6Binary:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{':'});
- break;
- case IPNotation.IPv6BinaryCIDR:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','/'});
- break;
- case IPNotation.IPv6IPv4Decimal:
- this.m_regexValidNumbers = new Regex("[0-9]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','.'});
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- this.m_regexValidNumbers = new Regex("[0-9]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','.','/'});
- break;
- case IPNotation.IPv6IPv4Binary:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','.'});
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- this.m_regexValidNumbers = new Regex("[01]");
- this.m_arlDelimeter = new ArrayList(new char[]{':','.','/'});
- break;
- default:
- break;
- }
-
- switch(arg_oldValue)
- {
- case IPNotation.IPv4Decimal:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- break;
- case IPNotation.IPv4DecimalCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- for(int i=0; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv4Binary:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- for(int i=0; i<arlFrom.Count; i++)
- {
- //Convert Binary to Decimal
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- //Convert Binary to Decimal
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- break;
- case IPNotation.IPv4BinaryCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the 1st 4 elements (IPv4 has only 4 elements)
- for(int i=4; i<arlFrom.Count; i++)
- {
- //Convert Hexadecimal to Decimal
- sTo += this.Hex2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- //Convert Hexadecimal to Binary
- sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //Convert Hexadecimal to Decimal
- sTo += this.Hex2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Hexadecimal:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- break;
- case IPNotation.IPv6Binary:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6Binary:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- //Convert Binary to Decimal
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- break;
- case IPNotation.IPv6BinaryCIDR:
- for(int i=0; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- //do not use the 1st 4 elements
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //Convert Binary to Decimal
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Hexadecimal:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Binary:
- for(int i=0; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=4; i<arlFrom.Count-1; i++)
- {
- //convert from IPv6 Binary to IPv4 Binary
- sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
- (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the 1st 2 elements (::)
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the 1st 2 elements (::)
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- for(int i=2; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- for(int i=2; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- //do not use th2 1st 2 elements
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the last Item, its the Subnetmask
- //do not use the 1st 2 Elements
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Dec2Bin(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- break;
- case IPNotation.IPv6IPv4Binary:
- sTo = "::";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the 1st 2 elements (::)
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the 1st 2 elements (::)
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Slash if its the last IPPart, els add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv4Binary:
- for(int i=2; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- for(int i=2; i<arlFrom.Count; i++)
- {
- //Convert Decimal to Binary
- sTo += arlFrom[i].ToString() +
- //Add Slash if its the last IPPart, else add a dot
- (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
- }
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- case IPNotation.IPv6IPv4Binary:
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count; i++)
- {
- sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
- }
- break;
- default:
- break;
- }
- break;
- case IPNotation.IPv6IPv4BinaryCIDR:
- switch(arg_newValue)
- {
- case IPNotation.IPv4Decimal:
- //do not use the last Item, its the Subnetmask
- //do not use th2 1st 2 elements
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4DecimalCIDR:
- //do not use the last Item, its the Subnetmask
- //do not use the 1st 2 Elements
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += this.Bin2Dec(arlFrom[i].ToString()) +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv4Binary:
- //do not use the last Item, its the Subnetmask
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv4BinaryCIDR:
- //do not use the last Item, its the Subnetmask
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- //Convert Decimal to Binary
- sTo += arlFrom[i].ToString() +
- //Add Dot if its not the last IPPart, else add nothing
- (i==arlFrom.Count-2?"":".");
- }
- //Add Subnetmask
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Hexadecimal:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6HexadecimalCIDR:
- sTo = "0000:0000:0000:0000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6Binary:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- break;
- case IPNotation.IPv6BinaryCIDR:
- sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
- }
- sTo += "/" + arlFrom[arlFrom.Count-1];
- break;
- case IPNotation.IPv6IPv4Decimal:
- sTo = "::";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- break;
- case IPNotation.IPv6IPv4DecimalCIDR:
- sTo = "::";
- for(int i=2; i<arlFrom.Count-1; i++)
- {
- sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
- }
- …
Large files files are truncated, but you can click here to view the full file