示例#1
0
 protected override WindowButton PopupSelectionWindow(ControlResult ui)
 {
     return App.Windows.ShowDialog(ui.Control, w =>
     {
         w.Title = this.Meta.Label.Translate();
         w.Width = 600;
         w.Height = 300;
     });
 }
示例#2
0
        protected virtual void OnChildUICreated(ControlResult childUI)
        {
            var handler = this.ChildUICreated;

            if (handler != null)
            {
                handler(this, new ChildUICreatedEventArgs(childUI));
            }
        }
示例#3
0
        /// <summary>
        /// 子类可以重写此方法来添加当前模块中 UI 的初始化逻辑。
        ///
        /// 当使用自动生成的 UI 时,此方法会被调用。
        /// </summary>
        /// <param name="ui"></param>
        internal protected virtual void OnUIGenerated(ControlResult ui)
        {
            var handler = this.UIGenerated;

            if (handler != null)
            {
                handler(this, new UIGeneratedEventArgs(ui));
            }
        }
示例#4
0
        /// <summary>
        /// 子类可以重写此方法来添加当前模块中 UI 的初始化逻辑。
        ///
        /// 当使用自动生成的 UI 时,此方法会被调用。
        /// </summary>
        /// <param name="ui"></param>
        internal protected override void OnUIGenerated(ControlResult ui)
        {
            this._ui = ui;

            if (!this.SuppressCallback)
            {
                this.CreateCallback();
            }

            base.OnUIGenerated(ui);
        }
示例#5
0
 /// <summary>
 /// 把焦点定位到第一个编辑器上
 /// </summary>
 /// <param name="ui"></param>
 private static void Focus(ControlResult ui)
 {
     ui.Control.Loaded += (o, e) =>
     {
         var mainView          = ui.MainView;
         var focusedDetailView = mainView.FocusFirstEditor();
         if (focusedDetailView == null)
         {
             mainView.Control.Focus();
         }
     };
 }
示例#6
0
        /// <summary>
        /// 自动加载列表的数据
        /// </summary>
        /// <param name="ui"></param>
        private void AsyncLoadListData(ControlResult ui)
        {
            //如果是个列表,并且没有导航面板,则默认开始查询数据
            var listView = ui.MainView as ListLogicalView;

            if (listView != null &&
                listView.ConditionQueryView == null &&
                listView.NavigationQueryView == null
                )
            {
                listView.DataLoader.LoadDataAsync();
            }
        }
示例#7
0
        protected override void OnUIGenerated(ControlResult ui)
        {
            base.OnUIGenerated(ui);

            this._planView = ui.MainView as ListLogicalView;
            this._taskView = this._planView.GetChildView(typeof(TaskOrCategory)) as ListLogicalView;
            this._weekCompletionView = this._taskView.GetChildView(typeof(WeekCompletion)) as ListLogicalView;
            var weekNoteView = this._planView.GetChildView(typeof(WeekNote)) as ListLogicalView;

            MPHelper.ModifyRowStyle(this._taskView, "TaskViewRowStyle");
            MPHelper.ModifyRowStyle(this._weekCompletionView, "CurrentWeekRowStyle");
            MPHelper.ModifyRowStyle(weekNoteView, "CurrentWeekRowStyle");

            this.ChangeTaskCompletionVisibility();

            this.AddWeekNotesOnPlan();
        }
示例#8
0
        protected override void OnUIGenerated(ControlResult ui)
        {
            base.OnUIGenerated(ui);

            var listView = this.ListView;

            //默认发起一次查询。
            var queryView = listView.ConditionQueryView;
            if (queryView != null) queryView.TryExecuteQuery();

            listView.IsReadOnly = ReadOnlyStatus.ReadOnly;

            //列表双击时,弹出查看窗口
            listView.Control.MouseDoubleClick += (o, e) =>
            {
                var cmd = listView.Commands.Find<ShowBill>();
                if (cmd != null) { cmd.TryExecute(); }
            };
        }
