private void btnGrantPresence_Click(object sender, RoutedEventArgs e) { channel = txtChannel.Text; this.IsEnabled = false; Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5.0); StackPanel pamAuthKeyStackPanel = new StackPanel(); pamAuthKeyStackPanel.Background = new SolidColorBrush(Colors.Blue); pamAuthKeyStackPanel.Width = 400; pamAuthKeyStackPanel.Height = 300; Popup pamAuthKeyPopup = new Popup(); pamAuthKeyPopup.Height = 300; pamAuthKeyPopup.Width = 300; var point = CalcOffsets((UIElement)sender); pamAuthKeyPopup.HorizontalOffset = point.X + 70; pamAuthKeyPopup.VerticalOffset = point.Y - 200; PAMAuthKeyUserControl control = new PAMAuthKeyUserControl(); TextBox txtPAMAuthKey = control.FindName("txtPAMAuthKey") as TextBox; if (txtPAMAuthKey != null) { txtPAMAuthKey.Text = ""; } pamAuthKeyStackPanel.Children.Add(control); border.Child = pamAuthKeyStackPanel; pamAuthKeyPopup.Child = border; pamAuthKeyPopup.IsOpen = true; pamAuthKeyPopup.Closed += (senderPopup, argsPopup) => { if (control.IsOKButtonEntered) { txtPAMAuthKey = control.FindName("txtPAMAuthKey") as TextBox; if (txtPAMAuthKey != null) { string pamAuthKey = txtPAMAuthKey.Text.Trim(); DisplayMessageInTextBox("Running GrantPresenceAccess:"); int ttlInMinutes = 1440; pubnub.GrantPresenceAccess <string>(channel, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } } pamAuthKeyPopup = null; this.IsEnabled = true; }; }
private void btnAuditPresence_Click(object sender, RoutedEventArgs e) { channel = txtChannel.Text; this.IsEnabled = false; Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5.0); StackPanel pamAuthKeyStackPanel = new StackPanel(); pamAuthKeyStackPanel.Background = new SolidColorBrush(Colors.Blue); pamAuthKeyStackPanel.Width = 400; pamAuthKeyStackPanel.Height = 300; Popup pamAuthKeyPopup = new Popup(); pamAuthKeyPopup.Height = 300; pamAuthKeyPopup.Width = 300; var point = CalcOffsets((UIElement)sender); pamAuthKeyPopup.HorizontalOffset = point.X + 70; pamAuthKeyPopup.VerticalOffset = point.Y - 200; PAMAuthKeyUserControl control = new PAMAuthKeyUserControl(); TextBox txtPAMAuthKey = control.FindName("txtPAMAuthKey") as TextBox; if (txtPAMAuthKey != null) { txtPAMAuthKey.Text = ""; } pamAuthKeyStackPanel.Children.Add(control); border.Child = pamAuthKeyStackPanel; pamAuthKeyPopup.Child = border; pamAuthKeyPopup.IsOpen = true; pamAuthKeyPopup.Closed += (senderPopup, argsPopup) => { if (control.IsOKButtonEntered) { txtPAMAuthKey = control.FindName("txtPAMAuthKey") as TextBox; if (txtPAMAuthKey != null) { string pamAuthKey = txtPAMAuthKey.Text.Trim(); DisplayMessageInTextBox("Running AuditPresenceAccess:"); pubnub.AuditPresenceAccess<string>(channel, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } } pamAuthKeyPopup = null; this.IsEnabled = true; }; }