private void btnChangeUUID_Click(object sender, RoutedEventArgs e) { this.IsEnabled = false; Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5.0); StackPanel changeUUIDStackPanel = new StackPanel(); changeUUIDStackPanel.Background = new SolidColorBrush(Colors.Blue); changeUUIDStackPanel.Width = 400; changeUUIDStackPanel.Height = 300; changeUUIDPopup = new Popup(); changeUUIDPopup.Height = 300; changeUUIDPopup.Width = 300; changeUUIDPopup.VerticalOffset = 10; changeUUIDPopup.HorizontalOffset = 10; ChangeUUIDUserControl control = new ChangeUUIDUserControl(); control.lblCurrentUUID.Text = uuid; changeUUIDStackPanel.Children.Add(control); border.Child = changeUUIDStackPanel; changeUUIDPopup.Child = border; changeUUIDPopup.IsOpen = true; control.btnOK.Click += (s, args) => { changeUUIDPopup.IsOpen = false; string newUUID = control.txtNewUUID.Text; if (!string.IsNullOrEmpty(newUUID) && newUUID.Trim().Length > 0) { uuid = newUUID; pubnub.ChangeUUID(uuid); TextBlock textBlock = new TextBlock(); textBlock.Text = string.Format("Change UUID done.\n"); messageStackPanel.Children.Add(textBlock); scrollViewerResult.UpdateLayout(); scrollViewerResult.ScrollToVerticalOffset(scrollViewerResult.ExtentHeight); } changeUUIDPopup = null; this.IsEnabled = true; }; control.btnCancel.Click += (s, args) => { changeUUIDPopup.IsOpen = false; changeUUIDPopup = null; this.IsEnabled = true; }; }
private void btnChangeUUID_Click(object sender, RoutedEventArgs e) { this.IsEnabled = false; Border border = new Border(); border.BorderBrush = new SolidColorBrush(Colors.Black); border.BorderThickness = new Thickness(5.0); StackPanel changeUUIDStackPanel = new StackPanel(); changeUUIDStackPanel.Background = new SolidColorBrush(Colors.Blue); changeUUIDStackPanel.Width = 400; changeUUIDStackPanel.Height = 300; changeUUIDPopup = new Popup(); changeUUIDPopup.Height = 300; changeUUIDPopup.Width = 300; changeUUIDPopup.HorizontalOffset = 10; changeUUIDPopup.VerticalOffset = 100; ChangeUUIDUserControl control = new ChangeUUIDUserControl(); TextBlock tbCurrentUUID = control.FindName("lblCurrentUUID") as TextBlock; if (tbCurrentUUID != null) { tbCurrentUUID.Text = data.sessionUUID; } changeUUIDStackPanel.Children.Add(control); border.Child = changeUUIDStackPanel; changeUUIDPopup.Child = border; changeUUIDPopup.IsOpen = true; changeUUIDPopup.Closed += (senderPopup, argsPopup) => { if (!control.IsCancelledButton) { TextBox txtNewUUID = control.FindName("txtNewUUID") as TextBox; if (txtNewUUID != null) { data.sessionUUID = txtNewUUID.Text; pubnub.ChangeUUID(data.sessionUUID); } } changeUUIDPopup = null; this.IsEnabled = true; }; }