private void BtnSend_Click(object sender, RoutedEventArgs e) { if (client != null) { string msg = TbText.Text; client.Broadcast(msg); TbText.Text = ""; TbText.Focus(); } }
public InputWindow( string title, string text, string tail, Func <string, string> check, Action <string> onOk, bool isPassword) { _isPassword = isPassword; this.Title = title; InitializeComponent(); this.TbUcName.Text = nameof(InputWindow); TbTitle.Text = title; if (isPassword) { TbText.Visibility = Visibility.Collapsed; PbPassword.Visibility = Visibility.Visible; PbPassword.Password = text; } else { TbText.Text = text; } TbTail.Text = tail; var owner = WpfUtil.GetTopWindow(); if (this != owner) { this.Owner = owner; } _check = check; _onOk = onOk ?? throw new ArgumentNullException(nameof(onOk)); TimeSpan.FromMilliseconds(100).Delay().ContinueWith(t => { UIThread.Execute(() => () => { if (isPassword) { PbPassword.Focus(); } else { if (!string.IsNullOrEmpty(TbText.Text)) { TbText.SelectionStart = TbText.Text.Length; } TbText.Focus(); } }); }); }