private void btnPAMChannel_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 pamChannelStackPanel = new StackPanel(); pamChannelStackPanel.Background = new SolidColorBrush(Colors.Blue); pamChannelStackPanel.Width = 400; pamChannelStackPanel.Height = 650; Popup pamChannelPopup = new Popup(); pamChannelPopup.Height = 650; pamChannelPopup.Width = 400; pamChannelPopup.HorizontalOffset = 10; pamChannelPopup.VerticalOffset = 10; PAMChannelUserControl control = new PAMChannelUserControl(); control.txtChannelName.Text = channel; pamChannelStackPanel.Children.Add(control); border.Child = pamChannelStackPanel; pamChannelPopup.Child = border; pamChannelPopup.IsOpen = true; control.btnOK.Click += (s, args) => { pamChannelPopup.IsOpen = false; string msg = ""; string pamUserChannelName = control.txtChannelName.Text; string pamAuthKey = control.txtAuthKey.Text; if (control.radGrantChannel.IsChecked.Value) { msg = "Running GrantAccess"; int ttlInMinutes = 1440; pubnub.GrantAccess<string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAuditChannel.IsChecked.Value) { msg = "Running AuditAccess"; pubnub.AuditAccess<string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRevokeChannel.IsChecked.Value) { msg = "Running Revoke Access"; pubnub.GrantAccess<string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radGrantPresenceChannel.IsChecked.Value) { msg = "Running GrantPresenceAccess"; int ttlInMinutes = 1440; pubnub.GrantPresenceAccess<string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAuditPresenceChannel.IsChecked.Value) { msg = "Running AuditPresenceAccess"; pubnub.AuditPresenceAccess<string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRevokePresenceChannel.IsChecked.Value) { msg = "Running Presence Revoke Access"; pubnub.GrantPresenceAccess<string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } TextBlock textBlock = new TextBlock(); textBlock.Text = msg; messageStackPanel.Children.Add(textBlock); scrollViewerResult.UpdateLayout(); scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight); pamChannelPopup = null; this.IsEnabled = true; }; control.btnCancel.Click += (s, args) => { pamChannelPopup.IsOpen = false; pamChannelPopup = null; this.IsEnabled = true; }; }
private void btnPAMChannel_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 pamChannelStackPanel = new StackPanel(); pamChannelStackPanel.Background = new SolidColorBrush(Colors.Blue); pamChannelStackPanel.Width = 400; pamChannelStackPanel.Height = 650; Popup pamChannelPopup = new Popup(); pamChannelPopup.Height = 650; pamChannelPopup.Width = 400; pamChannelPopup.HorizontalOffset = 10; pamChannelPopup.VerticalOffset = 10; PAMChannelUserControl control = new PAMChannelUserControl(); control.txtChannelName.Text = channel; pamChannelStackPanel.Children.Add(control); border.Child = pamChannelStackPanel; pamChannelPopup.Child = border; pamChannelPopup.IsOpen = true; control.btnOK.Click += (s, args) => { pamChannelPopup.IsOpen = false; string msg = ""; string pamUserChannelName = control.txtChannelName.Text; string pamAuthKey = control.txtAuthKey.Text; if (control.radGrantChannel.IsChecked.Value) { msg = "Running GrantAccess"; int ttlInMinutes = 1440; pubnub.GrantAccess <string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAuditChannel.IsChecked.Value) { msg = "Running AuditAccess"; pubnub.AuditAccess <string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRevokeChannel.IsChecked.Value) { msg = "Running Revoke Access"; pubnub.GrantAccess <string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radGrantPresenceChannel.IsChecked.Value) { msg = "Running GrantPresenceAccess"; int ttlInMinutes = 1440; pubnub.GrantPresenceAccess <string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAuditPresenceChannel.IsChecked.Value) { msg = "Running AuditPresenceAccess"; pubnub.AuditPresenceAccess <string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRevokePresenceChannel.IsChecked.Value) { msg = "Running Presence Revoke Access"; pubnub.GrantPresenceAccess <string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } TextBlock textBlock = new TextBlock(); textBlock.Text = msg; messageStackPanel.Children.Add(textBlock); scrollViewerResult.UpdateLayout(); scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight); pamChannelPopup = null; this.IsEnabled = true; }; control.btnCancel.Click += (s, args) => { pamChannelPopup.IsOpen = false; pamChannelPopup = null; this.IsEnabled = true; }; }
private void btnPAMChannel_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 pamChannelStackPanel = new StackPanel(); pamChannelStackPanel.Background = new SolidColorBrush(Colors.Blue); pamChannelStackPanel.Width = 400; pamChannelStackPanel.Height = 600; Popup pamChannelPopup = new Popup(); pamChannelPopup.Height = 300; pamChannelPopup.Width = 300; pamChannelPopup.HorizontalOffset = 10; pamChannelPopup.VerticalOffset = 100; PAMChannelUserControl control = new PAMChannelUserControl(); TextBox txtPAMChannelName = control.FindName("txtChannelName") as TextBox; if (txtPAMChannelName != null) { txtPAMChannelName.Text = channel; } pamChannelStackPanel.Children.Add(control); border.Child = pamChannelStackPanel; pamChannelPopup.Child = border; pamChannelPopup.IsOpen = true; pamChannelPopup.Closed += (senderPopup, argsPopup) => { if (control.IsOKButtonEntered) { string pamUserChannelName = ""; string pamAuthKey = ""; txtPAMChannelName = control.FindName("txtChannelName") as TextBox; if (txtPAMChannelName != null) { pamUserChannelName = txtPAMChannelName.Text.Trim(); } TextBox txtAuthKey = control.FindName("txtAuthKey") as TextBox; if (txtAuthKey != null) { pamAuthKey = txtAuthKey.Text; } RadioButton radGrantPAMChannel = control.FindName("radGrantChannel") as RadioButton; if (radGrantPAMChannel != null && radGrantPAMChannel.IsChecked.Value) { DisplayMessageInTextBox("Running GrantAccess:"); int ttlInMinutes = 1440; pubnub.GrantAccess<string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radAuditChannel = control.FindName("radAuditChannel") as RadioButton; if (radAuditChannel != null && radAuditChannel.IsChecked.Value) { DisplayMessageInTextBox("Running AuditAccess:"); pubnub.AuditAccess<string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radRevokeChannel = control.FindName("radRevokeChannel") as RadioButton; if (radRevokeChannel != null && radRevokeChannel.IsChecked.Value) { DisplayMessageInTextBox("Running Revoke Access:"); pubnub.GrantAccess<string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radGrantPresenceChannel = control.FindName("radGrantPresenceChannel") as RadioButton; if (radGrantPresenceChannel != null && radGrantPresenceChannel.IsChecked.Value) { DisplayMessageInTextBox("Running GrantPresenceAccess:"); int ttlInMinutes = 1440; pubnub.GrantPresenceAccess<string>(pamUserChannelName, pamAuthKey, true, true, ttlInMinutes,PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radAuditPresenceChannel = control.FindName("radAuditPresenceChannel") as RadioButton; if (radAuditPresenceChannel != null && radAuditPresenceChannel.IsChecked.Value) { DisplayMessageInTextBox("Running AuditPresenceAccess:"); pubnub.AuditPresenceAccess<string>(pamUserChannelName, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radRevokePresenceChannel = control.FindName("radRevokePresenceChannel") as RadioButton; if (radRevokePresenceChannel != null && radRevokePresenceChannel.IsChecked.Value) { DisplayMessageInTextBox("Running Presence Revoke Access:"); pubnub.GrantPresenceAccess<string>(pamUserChannelName, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage); } } pamChannelPopup = null; this.IsEnabled = true; }; }