Beispiel #1
0
        /// <summary>
        /// 初始化实体视图中的命令按钮
        /// </summary>
        /// <param name="evm"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta UseDefaultCommands(this WPFEntityViewMeta evm)
        {
            var em = evm.EntityMeta;

            if (em.EntityCategory != EntityCategory.QueryObject)
            {
                if (em.IsTreeEntity)
                {
                    evm.UseCommands(WPFCommandNames.TreeCommands);
                }
                else
                {
                    evm.UseCommands(WPFCommandNames.CommonCommands);
                }

                if (em.EntityCategory == EntityCategory.Root)
                {
                    evm.UseCommands(WPFCommandNames.RootCommands);
                }
            }

            var commands = evm.Commands;

            if (evm.NotAllowEdit)
            {
                commands.Remove(WPFCommandNames.Edit);
                commands.Remove(WPFCommandNames.SaveList);
            }

            return(evm);
        }
Beispiel #2
0
        protected WindowButton PopupEditingDialog(WPFEntityViewMeta evm, Entity tmpEntity, Action<ViewDialog> windowSetter)
        {
            //弹出窗体显示详细面板
            var detailView = AutoUI.ViewFactory.CreateDetailView(evm);
            detailView.Data = tmpEntity;

            //使用一个 StackPanel,保证详细面板不会自动变大
            var form = detailView.Control;
            form.VerticalAlignment = VerticalAlignment.Top;
            var ctrl = new StackPanel { Children = { form } };

            var result = App.Windows.ShowDialog(ctrl, w =>
            {
                w.Buttons = ViewDialogButtons.YesNo;
                w.SizeToContent = SizeToContent.Height;
                w.MinHeight = 200;
                w.MinWidth = 400;
                w.Width = 400 * detailView.CalculateColumnsCount();
                w.ValidateOperations += (o, e) =>
                {
                    var broken = tmpEntity.Validate();
                    if (broken.Count > 0)
                    {
                        App.MessageBox.Show(broken.ToString(), "属性错误".Translate());
                        e.Cancel = true;
                    }
                };

                windowSetter(w);

                w.Loaded += (o, e) =>
                {
                    var txt = w.GetVisualChild<TextBox>();
                    if (txt != null) { Keyboard.Focus(txt); }
                };

                //窗口在数据改变后再关闭窗口,需要提示用户是否保存。
                bool changed = false;
                tmpEntity.PropertyChanged += (o, e) => changed = true;
                w.Closing += (o, e) =>
                {
                    if (changed && w.DialogResult != true)
                    {
                        var res = App.MessageBox.Show("直接退出将不会保存数据,是否退出?".Translate(), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                        e.Cancel = res == MessageBoxResult.No;
                    }
                };

                this.OnWindowShowing(w);
            });

            return result;
        }
Beispiel #3
0
        /// <summary>
        /// 为某实体类构建一个条件查询面板视图
        /// </summary>
        /// <param name="entityViewInfo"></param>
        /// <returns></returns>
        public ConditionQueryLogicalView CreateConditionQueryView(WPFEntityViewMeta entityViewInfo)
        {
            var view = new ConditionQueryLogicalView(entityViewInfo);

            this.InitDetailView(view);

            view.AttachNewCriteria();

            this.OnViewCreated(view);

            return view;
        }
Beispiel #4
0
        /// <summary>
        /// 清空所有 WPF 命令
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="includeSystemCmds">
        /// 是否在清除的同时,一同删除所有系统级别的命令。
        /// </param>
        /// <returns></returns>
        public static WPFEntityViewMeta ClearCommands(this WPFEntityViewMeta meta, bool includeSystemCmds = true)
        {
            var commands = meta.Commands;

            if (includeSystemCmds)
            {
                commands.Clear();
            }
            else
            {
                for (int i = commands.Count - 1; i >= 0; i--)
                {
                    if (commands[i].GroupType != CommandGroupType.System)
                    {
                        commands.RemoveAt(i);
                    }
                }
            }

            return(meta);
        }
Beispiel #5
0
        /// <summary>
        /// 移除指定组中的所有按钮。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="groups"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta ClearCommands(this WPFEntityViewMeta meta, params int[] groups)
        {
            var commands = meta.Commands;

            if (groups != null && groups.Length > 0)
            {
                for (int i = commands.Count - 1; i >= 0; i--)
                {
                    var cmdGroup = commands[i].GroupType;
                    if (groups.Any(g => g == cmdGroup))
                    {
                        commands.RemoveAt(i);
                    }
                }
            }
            else
            {
                commands.Clear();
            }

            return(meta);
        }
Beispiel #6
0
        /// <summary>
        /// 指定某个类型使用指定的命令列表。
        ///
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="commands">
        /// 只支持两个类型:String、Type
        /// 如果是字符串,则是命令类型的全名称。
        /// </param>
        /// <remarks>
        /// 使用这个方法添加命令时,会自动防止添加重复的命令。
        /// 如果需要添加重复的命令,或者需要自定义构造 <see cref="WPFCommand"/> 元数据时,
        /// 请直接使用 <see cref="WPFEntityViewMeta.Commands"/> 集合。
        /// </remarks>
        /// <returns></returns>
        public static WPFEntityViewMeta UseCommands(this WPFEntityViewMeta meta, IEnumerable <object> commands)
        {
            if (!RafyEnvironment.Location.IsWebUI)
            {
                foreach (var cmd in commands)
                {
                    var cmdStr = cmd as string;
                    if (cmdStr != null)
                    {
                        var command = meta.Commands.Find(cmdStr);
                        if (command == null)
                        {
                            command = UIModel.WPFCommands[cmdStr].CloneMutable();
                            meta.Commands.Add(command);
                        }
                    }
                    else
                    {
                        var cmdType = cmd as Type;
                        if (cmdType == null)
                        {
                            throw new ArgumentNullException("只支持两个类型:String、Type");
                        }

                        var command = meta.Commands.Find(cmdType);
                        if (command == null)
                        {
                            command = UIModel.WPFCommands[cmdType].CloneMutable();
                            meta.Commands.Add(command);
                        }
                    }
                }
            }

            return(meta);
        }
Beispiel #7
0
 public static WPFEntityViewMeta RemoveCommands(this WPFEntityViewMeta meta, IEnumerable <Type> commands)
 {
     meta.Commands.Remove(commands);
     return(meta);
 }
Beispiel #8
0
 public static WPFEntityViewMeta RemoveCommands(this WPFEntityViewMeta meta, params Type[] commands)
 {
     meta.Commands.Remove(commands);
     return(meta);
 }
Beispiel #9
0
 /// <summary>
 /// 指定某个类型使用指定的命令列表。
 /// </summary>
 /// <param name="meta"></param>
 /// <param name="commands">
 /// 只支持两个类型:String、Type
 ///
 /// 如果 WPF 命令是一个单独的 dll,则使用使用字符串的方式来声明。
 /// 如果是字符串,则是命令类型的全名称。
 /// </param>
 /// <returns></returns>
 public static WPFEntityViewMeta UseCommands(this WPFEntityViewMeta meta, params object[] commands)
 {
     return(meta.UseCommands(commands as IEnumerable <object>));
 }
Beispiel #10
0
 internal DetailLogicalView(WPFEntityViewMeta entityViewInfo)
     : base(entityViewInfo)
 {
 }
Beispiel #11
0
        /// <summary>
        /// 通过指定的实体元数据,创建一个报表视图。
        /// </summary>
        /// <param name="evm"></param>
        /// <returns></returns>
        public ReportLogicalView CreateReportView(WPFEntityViewMeta evm)
        {
            var reportPath = evm.ReportPath;

            if (string.IsNullOrEmpty(reportPath)) { throw new InvalidOperationException("创建报表控件失败:没有为元数据设置需要显示的报表路径。"); }

            //开发期暂时使用的路径,方便开发。
            var relativePath = ConfigurationHelper.GetAppSettingOrDefault("Developing_ReportRootPath");
            if (!string.IsNullOrEmpty(relativePath)) { reportPath = System.IO.Path.Combine(relativePath, reportPath); }

            var view = new ReportLogicalView(evm);

            view.SetControl(new ReportHost()
            {
                ReportPath = reportPath
            });

            this.OnViewCreated(view);

            return view;
        }
Beispiel #12
0
        /// <summary>
        /// 为某实体类构建一个详细面板视图
        /// </summary>
        /// <param name="entityViewInfo"></param>
        /// <returns></returns>
        public DetailLogicalView CreateDetailView(WPFEntityViewMeta entityViewInfo)
        {
            var view = new DetailLogicalView(entityViewInfo);

            this.InitDetailView(view);

            this.OnViewCreated(view);

            return view;
        }
Beispiel #13
0
        /// <summary>
        /// 声明当前表单使用水平布局。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta UseDetailAsHorizontal(this WPFEntityViewMeta meta, bool value = true)
        {
            meta.DetailAsHorizontal = value;

            return(meta);
        }
Beispiel #14
0
        /// <summary>
        /// 声明当前表单使用的属性分组模式。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta UseDetailGroupingMode(this WPFEntityViewMeta meta, DetailGroupingMode value)
        {
            meta.DetailGroupingMode = value;

            return(meta);
        }
Beispiel #15
0
 /// <summary>
 /// 使用动态表单作为表单控件。
 /// </summary>
 /// <param name="meta"></param>
 /// <returns></returns>
 public static WPFEntityViewMeta UseAutoDetailPanel(this WPFEntityViewMeta meta)
 {
     meta.DetailPanelType = null;
     return(meta);
 }
Beispiel #16
0
 /// <summary>
 /// 使用自定义表单作为表单控件。
 /// </summary>
 /// <param name="meta"></param>
 /// <returns></returns>
 public static WPFEntityViewMeta UseDetailPanel <TControl>(this WPFEntityViewMeta meta)
 {
     meta.DetailPanelType = typeof(TControl);
     return(meta);
 }
Beispiel #17
0
 protected internal ReportLogicalView(WPFEntityViewMeta meta)
     : base(meta)
 {
 }
Beispiel #18
0
        /// <summary>
        /// 显式指明一个列表视图是否需要显示合计行。
        /// </summary>
        /// <param name="meta"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta ShowSummaryRow(this WPFEntityViewMeta meta)
        {
            BlockUIFactory.SetNeedSummary(meta, true);

            return(meta);
        }
Beispiel #19
0
        /// <summary>
        /// 在 DetailPanel 中显示的 Label 的宽度或者高度。
        /// 不指定,则使用系统默认宽度。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WPFEntityViewMeta HasDetailLabelSize(this WPFEntityViewMeta meta, double?value)
        {
            meta.DetailLabelSize = value;

            return(meta);
        }
Beispiel #20
0
 /// <summary>
 /// 为某一类型直接构造一个 ListLogicalView
 /// </summary>
 /// <param name="boType"></param>
 internal ListLogicalView(WPFEntityViewMeta entityViewInfo)
     : base(entityViewInfo)
 {
 }
Beispiel #21
0
        /// <summary>
        /// 为某个实体类型生成逻辑视图。
        /// </summary>
        /// <param name="entityViewInfo">实体类的视图元数据</param>
        /// <returns></returns>
        public ListLogicalView CreateListView(WPFEntityViewMeta entityViewInfo, bool isLookup = false)
        {
            var view = new ListLogicalView(entityViewInfo);

            if (isLookup) { view.ShowInWhere = ListShowInWhere.DropDown; }

            this.InitListView(view);

            this.OnViewCreated(view);

            return view;
        }
Beispiel #22
0
 internal void UseDefaultMeta()
 {
     this._view = null;
 }
Beispiel #23
0
 /// <summary>
 /// 指定某个实体元数据使用特定路径的 RDCL 报表文件。
 ///
 /// 报表 RDLC 文件中默认使用实体作为数据源,数据源的名称必须和实体名相同。
 /// </summary>
 /// <param name="evm"></param>
 /// <param name="path"></param>
 /// <returns></returns>
 public static WPFEntityViewMeta UseReport(this WPFEntityViewMeta evm, string path)
 {
     evm.ReportPath = path;
     return(evm);
 }
Beispiel #24
0
 internal QueryLogicalView(WPFEntityViewMeta evm)
     : base(evm)
 {
 }
 internal ConditionQueryLogicalView(WPFEntityViewMeta evm)
     : base(evm)
 {
 }
Beispiel #26
0
 public CustomLogicalView(WPFEntityViewMeta meta)
     : base(meta)
 {
 }