using System; using System.Threading; using System.Windows; using System.Windows.Controls; namespace XHZB.Desktop { //定义委托 public delegate void ChangeTextHandler(string text); /// /// RollCallPerfectionWindow.xaml 的交互逻辑 /// public partial class RollCallPerfectionWindow : Window { //定义事件 public event ChangeTextHandler ChangeTextEvent; public RollCallPerfectionWindow(string _name, string _pic) { InitializeComponent(); this.Opacity = 1; txbName.Text = _name; } public void Name(string _name) { this.Opacity = 1; txbName.Text = _name; } /// /// /// 事件源 /// 事件对象 private void radioButton1_CheckedChanged(object sender, EventArgs e) { } /// /// 结束 /// /// /// private void btnEnd_Click(object sender, RoutedEventArgs e) { //ToolbarWindow.IsNotOperation = false; new Thread(new ThreadStart(new Action(() => { Dispatcher.Invoke(new Action(() => { txbName.Text = ""; this.Opacity = 0; })); Thread.Sleep(200); Dispatcher.Invoke(new Action(() => { ChangeTextEvent?.Invoke("关闭窗口"); Hide(); })); }))).Start(); } /// /// 重新点名 /// /// /// private void btnNewRollCall_Click(object sender, RoutedEventArgs e) { RadioButton rdo = sender as RadioButton; //引发事件 if (ChangeTextEvent != null) { ChangeTextEvent("重新点名"); } new Thread(new ThreadStart(new Action(() => { Dispatcher.Invoke(new Action(() => { txbName.Text = ""; this.Opacity = 0; })); Thread.Sleep(200); Dispatcher.Invoke(new Action(() => { Hide(); })); }))).Start(); } } }