public Form1() : base("Snap N Viewer", 20, 20, 640, 480) { fAutoScale = true; // Create the backing buffer to retain the image fBackingBuffer = new GDIDIBSection(1600, 1200); // 1. Show a dialog box to allow the user to type in the // group IP address and port number. HostForm groupForm = new HostForm(); //groupForm.ShowDialog(); // 2. Get the address and port from the form, and use // them to setup the MultiSession object string groupIP = groupForm.groupAddressField.Text; int groupPort = int.Parse(groupForm.groupPortField.Text); IPEndPoint ipep = new IPEndPoint(IPAddress.Parse(groupIP), groupPort); Title = "Snap N Viewer - " + ipep.ToString(); fCommChannel = new CommChannel(ipep, false, true); // 3. Setup the chunk decoder so we can receive new images // when they come in fChunkDecoder = new GraphPortChunkDecoder(fBackingBuffer, fCommChannel); fChunkDecoder.PixBltPixelBuffer24Handler += this.PixBltPixelBuffer24; fChunkDecoder.PixBltLumbHandler += this.PixBltLum24; }
private void SetHostFormCaption() { if (HostForm.InvokeRequired) { HostForm.Invoke(new Action(SetHostFormCaption)); } else { HostForm.Text = IPAddressStr + " " + HostName; } }
protected override void OnClick(EventArgs aArgs) { base.OnClick(aArgs); if (HostForm != null) { switch (_hlBrIcon) { case TBorderIcon.biClose: HostForm.Close(); break; case TBorderIcon.biMinimize: HostForm.WindowState = FormWindowState.Minimized; break; case TBorderIcon.biResize: if (HostForm.WindowState == FormWindowState.Maximized) { _windowInfo.Assigned = false; HostForm.WindowState = FormWindowState.Normal; } else { _windowInfo = new _sFormInfo(this.HostForm); HostForm.WindowState = FormWindowState.Maximized; } break; } } if (_HighLighted > -1) { switch (_HlCtl) { case THighlightedCtl.ctlNext: RollLeft(); break; case THighlightedCtl.ctlPrev: RollRight(); break; default: if (_CloseHLighted && HighlightedPage.CloseAble) { HighlightedPage.ClosePage(); } else { SelectedPage = _HighLighted; } break; } Invalidate(); } }
public void ScanHostPorts() { CancelScanHostPorts = new CancellationTokenSource(); Task checkScanHostPorts = Task.Run(() => { while (!ScanTCPPortsIsRunning) { Thread.Sleep(1000); HostForm.setScanPortsProgress(CurrentHostPort, waitingForResponses, _maxWaitingForResponses); } while (ScanTCPPortsIsRunning) { Thread.Sleep(1000); HostForm.setScanPortsProgress(CurrentHostPort, waitingForResponses, _maxWaitingForResponses); } }); //https://www.codeproject.com/Articles/199016/Simple-TCP-Port-Scanner Task ScanHostTCPPorts = Task.Run(() => { ScanTCPPortsIsRunning = true; Ports = new EventedList <PortInfo>(); Ports.onChanged += () => { HostForm.FillHostOpenPorts(); }; waitingForResponses = 0; for (CurrentHostPort = 1; CurrentHostPort <= 65535 && !CancelScanHostPorts.Token.IsCancellationRequested; CurrentHostPort++) { while (waitingForResponses >= _maxWaitingForResponses) { Thread.Sleep(0); } try { ScanPortTCP(CurrentHostPort); } catch (Exception ex) { Debug.WriteLine(ex.Message + "r" + ex.StackTrace); } } while (waitingForResponses > 0) { Thread.Sleep(100); } ScanTCPPortsIsRunning = false; }); }
/////////////////////////////////////////////////////////////////////// protected virtual bool NewHostForm() { bool result = false; lock (syncRoot) { if (this.hostForm == null) { this.hostForm = new HostForm(this.interpreter); result = true; } } return(result); }
/////////////////////////////////////////////////////////////////////// #region Public Methods // // NOTE: This method is used by the HostForm class to notify this // interpreter host that it is being disposed. // public virtual bool ResetHostForm() { bool result = false; lock (syncRoot) { if (hostForm != null) { hostForm = null; result = true; } } return(result); }
/////////////////////////////////////////////////////////////////////// protected virtual bool SafeCloseHostForm() { bool result = false; HostForm hostForm; lock (syncRoot) { hostForm = this.hostForm; } if (hostForm != null) { hostForm.SafeClose(); result = true; } return(result); }
/////////////////////////////////////////////////////////////////////// protected virtual bool SafeWriteHostForm( string value, bool newLine ) { bool result = false; HostForm hostForm; lock (syncRoot) { hostForm = this.hostForm; } if (hostForm != null) { result = hostForm.SafeAppendLog(value, newLine); } return(result); }
public void ShowHostForm(System.Windows.Forms.IWin32Window owner = null) { if (HostForm == null || HostForm.IsDisposed) { HostForm = new HostForm(this); SetHostFormCaption(); } if (HostForm.Visible) { if (HostForm.WindowState == System.Windows.Forms.FormWindowState.Minimized) { HostForm.WindowState = System.Windows.Forms.FormWindowState.Normal; } HostForm.Focus(); } else { HostForm.Show(owner); } }
/// <summary> /// 分发事件 /// </summary> /// <param name="action"></param> public static void DispatchEvents(Action action) { HostForm.Invoke(action); }