zoukankan      html  css  js  c++  java
  • XAF 如何扩展应用程序模型<二> 编辑ListView自动保存

     

    using System;
    using System.ComponentModel;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Text;

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Actions;
    using DevExpress.Persistent.Base;
    using DevExpress.ExpressApp.Model;
    using DevExpress.ExpressApp.Win.SystemModule;

    namespace XafExtendTest.Module.SystemModule
    {
        
    public interface IModelClassAutoCommitListView : IModelNode
        {
            [Category(
    "MyCustomProperty")]
            [Description(
    "Control if change on editable listview will be autocommited")]
            
    bool AutoCommitListview { getset; }
        }
        [ModelInterfaceImplementor(
    typeof(IModelClassAutoCommitListView),"ModelClass")]
        
    public interface IModelListViewAutoCommitListView : IModelClassAutoCommitListView
        {
        }
        
    public class AutoCommitListViewController : ViewController<ListView>,IModelExtender
        {
            
    protected override void OnViewControllersActivated()
            {
                
    base.OnActivated();
                var winDetailViewController 
    = Frame.GetController<WinDetailViewController>();
                
    if (winDetailViewController != null && ((IModelListViewAutoCommitListView)View.Model).AutoCommitListview)
                {
                    winDetailViewController.AutoCommitListView 
    = true;
                    View.QueryCanChangeCurrentObject 
    += View_QueryCanChangeCurrentObject;
                }
            }

            
    void View_QueryCanChangeCurrentObject(object sender, CancelEventArgs e)
            {
                
    if(Frame.GetController<WinDetailViewController>().SuppressConfirmation)
                    ObjectSpace.CommitChanges();
            }

            
    protected override void OnDeactivated()
            {
                
    base.OnDeactivated();
                var winDetailViewController 
    = Frame.GetController<WinDetailViewController>();
                
    if (winDetailViewController != null && ((IModelListViewAutoCommitListView)View.Model).AutoCommitListview)
                {
                    winDetailViewController.AutoCommitListView 
    = true;
                    View.QueryCanChangeCurrentObject 
    -= View_QueryCanChangeCurrentObject;
                }
            }
            
    void IModelExtender.ExtendModelInterfaces(ModelInterfaceExtenders extenders)
            {
                extenders.Add
    <IModelClass, IModelClassAutoCommitListView>();
                extenders.Add
    <IModelListView, IModelListViewAutoCommitListView>();
            }
        }
    }

     欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/

  • 相关阅读:
    [AS3]AMF3+JAVA的调用范例
    SmartFoxServer,多人flash游戏开发
    Flex2 发现之旅:在Flex中嵌入完整HTML页面
    让.Net 程序脱离.net framework框架运行
    ASP.NET 数据列表控件的分页总结
    中国移动飞信免费发短信API接口(第三方 Fetion API)[原创]
    Ubuntu下安装wine详细介绍
    SQL SERVER 2008 R2 序列号大全
    linux 下安装ATI 显卡驱动
    jdk 环境变量设置
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/1924739.html
Copyright © 2011-2022 走看看