private void btnPAMChannelGroup_Click(object sender, RoutedEventArgs e)
        {
            channelGroup = txtChannelGroup.Text;

            this.IsEnabled = false;
            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel pamChannelGroupStackPanel = new StackPanel();
            pamChannelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue);
            pamChannelGroupStackPanel.Width = 400;
            pamChannelGroupStackPanel.Height = 650;

            Popup pamChannelGroupPopup = new Popup();
            pamChannelGroupPopup.Height = 650;
            pamChannelGroupPopup.Width = 300;

            pamChannelGroupPopup.HorizontalOffset = 10;
            pamChannelGroupPopup.VerticalOffset = 10;

            PAMChannelGroupUserControl control = new PAMChannelGroupUserControl();

            control.txtChannelGroup.Text = channelGroup;

            pamChannelGroupStackPanel.Children.Add(control);
            border.Child = pamChannelGroupStackPanel;

            pamChannelGroupPopup.Child = border;
            pamChannelGroupPopup.IsOpen = true;

            control.btnOK.Click += (s, args) =>
            {
                pamChannelGroupPopup.IsOpen = false;
                string msg = "";
                string pamUserChannelGroup = control.txtChannelGroup.Text;
                string pamAuthKey = control.txtAuthKey.Text;
                int ttlInMinutes = 1440;

                if (control.radGrantPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupGrantAccess";
                    pubnub.ChannelGroupGrantAccess<string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radAuditChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupAuditAccess";
                    pubnub.ChannelGroupAuditAccess<string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radRevokeChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroup Revoke Access";
                    pubnub.ChannelGroupGrantAccess<string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radGrantPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupGrantPresenceAccess";
                    pubnub.ChannelGroupGrantPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radAuditPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupAuditAccess";
                    pubnub.ChannelGroupAuditPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radRevokePresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroup Revoke Access";
                    pubnub.ChannelGroupGrantPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                TextBlock textBlock = new TextBlock();
                textBlock.Text = msg;
                messageStackPanel.Children.Add(textBlock);
                scrollViewerResult.UpdateLayout();
                scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight);
                pamChannelGroupPopup = null;
                this.IsEnabled = true;
            };
            control.btnCancel.Click += (s, args) =>
            {
                pamChannelGroupPopup.IsOpen = false;
                pamChannelGroupPopup = null;
                this.IsEnabled = true;
            };
        }
