private void Forwd_Click(object sender, EventArgs e) { this.maxfontwidth = 0; this.listBox1.HorizontalExtent = 0; subnets.upto = upto; subnets.LowerLimitAddress = StartEnd.LowerLimitAddress; subnets.UpperLimitAddress = StartEnd.UpperLimitAddress; subnets.Start = page.Start = page.End + BigInteger.One; this.listBox1.Items.Clear(); subnets = v6st.ListDnsRevPageForward(subnets, is128Checked); page.End = subnets.End; this.listBox1.Items.AddRange(subnets.liste.ToArray()); if (subnets.End.Equals(StartEnd.End)) { this.Forwd.Enabled = false; this.LastPage.Enabled = false; this.Backwd.Enabled = true; UpdateCount(); return; } else { this.Backwd.Enabled = true; this.LastPage.Enabled = true; } UpdateCount(); }
private void LastPage_Click(object sender, EventArgs e) { this.maxfontwidth = 0; this.listBox1.HorizontalExtent = 0; subnets.upto = upto; subnets.LowerLimitAddress = StartEnd.LowerLimitAddress; subnets.UpperLimitAddress = StartEnd.UpperLimitAddress; this.listBox1.Items.Clear(); subnets.subnetidx = BigInteger.Zero; subnets.End = page.End = StartEnd.End; subnets = v6st.ListDnsRevLastPage(subnets, is128Checked); page.Start = subnets.Start; this.listBox1.Items.AddRange(subnets.liste.ToArray()); if (subnets.subnetidx == 0) { this.Backwd.Enabled = false; } else { this.Backwd.Enabled = true; } this.Forwd.Enabled = false; this.LastPage.Enabled = false; UpdateCount(); }
private void PreCalc() { if (this.currentMode == "v6") { if (chks == CheckState.Checked) /* 128 bits */ { this.seaddr.End = BigInteger.Parse("0" + v6ST.FormalizeAddr(this.end), NumberStyles.AllowHexSpecifier); } else if (chks == CheckState.Unchecked) /* 64 bits */ { this.seaddr.End = BigInteger.Parse("0" + v6ST.FormalizeAddr(this.end).Substring(0, 16), NumberStyles.AllowHexSpecifier); } this.seaddr.slash = this.parentpflen; this.seaddr.subnetslash = this.pflen; this.seaddr = v6ST.EndStartAddresses(this.seaddr, this.chks); if (chks == CheckState.Checked) /* 128 bits */ { string s = String.Format("{0:x}", this.seaddr.Start); if (s.Length > 16) { s = s.Substring(1, 16); } this.last_start = v6ST.Kolonlar(s, this.chks); } else if (chks == CheckState.Unchecked) /* 64 bits */ { string s = String.Format("{0:x}", this.seaddr.Start); if (s.Length > 16) { s = s.Substring(1, 16); } this.last_start = v6ST.Kolonlar(s, this.chks); } this.last_start = v6ST.CompressAddress(this.last_start); } else // v4 { this.seaddr.End = BigInteger.Parse("0" + v6ST.FormalizeAddr_v4(this.end), NumberStyles.AllowHexSpecifier); this.seaddr.slash = this.parentpflen; this.seaddr.subnetslash = this.pflen; this.seaddr = v6ST.EndStartAddresses_v4(this.seaddr); string s = String.Format("{0:x}", this.seaddr.Start); this.last_start = v6ST.IPv4Format(s); } }
private string FindEnd_v4(string snet, short pflen) { SEaddress se = new SEaddress(); string end = ""; string start = v6ST.FormalizeAddr_v4(snet); se.Start = BigInteger.Parse(start, NumberStyles.AllowHexSpecifier); se.slash = this.t1; se.subnetslash = pflen; se = v6ST.Subnetting_v4(se); end = String.Format("{0:x}", se.End); end = v6ST.IPv4Format(end); return(end); }
private string FindEnd(string snet, short pflen, CheckState chks) { SEaddress se = new SEaddress(); string end = ""; string start = v6st.FormalizeAddr(snet); if (this.chks == CheckState.Checked) /* 128 bits */ { if (start.Length == 32) { start = "0" + start; } se.Start = BigInteger.Parse(start, NumberStyles.AllowHexSpecifier); se.slash = this.t1; se.subnetslash = pflen; se = v6st.Subnetting(se, this.chks); end = String.Format("{0:x}", se.End); if (end.Length > 32) { end = end.Substring(1, 32); } end = v6st.Kolonlar(end, this.chks); } else if (this.chks == CheckState.Unchecked) /* 64 bits */ { if (start.Length == 16) { start = "0" + start; } start = start.Substring(0, 16); se.Start = BigInteger.Parse(start, NumberStyles.AllowHexSpecifier); se.slash = this.t1; se.subnetslash = pflen; se = v6st.Subnetting(se, this.chks); end = String.Format("{0:x}", se.End); if (end.Length > 16) { end = end.Substring(1, 16); } end = v6st.Kolonlar(end, this.chks); } end = this.v6st.CompressAddress(end); return(end); }
private void Backwd_Click(object sender, EventArgs e) { this.maxfontwidth = 0; this.listBox1.HorizontalExtent = 0; subnets.upto = upto; subnets.LowerLimitAddress = StartEnd.LowerLimitAddress; subnets.UpperLimitAddress = StartEnd.UpperLimitAddress; this.listBox1.Items.Clear(); subnets.End = page.End = page.Start - BigInteger.One; if (this.currentMode == "v6") { subnets = v6ST.ListDnsRevPageBackward(subnets, is128Checked); } else // v4 { subnets = v6ST.ListDnsRevPageBackward_v4(subnets); } page.Start = subnets.Start; this.listBox1.Items.AddRange(subnets.liste.ToArray()); if (subnets.Start.Equals(StartEnd.Start)) { this.Backwd.Enabled = false; this.Forwd.Enabled = true; this.LastPage.Enabled = true; UpdateCount(); return; } else { this.Forwd.Enabled = true; this.LastPage.Enabled = true; } UpdateCount(); }
private void PreCalc() { if (chks == CheckState.Checked) /* 128 bits */ { this.seaddr.End = BigInteger.Parse("0" + this.v6st.FormalizeAddr(this.end), NumberStyles.AllowHexSpecifier); } else if (chks == CheckState.Unchecked) /* 64 bits */ { this.seaddr.End = BigInteger.Parse("0" + this.v6st.FormalizeAddr(this.end).Substring(0, 16), NumberStyles.AllowHexSpecifier); } this.seaddr.slash = this.parentpflen; this.seaddr.subnetslash = this.pflen; this.seaddr = this.v6st.EndStartAddresses(this.seaddr, this.chks); //Console.WriteLine("{0:x}", this.seaddr.Start); if (chks == CheckState.Checked) /* 128 bits */ { string s = String.Format("{0:x}", this.seaddr.Start); if (s.Length > 16) { s = s.Substring(1, 16); } this.last_start = v6st.Kolonlar(s, this.chks); } else if (chks == CheckState.Unchecked) /* 64 bits */ { string s = String.Format("{0:x}", this.seaddr.Start); if (s.Length > 16) { s = s.Substring(1, 16); } this.last_start = v6st.Kolonlar(s, this.chks); } this.last_start = this.v6st.CompressAddress(this.last_start); }
public ListDnsReverses(SEaddress input, CheckState is128Checked, CultureInfo culture) { InitializeComponent(); this.StartEnd.ID = ID; this.incomingID = input.ID; this.is128Checked = is128Checked; this.culture = culture; this.SwitchLanguage(this.culture); if (input.subnetslash % 4 == 1 && is128Checked == CheckState.Checked) { upto = 64; this.toolTip1.SetToolTip(this.Backwd, "-64"); this.toolTip1.SetToolTip(this.Forwd, "+64"); } StartEnd.Start = input.Start; StartEnd.End = input.End; StartEnd.Resultv6 = input.Resultv6; StartEnd.LowerLimitAddress = input.LowerLimitAddress; StartEnd.UpperLimitAddress = input.UpperLimitAddress; StartEnd.upto = upto; StartEnd.slash = input.slash; StartEnd.subnetslash = input.subnetslash; StartEnd.subnetidx = input.subnetidx; subnets.Start = input.Start; subnets.End = input.End; subnets.slash = input.slash; subnets.subnetslash = input.subnetslash; subnets.LowerLimitAddress = input.LowerLimitAddress; subnets.UpperLimitAddress = input.UpperLimitAddress; BigInteger max = NumberOfZones = (BigInteger.One << (input.subnetslash - input.slash)); zmaxval = max - BigInteger.One; this.textBox1.Text = NumberOfZones.ToString(); if (subnets.subnetslash % 4 != 0) { this.textBox3.Text = StringsDictionary.KeyValue("ListDNSRev_textBox3.Text", this.culture); } if (this.is128Checked == CheckState.Unchecked) { this.DefaultView(); string s = String.Format("{0:x}", StartEnd.Start); if (s == "0") { s = "0000000000000000"; } else if (s.Length > 16) { s = s.Substring(1, 16); } this.label5.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked)) + "/" + StartEnd.subnetslash.ToString(); s = String.Format("{0:x}", StartEnd.End); if (s == "0") { s = "0000000000000000"; } else if (s.Length > 16) { s = s.Substring(1, 16); } this.label6.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked)) + "/" + StartEnd.subnetslash.ToString(); } else if (this.is128Checked == CheckState.Checked) { this.ExpandView(); string s = String.Format("{0:x}", StartEnd.Start); if (s == "0") { s = "00000000000000000000000000000000"; } else if (s.Length > 32) { s = s.Substring(1, 32); } this.label5.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked)) + "/" + StartEnd.subnetslash.ToString(); s = String.Format("{0:x}", StartEnd.End); if (s == "0") { s = "00000000000000000000000000000000"; } else if (s.Length > 32) { s = s.Substring(1, 32); } this.label6.Text = v6st.CompressAddress(v6st.Kolonlar(s, is128Checked)) + "/" + StartEnd.subnetslash.ToString(); } this.FirstPage_Click(null, null); }
private void Goto_Click(object sender, EventArgs e) { this.maxfontwidth = 0; this.listBox1.HorizontalExtent = 0; String[] sa; List <string> liste = new List <string>(upto * 8); int count = 0; int spaces = 0; if (subnets.subnetslash % 4 != 0) { this.textBox3.Text = StringsDictionary.KeyValue("ListDNSRev_textBox3.Text", this.culture); } string newidx = this.textBox2.Text; if (newidx == "") { return; } subnets.subnetidx = BigInteger.Parse(newidx, NumberStyles.Number); subnets.slash = StartEnd.slash; subnets.subnetslash = StartEnd.subnetslash; subnets.Start = StartEnd.Start; subnets.Resultv6 = StartEnd.Resultv6; subnets = v6st.GoToSubnet(subnets, this.is128Checked); page.Start = subnets.Start; page.End = BigInteger.Zero; if (subnets.End.Equals(StartEnd.End)) { this.Forwd.Enabled = false; } this.listBox1.Items.Clear(); for (count = 0; count < upto; count++) { subnets = v6st.Subnetting(subnets, this.is128Checked); sa = v6st.DnsRev(subnets.Start, subnets.subnetslash, this.is128Checked); //string sf = "s" + subnets.subnetidx + "> " + sa[0]; string sf = "p" + subnets.subnetidx + "> " + sa[0]; liste.Add(sf); string[] sr = sf.Split(' '); spaces = sr[0].Length + 1; for (int i = 1; i < 8; i++) { if (sa[i] == null) { break; } sa[i] = sa[i].PadLeft(sa[i].Length + spaces, ' '); liste.Add(sa[i]); } if (subnets.End.Equals(StartEnd.End)) { this.Forwd.Enabled = false; break; } else { subnets.Start = subnets.End + BigInteger.One; } } this.listBox1.Items.AddRange(liste.ToArray()); page.End = subnets.End; if (BigInteger.Parse(newidx) == 0) { this.Backwd.Enabled = false; } else { this.Backwd.Enabled = true; } if (subnets.subnetidx == this.zmaxval) { this.Forwd.Enabled = false; this.LastPage.Enabled = false; } else { this.Forwd.Enabled = true; this.LastPage.Enabled = true; } UpdateCount(); }
private void FirstPage_Click(object sender, EventArgs e) { this.textBox1.Text = NumberOfZones.ToString(); this.maxfontwidth = 0; this.listBox1.HorizontalExtent = 0; subnets.Start = page.Start = StartEnd.Start; subnets.End = page.End = BigInteger.Zero; subnets.subnetidx = BigInteger.Zero; subnets.slash = StartEnd.slash; subnets.subnetslash = StartEnd.subnetslash; subnets.upto = upto; subnets.UpperLimitAddress = StartEnd.UpperLimitAddress; subnets.LowerLimitAddress = StartEnd.LowerLimitAddress; if (subnets.End.Equals(StartEnd.End)) { UpdateCount(); // entries return; } if (subnets.subnetslash % 4 != 0) { this.textBox3.Text = StringsDictionary.KeyValue("ListDNSRev_textBox3.Text", this.culture); } this.listBox1.Items.Clear(); String[] sa; if ((this.is128Checked == CheckState.Unchecked && StartEnd.slash == 64) || (this.is128Checked == CheckState.Checked && StartEnd.slash == 128)) { subnets.Start = StartEnd.Resultv6; sa = v6st.DnsRev(subnets.Start, subnets.subnetslash, this.is128Checked); //this.listBox1.Items.Add("s0> " + sa[0]); this.listBox1.Items.Add("p0> " + sa[0]); UpdateCount(); return; } subnets = v6st.ListDnsRevFirstPage(subnets, this.is128Checked); this.listBox1.Items.AddRange(subnets.liste.ToArray()); this.page.End = subnets.End; if (NumberOfZones <= upto) { this.Backwd.Enabled = false; this.Forwd.Enabled = false; this.LastPage.Enabled = false; } else { this.Backwd.Enabled = false; this.Forwd.Enabled = true; this.LastPage.Enabled = true; } UpdateCount(); }
public ListSubnetRange(SEaddress input, string sin, int slash, int subnetslash, CheckState is128Checked, CultureInfo culture, OdbcConnection sqlcon, DBServerInfo servinfo) { InitializeComponent(); this.graph = this.CreateGraphics(); this.graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; this.MySQLconnection = sqlcon; this.ServerInfo = servinfo; this.parentpflen = (short)input.slash; this.StartEnd.ID = ID; this.incomingID = input.ID; this.culture = culture; this.SwitchLanguage(this.culture); this.is128Checked = is128Checked; this.Forwd.Enabled = false; this.Backwd.Enabled = false; this.LastPage.Enabled = false; string[] sa = sin.Split(' '); sa = sa[1].Split('/'); string s = this.v6st.FormalizeAddr(sa[0]); s = this.v6st.Kolonlar(s, this.is128Checked); sa = s.Split(':'); s = ""; if (this.is128Checked == CheckState.Checked) { s = "0" + sa[0] + sa[1] + sa[2] + sa[3] + sa[4] + sa[5] + sa[6] + sa[7]; StartEnd.Resultv6 = BigInteger.Parse(s, NumberStyles.AllowHexSpecifier); if (s.Length > 32) { s = s.Substring(1, 32); } this.label3.Text = StringsDictionary.KeyValue("ListSubnetRange_label3.Text", this.culture); } else if (this.is128Checked == CheckState.Unchecked) { s = "0" + sa[0] + sa[1] + sa[2] + sa[3]; StartEnd.Resultv6 = BigInteger.Parse(s, NumberStyles.AllowHexSpecifier); if (s.Length > 16) { s = s.Substring(1, 16); } this.label3.Text = StringsDictionary.KeyValue("ListSubnetRange_label3.Text", this.culture); } StartEnd.slash = subnetslash; StartEnd.subnetslash = subnetslash; StartEnd = v6st.StartEndAddresses(StartEnd, this.is128Checked); NumberOfSubnets = StartEnd.End - StartEnd.Start + BigInteger.One; String s1 = "", s2 = ""; if (this.is128Checked == CheckState.Unchecked) { this.DefaultView(); s1 = String.Format("{0:x}", StartEnd.Start); if (s1.Length > 16) { s1 = s1.Substring(1, 16); } s1 = v6st.Kolonlar(s1, this.is128Checked); s1 = v6st.CompressAddress(s1); s2 = String.Format("{0:x}", StartEnd.End); if (s2.Length > 16) { s2 = s2.Substring(1, 16); } s2 = v6st.Kolonlar(s2, this.is128Checked); s2 = v6st.CompressAddress(s2); } else if (this.is128Checked == CheckState.Checked) { this.ExpandView(); s1 = String.Format("{0:x}", StartEnd.Start); if (s1.Length > 32) { s1 = s1.Substring(1, 32); } s1 = v6st.Kolonlar(s1, this.is128Checked); s1 = v6st.CompressAddress(s1); s2 = String.Format("{0:x}", StartEnd.End); if (s2.Length > 32) { s2 = s2.Substring(1, 32); } s2 = v6st.Kolonlar(s2, this.is128Checked); s2 = v6st.CompressAddress(s2); } this.textBox1.Text = String.Format("{0}", NumberOfSubnets); this.label5.Text = s1 + "/" + StartEnd.subnetslash; this.label6.Text = s2 + "/" + StartEnd.subnetslash; this.FirstPage_Click(null, null); }
public SaveAsText(SEaddress input, CheckState is128Checked, CultureInfo culture, bool selectedrange) { InitializeComponent(); #region special initials -yucel this.StartEnd.ID = ID; this.incomingID = input.ID; this.culture = culture; this.SelectedRange = selectedrange; this.input_subnetslash = input.subnetslash; #endregion this.SwitchLanguage(this.culture); this.is128Checked = is128Checked; this.StartEnd.LowerLimitAddress = input.LowerLimitAddress; this.StartEnd.ResultIPAddr = input.ResultIPAddr; this.StartEnd.slash = input.slash; this.StartEnd.Start = input.Start; this.StartEnd.End = input.End; this.StartEnd.subnetidx = input.subnetidx; this.StartEnd.subnetslash = input.subnetslash; this.StartEnd.UpperLimitAddress = input.UpperLimitAddress; this.StartEnd.upto = input.upto; string ss = String.Format("{0:x}", input.Start); string se = String.Format("{0:x}", input.End); if (IPv6SubnettingTool.Form1.ipmode == "v6") { ss = ss.TrimStart('0'); se = se.TrimStart('0'); if (this.is128Checked == CheckState.Unchecked) { ss = ss.PadLeft(16, '0'); ss = v6ST.Kolonlar(ss, this.is128Checked) + "/" + input.subnetslash.ToString(); se = se.PadLeft(16, '0'); se = v6ST.Kolonlar(se, this.is128Checked) + "/" + input.subnetslash.ToString(); } else if (this.is128Checked == CheckState.Checked) { ss = ss.PadLeft(32, '0'); ss = v6ST.Kolonlar(ss, this.is128Checked) + "/" + input.subnetslash.ToString(); se = se.PadLeft(32, '0'); se = v6ST.Kolonlar(se, this.is128Checked) + "/" + input.subnetslash.ToString(); } } else // v4 { ss = v6ST.IPv4Format(ss) + "/" + input.subnetslash.ToString(); se = v6ST.IPv4Format(se) + "/" + input.subnetslash.ToString(); } this.label8.Text = ss; this.label9.Text = se; if (input.ID == 0 || input.ID == 2) { this.maxsubnet = (BigInteger.One << (this.StartEnd.subnetslash - this.StartEnd.slash)); } else if (input.ID == 1) { if (IPv6SubnettingTool.Form1.ipmode == "v6") { if (this.is128Checked == CheckState.Unchecked) { this.maxsubnet = (BigInteger.One << (64 - this.StartEnd.subnetslash)); } else if (this.is128Checked == CheckState.Checked) { this.maxsubnet = (BigInteger.One << (128 - this.StartEnd.subnetslash)); } } else // v4 { this.maxsubnet = (BigInteger.One << (32 - this.StartEnd.subnetslash)); } } else { return; } this.textBox4.Text = (maxsubnet - 1).ToString(); ShowDiskInfo(); if (IPv6SubnettingTool.Form1.ipmode == "v6") { if (this.is128Checked == CheckState.Unchecked && input.subnetslash == 64 || this.is128Checked == CheckState.Checked && input.subnetslash == 128 || this.incomingID == 1 || this.incomingID == 2 ) { this.checkBox1.Checked = false; this.checkBox1.Enabled = false; } else { this.checkBox1.Enabled = true; } } else // v4 { if (input.subnetslash == 32 || this.incomingID == 1 || this.incomingID == 2) { this.checkBox1.Checked = false; this.checkBox1.Enabled = false; } else { this.checkBox1.Enabled = true; } } if (input.ID == 0 || input.ID == 1) { this.label1.Text = "(Prefixes)"; } else if (input.ID == 2) { this.label1.Text = "(Reverse DNS)"; } }
void bgw_DoWork(object sender, DoWorkEventArgs e) { if (StartEnd.Start > StartEnd.UpperLimitAddress) { return; } var saveAsName = new StreamWriter(saveDialog.FileName); string ss = "", se = ""; howmany = (this.ToIndex - this.FromIndex + 1); int perc = 0; this.count = 0; this.TotalBytes = BigInteger.Zero; StartEnd.subnetidx = this.FromIndex; if (this.incomingID == 1) { if (IPv6SubnettingTool.Form1.ipmode == "v6") { if (this.is128Checked == CheckState.Unchecked) { StartEnd.subnetslash = 64; } else if (this.is128Checked == CheckState.Checked) { StartEnd.subnetslash = 128; } } else // v4 { StartEnd.subnetslash = 32; } } if (IPv6SubnettingTool.Form1.ipmode == "v6") { StartEnd = v6ST.GoToSubnet(this.StartEnd, this.is128Checked); } else // v4 { StartEnd = v6ST.GoToSubnet_v4(this.StartEnd); } BigInteger i; for (i = 0; i < howmany; i++) { this.count++; if (backgroundWorker1.CancellationPending) { this.count--; e.Cancel = true; break; } else // no cancel { if (IPv6SubnettingTool.Form1.ipmode == "v6") { StartEnd = v6ST.Subnetting(StartEnd, this.is128Checked); if (this.is128Checked == CheckState.Unchecked) { if (this.incomingID == 0 || this.incomingID == 1) { ss = String.Format("{0:x}", StartEnd.Start); if (ss.Length > 16) { ss = ss.Substring(1, 16); } ss = v6ST.Kolonlar(ss, this.is128Checked); ss = v6ST.CompressAddress(ss); se = String.Format("{0:x}", StartEnd.End); if (se.Length > 16) { se = se.Substring(1, 16); } se = v6ST.Kolonlar(se, this.is128Checked); se = v6ST.CompressAddress(se); if (this.SelectedRange) { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + this.input_subnetslash; } else { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + StartEnd.subnetslash; } TotalBytes += ss.Length + 2; saveAsName.WriteLine(ss); if (StartEnd.subnetslash != 64) { if (this.checkBox1.CheckState == CheckState.Checked) { if (this.SelectedRange) { se = "e" + StartEnd.subnetidx + "> " + se + "/" + this.input_subnetslash; } else { se = "e" + StartEnd.subnetidx + "> " + se + "/" + StartEnd.subnetslash; } TotalBytes += se.Length + 4; saveAsName.WriteLine(se); saveAsName.WriteLine(""); } } } else if (this.incomingID == 2) { String[] sa; int spaces = 0; sa = v6ST.DnsRev(StartEnd.Start, StartEnd.subnetslash, this.is128Checked); sa[0] = "p" + StartEnd.subnetidx + "> " + sa[0]; spaces = sa[0].Split(' ')[0].Length + 1; for (int n = 0; n < 8; n++) { if (sa[n] == null) { break; } if (n > 0) { sa[n] = sa[n].PadLeft(sa[n].Length + spaces, ' '); } TotalBytes += sa[n].Length + 2; saveAsName.WriteLine(sa[n]); } } } else if (this.is128Checked == CheckState.Checked) { if (this.incomingID == 0 || this.incomingID == 1) { ss = String.Format("{0:x}", StartEnd.Start); if (ss.Length > 32) { ss = ss.Substring(1, 32); } ss = v6ST.Kolonlar(ss, this.is128Checked); ss = v6ST.CompressAddress(ss); se = String.Format("{0:x}", StartEnd.End); if (se.Length > 32) { se = se.Substring(1, 32); } se = v6ST.Kolonlar(se, this.is128Checked); se = v6ST.CompressAddress(se); if (this.SelectedRange) { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + this.input_subnetslash; } else { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + StartEnd.subnetslash; } TotalBytes += ss.Length + 2; saveAsName.WriteLine(ss); if (StartEnd.subnetslash != 128) { if (this.checkBox1.CheckState == CheckState.Checked) { if (this.SelectedRange) { se = "e" + StartEnd.subnetidx + "> " + se + "/" + this.input_subnetslash; } else { se = "e" + StartEnd.subnetidx + "> " + se + "/" + StartEnd.subnetslash; } TotalBytes += se.Length + 4; saveAsName.WriteLine(se); saveAsName.WriteLine(""); } } } else if (this.incomingID == 2) { String[] sa; int spaces = 0; sa = v6ST.DnsRev(StartEnd.Start, StartEnd.subnetslash, this.is128Checked); sa[0] = "s" + StartEnd.subnetidx + "> " + sa[0]; spaces = sa[0].Split(' ')[0].Length + 1; for (int n = 0; n < 8; n++) { if (sa[n] == null) { break; } if (n > 0) { sa[n] = sa[n].PadLeft(sa[n].Length + spaces, ' '); } TotalBytes += sa[n].Length + 2; saveAsName.WriteLine(sa[n]); } } } } else // v4 { StartEnd = v6ST.Subnetting_v4(StartEnd); if (this.incomingID == 0 || this.incomingID == 1) { ss = String.Format("{0:x}", StartEnd.Start); ss = v6ST.IPv4Format(ss); se = String.Format("{0:x}", StartEnd.End); se = v6ST.IPv4Format(se); if (this.SelectedRange) { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + this.input_subnetslash; } else { ss = "p" + StartEnd.subnetidx + "> " + ss + "/" + StartEnd.subnetslash; } TotalBytes += ss.Length + 2; saveAsName.WriteLine(ss); if (StartEnd.subnetslash != 32) { if (this.checkBox1.CheckState == CheckState.Checked) { if (this.SelectedRange) { se = "e" + StartEnd.subnetidx + "> " + se + "/" + this.input_subnetslash; } else { se = "e" + StartEnd.subnetidx + "> " + se + "/" + StartEnd.subnetslash; } TotalBytes += se.Length + 4; saveAsName.WriteLine(se); saveAsName.WriteLine(""); } } } else if (this.incomingID == 2) { String[] sa; int spaces = 0; sa = v6ST.DnsRev_v4(StartEnd.Start, StartEnd.subnetslash); if (sa[0] != null) { sa[0] = "p" + StartEnd.subnetidx + "> " + sa[0]; spaces = sa[0].Split(' ')[0].Length + 1; TotalBytes += sa[0].Length + 2; saveAsName.WriteLine(sa[0]); for (int n = 1; n < sa.Length; n++) { if (sa[n] == null) { break; } //if (n > 0) sa[n] = sa[n].PadLeft(sa[n].Length + spaces, ' '); TotalBytes += sa[n].Length + 2; saveAsName.WriteLine(sa[n]); } } } } if (StartEnd.Start == StartEnd.UpperLimitAddress || StartEnd.subnetidx == (maxsubnet - 1)) { break; } StartEnd.Start = StartEnd.End + BigInteger.One; perc = (int)(i * 100 / howmany); saveState.SavedLines = this.count; saveState.percentage = perc; this.backgroundWorker1.ReportProgress(perc); } } perc = (int)(i * 100 / howmany); saveState.SavedLines = this.count; saveState.percentage = perc; this.backgroundWorker1.ReportProgress(perc); saveAsName.Close(); }
private void SaveAs_Click(object sender, EventArgs e) { this.backgroundWorker1.CancelAsync(); this.backgroundWorker2.CancelAsync(); this.progressBar1.Value = 0; if (this.textBox1.Text.Trim() == "" || this.textBox2.Text.Trim() == "") { this.label5.ForeColor = Color.Red; this.label5.Text = StringsDictionary.KeyValue("SaveAs_Click_e0", this.culture); return; } try { this.FromIndex = BigInteger.Parse(this.textBox1.Text, NumberStyles.Number); } catch { this.textBox1.Text = ""; this.label5.ForeColor = Color.Red; this.label5.Text = StringsDictionary.KeyValue("SaveAs_Click_e0", this.culture); this.textBox1.Focus(); return; } try { this.ToIndex = BigInteger.Parse(this.textBox2.Text, NumberStyles.Number); } catch { this.textBox2.Text = ""; this.label5.ForeColor = Color.Red; this.label5.Text = StringsDictionary.KeyValue("SaveAs_Click_e0", this.culture); this.textBox2.Focus(); return; } if (this.ToIndex > (maxsubnet - 1)) { this.textBox2.BackColor = Color.FromKnownColor(KnownColor.Info); this.textBox2.SelectAll(); this.label5.ForeColor = Color.Red; this.label5.Text = StringsDictionary.KeyValue("SaveAs_Click_e1", this.culture); return; } else if (this.ToIndex < this.FromIndex) { this.textBox2.BackColor = Color.FromKnownColor(KnownColor.Info); this.textBox2.SelectAll(); this.label5.ForeColor = Color.Red; this.label5.Text = StringsDictionary.KeyValue("SaveAs_Click_e2", this.culture); return; } else { this.SaveAs.Enabled = false; this.textBox1.Enabled = false; this.textBox2.Enabled = false; this.label5.Text = ""; StartEnd.subnetidx = this.FromIndex; this.TotalBytes = BigInteger.Zero; StartEnd.Start = StartEnd.LowerLimitAddress; StartEnd.End = StartEnd.UpperLimitAddress; string fnamestart = ""; BigInteger OnceTotalBytes = BigInteger.Zero; BigInteger OnceDnsTotalBytes = BigInteger.Zero; if (IPv6SubnettingTool.Form1.ipmode == "v6") { StartEnd = v6ST.GoToSubnet(this.StartEnd, this.is128Checked); fnamestart = String.Format("{0:x}", this.StartEnd.Start); fnamestart = fnamestart.TrimStart('0'); if (this.is128Checked == CheckState.Unchecked) { fnamestart = fnamestart.PadLeft(16, '0'); } else if (this.is128Checked == CheckState.Checked) { fnamestart = fnamestart.PadLeft(32, '0'); } } else // v4 { StartEnd = v6ST.GoToSubnet_v4(this.StartEnd); fnamestart = v6ST.IPv4Format(String.Format("{0:x}", this.StartEnd.Start)); } saveDialog.Filter = "Text (*.wordpad)|*.wordpad|Text (*.txt)|*.txt"; if (this.incomingID == 0 || this.incomingID == 1) // (Form1 || ListSubnetRange) { saveDialog.FileName = fnamestart + StringsDictionary.KeyValue("SaveAs_FileName_prefix", this.culture) + this.StartEnd.slash + StringsDictionary.KeyValue("SaveAs_FileName_to", this.culture) + this.StartEnd.subnetslash.ToString() + StringsDictionary.KeyValue("SaveAs_FileName_index", this.culture) + this.FromIndex.ToString() + StringsDictionary.KeyValue("SaveAs_FileName_to", this.culture) + this.ToIndex.ToString(); } else if (this.incomingID == 2) // ListDnsReverses { OnceTotalBytes = OnceDnsTotalBytes; saveDialog.FileName = StringsDictionary.KeyValue("SaveAs_FileName_ReverseDNS", this.culture) + fnamestart + StringsDictionary.KeyValue("SaveAs_FileName_prefix", this.culture) + this.StartEnd.subnetslash.ToString() + StringsDictionary.KeyValue("SaveAs_FileName_index", this.culture) + this.FromIndex.ToString() + StringsDictionary.KeyValue("SaveAs_FileName_to", this.culture) + this.ToIndex.ToString(); } this.textBox1.BackColor = Color.White; this.textBox2.BackColor = Color.White; if (saveDialog.ShowDialog() == DialogResult.OK) { this.progressBar1.Visible = true; this.textBox5.Visible = true; this.cancelButton.Enabled = true; this.label5.Text = ""; this.label5.ForeColor = Color.RoyalBlue; backgroundWorker1.RunWorkerAsync(); Thread.Sleep(7); } else { this.SaveAs.Enabled = true; this.cancelButton.Enabled = false; this.textBox1.Enabled = true; this.textBox2.Enabled = true; } } }
public SaveAsText(SEaddress input, CheckState is128Checked, CultureInfo culture) { InitializeComponent(); #region special initials -yucel this.StartEnd.ID = ID; this.incomingID = input.ID; this.culture = culture; #endregion this.SwitchLanguage(this.culture); this.is128Checked = is128Checked; this.StartEnd.LowerLimitAddress = input.LowerLimitAddress; this.StartEnd.Resultv6 = input.Resultv6; this.StartEnd.slash = input.slash; this.StartEnd.Start = input.Start; this.StartEnd.End = input.End; this.StartEnd.subnetidx = input.subnetidx; this.StartEnd.subnetslash = input.subnetslash; this.StartEnd.UpperLimitAddress = input.UpperLimitAddress; this.StartEnd.upto = input.upto; string ss = String.Format("{0:x}", input.Start); string se = String.Format("{0:x}", input.End); ss = ss.TrimStart('0'); se = se.TrimStart('0'); if (this.is128Checked == CheckState.Unchecked) { ss = ss.PadLeft(16, '0'); ss = v6st.Kolonlar(ss, this.is128Checked) + "/" + input.subnetslash.ToString(); se = se.PadLeft(16, '0'); se = v6st.Kolonlar(se, this.is128Checked) + "/" + input.subnetslash.ToString(); } else if (this.is128Checked == CheckState.Checked) { ss = ss.PadLeft(32, '0'); ss = v6st.Kolonlar(ss, this.is128Checked) + "/" + input.subnetslash.ToString(); se = se.PadLeft(32, '0'); se = v6st.Kolonlar(se, this.is128Checked) + "/" + input.subnetslash.ToString(); } this.label8.Text = ss; this.label9.Text = se; if (input.ID == 0 || input.ID == 2) { this.maxsubnet = (BigInteger.One << (this.StartEnd.subnetslash - this.StartEnd.slash)); } else if (input.ID == 1) { if (this.is128Checked == CheckState.Unchecked) { this.maxsubnet = (BigInteger.One << (64 - this.StartEnd.subnetslash)); } else if (this.is128Checked == CheckState.Checked) { this.maxsubnet = (BigInteger.One << (128 - this.StartEnd.subnetslash)); } } else { return; } this.textBox4.Text = (maxsubnet - 1).ToString(); ShowDiskInfo(); }