private void Connect() { this.UseWaitCursor = true; // subscribe event _wa.OnStartup += OnStartupHandler; _wa.OnReceiveMessage += OnReceiveMessageHandler; _wa.OnClientConnected += OnClientConnectedHandler; _wa.Connect(); using (var frm = new FrmStartUp()) { // subscribe event _wa.OnStartup += frm.OnStartupHandler; _wa.OnScanMe += frm.OnScanMeHandler; frm.UseWaitCursor = true; frm.ShowDialog(); // unsubscribe event _wa.OnStartup -= frm.OnStartupHandler; _wa.OnScanMe -= frm.OnScanMeHandler; } }
private void btnStart_Click(object sender, EventArgs e) { _whatsAppApi = new WhatsAppNETAPI.WhatsAppNETAPI(); var url = "https://web.whatsapp.com"; using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_whatsAppApi.Connect(url, chkHeadless.Checked)) { while (!_whatsAppApi.OnReady()) { if (chkHeadless.Checked) { if (_whatsAppApi.IsScanMe()) { var frmScanQRCode = new FrmScanQRCode(_whatsAppApi); frmScanQRCode.ShowDialog(); } } Thread.Sleep(1000); } btnStart.Enabled = false; btnStop.Enabled = true; btnGrabContacts.Enabled = true; btnKirim.Enabled = true; chkSubscribe.Enabled = true; chkMessageSentSubscribe.Enabled = true; } else { _whatsAppApi.Disconnect(); } } }
private void btnStart_Click(object sender, EventArgs e) { _whatsAppApi = new WhatsAppNETAPI.WhatsAppNETAPI(); var url = "https://web.whatsapp.com"; using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_whatsAppApi.Connect(url)) { while (!_whatsAppApi.OnReady()) { Thread.Sleep(1000); } btnStart.Enabled = false; btnStop.Enabled = true; btnKirim.Enabled = true; chkSubscribe.Enabled = true; } } }