示例#9
0
        /// <summary>
        /// 为聚合对象生成组合控件。
        /// </summary>
        /// <param name="aggt">
        /// 需要生成聚合控件的聚合对象元数据
        /// </param>
        /// <param name="mainView">
        /// 已经生成好的聚合对象 aggt 中的“根”对象所对应的 LogicalView。
        /// </param>
        /// <returns></returns>
        private ControlResult GenerateCompoundControl(AggtBlocks aggt, LogicalView mainView)
        {
            var regions = new RegionContainer(aggt);

            //如果不要查询面板,则需要生成主区域
            var viewInfo = aggt.MainBlock.ViewMeta;

            regions.Add(TraditionalRegions.Main, AutoUIHelper.CreateBusyControlResult(mainView));
            if (mainView.CommandsContainer != null)
            {
                regions.Add(TraditionalRegions.CommandsContainer, new ControlResult(mainView.CommandsContainer, mainView));
            }

            //Surrounders
            this.SurroundersToRegions(aggt.Surrounders, mainView, regions);

            //Children
            this.ChildrenToRegions(aggt.Children, mainView, regions);

            //Layout
            var layout = CreateLayoutMethod(aggt);
            var result = layout.Arrange(regions);

            //在 View 中保存最终布局完成的控件。
            mainView.LayoutControl = result;

            //返回布局后的整个控件。
            var ui = new ControlResult(result, mainView, aggt);

            if (this.GesturesLocation == GesturesLocation.Layout)
            {
                this.CreateCommandBindings(ui.Control, ui.MainView);
            }

            return(ui);
        }
示例#10
0
        /// <summary>
        /// 构造模块的窗口
        /// </summary>
        /// <param name="moduleMeta"></param>
        public WorkspaceWindow CreateModule(WPFModuleMeta moduleMeta)
        {
            if (moduleMeta == null)
            {
                throw new ArgumentNullException("moduleMeta");
            }

            //创建 WorkspaceWindow
            var window = new ModuleWorkspaceWindow
            {
                ModuleMeta = moduleMeta,
                Title      = moduleMeta.Label
            };

            var args = new ModuleEventArgs(window);

            if (!moduleMeta.IsCustomUI)
            {
                try
                {
                    AutoUI.AggtUIFactory.PermissionModule = moduleMeta;

                    ControlResult ui = null;
                    //在 WPF 中,TemplateType 属性应该是继承自 UITemplate 的类,表示使用的自定义实体模块类型
                    if (moduleMeta.BlocksTemplate != null)
                    {
                        var module = Activator.CreateInstance(moduleMeta.BlocksTemplate) as UITemplate;
                        if (module == null)
                        {
                            throw new InvalidProgramException("WPF 中模板类需要从 UITemplate 类继承。");
                        }
                        window.Template            = module;
                        window.Template.EntityType = moduleMeta.EntityType;
                        this.OnModuleTemplateCreated(args);

                        window.Blocks = module.GetBlocks();
                        this.OnModuleBlocksCreated(args);

                        ui = module.CreateUI(window.Blocks);
                    }
                    else
                    {
                        AggtBlocks blocks = UIModel.AggtBlocks.GetModuleBlocks(moduleMeta);
                        window.Blocks = blocks;

                        this.OnModuleBlocksCreated(args);
                        ui = AutoUI.AggtUIFactory.GenerateControl(blocks);
                    }
                    window.WindowControl = ui.Control;
                    window.MainView      = ui.MainView;

                    Focus(ui);

                    //刚创建的窗体,尝试加载数据。
                    if (moduleMeta.TryAutoLoadData)
                    {
                        this.AsyncLoadListData(ui);
                    }
                }
                finally
                {
                    AutoUI.AggtUIFactory.PermissionModule = null;
                }
            }
            else
            {
                window.WindowControl = Activator.CreateInstance(moduleMeta.CustomUI) as FrameworkElement;
                if (window.WindowControl == null)
                {
                    throw new InvalidProgramException(moduleMeta.CustomUI + " 类型必须是一个 FrameworkElement。");
                }
            }

            AutomationProperties.SetName(window.WindowControl, moduleMeta.Label);

            this.OnModuleCreated(args);

            return(window);
        }
示例#11
0
 public UIGeneratedEventArgs(ControlResult ui)
 {
     this.UI = ui;
 }
示例#12
0
 public ChildUICreatedEventArgs(ControlResult childUI)
 {
     this.ChildUI = childUI;
 }
示例#13
0
 public UIGeneratedEventArgs(ControlResult ui)
 {
     this.UI = ui;
 }
