예제 #1
0
        public override bool CanExecute(LogicalView view)
        {
            var curControl = GetParentLayout(view.Control);
            if (curControl == null) return false;

            return base.CanExecute(view);
        }
예제 #2
0
        /// <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;
                    }
                }
            };
        }
예제 #3
0
 public override void Execute(LogicalView view)
 {
     var res = CheckErrorRedundancy();
     if (res)
     {
         App.MessageBox.Show("检查完成,未检测到编码错误。");
     }
 }
예제 #4
0
        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;
        }
예제 #5
0
        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;
        }
예제 #6
0
        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());
            }
        }
예제 #7
0
        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();
        }
예제 #8
0
        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);
        }
예제 #9
0
        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();
            }
        }
예제 #10
0
        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);
                        }
                    }
                };
            });
        }
예제 #11
0
        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
                });
        }
예제 #12
0
        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(); }
        }
예제 #13
0
        /// <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;
            }
        }
예제 #14
0
        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
            });
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
        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;
        }
예제 #17
0
        /// <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;
                }
            };
        }
예제 #18
0
        /// <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.
 }
예제 #20
0
 public override bool CanExecute(LogicalView view)
 {
     return(base.CanExecute(view) && view.Current != null);
 }
예제 #21
0
 private void RaiseViewCreated(LogicalView view)
 {
     var handler = this.ViewCreated;
     if (handler != null) handler(this, new InstanceEventArgs<LogicalView>(view));
 }
예제 #22
0
        public override bool CanExecute(LogicalView view)
        {
            var data = view.Current;

            return(data != null && data.IsDirty);
        }
예제 #23
0
 public override bool CanExecute(LogicalView view)
 {
     var data = view.Current;
     return data != null && data.IsDirty;
 }
예제 #24
0
파일: Commands.cs 프로젝트: 569550384/Rafy
 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;
         });
     }
 }
예제 #25
0
        /// <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);
                }
            }
        }
예제 #26
0
 private static bool DisableLog(WPFCommand cmd, LogicalView view)
 {
     return(view is QueryLogicalView);
 }
예제 #27
0
 /// <summary>
 /// 通过 View 找到外层控件中最近的一个 WorkspaceWindow
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public static WorkspaceWindow GetOuterWorkspaceWindow(LogicalView view)
 {
     //这里直接通过控件树关系,而不能只通过视图的父子关系查询,这是因为环绕坏并不是主块的子块。
     return GetOuterWorkspaceWindow(view.GetRootView().Control as DependencyObject);
 }
예제 #28
0
파일: WPFMeta.cs 프로젝트: 569550384/Rafy
 public static void SetLogicalView(DependencyObject d, LogicalView value)
 {
     d.SetValue(LogicalViewProperty, value);
 }
예제 #29
0
        private void OnViewCreated(LogicalView view)
        {
            //模型标记不可编辑,则初始化只读属性。
            if (view.Meta.NotAllowEdit)
            {
                view.IsReadOnly = ReadOnlyStatus.ReadOnly;
            }

            this.RaiseViewCreated(view);
        }
예제 #30
0
 public override bool CanExecute(LogicalView view)
 {
     return(RafyEnvironment.Location.IsWPFUI && !RafyEnvironment.Location.ConnectDataDirectly);
 }
예제 #31
0
        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();
        }
예제 #32
0
        public override bool CanExecute(LogicalView view)
        {
            var data = view.Data as IDirtyAware;

            return(data != null && data.IsDirty && !view.DataLoader.IsLoadingData);
        }
예제 #33
0
 public override bool CanExecute(LogicalView view)
 {
     return(null != view.Current);
 }
예제 #34
0
 /// <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.
 }
예제 #35
0
 /// <summary>
 /// 子类重写此方法实现撤消手工设置的数据。
 ///
 /// 默认实现是直接设置 view.Data 为 null。
 /// </summary>
 /// <param name="view"></param>
 protected virtual void CancelCustomData(LogicalView view)
 {
     view.Data = null;
 }
예제 #36
0
 public override void Execute(LogicalView view)
 {
     view.CastTo <QueryLogicalView>().AttachNewCriteria();
 }
예제 #37
0
 private static bool DisableLog(WPFCommand cmd, LogicalView view)
 {
     return view is QueryLogicalView;
 }
예제 #38
0
 public override void Execute(LogicalView view)
 {
     ChangePwd.Execute(view.Current as User);
 }
예제 #39
0
        /// <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);
        }
예제 #40
0
 public override bool CanExecute(LogicalView view)
 {
     var list = view.Data as IList;
     return list != null && list.Count > 0;
 }