public override bool CanExecute(LogicalView view) { var curControl = GetParentLayout(view.Control); if (curControl == null) return false; return base.CanExecute(view); }
/// <summary> /// 把view的行为适配到control上。 /// 同时也把control的行为适配到view上。 /// /// LogicalView.IsVisible 和 TabItem.Visibility 的关系: /// 在目标上,两者实现双向绑定。 /// 1. LogicalView.IsVisible 的改变,直接通过 IsVisibleChanged 事件的处理函数来设置对应的 TabItem 的 Visibility 属性。 /// 2. TabItem.Visibility 先使用 OnWay 的 Binding 来直接绑定在实体类父对象的某个属性上,实现动态可见性。 /// 然后,在 Binding 的 UpdateTarget 事件处理函数中,再设置 LogicalView.IsVisible 的值。 /// 代码位于 ListLogicalView.ResetVisibility() 方法中。 /// </summary> /// <param name="childView"></param> /// <param name="control"></param> public static void AdaptView(LogicalView childView, TabItem control) { //IsActive control.IsSelected = childView.IsActive; childView.IsActiveChanged += (o, e) => { control.IsSelected = childView.IsActive; }; //IsVisible control.Visibility = childView.IsVisible ? Visibility.Visible : Visibility.Collapsed; childView.IsVisibleChanged += (o, e) => { var tabControl = control.GetLogicalParent<TabControl>(); Debug.Assert(tabControl != null, "tabControl != null"); if (childView.IsVisible) { control.Visibility = Visibility.Visible; tabControl.Visibility = Visibility.Visible; } else { control.Visibility = Visibility.Collapsed; if (tabControl.Items.OfType<TabItem>().All(i => i.Visibility == Visibility.Collapsed)) { tabControl.Visibility = Visibility.Collapsed; } } }; }
public override void Execute(LogicalView view) { var res = CheckErrorRedundancy(); if (res) { App.MessageBox.Show("检查完成,未检测到编码错误。"); } }
public RelationView(string surrounderType, LogicalView view) { if (string.IsNullOrEmpty(surrounderType)) throw new ArgumentNullException("surrounderType"); if (view == null) throw new ArgumentNullException("view"); this.SurrounderType = surrounderType; this.View = view; }
public ControlResult(FrameworkElement control, LogicalView view) { if (control == null) throw new ArgumentNullException("control"); if (view == null) throw new ArgumentNullException("control"); this.Control = control; this.MainView = view; }
public override void Execute(LogicalView view) { var c = view.Current as ViewConfigurationModel; var svc = ServiceFactory.Create<GetBlockConfigFileService>(); svc.Model = c.EntityType; svc.ViewName = c.ViewName; svc.Invoke(); if (!svc.Opened) { App.MessageBox.Show("暂时还没有进行任何配置,没有找到对应的 XML 文件。".Translate()); } }
public override void Execute(LogicalView view) { //检测条件 var current = view.Current; var brokenRules = current.Validate(); if (brokenRules.Count > 0) { App.MessageBox.Show(brokenRules.ToString(), "保存出错".Translate()); return; } RF.Save(current, EntitySaveType.DiffSave); this.OnSaveSuccessed(); }
public override void Execute(LogicalView view) { var curControl = GetParentLayout(view.Control); if (curControl == null) return; view.IsActive = true; var oldPrent = curControl.Parent; curControl.RemoveFromParent(false); double initScale = GetInitScale(curControl); //必须放在 parent.Content = null;之前 //Title var title = string.Empty; if (view.ChildBlock == null) { title = view.Meta.Label; } else { title = view.ChildBlock.ViewMeta.Label; } //window App.Windows.ShowDialog(curControl, win => { win.ResizeMode = ResizeMode.CanResize; win.Title = title.Translate(); win.Buttons = ViewDialogButtons.None; #region 窗体设置 //不要显示最大化,根据屏幕分辨率获取高度和宽度,上面留一块儿 win.WindowStartupLocation = WindowStartupLocation.Manual; win.Top = 100; win.Left = 0; win.Width = SystemParameters.PrimaryScreenWidth; win.Height = SystemParameters.PrimaryScreenHeight - 200; win.Topmost = false; #endregion Zoom.EnableZoom(win, initScale); }); curControl.LayoutTransform = null; curControl.RemoveFromParent(); curControl.AttachToParent(oldPrent); }
public override void Execute(LogicalView view) { var result = App.MessageBox.Show("确定清空所有日志?".Translate(), "请确认".Translate(), MessageBoxButton.YesNo); if (result != MessageBoxResult.Yes) return; //清空 ServiceFactory.Create<ClearLogService>().Invoke(); //刷新数据 if (view.DataLoader.AnyLoaded) { view.DataLoader.ReloadDataAsync(); } }
public override void Execute(LogicalView view) { var blocks = UIModel.AggtBlocks.GetDefinedBlocks("ViewConfigurationModel模块界面"); var ui = AutoUI.AggtUIFactory.GenerateControl(blocks); ui.MainView.DataLoader.LoadDataAsync(() => { var model = RF.Concrete<ViewConfigurationModelRepository>() .GetByName(new ViewConfigurationModelNameCriteria { EntityType = ClientEntities.GetClientName(view.EntityType), ViewName = view.Meta.ExtendView }); return model; }); App.Windows.ShowWindow(ui.Control, w => { w.Title = "定制".Translate() + " " + view.Meta.Label.Translate(); w.WindowClosedByUser += (o, e) => { if (e.Button == WindowButton.Yes) { //先执行保存。 ui.MainView.Commands[WPFCommandNames.SaveBill].TryExecute(); if (!App.Windows.HasPopup) { var res = App.MessageBox.Show("重新打开当前模块以使设置生效?".Translate(), MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { var ws = App.Current.Workspace; var aw = ws.ActiveWindow; if (aw != null && ws.TryRemove(aw)) { App.Current.OpenModuleOrAlert(aw.Title); } } } else { App.MessageBox.Show("下次打开此弹出窗口时生效。".Translate(), MessageBoxButton.OK); } } }; }); }
public override void Execute(LogicalView view) { var c = view.Current as ViewConfigurationModel; var svc = this.CreateSVC(); svc.Model = c.EntityType; svc.ViewName = c.ViewName; svc.Invoke(); view.Current = RF.Concrete<ViewConfigurationModelRepository>() .GetByName(new ViewConfigurationModelNameCriteria { EntityType = c.EntityType, ViewName = c.ViewName }); }
public override void Execute(LogicalView view) { //设置查询时间为从当前时间起。 var queryView = view.ConditionQueryView; if (queryView != null) { var criteria = queryView.Current as DbMigrationHistoryQueryCriteria; criteria.StartTime = DateTime.Now; } //升级数据库。 ClientMigrationHelper.MigrateOnClient(); //重新加载数据。 if (view.DataLoader.AnyLoaded) { view.DataLoader.ReloadDataAsync(); } }
/// <summary> /// 使用 View 的数据加载器,尝试为 control 创建一个带 “Busy”控件的控件。 /// </summary> /// <param name="target"></param> /// <returns></returns> public static FrameworkElement TryWrapWithBusyControl(LogicalView target) { var viewController = target.DataLoader as ViewDataLoader; if (viewController != null) { var busy = CreateBusyControl(viewController); var busyContent = new Grid(); busyContent.Children.Add(target.Control); busyContent.Children.Add(busy); return busyContent; } else { return target.Control; } }
private static void LogAsync(string title, string coderContent, LogicalView view) { int? entityId = null; var entity = view.Current as IntEntity; if (entity != null) { entityId = entity.Id; } AuditLogService.LogAsync(new AuditLogItem() { Title = title, FriendlyContent = string.Format(@"对象:{0}", view.Meta.Label), PrivateContent = coderContent, ModuleName = App.Current.Workspace.ActiveWindow.Title, Type = AuditLogType.Command, EntityId = entityId }); }
public override void Execute(LogicalView view) { var listView = view.CastTo<ListLogicalView>(); var list = listView.Data; if (list.IsDirty) { //检测条件 if (!this.ValidateData(listView)) return; //如果元数据中指定了列表保存的服务,则尝试使用这个服务。 var svcType = view.Meta.EntityMeta.GetSaveListServiceType(); if (svcType != null) { var svc = Activator.CreateInstance(svcType) as ISaveListService; if (svc == null) throw new InvalidProgramException(string.Format("{0} 服务应该实现 ISaveListService 接口。", svcType)); svc.EntityList = list; svc.Invoke(); if (!svc.Result) { App.MessageBox.Show(svc.Result.Message, "保存出错".Translate()); return; } else { listView.Data = svc.EntityList; } } else { RF.Save(list); } this.OnSaveSuccessed(); this.RefreshAll(listView); } }
public override void Execute(LogicalView view) { //ListLogicalView 需要被特殊处理。 object oldCurObjId = null; var listView = view as ListLogicalView; if (listView != null) { var e = view.Current; if (e != null) oldCurObjId = e.Id; } //再尝试对 SaveAsChangedBehavior 进行特殊处理。 var b = view.FindBehavior<SaveAsChangedBehavior>(); if (b != null) b.SuppressSaveAction = true; var loader = view.DataLoader; if (loader.AnyLoaded) { //重新获取数据 view.DataLoader.ReloadDataAsync(() => { //如果之前已经选中了某一行,这里只需要再次设置为该行就可以了。 if (oldCurObjId != null) { listView.SetCurrentById(oldCurObjId); } }); } else { //当数据不是由 DataLoader 加载的时候,说明这些数据来自于手工设置,调用 CancelCustomData 方法撤消。 this.CancelCustomData(view); } if (b != null) b.SuppressSaveAction = false; }
/// <summary> /// 把 childrenTab 的选择项同步到 View.IsActive 属性上。 /// </summary> /// <param name="parentView"></param> /// <param name="childrenTab"></param> public static void AdaptView(LogicalView parentView, TabControl childrenTab) { //任何一个子 View 可见,整个控件都可见 childrenTab.Visibility = parentView.ChildrenViews.Any(v => v.IsVisible) ? Visibility.Visible : Visibility.Collapsed; //在选择状态发生改变时,设置每个view的Active状态 childrenTab.SelectionChanged += (sender, e) => { //设置每个view的Active状态 if (sender == e.OriginalSource && e.AddedItems.Count > 0) { foreach (TabItem item in e.AddedItems) { var childView = WPFMeta.GetLogicalView(item); childView.IsActive = true; } foreach (TabItem item in e.RemovedItems) { var childView = WPFMeta.GetLogicalView(item); childView.IsActive = false; } e.Handled = true; } }; }
/// <summary> /// 记录日志 /// </summary> /// <param name="view"></param> private static void LogCommandSuccess(WPFCommand cmd, LogicalView view) { if (DisableLog(cmd, view)) return; string title = "执行命令完成:" + cmd.Label; string coderContent = string.Format( @"类型名:{0} 命令名称:{1}", view.EntityType.Name, cmd.Name); LogAsync(title, coderContent, view); }
/// <include file='doc\ProvideViewAttribute.uex' path='docs/doc[@for="ProvideViewAttribute.ProvideViewAttribute"]' /> /// <devdoc> /// Creates a new ProvideViewAttribute. /// </devdoc> public ProvideViewAttribute(LogicalView logicalView, string physicalView) { _logicalView = logicalView; _physicalView = physicalView; // NULL is valid here. }
public override bool CanExecute(LogicalView view) { return(base.CanExecute(view) && view.Current != null); }
private void RaiseViewCreated(LogicalView view) { var handler = this.ViewCreated; if (handler != null) handler(this, new InstanceEventArgs<LogicalView>(view)); }
public override bool CanExecute(LogicalView view) { var data = view.Current; return(data != null && data.IsDirty); }
public override bool CanExecute(LogicalView view) { var data = view.Current; return data != null && data.IsDirty; }
public override void Execute(LogicalView view) { var res = App.MessageBox.Show("打开所有模块需要一定时间,确定吗?".Translate(), MessageBoxButton.YesNo); if (res == MessageBoxResult.Yes) { var modules = App.Current.UserRootModules; modules.TravalTree(vm => { if (vm.Type == ModuleViewModelType.EntityModule) { vm.IsSelected = true; } return false; }); } }
/// <summary> /// 列表保存后,新加的实体的 Id 已经变化,需要重新刷新表格控件。 /// </summary> /// <param name="view"></param> private void RefreshAll(LogicalView view) { view.RefreshControl(); var current = view.Current; if (current != null) { foreach (var childView in view.ChildrenViews) { this.RefreshAll(childView); } } }
private static bool DisableLog(WPFCommand cmd, LogicalView view) { return(view is QueryLogicalView); }
/// <summary> /// 通过 View 找到外层控件中最近的一个 WorkspaceWindow /// </summary> /// <param name="element"></param> /// <returns></returns> public static WorkspaceWindow GetOuterWorkspaceWindow(LogicalView view) { //这里直接通过控件树关系,而不能只通过视图的父子关系查询,这是因为环绕坏并不是主块的子块。 return GetOuterWorkspaceWindow(view.GetRootView().Control as DependencyObject); }
public static void SetLogicalView(DependencyObject d, LogicalView value) { d.SetValue(LogicalViewProperty, value); }
private void OnViewCreated(LogicalView view) { //模型标记不可编辑,则初始化只读属性。 if (view.Meta.NotAllowEdit) { view.IsReadOnly = ReadOnlyStatus.ReadOnly; } this.RaiseViewCreated(view); }
public override bool CanExecute(LogicalView view) { return(RafyEnvironment.Location.IsWPFUI && !RafyEnvironment.Location.ConnectDataDirectly); }
private void Button_Click(object sender, RoutedEventArgs e) { if (DefaultSolutionBuilderView == null) { DefaultSolutionBuilderView = ContentScrollViewer.Content; } if (NServiceBusView == null) { var SBdataContext = DataContext; LogicalViewModel.NServiceBusViewModel = new LogicalViewModel(SBdataContext as ISolutionBuilderViewModel); NServiceBusView = new LogicalView(LogicalViewModel.NServiceBusViewModel) { VerticalAlignment = VerticalAlignment.Stretch }; NServiceBusView.InitializeViewSelector(); EnableDisableNServiceBusView(IsEnabledNServiceBusView); NServiceBusView.SelectedItemChanged += (s, f) => { if (s != null) { var selected = (s as LogicalViewModel.LogicalViewModelNode); if (selected != null) { var fe = selected.InnerViewModel; var window = (NServiceBusDetailsToolWindow)ServiceProvider.GetService(typeof(NServiceBusDetailsToolWindow)); if (window != null) { Dispatcher.BeginInvoke(new Action(() => { ((DetailsPanel)window.Content).SetView(ServiceProvider, fe, SBdataContext); ((IVsWindowFrame)window.Frame).Show(); })); } } } }; } else { NServiceBusView.DataContext = LogicalViewModel.NServiceBusViewModel; } ShowNServiceBusStudioView(); }
public override bool CanExecute(LogicalView view) { var data = view.Data as IDirtyAware; return(data != null && data.IsDirty && !view.DataLoader.IsLoadingData); }
public override bool CanExecute(LogicalView view) { return(null != view.Current); }
/// <include file='doc\ProvideViewAttribute.uex' path='docs/doc[@for="ProvideViewAttribute.ProvideViewAttribute"]' /> /// <devdoc> /// Creates a new ProvideViewAttribute. /// </devdoc> public ProvideViewAttribute(LogicalView logicalView, string physicalView) { _logicalView = logicalView; _physicalView = physicalView; // NULL is valid here. }
/// <summary> /// 子类重写此方法实现撤消手工设置的数据。 /// /// 默认实现是直接设置 view.Data 为 null。 /// </summary> /// <param name="view"></param> protected virtual void CancelCustomData(LogicalView view) { view.Data = null; }
public override void Execute(LogicalView view) { view.CastTo <QueryLogicalView>().AttachNewCriteria(); }
private static bool DisableLog(WPFCommand cmd, LogicalView view) { return view is QueryLogicalView; }
public override void Execute(LogicalView view) { ChangePwd.Execute(view.Current as User); }
/// <summary> /// 记录执行错误的日志 /// </summary> /// <param name="view"></param> /// <param name="ex"></param> private static void LogCommandFailed(WPFCommand cmd, LogicalView view, Exception ex) { if (DisableLog(cmd, view)) return; string title = "执行命令失败:" + cmd.Label; string coderContent = string.Format( @"类型名:{0} 命令类型:{1} 发生异常:{2} 堆栈:{3}", view.EntityType.Name, cmd.Name, ex.Message, ex.StackTrace); LogAsync(title, coderContent, view); }
public override bool CanExecute(LogicalView view) { var list = view.Data as IList; return list != null && list.Count > 0; }