private void Initialize(WindowInfo windowInfo)
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList<WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);
            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager smMaster = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(tabInfos[0], null);
            IWindowControlManager cmMaster = ServiceProvider.GetService<IManagerFactory>().GenerateControlManager(tabInfos[0], smMaster) as IWindowControlManager;

            IBaseDao daoParent = ServiceProvider.GetService<IManagerFactory>().GenerateBusinessLayer(tabInfos[0]);
            cmMaster.Dao = daoParent;

            ((IArchiveGrid)base.MasterGrid).SetControlManager(cmMaster, tabInfos[0].GridName);

            // daoParent's subDao is inserted in detailForm
            if (base.MasterGrid is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids(base.MasterGrid as IBoundGridWithDetailGridLoadOnDemand, tabInfos[0]);
            }

            // Load Additional Menus
            IList<WindowMenuInfo> windowMenuInfos = ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name);
            IList<WindowMenuInfo> masterWindowMenuInfos;
            IList<WindowMenuInfo> detailWindowMenuInfos;
            GeneratedArchiveSeeForm.SplitWindowMenu(windowMenuInfos, out masterWindowMenuInfos, out detailWindowMenuInfos);
            if (masterWindowMenuInfos.Count > 0)
            {
                this.GenerateWindowMenu(masterWindowMenuInfos);
            }

            if (windowInfo.GenerateDetailForm)
            {
                if (windowInfo.DetailForm != null)
                {
                    m_detailForm = ArchiveFormFactory.CreateForm(ADInfoBll.Instance.GetFormInfo(windowInfo.DetailForm.Name)) as IArchiveDetailForm;
                    if (windowInfo.DetailWindow == null)
                    {
                        ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, cmMaster, daoParent, null, m_detailForm);
                    }
                }
                // 和主窗体不关联
                else if (windowInfo.DetailWindow != null)
                {
                    WindowInfo detailWindowInfo = ADInfoBll.Instance.GetWindowInfo(windowInfo.DetailWindow.Name);
                    m_detailForm = ServiceProvider.GetService<IWindowFactory>().CreateWindow(detailWindowInfo) as IArchiveDetailForm;
                    var searchWindow = m_detailForm.GetCustomProperty(MyChildForm.SearchPanelName) as ArchiveSearchForm;
                    if (searchWindow != null)
                    {
                        searchWindow.EnableProgressForm = false;
                    }
                }
                else
                {
                    m_detailForm = ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, cmMaster, daoParent as IRelationalDao);
                }

                if (m_detailForm != null)
                {
                    //m_detailWindow.ParentArchiveForm = this;
                    // Generate DetailForm's Menu
                    if (detailWindowMenuInfos.Count > 0)
                    {
                        m_detailForm.GenerateWindowMenu(detailWindowMenuInfos);

                        m_detailForm.VisibleChanged += new EventHandler(m_detailForm_VisibleChanged);
                    }
                }
            }

            ArchiveSearchForm searchForm = null;
            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                    if (cmMaster != null)
                    {
                        cmMaster.StateControls.Add(searchForm);
                    }
                }
                return searchForm;
            });

            m_attachmentForm = GeneratedArchiveSeeForm.CreateAttachmentWindow(this, windowInfo);

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            m_windowInfo = windowInfo;
        }
        private void Initialize(WindowInfo windowInfo)
        {
            this.Name = windowInfo.Name;
            this.Text = windowInfo.Text;

            IList<WindowTabInfo> tabInfos = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);
            if (tabInfos == null)
            {
                throw new ArgumentException("there is no windowTab with windowId of " + windowInfo.Name);
            }
            if (tabInfos.Count == 0)
            {
                throw new ArgumentException("There should be at least one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }
            if (tabInfos.Count > 1)
            {
                throw new ArgumentException("There should be at most one TabInfo in WindowInfo with name is " + windowInfo.Name + "!");
            }

            ISearchManager smMaster = ServiceProvider.GetService<IManagerFactory>().GenerateSearchManager(tabInfos[0], null);

            IDisplayManager dmMaster = ServiceProvider.GetService<IManagerFactory>().GenerateDisplayManager(tabInfos[0], smMaster);

            (base.MasterGrid as IBoundGrid).SetDisplayManager(dmMaster, tabInfos[0].GridName);

            if (base.MasterGrid is IBoundGridWithDetailGridLoadOnDemand)
            {
                ArchiveFormFactory.GenerateDetailGrids((IBoundGridWithDetailGridLoadOnDemand)base.MasterGrid, tabInfos[0]);
            }

            // Load Additional Menus
            IList<WindowMenuInfo> windowMenuInfos = ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name);
            IList<WindowMenuInfo> masterWindowMenuInfos;
            IList<WindowMenuInfo> detailWindowMenuInfos;
            GeneratedArchiveSeeForm.SplitWindowMenu(windowMenuInfos, out masterWindowMenuInfos, out detailWindowMenuInfos);
            if (masterWindowMenuInfos.Count > 0)
            {
                this.GenerateWindowMenu(masterWindowMenuInfos);
            }

            if (windowInfo.GenerateDetailForm)
            {
                // 自定义窗体
                if (windowInfo.DetailForm != null)
                {
                    m_detailForm = ArchiveFormFactory.CreateForm(ADInfoBll.Instance.GetFormInfo(windowInfo.DetailForm.Name)) as IArchiveDetailForm;
                    if (windowInfo.DetailWindow == null)
                    {
                        ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, null, null, dmMaster, m_detailForm);
                    }
                }
                // 跟主DisplayManager无关的DetailForm
                else if (windowInfo.DetailWindow != null)
                {
                    WindowInfo detailWindowInfo = ADInfoBll.Instance.GetWindowInfo(windowInfo.DetailWindow.Name);
                    m_detailForm = ServiceProvider.GetService<IWindowFactory>().CreateWindow(detailWindowInfo) as IArchiveDetailForm;
                    var searchWindow = m_detailForm.GetCustomProperty(MyChildForm.SearchPanelName) as ArchiveSearchForm;
                    if (searchWindow != null)
                    {
                        searchWindow.EnableProgressForm = false;
                    }
                }
                else
                {
                    // 当DetailFormId有值的时候,不一定是DetailForm,而只是其中的一部分
                    // 和主表一致的明细窗体
                    m_detailForm = ArchiveFormFactory.GenerateArchiveDetailForm(windowInfo, dmMaster);
                }
                if (m_detailForm != null)
                {
                    //m_detailWindow.ParentArchiveForm = this;
                    //m_detailWindow = m_detailWindow;

                    // Generate DetailForm's Menu
                    if (detailWindowMenuInfos.Count > 0)
                    {
                        m_detailForm.GenerateWindowMenu(detailWindowMenuInfos);
                        m_detailForm.VisibleChanged += new EventHandler(m_detailForm_VisibleChanged);
                    }
                }
            }

            ArchiveSearchForm searchForm = null;
            this.SetSearchPanel(() =>
            {
                if (searchForm == null)
                {
                    searchForm = new ArchiveSearchForm(this, smMaster, tabInfos[0]);
                }
                return searchForm;
            });

            m_attachmentForm = CreateAttachmentWindow(this, windowInfo);

            GeneratedArchiveSeeForm.InitializeWindowProcess(windowInfo, this);

            m_windowInfo = windowInfo;
        }