// 开门 NormalResult OpenDoor() { // 打开对话框,询问门号 ProgressWindow progress = null; Application.Current.Dispatcher.Invoke(new Action(() => { progress = new ProgressWindow(); progress.MessageText = "正在处理,请稍候 ..."; progress.Owner = Application.Current.MainWindow; progress.WindowStartupLocation = WindowStartupLocation.CenterOwner; progress.Closed += Progress_Closed; progress.Show(); AddLayer(); })); try { progress = null; return(new NormalResult()); } finally { Application.Current.Dispatcher.Invoke(new Action(() => { if (progress != null) { progress.Close(); } })); } }
private void PageInventory_Loaded(object sender, RoutedEventArgs e) { App.NewTagChanged += CurrentApp_NewTagChanged; App.IsPageInventoryActive = true; _ = Task.Run(() => { CancellationTokenSource cancel = new CancellationTokenSource(); ProgressWindow progress = null; App.Invoke(new Action(() => { progress = new ProgressWindow(); progress.TitleText = "dp2SSL -- 盘点"; progress.MessageText = "正在获取 UID 对照信息,请稍候 ..."; progress.Owner = Application.Current.MainWindow; progress.WindowStartupLocation = WindowStartupLocation.CenterOwner; progress.Closed += (s, e1) => { cancel.Cancel(); }; progress.okButton.Visibility = Visibility.Collapsed; // progress.okButton.Content = "停止"; App.SetSize(progress, "middle"); progress.BackColor = "green"; progress.Show(); })); try { Hashtable uid_table = new Hashtable(); var result = InventoryData.DownloadUidTable( null, uid_table, (text) => { App.Invoke(new Action(() => { progress.MessageText = text; })); }, cancel.Token); InventoryData.SetUidTable(uid_table); } catch (Exception ex) { WpfClientInfo.WriteErrorLog($"准备册记录过程出现异常: {ExceptionUtil.GetDebugText(ex)}"); } finally { App.Invoke(new Action(() => { progress.Close(); })); } }); }
void ErrorBox(string message, string color = "red", string style = "") { ProgressWindow progress = null; App.Invoke(new Action(() => { progress = new ProgressWindow(); progress.MessageText = "正在处理,请稍候 ..."; progress.Owner = Application.Current.MainWindow; progress.WindowStartupLocation = WindowStartupLocation.CenterOwner; App.SetSize(progress, "tall"); //progress.Width = Math.Min(700, this.ActualWidth); //progress.Height = Math.Min(900, this.ActualHeight); progress.Closed += (o1, e1) => { //RemoveLayer(); }; if (StringUtil.IsInList("button_ok", style)) { progress.okButton.Content = "确定"; } progress.Show(); //AddLayer(); })); if (StringUtil.IsInList("auto_close", style)) { DisplayMessage(progress, message, color); _ = Task.Run(async() => { try { // TODO: 显示倒计时计数? await Task.Delay(TimeSpan.FromSeconds(1)); App.Invoke(new Action(() => { progress.Close(); })); } catch { // TODO: 写入错误日志 } }); } else { DisplayError(ref progress, message, color); } }
private void Message_MouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Right) { Clipboard.SetDataObject(this.message.Text, true); } if (e.ChangedButton == MouseButton.Left) { // 测试功能 MessageDocument doc = new MessageDocument(); DateTime now = DateTime.Now; doc.Add(new Operator { PatronName = "姓名" }, now, "borrow", "succeed", "", "", new Entity { Title = "书名1" }); doc.Add(new Operator { PatronName = "姓名" }, now, "borrow", "succeed", "", "", new Entity { Title = "书名2" }); doc.Add(new Operator { PatronName = "姓名" }, now, "return", "warning", "这是警告信息", "", new Entity { Title = "书名3" }); doc.Add(new Operator { PatronName = "姓名" }, now, "return", "error", "还书出错", "errorCode", new Entity { Title = "书名4" }); ProgressWindow progress = null; App.Invoke(new Action(() => { progress = new ProgressWindow(); // progress.MessageText = "正在处理,请稍候 ..."; progress.MessageDocument = doc.BuildDocument( MessageDocument.BaseFontSize, "", out string speak); progress.Owner = Application.Current.MainWindow; progress.WindowStartupLocation = WindowStartupLocation.CenterOwner; //progress.Closed += Progress_Closed; App.SetSize(progress, "wide"); //progress.Width = Math.Min(700, this.ActualWidth); //progress.Height = Math.Min(500, this.ActualHeight); progress.Show(); //AddLayer(); })); } }
private void PageInventory_Loaded(object sender, RoutedEventArgs e) { App.NewTagChanged += CurrentApp_NewTagChanged; App.IsPageInventoryActive = true; RefreshActionModeMenu(); _ = Task.Run(() => { // 获得馆藏地列表 GetLocationListResult get_result = LibraryChannelUtil.GetLocationList(); if (get_result.Value == -1) { App.SetError("inventory", $"获得馆藏地列表时出错: {get_result.ErrorInfo}"); } string batchNo = "inventory_" + DateTime.Now.ToShortDateString(); bool slow_mode = false; bool dialog_result = false; // “开始盘点”对话框 App.Invoke(new Action(() => { App.PauseBarcodeScan(); try { BeginInventoryWindow dialog = new BeginInventoryWindow(); dialog.TitleText = $"开始盘点"; // dialog.Text = $"如何处理以上放入 {door_names} 的 {collection.Count} 册图书?"; dialog.Owner = App.CurrentApp.MainWindow; // dialog.BatchNo = batchNo; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; App.SetSize(dialog, "tall"); dialog.location.ItemsSource = get_result.List; // result.List; dialog.BatchNo = batchNo; dialog.ActionMode = ActionMode; dialog.ShowDialog(); if (dialog.DialogResult == false) { dialog_result = false; } else { dialog_result = true; { _actionMode = dialog.ActionMode; RefreshActionModeMenu(); } CurrentLocation = dialog.Location; CurrentBatchNo = dialog.BatchNo; slow_mode = dialog.SlowMode; } } finally { App.ContinueBarcodeScan(); } })); ClearList(); if (dialog_result == true && slow_mode == false) { CancellationTokenSource cancel = new CancellationTokenSource(); ProgressWindow progress = null; App.Invoke(new Action(() => { progress = new ProgressWindow(); progress.TitleText = "dp2SSL -- 盘点"; progress.MessageText = "正在获取 UID 对照信息,请稍候 ..."; progress.Owner = Application.Current.MainWindow; progress.WindowStartupLocation = WindowStartupLocation.CenterOwner; progress.Closed += (s, e1) => { cancel.Cancel(); }; progress.okButton.Visibility = Visibility.Collapsed; // progress.okButton.Content = "停止"; App.SetSize(progress, "middle"); progress.BackColor = "green"; progress.Show(); })); try { Hashtable uid_table = new Hashtable(); var result = InventoryData.DownloadUidTable( null, uid_table, (text) => { App.Invoke(new Action(() => { progress.MessageText = text; })); }, cancel.Token); InventoryData.SetUidTable(uid_table); } catch (Exception ex) { WpfClientInfo.WriteErrorLog($"准备册记录过程出现异常: {ExceptionUtil.GetDebugText(ex)}"); } finally { App.Invoke(new Action(() => { progress.Close(); })); } } }); }