/////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void PortMapper_DidReceiveUPNPMappingTable(PortMapper sender, List<ExistingUPnPPortMapping> existingMappings) { mappingsListView.BeginUpdate(); { mappings.Clear(); foreach (ExistingUPnPPortMapping pm in existingMappings) { String protocol; if(pm.TransportProtocol == PortMappingTransportProtocol.UDP) protocol = "UDP"; else protocol = "TCP"; ListViewItem lvi = new ListViewItem(protocol); lvi.SubItems.Add(pm.ExternalPort.ToString()); lvi.SubItems.Add(pm.LocalAddress.ToString()); lvi.SubItems.Add(pm.LocalPort.ToString()); lvi.SubItems.Add(pm.Description); lvi.Tag = pm; mappings.Add(lvi); } mappingsListView.VirtualListSize = mappings.Count; } mappingsListView.EndUpdate(); progressPictureBox.Visible = false; refreshButton.Enabled = true; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void PortMapper_WillStartSearchForRouter(PortMapper sender) { DebugLog.WriteLine("Form1: PortMapper_WillStartSearchForRouter"); progressPictureBox.Visible = true; externalIPAddressLabel.Text = "Searching for Router..."; internalIPAddressLabel.Text = ""; }
private void PortMapper_ExternalIPAddressDidChange(PortMapper sender, System.Net.IPAddress ip) { DebugLog.WriteLine("Form1: PortMapper_ExternalIPAddressDidChange"); UpdateTagLine(); }
private void PortMapper_DidStartWork(PortMapper sender) { DebugLog.WriteLine("Form1: PortMapper_DidStartWork"); }
private void PortMapper_DidFinishSearchForRouter(PortMapper sender) { DebugLog.WriteLine("Form1: PortMapper_DidFinishSearchForRouter"); progressPictureBox.Visible = false; if (PortMapper.SharedInstance.MappingProtocolName == "UPnP") { allUpnpButton.Enabled = true; } else { allUpnpButton.Enabled = false; } UpdateTagLine(); }
private void PortMapper_DidChangeMappingStatus(PortMapper sender, PortMapping pm) { DebugLog.WriteLine("Form1: PortMapper_DidChangeMappingStatus"); foreach (ListViewItem lvi in mappings) { PortMapping lvi_pm = (PortMapping)lvi.Tag; if (lvi_pm == pm) { mappingsListView.RedrawItems(lvi.Index, lvi.Index, false); } } }
/// <summary> /// Static constructor. /// - executes before any instance of the class is created. /// - executes before any of the static members for the class are referenced. /// - executes after the static field initializers (if any) for the class. /// - executes at most one time during a single program instantiation. /// - called automatically to initialize the class before the first instance is created or any static members are referenced. /// </summary> static PortMapper() { sharedInstance = new PortMapper(); }