private void btnPrinterDetail_Click(object sender, RoutedEventArgs e) { try { basicSituation = new TextBasicSituation(); skipPages.Content = basicSituation; } catch (Exception ex) { MessageBox.Show(ex.Message, this.Title, MessageBoxButton.OK); } }
//点击按钮找到打印机列表的SN码 private void printerMessage_Click_1(object sender, RoutedEventArgs e) { printer = new Printer(); //isVisibilityForEnter.Visibility = Visibility.Visible; btnPrinterDetail.IsChecked = true; List <Button> buttonItems = printer.GetChildObjects <Button>(itemsPrinters, ""); TextBlock txt = null; foreach (Button button in buttonItems) { if (button.IsFocused) { txt = printer.FindFirstVisualChild <TextBlock>(button, "txtPrintersSN"); txtPrinterSN.Text = txt.Text; break; } } basicSituation = new TextBasicSituation(txt.Text); skipPages.Content = basicSituation; }