示例#14
0
 /// <summary>
 /// 子类可以重写此方法来添加当前模块中 UI 的初始化逻辑。
 /// 
 /// 当使用自动生成的 UI 时,此方法会被调用。
 /// </summary>
 /// <param name="ui"></param>
 protected internal virtual void OnUIGenerated(ControlResult ui)
 {
     var handler = this.UIGenerated;
     if (handler != null) handler(this, new UIGeneratedEventArgs(ui));
 }
示例#15
0
 /// <summary>
 /// 自动加载列表的数据
 /// </summary>
 /// <param name="ui"></param>
 private void AsyncLoadListData(ControlResult ui)
 {
     //如果是个列表,并且没有导航面板,则默认开始查询数据
     var listView = ui.MainView as ListLogicalView;
     if (listView != null &&
         listView.ConditionQueryView == null &&
         listView.NavigationQueryView == null
         )
     {
         listView.DataLoader.LoadDataAsync();
     }
 }
示例#16
0
 /// <summary>
 /// 把焦点定位到第一个编辑器上
 /// </summary>
 /// <param name="ui"></param>
 private static void Focus(ControlResult ui)
 {
     ui.Control.Loaded += (o, e) =>
     {
         var mainView = ui.MainView;
         var focusedDetailView = mainView.FocusFirstEditor();
         if (focusedDetailView == null)
         {
             mainView.Control.Focus();
         }
     };
 }
示例#17
0
 /// <summary>
 /// 添加一个控件到孩子区域集合中。
 /// </summary>
 /// <param name="control"></param>
 public void AddChildren(string label, ControlResult control)
 {
     this._regions.Add(new Region(TraditionalRegions.Children, label, control));
 }
示例#18
0
 /// <summary>
 /// 添加一个控件到区域集合中。
 /// </summary>
 /// <param name="regionName"></param>
 /// <param name="control"></param>
 public void Add(string regionName, ControlResult control)
 {
     this._regions.Add(new Region(regionName, control));
 }
示例#19
0
        /// <summary>
        /// 为聚合对象生成组合控件。
        /// </summary>
        /// <param name="aggt">
        /// 需要生成聚合控件的聚合对象元数据
        /// </param>
        /// <param name="mainView">
        /// 已经生成好的聚合对象 aggt 中的“根”对象所对应的 LogicalView。
        /// </param>
        /// <returns></returns>
        private ControlResult GenerateCompoundControl(AggtBlocks aggt, LogicalView mainView)
        {
            var regions = new RegionContainer(aggt);

            //如果不要查询面板,则需要生成主区域
            var viewInfo = aggt.MainBlock.ViewMeta;

            regions.Add(TraditionalRegions.Main, AutoUIHelper.CreateBusyControlResult(mainView));
            if (mainView.CommandsContainer != null)
            {
                regions.Add(TraditionalRegions.CommandsContainer, new ControlResult(mainView.CommandsContainer, mainView));
            }

            //Surrounders
            this.SurroundersToRegions(aggt.Surrounders, mainView, regions);

            //Children
            this.ChildrenToRegions(aggt.Children, mainView, regions);

            //Layout
            var layout = CreateLayoutMethod(aggt);
            var result = layout.Arrange(regions);

            //在 View 中保存最终布局完成的控件。
            mainView.LayoutControl = result;

            //返回布局后的整个控件。
            var ui = new ControlResult(result, mainView, aggt);

            if (this.GesturesLocation == GesturesLocation.Layout)
            {
                this.CreateCommandBindings(ui.Control, ui.MainView);
            }

            return ui;
        }
示例#20
0
 public ChildUICreatedEventArgs(ControlResult childUI)
 {
     this.ChildUI = childUI;
 }
示例#21
0
 /// <summary>
 /// 子类重写此方法实现自己的弹窝逻辑。
 /// </summary>
 /// <param name="ui"></param>
 /// <returns></returns>
 protected virtual WindowButton PopupSelectionWindow(ControlResult ui)
 {
     return App.Windows.ShowDialog(ui.Control, w =>
     {
         w.Title = this.Meta.Label.Translate();
     });
 }
示例#22
0
 protected virtual void OnChildUICreated(ControlResult childUI)
 {
     var handler = this.ChildUICreated;
     if (handler != null) handler(this, new ChildUICreatedEventArgs(childUI));
 }