PageRenderTime 33ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/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

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Windows.Forms;
  5. using System.Text.RegularExpressions;
  6. namespace Mimoza.Plugin.Forms
  7. {
  8. [
  9. DefaultProperty("Text"),
  10. DefaultEvent("TextChanged"),
  11. ]
  12. /// <summary>
  13. /// IPAddressTextBox
  14. /// Control to enter IP-Addresses manually
  15. /// Supports Binary and Decimal Notation
  16. /// Supports input of CIDR Notation (appending of Bitmask of Subnetmask devided by Slash)
  17. /// Support input of IP-Address in IPv6 format
  18. /// </summary>
  19. public class IPAddressTextBox : System.Windows.Forms.TextBox
  20. {
  21. /// <summary>
  22. /// Required designer variable.
  23. /// </summary>
  24. private System.ComponentModel.Container components = null;
  25. private IPNotation m_ipNotation = IPNotation.IPv4Decimal;
  26. private IPNotation m_newIPNotation = IPNotation.IPv4Decimal;
  27. private bool m_bOverwrite = true;
  28. private bool m_bPreventLeave = true;
  29. private System.Windows.Forms.ErrorProvider error;
  30. private Regex m_regexValidNumbers = new Regex("[0-9]");
  31. private ArrayList m_arlDelimeter = new ArrayList(new char[]{'.'});
  32. public enum IPNotation
  33. {
  34. IPv4Decimal, //192.168.000.001
  35. IPv4Binary, //11000000.10101000.00000000.00000001
  36. IPv4DecimalCIDR, //192.168.000.001/16
  37. IPv4BinaryCIDR, //11000000.10101000.00000000.00000001/16
  38. IPv6Hexadecimal, //0000:0000:0000:0000:00c0:00a8:0000:0001
  39. IPv6Binary, //0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000011000000:0000000010101000:0000000000000000:0000000000000001
  40. IPv6HexadecimalCIDR, //0000:0000:0000:0000:00c0:00a8:0000:0001/16
  41. IPv6BinaryCIDR, //0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000011000000:0000000010101000:0000000000000000:0000000000000001/16
  42. IPv6IPv4Decimal, //::192.168.000.001
  43. IPv6IPv4Binary, //::11000000.10101000.00000000.00000001
  44. IPv6IPv4DecimalCIDR, //::192.168.000.001/16
  45. IPv6IPv4BinaryCIDR //::11000000.10101000.00000000.00000001/16
  46. }
  47. /*
  48. switch(arg_value)
  49. {
  50. case IPNotation.IPv4Decimal:
  51. break;
  52. case IPNotation.IPv4DecimalCIDR:
  53. break;
  54. case IPNotation.IPv4Binary:
  55. break;
  56. case IPNotation.IPv4BinaryCIDR:
  57. break;
  58. case IPNotation.IPv6Hexadecimal:
  59. break;
  60. case IPNotation.IPv6HexadecimalCIDR:
  61. break;
  62. case IPNotation.IPv6Binary:
  63. break;
  64. case IPNotation.IPv6BinaryCIDR:
  65. break;
  66. case IPNotation.IPv6IPv4Decimal:
  67. break;
  68. case IPNotation.IPv6IPv4DecimalCIDR:
  69. break;
  70. case IPNotation.IPv6IPv4Binary:
  71. break;
  72. case IPNotation.IPv6IPv4BinaryCIDR:
  73. break;
  74. default:
  75. break;
  76. }
  77. */
  78. /// <summary>
  79. /// Constructor
  80. /// </summary>
  81. public IPAddressTextBox():base()
  82. {
  83. this.InitializeComponent();
  84. this.ResetText();
  85. }
  86. private void InitializeComponent()
  87. {
  88. this.error = new System.Windows.Forms.ErrorProvider();
  89. }
  90. /// <summary>
  91. /// Clean up any resources being used.
  92. /// </summary>
  93. protected override void Dispose( bool disposing )
  94. {
  95. if( disposing )
  96. {
  97. if( components != null )
  98. components.Dispose();
  99. }
  100. base.Dispose( disposing );
  101. }
  102. #region Properties
  103. #region Not allowed Properties from BaseClass
  104. /// <summary>
  105. /// Multiline is not allowed
  106. /// </summary>
  107. [
  108. Category("Behavior"),
  109. Description("Multiline is not allowed"),
  110. DefaultValue(false),
  111. Browsable(false)
  112. ]
  113. public override bool Multiline
  114. {
  115. get
  116. {
  117. return base.Multiline;
  118. }
  119. set
  120. {
  121. //base.Multiline = value;
  122. base.Multiline = false;
  123. }
  124. }
  125. [
  126. Category("Behavior"),
  127. Description("AllowDrop is not allowed"),
  128. DefaultValue(false),
  129. Browsable(false)
  130. ]
  131. public override bool AllowDrop
  132. {
  133. get
  134. {
  135. return base.AllowDrop;
  136. }
  137. set
  138. {
  139. //base.AllowDrop = value;
  140. base.AllowDrop = false;
  141. }
  142. }
  143. [
  144. Category("Behavior"),
  145. Description("AcceptsReturn is not allowed"),
  146. DefaultValue(false),
  147. Browsable(false)
  148. ]
  149. public new bool AcceptsReturn
  150. {
  151. get
  152. {
  153. return base.AcceptsReturn;
  154. }
  155. set
  156. {
  157. //base.AcceptsReturn = value;
  158. base.AcceptsReturn = false;
  159. }
  160. }
  161. [
  162. Category("Behavior"),
  163. Description("AcceptsTab is not allowed"),
  164. DefaultValue(false),
  165. Browsable(false)
  166. ]
  167. public new bool AcceptsTab
  168. {
  169. get
  170. {
  171. return base.AcceptsTab;
  172. }
  173. set
  174. {
  175. //base.AcceptTab = value;
  176. base.AcceptsTab = false;
  177. }
  178. }
  179. [
  180. Category("Behavior"),
  181. Description("CharacterCasing is not allowed"),
  182. DefaultValue(CharacterCasing.Normal),
  183. Browsable(false)
  184. ]
  185. public new CharacterCasing CharacterCasing
  186. {
  187. get
  188. {
  189. return base.CharacterCasing;
  190. }
  191. set
  192. {
  193. //base.CharacterCasing = value;
  194. base.CharacterCasing = CharacterCasing.Normal;
  195. }
  196. }
  197. [
  198. Category("Behavior"),
  199. Description("WordWrap is not allowed"),
  200. DefaultValue(true),
  201. Browsable(false)
  202. ]
  203. public new bool WordWrap
  204. {
  205. get
  206. {
  207. return base.WordWrap;
  208. }
  209. set
  210. {
  211. //base.WordWrap = value;
  212. base.WordWrap = true;
  213. }
  214. }
  215. /// <summary>
  216. /// Maxlength must not be changed by user
  217. /// </summary>
  218. [
  219. Category("Behavior"),
  220. Description("Specifies maximum length of a String. Change is not allowed"),
  221. DefaultValue(15),
  222. Browsable(false)
  223. ]
  224. public override int MaxLength
  225. {
  226. get
  227. {
  228. return base.MaxLength;
  229. }
  230. set
  231. {
  232. //base.MaxLength = value;
  233. base.MaxLength = this.Text.Length;
  234. }
  235. }
  236. #endregion // Not allowed Properties from BaseClass
  237. /// <summary>
  238. /// Specifies if IP-Address
  239. /// </summary>
  240. [
  241. Category("Appearance"),
  242. Description("Specifies the IP-Address"),
  243. DefaultValue(" . . . ")
  244. ]
  245. public override string Text
  246. {
  247. get
  248. {
  249. return base.Text;
  250. }
  251. set
  252. {
  253. try
  254. {
  255. if(IPAddressTextBox.ValidateIP(value, this.m_newIPNotation, this.m_arlDelimeter))
  256. base.Text = IPAddressTextBox.MakeValidSpaces(value, this.m_newIPNotation, this.m_arlDelimeter);
  257. }
  258. catch
  259. {
  260. }
  261. }
  262. }
  263. /// <summary>
  264. /// Specifies if Numbers should be overwritten
  265. /// </summary>
  266. [
  267. Category("Behavior"),
  268. Description("Specifies if Numbers should be overwritten"),
  269. DefaultValue(true)
  270. ]
  271. public bool OverWriteMode
  272. {
  273. get
  274. {
  275. return this.m_bOverwrite;
  276. }
  277. set
  278. {
  279. if(value!=this.m_bOverwrite)
  280. {
  281. this.m_bOverwrite = value;
  282. this.OnOverWriteChanged(value);
  283. }
  284. }
  285. }
  286. /// <summary>
  287. /// Prevents leaving of Control if there is an input-error
  288. /// </summary>
  289. [
  290. Category("Behavior"),
  291. Description("Prevents leaving of Control if there is an input-error"),
  292. DefaultValue(true)
  293. ]
  294. public bool PreventLeaveAtError
  295. {
  296. get
  297. {
  298. return this.m_bPreventLeave;
  299. }
  300. set
  301. {
  302. if(value!=this.m_bPreventLeave)
  303. {
  304. this.m_bPreventLeave = value;
  305. this.OnPreventLeaveChanged(value);
  306. }
  307. }
  308. }
  309. /// <summary>
  310. /// Specifies if IP-Address Notation (IPv4, IPv6, Binary, Decimal, CIDR
  311. /// </summary>
  312. [
  313. Category("Appearance"),
  314. Description("Specifies if IP-Address Notation (IPv4, IPv6, Binary, Decimal, CIDR"),
  315. DefaultValue(IPNotation.IPv4Decimal)
  316. ]
  317. public IPNotation Notation
  318. {
  319. get
  320. {
  321. return this.m_ipNotation;
  322. }
  323. set
  324. {
  325. if(value!=this.m_ipNotation)
  326. {
  327. try
  328. {
  329. this.m_newIPNotation = value;
  330. this.ChangeNotation(this.m_ipNotation, this.m_newIPNotation);
  331. this.m_ipNotation = this.m_newIPNotation;
  332. this.OnNotationChanged(this.m_newIPNotation);
  333. }
  334. catch(Exception LastError)
  335. {
  336. System.Diagnostics.Debug.WriteLine(LastError.Message);
  337. throw LastError;
  338. }
  339. }
  340. }
  341. }
  342. /// <summary>
  343. /// Specifies the Errorprovider that appears at invalid IPs
  344. /// </summary>
  345. [
  346. Category("Appearance"),
  347. Description("Specifies the Errorprovider that appears at invalid IPs"),
  348. DefaultValue(false)
  349. ]
  350. public ErrorProvider IPError
  351. {
  352. get
  353. {
  354. return this.error;
  355. }
  356. }
  357. #endregion //Properties
  358. #region Eventhandling
  359. /// <summary>
  360. /// Delegate for Notation-Events
  361. /// </summary>
  362. public delegate void NotationChangedEventHandler(IPNotation arg_newValue);
  363. /// <summary>
  364. /// Event called if AppearanceMode Notation is changed
  365. /// </summary>
  366. public event NotationChangedEventHandler NotationChanged;
  367. /// <summary>
  368. /// Delegate for Bool-Properties-Events
  369. /// </summary>
  370. public delegate void BoolPropertyChangedEventHandler(bool arg_bNewValue);
  371. /// <summary>
  372. /// Event called if BehaviorMode OverWriteMode is changed
  373. /// </summary>
  374. public event BoolPropertyChangedEventHandler OverWriteModeChanged;
  375. /// <summary>
  376. /// Event called if BehaviorMode PreventLeave is changed
  377. /// </summary>
  378. public event BoolPropertyChangedEventHandler PreventLeaveChanged;
  379. /// <summary>
  380. /// Occures when Appearance-Mode Notation was changed
  381. /// </summary>
  382. /// <param name="arg_Value">Value, Input IP-Address notation</param>
  383. protected virtual void OnNotationChanged(IPNotation arg_Value)
  384. {
  385. if(this.NotationChanged!=null)
  386. this.NotationChanged(arg_Value);
  387. }
  388. private void ChangeNotation(IPNotation arg_oldValue, IPNotation arg_newValue)
  389. {
  390. string sTo = "";
  391. ArrayList arlFrom = new ArrayList(this.Text.Replace(" ","").Split((char[])this.m_arlDelimeter.ToArray(typeof(char))));
  392. switch(arg_newValue)
  393. {
  394. case IPNotation.IPv4Decimal:
  395. this.m_regexValidNumbers = new Regex("[0-9]");
  396. this.m_arlDelimeter = new ArrayList(new char[]{'.'});
  397. break;
  398. case IPNotation.IPv4DecimalCIDR:
  399. this.m_regexValidNumbers = new Regex("[0-9]");
  400. this.m_arlDelimeter = new ArrayList(new char[]{'.','/'});
  401. break;
  402. case IPNotation.IPv4Binary:
  403. this.m_regexValidNumbers = new Regex("[01]");
  404. this.m_arlDelimeter = new ArrayList(new char[]{'.'});
  405. break;
  406. case IPNotation.IPv4BinaryCIDR:
  407. this.m_regexValidNumbers = new Regex("[01]");
  408. this.m_arlDelimeter = new ArrayList(new char[]{'.','/'});
  409. break;
  410. case IPNotation.IPv6Hexadecimal:
  411. this.m_regexValidNumbers = new Regex("[0-9a-fA-F]");
  412. this.m_arlDelimeter = new ArrayList(new char[]{':'});
  413. break;
  414. case IPNotation.IPv6HexadecimalCIDR:
  415. this.m_regexValidNumbers = new Regex("[0-9a-fA-F]");
  416. this.m_arlDelimeter = new ArrayList(new char[]{':','/'});
  417. break;
  418. case IPNotation.IPv6Binary:
  419. this.m_regexValidNumbers = new Regex("[01]");
  420. this.m_arlDelimeter = new ArrayList(new char[]{':'});
  421. break;
  422. case IPNotation.IPv6BinaryCIDR:
  423. this.m_regexValidNumbers = new Regex("[01]");
  424. this.m_arlDelimeter = new ArrayList(new char[]{':','/'});
  425. break;
  426. case IPNotation.IPv6IPv4Decimal:
  427. this.m_regexValidNumbers = new Regex("[0-9]");
  428. this.m_arlDelimeter = new ArrayList(new char[]{':','.'});
  429. break;
  430. case IPNotation.IPv6IPv4DecimalCIDR:
  431. this.m_regexValidNumbers = new Regex("[0-9]");
  432. this.m_arlDelimeter = new ArrayList(new char[]{':','.','/'});
  433. break;
  434. case IPNotation.IPv6IPv4Binary:
  435. this.m_regexValidNumbers = new Regex("[01]");
  436. this.m_arlDelimeter = new ArrayList(new char[]{':','.'});
  437. break;
  438. case IPNotation.IPv6IPv4BinaryCIDR:
  439. this.m_regexValidNumbers = new Regex("[01]");
  440. this.m_arlDelimeter = new ArrayList(new char[]{':','.','/'});
  441. break;
  442. default:
  443. break;
  444. }
  445. switch(arg_oldValue)
  446. {
  447. case IPNotation.IPv4Decimal:
  448. switch(arg_newValue)
  449. {
  450. case IPNotation.IPv4Decimal:
  451. break;
  452. case IPNotation.IPv4DecimalCIDR:
  453. for(int i=0; i<arlFrom.Count; i++)
  454. {
  455. sTo += arlFrom[i].ToString() +
  456. //Add Slash if its the last IPPart, els add a dot
  457. (i==arlFrom.Count-1?"/ ":".");
  458. }
  459. break;
  460. case IPNotation.IPv4Binary:
  461. for(int i=0; i<arlFrom.Count; i++)
  462. {
  463. //Convert Decimal to Binary
  464. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  465. //Add Dot if its not the last IPPart, else add nothing
  466. (i==arlFrom.Count-1?"":".");
  467. }
  468. break;
  469. case IPNotation.IPv4BinaryCIDR:
  470. for(int i=0; i<arlFrom.Count; i++)
  471. {
  472. //Convert Decimal to Binary
  473. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  474. //Add Slash if its the last IPPart, else add a dot
  475. (i==arlFrom.Count-1?"/ ":".");
  476. }
  477. break;
  478. case IPNotation.IPv6Hexadecimal:
  479. sTo = "0000:0000:0000:0000:";
  480. for(int i=0; i<arlFrom.Count; i++)
  481. {
  482. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  483. }
  484. break;
  485. case IPNotation.IPv6HexadecimalCIDR:
  486. sTo = "0000:0000:0000:0000:";
  487. for(int i=0; i<arlFrom.Count; i++)
  488. {
  489. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  490. }
  491. break;
  492. case IPNotation.IPv6Binary:
  493. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  494. for(int i=0; i<arlFrom.Count; i++)
  495. {
  496. sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"":":");
  497. }
  498. break;
  499. case IPNotation.IPv6BinaryCIDR:
  500. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  501. for(int i=0; i<arlFrom.Count; i++)
  502. {
  503. sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"/ ":":");
  504. }
  505. break;
  506. case IPNotation.IPv6IPv4Decimal:
  507. sTo = "::";
  508. for(int i=0; i<arlFrom.Count; i++)
  509. {
  510. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"":".");
  511. }
  512. break;
  513. case IPNotation.IPv6IPv4DecimalCIDR:
  514. sTo = "::";
  515. for(int i=0; i<arlFrom.Count; i++)
  516. {
  517. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
  518. }
  519. break;
  520. case IPNotation.IPv6IPv4Binary:
  521. sTo = "::";
  522. for(int i=0; i<arlFrom.Count; i++)
  523. {
  524. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  525. }
  526. break;
  527. case IPNotation.IPv6IPv4BinaryCIDR:
  528. sTo = "::";
  529. for(int i=0; i<arlFrom.Count; i++)
  530. {
  531. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  532. }
  533. break;
  534. default:
  535. break;
  536. }
  537. break;
  538. case IPNotation.IPv4DecimalCIDR:
  539. switch(arg_newValue)
  540. {
  541. case IPNotation.IPv4Decimal:
  542. //do not use the last Item, its the Subnetmask
  543. for(int i=0; i<arlFrom.Count-1; i++)
  544. {
  545. sTo += arlFrom[i].ToString() +
  546. //Add Dot if its not the last IPPart, else add nothing
  547. (i==arlFrom.Count-2?"":".");
  548. }
  549. break;
  550. case IPNotation.IPv4DecimalCIDR:
  551. break;
  552. case IPNotation.IPv4Binary:
  553. //do not use the last Item, its the Subnetmask
  554. for(int i=0; i<arlFrom.Count-1; i++)
  555. {
  556. //Convert Decimal to Binary
  557. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  558. //Add Dot if its not the last IPPart, else add nothing
  559. (i==arlFrom.Count-2?"":".");
  560. }
  561. break;
  562. case IPNotation.IPv4BinaryCIDR:
  563. //do not use the last Item, its the Subnetmask
  564. for(int i=0; i<arlFrom.Count-1; i++)
  565. {
  566. //Convert Decimal to Binary
  567. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  568. //Add Dot if its not the last IPPart, else add nothing
  569. (i==arlFrom.Count-2?"":".");
  570. }
  571. //Add Subnetmask
  572. sTo += "/" + arlFrom[arlFrom.Count-1];
  573. break;
  574. case IPNotation.IPv6Hexadecimal:
  575. sTo = "0000:0000:0000:0000:";
  576. for(int i=0; i<arlFrom.Count-1; i++)
  577. {
  578. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  579. }
  580. break;
  581. case IPNotation.IPv6HexadecimalCIDR:
  582. sTo = "0000:0000:0000:0000:";
  583. for(int i=0; i<arlFrom.Count-1; i++)
  584. {
  585. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  586. }
  587. sTo += "/" + arlFrom[arlFrom.Count-1];
  588. break;
  589. case IPNotation.IPv6Binary:
  590. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  591. for(int i=0; i<arlFrom.Count-1; i++)
  592. {
  593. sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
  594. }
  595. break;
  596. case IPNotation.IPv6BinaryCIDR:
  597. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  598. for(int i=0; i<arlFrom.Count-1; i++)
  599. {
  600. sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
  601. }
  602. sTo += "/" + arlFrom[arlFrom.Count-1];
  603. break;
  604. case IPNotation.IPv6IPv4Decimal:
  605. sTo = "::";
  606. for(int i=0; i<arlFrom.Count-1; i++)
  607. {
  608. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
  609. }
  610. break;
  611. case IPNotation.IPv6IPv4DecimalCIDR:
  612. sTo = "::";
  613. for(int i=0; i<arlFrom.Count-1; i++)
  614. {
  615. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
  616. }
  617. sTo += "/" + arlFrom[arlFrom.Count-1];
  618. break;
  619. case IPNotation.IPv6IPv4Binary:
  620. sTo = "::";
  621. for(int i=0; i<arlFrom.Count-1; i++)
  622. {
  623. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  624. }
  625. break;
  626. case IPNotation.IPv6IPv4BinaryCIDR:
  627. sTo = "::";
  628. for(int i=0; i<arlFrom.Count-1; i++)
  629. {
  630. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  631. }
  632. sTo += "/" + arlFrom[arlFrom.Count-1];
  633. break;
  634. default:
  635. break;
  636. }
  637. break;
  638. case IPNotation.IPv4Binary:
  639. switch(arg_newValue)
  640. {
  641. case IPNotation.IPv4Decimal:
  642. for(int i=0; i<arlFrom.Count; i++)
  643. {
  644. //Convert Binary to Decimal
  645. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  646. //Add Dot if its not the last IPPart, else add nothing
  647. (i==arlFrom.Count-1?"":".");
  648. }
  649. break;
  650. case IPNotation.IPv4DecimalCIDR:
  651. for(int i=0; i<arlFrom.Count; i++)
  652. {
  653. //Convert Binary to Decimal
  654. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  655. //Add Slash if its the last IPPart, els add a dot
  656. (i==arlFrom.Count-1?"/ ":".");
  657. }
  658. break;
  659. case IPNotation.IPv4Binary:
  660. break;
  661. case IPNotation.IPv4BinaryCIDR:
  662. for(int i=0; i<arlFrom.Count; i++)
  663. {
  664. sTo += arlFrom[i].ToString() +
  665. //Add Slash if its the last IPPart, else add a dot
  666. (i==arlFrom.Count-1?"/ ":".");
  667. }
  668. break;
  669. case IPNotation.IPv6Hexadecimal:
  670. sTo = "0000:0000:0000:0000:";
  671. for(int i=0; i<arlFrom.Count; i++)
  672. {
  673. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  674. }
  675. break;
  676. case IPNotation.IPv6HexadecimalCIDR:
  677. sTo = "0000:0000:0000:0000:";
  678. for(int i=0; i<arlFrom.Count; i++)
  679. {
  680. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  681. }
  682. break;
  683. case IPNotation.IPv6Binary:
  684. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  685. for(int i=0; i<arlFrom.Count; i++)
  686. {
  687. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"":":");
  688. }
  689. break;
  690. case IPNotation.IPv6BinaryCIDR:
  691. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  692. for(int i=0; i<arlFrom.Count; i++)
  693. {
  694. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
  695. }
  696. break;
  697. case IPNotation.IPv6IPv4Decimal:
  698. sTo = "::";
  699. for(int i=0; i<arlFrom.Count; i++)
  700. {
  701. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  702. }
  703. break;
  704. case IPNotation.IPv6IPv4DecimalCIDR:
  705. sTo = "::";
  706. for(int i=0; i<arlFrom.Count; i++)
  707. {
  708. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  709. }
  710. break;
  711. case IPNotation.IPv6IPv4Binary:
  712. sTo = "::";
  713. for(int i=0; i<arlFrom.Count; i++)
  714. {
  715. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"":".");
  716. }
  717. break;
  718. case IPNotation.IPv6IPv4BinaryCIDR:
  719. sTo = "::";
  720. for(int i=0; i<arlFrom.Count; i++)
  721. {
  722. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
  723. }
  724. break;
  725. default:
  726. break;
  727. }
  728. break;
  729. case IPNotation.IPv4BinaryCIDR:
  730. switch(arg_newValue)
  731. {
  732. case IPNotation.IPv4Decimal:
  733. //do not use the last Item, its the Subnetmask
  734. for(int i=0; i<arlFrom.Count-1; i++)
  735. {
  736. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  737. //Add Dot if its not the last IPPart, else add nothing
  738. (i==arlFrom.Count-2?"":".");
  739. }
  740. break;
  741. case IPNotation.IPv4DecimalCIDR:
  742. //do not use the last Item, its the Subnetmask
  743. for(int i=0; i<arlFrom.Count-1; i++)
  744. {
  745. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  746. //Add Dot if its not the last IPPart, else add nothing
  747. (i==arlFrom.Count-2?"":".");
  748. }
  749. //Add Subnetmask
  750. sTo += "/" + arlFrom[arlFrom.Count-1];
  751. break;
  752. case IPNotation.IPv4Binary:
  753. //do not use the last Item, its the Subnetmask
  754. for(int i=0; i<arlFrom.Count-1; i++)
  755. {
  756. sTo += arlFrom[i].ToString() +
  757. //Add Dot if its not the last IPPart, else add nothing
  758. (i==arlFrom.Count-2?"":".");
  759. }
  760. break;
  761. case IPNotation.IPv4BinaryCIDR:
  762. break;
  763. case IPNotation.IPv6Hexadecimal:
  764. sTo = "0000:0000:0000:0000:";
  765. for(int i=0; i<arlFrom.Count-1; i++)
  766. {
  767. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  768. }
  769. break;
  770. case IPNotation.IPv6HexadecimalCIDR:
  771. sTo = "0000:0000:0000:0000:";
  772. for(int i=0; i<arlFrom.Count-1; i++)
  773. {
  774. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  775. }
  776. sTo += "/" + arlFrom[arlFrom.Count-1];
  777. break;
  778. case IPNotation.IPv6Binary:
  779. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  780. for(int i=0; i<arlFrom.Count-1; i++)
  781. {
  782. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  783. }
  784. break;
  785. case IPNotation.IPv6BinaryCIDR:
  786. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  787. for(int i=0; i<arlFrom.Count-1; i++)
  788. {
  789. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  790. }
  791. sTo += "/" + arlFrom[arlFrom.Count-1];
  792. break;
  793. case IPNotation.IPv6IPv4Decimal:
  794. sTo = "::";
  795. for(int i=0; i<arlFrom.Count-1; i++)
  796. {
  797. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  798. }
  799. break;
  800. case IPNotation.IPv6IPv4DecimalCIDR:
  801. sTo = "::";
  802. for(int i=0; i<arlFrom.Count-1; i++)
  803. {
  804. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  805. }
  806. sTo += "/" + arlFrom[arlFrom.Count-1];
  807. break;
  808. case IPNotation.IPv6IPv4Binary:
  809. sTo = "::";
  810. for(int i=0; i<arlFrom.Count-1; i++)
  811. {
  812. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
  813. }
  814. break;
  815. case IPNotation.IPv6IPv4BinaryCIDR:
  816. sTo = "::";
  817. for(int i=0; i<arlFrom.Count-1; i++)
  818. {
  819. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
  820. }
  821. sTo += "/" + arlFrom[arlFrom.Count-1];
  822. break;
  823. default:
  824. break;
  825. }
  826. break;
  827. case IPNotation.IPv6Hexadecimal:
  828. switch(arg_newValue)
  829. {
  830. case IPNotation.IPv4Decimal:
  831. //do not use the 1st 4 elements (IPv4 has only 4 elements)
  832. for(int i=4; i<arlFrom.Count; i++)
  833. {
  834. //Convert Hexadecimal to Decimal
  835. sTo += this.Hex2Dec(arlFrom[i].ToString()) +
  836. //Add Dot if its not the last IPPart, else add nothing
  837. (i==arlFrom.Count-1?"":".");
  838. }
  839. break;
  840. case IPNotation.IPv4DecimalCIDR:
  841. //do not use the 1st 4 elements
  842. for(int i=4; i<arlFrom.Count; i++)
  843. {
  844. sTo += this.Hex2Dec(arlFrom[i].ToString()) +
  845. //Add Slash if its the last IPPart, els add a dot
  846. (i==arlFrom.Count-1?"/ ":".");
  847. }
  848. break;
  849. case IPNotation.IPv4Binary:
  850. //do not use the 1st 4 elements
  851. for(int i=4; i<arlFrom.Count; i++)
  852. {
  853. //Convert Hexadecimal to Binary
  854. sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
  855. //Add Dot if its not the last IPPart, else add nothing
  856. (i==arlFrom.Count-1?"":".");
  857. }
  858. break;
  859. case IPNotation.IPv4BinaryCIDR:
  860. //do not use the 1st 4 elements
  861. for(int i=4; i<arlFrom.Count; i++)
  862. {
  863. sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
  864. //Add Slash if its the last IPPart, else add a dot
  865. (i==arlFrom.Count-1?"/ ":".");
  866. }
  867. break;
  868. case IPNotation.IPv6Hexadecimal:
  869. break;
  870. case IPNotation.IPv6HexadecimalCIDR:
  871. for(int i=0; i<arlFrom.Count; i++)
  872. {
  873. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
  874. }
  875. break;
  876. case IPNotation.IPv6Binary:
  877. for(int i=0; i<arlFrom.Count; i++)
  878. {
  879. sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  880. }
  881. break;
  882. case IPNotation.IPv6BinaryCIDR:
  883. for(int i=0; i<arlFrom.Count; i++)
  884. {
  885. sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  886. }
  887. break;
  888. case IPNotation.IPv6IPv4Decimal:
  889. sTo = "::";
  890. for(int i=4; i<arlFrom.Count; i++)
  891. {
  892. sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  893. }
  894. break;
  895. case IPNotation.IPv6IPv4DecimalCIDR:
  896. sTo = "::";
  897. for(int i=4; i<arlFrom.Count; i++)
  898. {
  899. sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  900. }
  901. break;
  902. case IPNotation.IPv6IPv4Binary:
  903. sTo = "::";
  904. for(int i=4; i<arlFrom.Count; i++)
  905. {
  906. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  907. }
  908. break;
  909. case IPNotation.IPv6IPv4BinaryCIDR:
  910. sTo = "::";
  911. for(int i=4; i<arlFrom.Count; i++)
  912. {
  913. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  914. }
  915. break;
  916. default:
  917. break;
  918. }
  919. break;
  920. case IPNotation.IPv6HexadecimalCIDR:
  921. switch(arg_newValue)
  922. {
  923. case IPNotation.IPv4Decimal:
  924. //do not use the last Item, its the Subnetmask
  925. //do not use the 1st 4 elements
  926. for(int i=4; i<arlFrom.Count-1; i++)
  927. {
  928. sTo += this.Hex2Dec(arlFrom[i].ToString()) +
  929. //Add Dot if its not the last IPPart, else add nothing
  930. (i==arlFrom.Count-2?"":".");
  931. }
  932. break;
  933. case IPNotation.IPv4DecimalCIDR:
  934. //do not use the last Item, its the Subnetmask
  935. for(int i=4; i<arlFrom.Count-1; i++)
  936. {
  937. //Convert Hexadecimal to Decimal
  938. sTo += this.Hex2Dec(arlFrom[i].ToString()) +
  939. //Add Dot if its not the last IPPart, else add nothing
  940. (i==arlFrom.Count-2?"":".");
  941. }
  942. //Add Subnetmask
  943. sTo += "/" + arlFrom[arlFrom.Count-1];
  944. break;
  945. case IPNotation.IPv4Binary:
  946. //do not use the last Item, its the Subnetmask
  947. for(int i=4; i<arlFrom.Count-1; i++)
  948. {
  949. sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
  950. //Add Dot if its not the last IPPart, else add nothing
  951. (i==arlFrom.Count-2?"":".");
  952. }
  953. break;
  954. case IPNotation.IPv4BinaryCIDR:
  955. //do not use the last Item, its the Subnetmask
  956. for(int i=4; i<arlFrom.Count-1; i++)
  957. {
  958. sTo += this.Hex2Bin(arlFrom[i].ToString(), false) +
  959. //Add Dot if its not the last IPPart, else add nothing
  960. (i==arlFrom.Count-2?"":".");
  961. }
  962. //Add Subnetmask
  963. sTo += "/" + arlFrom[arlFrom.Count-1];
  964. break;
  965. case IPNotation.IPv6Hexadecimal:
  966. for(int i=0; i<arlFrom.Count-1; i++)
  967. {
  968. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  969. }
  970. break;
  971. case IPNotation.IPv6HexadecimalCIDR:
  972. break;
  973. case IPNotation.IPv6Binary:
  974. for(int i=0; i<arlFrom.Count-1; i++)
  975. {
  976. sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  977. }
  978. break;
  979. case IPNotation.IPv6BinaryCIDR:
  980. for(int i=0; i<arlFrom.Count-1; i++)
  981. {
  982. sTo += this.Hex2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  983. }
  984. sTo += "/" + arlFrom[arlFrom.Count-1];
  985. break;
  986. case IPNotation.IPv6IPv4Decimal:
  987. sTo = "::";
  988. for(int i=4; i<arlFrom.Count-1; i++)
  989. {
  990. sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  991. }
  992. break;
  993. case IPNotation.IPv6IPv4DecimalCIDR:
  994. sTo = "::";
  995. for(int i=4; i<arlFrom.Count-1; i++)
  996. {
  997. sTo += this.Hex2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  998. }
  999. sTo += "/" + arlFrom[arlFrom.Count-1];
  1000. break;
  1001. case IPNotation.IPv6IPv4Binary:
  1002. sTo = "::";
  1003. for(int i=4; i<arlFrom.Count-1; i++)
  1004. {
  1005. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1006. }
  1007. break;
  1008. case IPNotation.IPv6IPv4BinaryCIDR:
  1009. sTo = "::";
  1010. for(int i=4; i<arlFrom.Count-1; i++)
  1011. {
  1012. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1013. }
  1014. sTo += "/" + arlFrom[arlFrom.Count-1];
  1015. break;
  1016. default:
  1017. break;
  1018. }
  1019. break;
  1020. case IPNotation.IPv6Binary:
  1021. switch(arg_newValue)
  1022. {
  1023. case IPNotation.IPv4Decimal:
  1024. //do not use the 1st 4 elements
  1025. for(int i=4; i<arlFrom.Count; i++)
  1026. {
  1027. //Convert Binary to Decimal
  1028. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1029. //Add Dot if its not the last IPPart, else add nothing
  1030. (i==arlFrom.Count-1?"":".");
  1031. }
  1032. break;
  1033. case IPNotation.IPv4DecimalCIDR:
  1034. //do not use the 1st 4 elements
  1035. for(int i=4; i<arlFrom.Count; i++)
  1036. {
  1037. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1038. //Add Slash if its the last IPPart, els add a dot
  1039. (i==arlFrom.Count-1?"/ ":".");
  1040. }
  1041. break;
  1042. case IPNotation.IPv4Binary:
  1043. //do not use the 1st 4 elements
  1044. for(int i=4; i<arlFrom.Count; i++)
  1045. {
  1046. //convert from IPv6 Binary to IPv4 Binary
  1047. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1048. //Add Dot if its not the last IPPart, else add nothing
  1049. (i==arlFrom.Count-1?"":".");
  1050. }
  1051. break;
  1052. case IPNotation.IPv4BinaryCIDR:
  1053. //do not use the 1st 4 elements
  1054. for(int i=4; i<arlFrom.Count; i++)
  1055. {
  1056. //convert from IPv6 Binary to IPv4 Binary
  1057. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1058. //Add Slash if its the last IPPart, else add a dot
  1059. (i==arlFrom.Count-1?"/ ":".");
  1060. }
  1061. break;
  1062. case IPNotation.IPv6Hexadecimal:
  1063. for(int i=0; i<arlFrom.Count; i++)
  1064. {
  1065. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  1066. }
  1067. break;
  1068. case IPNotation.IPv6HexadecimalCIDR:
  1069. for(int i=0; i<arlFrom.Count; i++)
  1070. {
  1071. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  1072. }
  1073. break;
  1074. case IPNotation.IPv6Binary:
  1075. break;
  1076. case IPNotation.IPv6BinaryCIDR:
  1077. for(int i=0; i<arlFrom.Count; i++)
  1078. {
  1079. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
  1080. }
  1081. break;
  1082. case IPNotation.IPv6IPv4Decimal:
  1083. sTo = "::";
  1084. for(int i=4; i<arlFrom.Count; i++)
  1085. {
  1086. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  1087. }
  1088. break;
  1089. case IPNotation.IPv6IPv4DecimalCIDR:
  1090. sTo = "::";
  1091. for(int i=4; i<arlFrom.Count; i++)
  1092. {
  1093. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  1094. }
  1095. break;
  1096. case IPNotation.IPv6IPv4Binary:
  1097. sTo = "::";
  1098. for(int i=4; i<arlFrom.Count; i++)
  1099. {
  1100. //convert from IPv6 Binary to IPv4 Binary
  1101. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1102. (i==arlFrom.Count-1?"":".");
  1103. }
  1104. break;
  1105. case IPNotation.IPv6IPv4BinaryCIDR:
  1106. sTo = "::";
  1107. for(int i=4; i<arlFrom.Count; i++)
  1108. {
  1109. //convert from IPv6 Binary to IPv4 Binary
  1110. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1111. (i==arlFrom.Count-1?"/ ":".");
  1112. }
  1113. break;
  1114. default:
  1115. break;
  1116. }
  1117. break;
  1118. case IPNotation.IPv6BinaryCIDR:
  1119. switch(arg_newValue)
  1120. {
  1121. case IPNotation.IPv4Decimal:
  1122. //do not use the last Item, its the Subnetmask
  1123. //do not use the 1st 4 elements
  1124. for(int i=4; i<arlFrom.Count-1; i++)
  1125. {
  1126. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1127. //Add Dot if its not the last IPPart, else add nothing
  1128. (i==arlFrom.Count-2?"":".");
  1129. }
  1130. break;
  1131. case IPNotation.IPv4DecimalCIDR:
  1132. //do not use the last Item, its the Subnetmask
  1133. for(int i=4; i<arlFrom.Count-1; i++)
  1134. {
  1135. //Convert Binary to Decimal
  1136. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1137. //Add Dot if its not the last IPPart, else add nothing
  1138. (i==arlFrom.Count-2?"":".");
  1139. }
  1140. //Add Subnetmask
  1141. sTo += "/" + arlFrom[arlFrom.Count-1];
  1142. break;
  1143. case IPNotation.IPv4Binary:
  1144. //do not use the last Item, its the Subnetmask
  1145. for(int i=4; i<arlFrom.Count-1; i++)
  1146. {
  1147. //convert from IPv6 Binary to IPv4 Binary
  1148. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1149. //Add Dot if its not the last IPPart, else add nothing
  1150. (i==arlFrom.Count-2?"":".");
  1151. }
  1152. break;
  1153. case IPNotation.IPv4BinaryCIDR:
  1154. //do not use the last Item, its the Subnetmask
  1155. for(int i=4; i<arlFrom.Count-1; i++)
  1156. {
  1157. //convert from IPv6 Binary to IPv4 Binary
  1158. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1159. //Add Dot if its not the last IPPart, else add nothing
  1160. (i==arlFrom.Count-2?"":".");
  1161. }
  1162. //Add Subnetmask
  1163. sTo += "/" + arlFrom[arlFrom.Count-1];
  1164. break;
  1165. case IPNotation.IPv6Hexadecimal:
  1166. for(int i=0; i<arlFrom.Count-1; i++)
  1167. {
  1168. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1169. }
  1170. break;
  1171. case IPNotation.IPv6HexadecimalCIDR:
  1172. for(int i=0; i<arlFrom.Count-1; i++)
  1173. {
  1174. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1175. }
  1176. sTo += "/" + arlFrom[arlFrom.Count-1];
  1177. break;
  1178. case IPNotation.IPv6Binary:
  1179. for(int i=0; i<arlFrom.Count-1; i++)
  1180. {
  1181. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  1182. }
  1183. break;
  1184. case IPNotation.IPv6BinaryCIDR:
  1185. break;
  1186. case IPNotation.IPv6IPv4Decimal:
  1187. sTo = "::";
  1188. for(int i=4; i<arlFrom.Count-1; i++)
  1189. {
  1190. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1191. }
  1192. break;
  1193. case IPNotation.IPv6IPv4DecimalCIDR:
  1194. sTo = "::";
  1195. for(int i=4; i<arlFrom.Count-1; i++)
  1196. {
  1197. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1198. }
  1199. sTo += "/" + arlFrom[arlFrom.Count-1];
  1200. break;
  1201. case IPNotation.IPv6IPv4Binary:
  1202. sTo = "::";
  1203. for(int i=4; i<arlFrom.Count-1; i++)
  1204. {
  1205. //convert from IPv6 Binary to IPv4 Binary
  1206. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1207. (i==arlFrom.Count-2?"":".");
  1208. }
  1209. break;
  1210. case IPNotation.IPv6IPv4BinaryCIDR:
  1211. sTo = "::";
  1212. for(int i=4; i<arlFrom.Count-1; i++)
  1213. {
  1214. //convert from IPv6 Binary to IPv4 Binary
  1215. sTo += this.Dec2Bin(this.Bin2Dec(arlFrom[i].ToString())) +
  1216. (i==arlFrom.Count-2?"":".");
  1217. }
  1218. sTo += "/" + arlFrom[arlFrom.Count-1];
  1219. break;
  1220. default:
  1221. break;
  1222. }
  1223. break;
  1224. case IPNotation.IPv6IPv4Decimal:
  1225. switch(arg_newValue)
  1226. {
  1227. case IPNotation.IPv4Decimal:
  1228. //do not use the 1st 2 elements (::)
  1229. for(int i=2; i<arlFrom.Count; i++)
  1230. {
  1231. sTo += arlFrom[i].ToString() +
  1232. //Add Dot if its not the last IPPart, else add nothing
  1233. (i==arlFrom.Count-1?"":".");
  1234. }
  1235. break;
  1236. case IPNotation.IPv4DecimalCIDR:
  1237. //do not use the 1st 2 elements (::)
  1238. for(int i=2; i<arlFrom.Count; i++)
  1239. {
  1240. sTo += arlFrom[i].ToString() +
  1241. //Add Slash if its the last IPPart, els add a dot
  1242. (i==arlFrom.Count-1?"/ ":".");
  1243. }
  1244. break;
  1245. case IPNotation.IPv4Binary:
  1246. for(int i=2; i<arlFrom.Count; i++)
  1247. {
  1248. //Convert Decimal to Binary
  1249. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  1250. //Add Dot if its not the last IPPart, else add nothing
  1251. (i==arlFrom.Count-1?"":".");
  1252. }
  1253. break;
  1254. case IPNotation.IPv4BinaryCIDR:
  1255. for(int i=2; i<arlFrom.Count; i++)
  1256. {
  1257. //Convert Decimal to Binary
  1258. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  1259. //Add Slash if its the last IPPart, else add a dot
  1260. (i==arlFrom.Count-1?"/ ":".");
  1261. }
  1262. break;
  1263. case IPNotation.IPv6Hexadecimal:
  1264. sTo = "0000:0000:0000:0000:";
  1265. for(int i=2; i<arlFrom.Count; i++)
  1266. {
  1267. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  1268. }
  1269. break;
  1270. case IPNotation.IPv6HexadecimalCIDR:
  1271. sTo = "0000:0000:0000:0000:";
  1272. for(int i=2; i<arlFrom.Count; i++)
  1273. {
  1274. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  1275. }
  1276. break;
  1277. case IPNotation.IPv6Binary:
  1278. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1279. for(int i=2; i<arlFrom.Count; i++)
  1280. {
  1281. sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"":":");
  1282. }
  1283. break;
  1284. case IPNotation.IPv6BinaryCIDR:
  1285. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1286. for(int i=2; i<arlFrom.Count; i++)
  1287. {
  1288. sTo += this.Dec2Bin(arlFrom[i].ToString(), true) + (i==arlFrom.Count-1?"/ ":":");
  1289. }
  1290. break;
  1291. case IPNotation.IPv6IPv4Decimal:
  1292. break;
  1293. case IPNotation.IPv6IPv4DecimalCIDR:
  1294. sTo = "::";
  1295. for(int i=2; i<arlFrom.Count; i++)
  1296. {
  1297. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
  1298. }
  1299. break;
  1300. case IPNotation.IPv6IPv4Binary:
  1301. sTo = "::";
  1302. for(int i=2; i<arlFrom.Count; i++)
  1303. {
  1304. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  1305. }
  1306. break;
  1307. case IPNotation.IPv6IPv4BinaryCIDR:
  1308. sTo = "::";
  1309. for(int i=2; i<arlFrom.Count; i++)
  1310. {
  1311. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  1312. }
  1313. break;
  1314. default:
  1315. break;
  1316. }
  1317. break;
  1318. case IPNotation.IPv6IPv4DecimalCIDR:
  1319. switch(arg_newValue)
  1320. {
  1321. case IPNotation.IPv4Decimal:
  1322. //do not use the last Item, its the Subnetmask
  1323. //do not use th2 1st 2 elements
  1324. for(int i=2; i<arlFrom.Count-1; i++)
  1325. {
  1326. sTo += arlFrom[i].ToString() +
  1327. //Add Dot if its not the last IPPart, else add nothing
  1328. (i==arlFrom.Count-2?"":".");
  1329. }
  1330. break;
  1331. case IPNotation.IPv4DecimalCIDR:
  1332. //do not use the last Item, its the Subnetmask
  1333. //do not use the 1st 2 Elements
  1334. for(int i=2; i<arlFrom.Count-1; i++)
  1335. {
  1336. //Convert Decimal to Binary
  1337. sTo += arlFrom[i].ToString() +
  1338. //Add Dot if its not the last IPPart, else add nothing
  1339. (i==arlFrom.Count-2?"":".");
  1340. }
  1341. //Add Subnetmask
  1342. sTo += "/" + arlFrom[arlFrom.Count-1];
  1343. break;
  1344. case IPNotation.IPv4Binary:
  1345. //do not use the last Item, its the Subnetmask
  1346. for(int i=2; i<arlFrom.Count-1; i++)
  1347. {
  1348. //Convert Decimal to Binary
  1349. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  1350. //Add Dot if its not the last IPPart, else add nothing
  1351. (i==arlFrom.Count-2?"":".");
  1352. }
  1353. break;
  1354. case IPNotation.IPv4BinaryCIDR:
  1355. //do not use the last Item, its the Subnetmask
  1356. for(int i=2; i<arlFrom.Count-1; i++)
  1357. {
  1358. //Convert Decimal to Binary
  1359. sTo += this.Dec2Bin(arlFrom[i].ToString()) +
  1360. //Add Dot if its not the last IPPart, else add nothing
  1361. (i==arlFrom.Count-2?"":".");
  1362. }
  1363. //Add Subnetmask
  1364. sTo += "/" + arlFrom[arlFrom.Count-1];
  1365. break;
  1366. case IPNotation.IPv6Hexadecimal:
  1367. sTo = "0000:0000:0000:0000:";
  1368. for(int i=2; i<arlFrom.Count-1; i++)
  1369. {
  1370. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1371. }
  1372. break;
  1373. case IPNotation.IPv6HexadecimalCIDR:
  1374. sTo = "0000:0000:0000:0000:";
  1375. for(int i=2; i<arlFrom.Count-1; i++)
  1376. {
  1377. sTo += this.Dec2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1378. }
  1379. sTo += "/" + arlFrom[arlFrom.Count-1];
  1380. break;
  1381. case IPNotation.IPv6Binary:
  1382. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1383. for(int i=2; i<arlFrom.Count-1; i++)
  1384. {
  1385. sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
  1386. }
  1387. break;
  1388. case IPNotation.IPv6BinaryCIDR:
  1389. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1390. for(int i=2; i<arlFrom.Count-1; i++)
  1391. {
  1392. sTo += this.Dec2Bin(arlFrom[i].ToString(),true) + (i==arlFrom.Count-2?"":":");
  1393. }
  1394. sTo += "/" + arlFrom[arlFrom.Count-1];
  1395. break;
  1396. case IPNotation.IPv6IPv4Decimal:
  1397. sTo = "::";
  1398. for(int i=2; i<arlFrom.Count-1; i++)
  1399. {
  1400. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-2?"":".");
  1401. }
  1402. break;
  1403. case IPNotation.IPv6IPv4DecimalCIDR:
  1404. break;
  1405. case IPNotation.IPv6IPv4Binary:
  1406. sTo = "::";
  1407. for(int i=2; i<arlFrom.Count-1; i++)
  1408. {
  1409. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1410. }
  1411. break;
  1412. case IPNotation.IPv6IPv4BinaryCIDR:
  1413. sTo = "::";
  1414. for(int i=2; i<arlFrom.Count-1; i++)
  1415. {
  1416. sTo += this.Dec2Bin(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1417. }
  1418. sTo += "/" + arlFrom[arlFrom.Count-1];
  1419. break;
  1420. default:
  1421. break;
  1422. }
  1423. break;
  1424. case IPNotation.IPv6IPv4Binary:
  1425. switch(arg_newValue)
  1426. {
  1427. case IPNotation.IPv4Decimal:
  1428. //do not use the 1st 2 elements (::)
  1429. for(int i=2; i<arlFrom.Count; i++)
  1430. {
  1431. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1432. //Add Dot if its not the last IPPart, else add nothing
  1433. (i==arlFrom.Count-1?"":".");
  1434. }
  1435. break;
  1436. case IPNotation.IPv4DecimalCIDR:
  1437. //do not use the 1st 2 elements (::)
  1438. for(int i=2; i<arlFrom.Count; i++)
  1439. {
  1440. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1441. //Add Slash if its the last IPPart, els add a dot
  1442. (i==arlFrom.Count-1?"/ ":".");
  1443. }
  1444. break;
  1445. case IPNotation.IPv4Binary:
  1446. for(int i=2; i<arlFrom.Count; i++)
  1447. {
  1448. //Convert Decimal to Binary
  1449. sTo += arlFrom[i].ToString() +
  1450. //Add Dot if its not the last IPPart, else add nothing
  1451. (i==arlFrom.Count-1?"":".");
  1452. }
  1453. break;
  1454. case IPNotation.IPv4BinaryCIDR:
  1455. for(int i=2; i<arlFrom.Count; i++)
  1456. {
  1457. //Convert Decimal to Binary
  1458. sTo += arlFrom[i].ToString() +
  1459. //Add Slash if its the last IPPart, else add a dot
  1460. (i==arlFrom.Count-1?"/ ":".");
  1461. }
  1462. break;
  1463. case IPNotation.IPv6Hexadecimal:
  1464. sTo = "0000:0000:0000:0000:";
  1465. for(int i=2; i<arlFrom.Count; i++)
  1466. {
  1467. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":":");
  1468. }
  1469. break;
  1470. case IPNotation.IPv6HexadecimalCIDR:
  1471. sTo = "0000:0000:0000:0000:";
  1472. for(int i=2; i<arlFrom.Count; i++)
  1473. {
  1474. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":":");
  1475. }
  1476. break;
  1477. case IPNotation.IPv6Binary:
  1478. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1479. for(int i=2; i<arlFrom.Count; i++)
  1480. {
  1481. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"":":");
  1482. }
  1483. break;
  1484. case IPNotation.IPv6BinaryCIDR:
  1485. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1486. for(int i=2; i<arlFrom.Count; i++)
  1487. {
  1488. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":":");
  1489. }
  1490. break;
  1491. case IPNotation.IPv6IPv4Decimal:
  1492. sTo = "::";
  1493. for(int i=2; i<arlFrom.Count; i++)
  1494. {
  1495. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"":".");
  1496. }
  1497. break;
  1498. case IPNotation.IPv6IPv4DecimalCIDR:
  1499. sTo = "::";
  1500. for(int i=2; i<arlFrom.Count; i++)
  1501. {
  1502. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-1?"/ ":".");
  1503. }
  1504. break;
  1505. case IPNotation.IPv6IPv4Binary:
  1506. break;
  1507. case IPNotation.IPv6IPv4BinaryCIDR:
  1508. sTo = "::";
  1509. for(int i=2; i<arlFrom.Count; i++)
  1510. {
  1511. sTo += arlFrom[i].ToString() + (i==arlFrom.Count-1?"/ ":".");
  1512. }
  1513. break;
  1514. default:
  1515. break;
  1516. }
  1517. break;
  1518. case IPNotation.IPv6IPv4BinaryCIDR:
  1519. switch(arg_newValue)
  1520. {
  1521. case IPNotation.IPv4Decimal:
  1522. //do not use the last Item, its the Subnetmask
  1523. //do not use th2 1st 2 elements
  1524. for(int i=2; i<arlFrom.Count-1; i++)
  1525. {
  1526. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1527. //Add Dot if its not the last IPPart, else add nothing
  1528. (i==arlFrom.Count-2?"":".");
  1529. }
  1530. break;
  1531. case IPNotation.IPv4DecimalCIDR:
  1532. //do not use the last Item, its the Subnetmask
  1533. //do not use the 1st 2 Elements
  1534. for(int i=2; i<arlFrom.Count-1; i++)
  1535. {
  1536. //Convert Decimal to Binary
  1537. sTo += this.Bin2Dec(arlFrom[i].ToString()) +
  1538. //Add Dot if its not the last IPPart, else add nothing
  1539. (i==arlFrom.Count-2?"":".");
  1540. }
  1541. //Add Subnetmask
  1542. sTo += "/" + arlFrom[arlFrom.Count-1];
  1543. break;
  1544. case IPNotation.IPv4Binary:
  1545. //do not use the last Item, its the Subnetmask
  1546. for(int i=2; i<arlFrom.Count-1; i++)
  1547. {
  1548. //Convert Decimal to Binary
  1549. sTo += arlFrom[i].ToString() +
  1550. //Add Dot if its not the last IPPart, else add nothing
  1551. (i==arlFrom.Count-2?"":".");
  1552. }
  1553. break;
  1554. case IPNotation.IPv4BinaryCIDR:
  1555. //do not use the last Item, its the Subnetmask
  1556. for(int i=2; i<arlFrom.Count-1; i++)
  1557. {
  1558. //Convert Decimal to Binary
  1559. sTo += arlFrom[i].ToString() +
  1560. //Add Dot if its not the last IPPart, else add nothing
  1561. (i==arlFrom.Count-2?"":".");
  1562. }
  1563. //Add Subnetmask
  1564. sTo += "/" + arlFrom[arlFrom.Count-1];
  1565. break;
  1566. case IPNotation.IPv6Hexadecimal:
  1567. sTo = "0000:0000:0000:0000:";
  1568. for(int i=2; i<arlFrom.Count-1; i++)
  1569. {
  1570. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1571. }
  1572. break;
  1573. case IPNotation.IPv6HexadecimalCIDR:
  1574. sTo = "0000:0000:0000:0000:";
  1575. for(int i=2; i<arlFrom.Count-1; i++)
  1576. {
  1577. sTo += this.Bin2Hex(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":":");
  1578. }
  1579. sTo += "/" + arlFrom[arlFrom.Count-1];
  1580. break;
  1581. case IPNotation.IPv6Binary:
  1582. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1583. for(int i=2; i<arlFrom.Count-1; i++)
  1584. {
  1585. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  1586. }
  1587. break;
  1588. case IPNotation.IPv6BinaryCIDR:
  1589. sTo = "0000000000000000:0000000000000000:0000000000000000:0000000000000000:";
  1590. for(int i=2; i<arlFrom.Count-1; i++)
  1591. {
  1592. sTo += "00000000" + arlFrom[i].ToString() + (i==arlFrom.Count-2?"":":");
  1593. }
  1594. sTo += "/" + arlFrom[arlFrom.Count-1];
  1595. break;
  1596. case IPNotation.IPv6IPv4Decimal:
  1597. sTo = "::";
  1598. for(int i=2; i<arlFrom.Count-1; i++)
  1599. {
  1600. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1601. }
  1602. break;
  1603. case IPNotation.IPv6IPv4DecimalCIDR:
  1604. sTo = "::";
  1605. for(int i=2; i<arlFrom.Count-1; i++)
  1606. {
  1607. sTo += this.Bin2Dec(arlFrom[i].ToString()) + (i==arlFrom.Count-2?"":".");
  1608. }

Large files files are truncated, but you can click here to view the full file