private void btnChannelGroup_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 channelGroupStackPanel = new StackPanel(); channelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue); channelGroupStackPanel.Width = 400; channelGroupStackPanel.Height = 440; Popup channelGroupPopup = new Popup(); channelGroupPopup.Height = 420; channelGroupPopup.Width = 300; channelGroupPopup.HorizontalOffset = 10; channelGroupPopup.VerticalOffset = 100; ChannelGroupUserControl control = new ChannelGroupUserControl(); control.txtChannelGroup.Text = channelGroup; control.txtChannelName.Text = "ch1"; channelGroupStackPanel.Children.Add(control); border.Child = channelGroupStackPanel; channelGroupPopup.Child = border; channelGroupPopup.IsOpen = true; control.btnOK.Click += (s, args) => { channelGroupPopup.IsOpen = false; string msg = ""; string userChannelGroup = control.txtChannelGroup.Text; ; string userChannelName = control.txtChannelName.Text; if (control.radGetChannelsOfChannelGroup.IsChecked.Value) { msg = "Running GetChannelsForChannelGroup"; pubnub.GetChannelsForChannelGroup<string>(userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAddChannelToChannelGroup.IsChecked.Value) { msg = "Running AddChannelsToChannelGroup"; pubnub.AddChannelsToChannelGroup<string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRemoveChannelFromChannelGroup.IsChecked.Value) { msg = "Running RemoveChannelsFromChannelGroup"; pubnub.RemoveChannelsFromChannelGroup<string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } TextBlock textBlock = new TextBlock(); textBlock.Text = msg; messageStackPanel.Children.Add(textBlock); scrollViewerResult.UpdateLayout(); scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight); channelGroupPopup = null; this.IsEnabled = true; }; control.btnCancel.Click += (s, args) => { channelGroupPopup.IsOpen = false; channelGroupPopup = null; this.IsEnabled = true; }; }
private void btnChannelGroup_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 channelGroupStackPanel = new StackPanel(); channelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue); channelGroupStackPanel.Width = 400; channelGroupStackPanel.Height = 440; Popup channelGroupPopup = new Popup(); channelGroupPopup.Height = 420; channelGroupPopup.Width = 300; channelGroupPopup.HorizontalOffset = 10; channelGroupPopup.VerticalOffset = 100; ChannelGroupUserControl control = new ChannelGroupUserControl(); control.txtChannelGroup.Text = channelGroup; control.txtChannelName.Text = "ch1"; channelGroupStackPanel.Children.Add(control); border.Child = channelGroupStackPanel; channelGroupPopup.Child = border; channelGroupPopup.IsOpen = true; control.btnOK.Click += (s, args) => { channelGroupPopup.IsOpen = false; string msg = ""; string userChannelGroup = control.txtChannelGroup.Text;; string userChannelName = control.txtChannelName.Text; if (control.radGetChannelsOfChannelGroup.IsChecked.Value) { msg = "Running GetChannelsForChannelGroup"; pubnub.GetChannelsForChannelGroup <string>(userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radAddChannelToChannelGroup.IsChecked.Value) { msg = "Running AddChannelsToChannelGroup"; pubnub.AddChannelsToChannelGroup <string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } if (control.radRemoveChannelFromChannelGroup.IsChecked.Value) { msg = "Running RemoveChannelsFromChannelGroup"; pubnub.RemoveChannelsFromChannelGroup <string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } TextBlock textBlock = new TextBlock(); textBlock.Text = msg; messageStackPanel.Children.Add(textBlock); scrollViewerResult.UpdateLayout(); scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight); channelGroupPopup = null; this.IsEnabled = true; }; control.btnCancel.Click += (s, args) => { channelGroupPopup.IsOpen = false; channelGroupPopup = null; this.IsEnabled = true; }; }
private void btnChannelGroup_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 channelGroupStackPanel = new StackPanel(); channelGroupStackPanel.Background = new SolidColorBrush(Colors.Blue); channelGroupStackPanel.Width = 400; channelGroupStackPanel.Height = 600; Popup channelGroupPopup = new Popup(); channelGroupPopup.Height = 300; channelGroupPopup.Width = 300; channelGroupPopup.HorizontalOffset = 10; channelGroupPopup.VerticalOffset = 100; ChannelGroupUserControl control = new ChannelGroupUserControl(); TextBox txtPAMChannelGroup = control.FindName("txtChannelGroup") as TextBox; if (txtPAMChannelGroup != null) { txtPAMChannelGroup.Text = channelGroup; } TextBox txtChannelName = control.FindName("txtChannelName") as TextBox; if (txtChannelName != null) { txtChannelName.Text = "ch1"; } channelGroupStackPanel.Children.Add(control); border.Child = channelGroupStackPanel; channelGroupPopup.Child = border; channelGroupPopup.IsOpen = true; channelGroupPopup.Closed += (senderPopup, argsPopup) => { if (control.IsOKButtonEntered) { string userChannelGroup = ""; string userChannelName = ""; txtPAMChannelGroup = control.FindName("txtChannelGroup") as TextBox; if (txtPAMChannelGroup != null) { userChannelGroup = txtPAMChannelGroup.Text; txtChannelName = control.FindName("txtChannelName") as TextBox; if (txtChannelName != null) { userChannelName = txtChannelName.Text; } RadioButton radGetChannelsOfChannelGroup = control.FindName("radGetChannelsOfChannelGroup") as RadioButton; if (radGetChannelsOfChannelGroup != null && radGetChannelsOfChannelGroup.IsChecked.Value) { DisplayMessageInTextBox("Running GetChannelsForChannelGroup:"); pubnub.GetChannelsForChannelGroup<string>(userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radAddChannelToChannelGroup = control.FindName("radAddChannelToChannelGroup") as RadioButton; if (radAddChannelToChannelGroup != null && radAddChannelToChannelGroup.IsChecked.Value) { DisplayMessageInTextBox("Running AddChannelsToChannelGroup:"); pubnub.AddChannelsToChannelGroup<string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } RadioButton radRemoveChannelFromChannelGroup = control.FindName("radRemoveChannelFromChannelGroup") as RadioButton; if (radRemoveChannelFromChannelGroup != null && radRemoveChannelFromChannelGroup.IsChecked.Value) { DisplayMessageInTextBox("Running RemoveChannelsFromChannelGroup:"); pubnub.RemoveChannelsFromChannelGroup<string>(new string[] { userChannelName }, userChannelGroup, PubnubCallbackResult, PubnubDisplayErrorMessage); } } } channelGroupPopup = null; this.IsEnabled = true; }; }