public IEnumerable <ViewBindingInfo> CreateViewBindings() { _view = new SelectTablesUI(); var bindingInfo = new ViewBindingInfo() { View = _view }; return(new List <ViewBindingInfo>() { bindingInfo }); }
// 如果活动返回值,则从 CodeActivity<TResult> // 并从 Execute 方法返回该值。 protected override void Execute(CodeActivityContext context) { try { _autoResetEvent = new AutoResetEvent(false); Executing?.Invoke(); // 获取 Text 输入参数的运行时值 string materialId = context.GetValue(this.FileId); TablePositioningOptions options = new TablePositioningOptions() { RegionInclude = this.GetListString(context, this.RegionInclude), RegionExclude = this.GetListString(context, this.RegionExclude), RegionAboveInclude = this.GetListString(context, this.RegionAboveInclude), RegionAboveExclude = this.GetListString(context, this.RegionAboveExclude), }; if (_view != null) { _view.Dispatcher.BeginInvoke(new Action(() => { _view.SetData(options, materialId, _autoResetEvent); })); } else { //todo:等设计器实现了显示执行时UI的功能后去掉else部分的代码 Thread thread = new Thread((ThreadStart) delegate { Window window = new Window() { Title = "表格选择" }; _view = new SelectTablesUI(); _view.SetData(options, materialId, _autoResetEvent, window); window.Content = _view; window.ShowDialog(); if (_autoResetEvent != null) { _autoResetEvent.Set(); } }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } _autoResetEvent.WaitOne(); _autoResetEvent.Dispose(); _autoResetEvent = null; this.TableIds.Set(context, _view.GetTables()); } catch (Exception ex) { //todo: log exception throw; } finally { _view = null; Executed?.Invoke(); } }