Beispiel #2
0
        private void btnPAMChannelGroup_Click(object sender, RoutedEventArgs e)
        {
            channelGroup = txtChannelGroup.Text;

            this.IsEnabled = false;
            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel pamChannelGroupStackPanel = new StackPanel();

            pamChannelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue);
            pamChannelGroupStackPanel.Width      = 400;
            pamChannelGroupStackPanel.Height     = 650;

            Popup pamChannelGroupPopup = new Popup();

            pamChannelGroupPopup.Height = 650;
            pamChannelGroupPopup.Width  = 300;

            pamChannelGroupPopup.HorizontalOffset = 10;
            pamChannelGroupPopup.VerticalOffset   = 10;

            PAMChannelGroupUserControl control = new PAMChannelGroupUserControl();

            control.txtChannelGroup.Text = channelGroup;

            pamChannelGroupStackPanel.Children.Add(control);
            border.Child = pamChannelGroupStackPanel;

            pamChannelGroupPopup.Child  = border;
            pamChannelGroupPopup.IsOpen = true;

            control.btnOK.Click += (s, args) =>
            {
                pamChannelGroupPopup.IsOpen = false;
                string msg = "";
                string pamUserChannelGroup = control.txtChannelGroup.Text;
                string pamAuthKey          = control.txtAuthKey.Text;
                int    ttlInMinutes        = 1440;

                if (control.radGrantPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupGrantAccess";
                    pubnub.ChannelGroupGrantAccess <string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radAuditChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupAuditAccess";
                    pubnub.ChannelGroupAuditAccess <string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radRevokeChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroup Revoke Access";
                    pubnub.ChannelGroupGrantAccess <string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radGrantPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupGrantPresenceAccess";
                    pubnub.ChannelGroupGrantPresenceAccess <string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radAuditPresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroupAuditAccess";
                    pubnub.ChannelGroupAuditPresenceAccess <string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                if (control.radRevokePresenceChannelGroup.IsChecked.Value)
                {
                    msg = "Running ChannelGroup Revoke Access";
                    pubnub.ChannelGroupGrantPresenceAccess <string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                }

                TextBlock textBlock = new TextBlock();
                textBlock.Text = msg;
                messageStackPanel.Children.Add(textBlock);
                scrollViewerResult.UpdateLayout();
                scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight);
                pamChannelGroupPopup = null;
                this.IsEnabled       = true;
            };
            control.btnCancel.Click += (s, args) =>
            {
                pamChannelGroupPopup.IsOpen = false;
                pamChannelGroupPopup        = null;
                this.IsEnabled = true;
            };
        }
        private void btnPAMChannelGroup_Click(object sender, RoutedEventArgs e)
        {
            channelGroup = txtChannelGroup.Text;

            this.IsEnabled = false;
            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.Black);
            border.BorderThickness = new Thickness(5.0);

            StackPanel pamChannelGroupStackPanel = new StackPanel();
            pamChannelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue);
            pamChannelGroupStackPanel.Width = 400;
            pamChannelGroupStackPanel.Height = 600;

            Popup pamChannelGroupPopup = new Popup();
            pamChannelGroupPopup.Height = 300;
            pamChannelGroupPopup.Width = 300;

            pamChannelGroupPopup.HorizontalOffset = 10;
            pamChannelGroupPopup.VerticalOffset = 100;

            PAMChannelGroupUserControl control = new PAMChannelGroupUserControl();

            TextBox txtPAMChannelGroup = control.FindName("txtChannelGroup") as TextBox;
            if (txtPAMChannelGroup != null)
            {
                txtPAMChannelGroup.Text = channelGroup;
            }

            pamChannelGroupStackPanel.Children.Add(control);
            border.Child = pamChannelGroupStackPanel;

            pamChannelGroupPopup.Child = border;
            pamChannelGroupPopup.IsOpen = true;

            pamChannelGroupPopup.Closed += (senderPopup, argsPopup) =>
            {
                if (control.IsOKButtonEntered)
                {
                    string pamUserChannelGroup = "";
                    string pamAuthKey = "";
                    int ttlInMinutes = 1440;
                    txtPAMChannelGroup = control.FindName("txtChannelGroup") as TextBox;
                    if (txtPAMChannelGroup != null)
                    {
                        pamUserChannelGroup = txtPAMChannelGroup.Text;

                        TextBox txtAuthKey = control.FindName("txtAuthKey") as TextBox;
                        if (txtAuthKey != null)
                        {
                            pamAuthKey = txtAuthKey.Text;
                        }

                        RadioButton radGrantPAMChannelGroup = control.FindName("radGrantChannelGroup") as RadioButton;
                        if (radGrantPAMChannelGroup != null && radGrantPAMChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroupGrantAccess:");
                            pubnub.ChannelGroupGrantAccess<string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }
                        
                        RadioButton radAuditPAMChannelGroup = control.FindName("radAuditChannelGroup") as RadioButton;
                        if (radAuditPAMChannelGroup != null && radAuditPAMChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroupAuditAccess:");
                            pubnub.ChannelGroupAuditAccess<string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }
                        
                        RadioButton radRevokePAMChannelGroup = control.FindName("radRevokeChannelGroup") as RadioButton;
                        if (radRevokePAMChannelGroup != null && radRevokePAMChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroup Revoke Access:");
                            pubnub.ChannelGroupGrantAccess<string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }

                        RadioButton radGrantPAMPresenceChannelGroup = control.FindName("radGrantPresenceChannelGroup") as RadioButton;
                        if (radGrantPAMPresenceChannelGroup != null && radGrantPAMPresenceChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroupGrantPresenceAccess:");
                            pubnub.ChannelGroupGrantPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, true, true, ttlInMinutes, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }

                        RadioButton radAuditPAMPresenceChannelGroup = control.FindName("radAuditPresenceChannelGroup") as RadioButton;
                        if (radAuditPAMPresenceChannelGroup != null && radAuditPAMPresenceChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroupAuditAccess:");
                            pubnub.ChannelGroupAuditPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }

                        RadioButton radRevokePAMPresenceChannelGroup = control.FindName("radRevokePresenceChannelGroup") as RadioButton;
                        if (radRevokePAMPresenceChannelGroup != null && radRevokePAMPresenceChannelGroup.IsChecked.Value)
                        {
                            DisplayMessageInTextBox("Running ChannelGroup Revoke Access:");
                            pubnub.ChannelGroupGrantPresenceAccess<string>(pamUserChannelGroup, pamAuthKey, false, false, PubnubCallbackResult, PubnubDisplayErrorMessage);
                        }
                    }
                }
                pamChannelGroupPopup = null;
                this.IsEnabled = true;
            };

        }