private static MVCController <TEntity> GenerateSearchMVCController <TViewer>(TViewer viewerToShow, ViewerName viewerName,
                                                                                     AbstractViewerType viewerType) where TViewer : IViewer
        {
            MVCSearchController =
                (MVCController <TEntity>)MVCControllerFactory.GetControllerFactory <TEntity>(viewerName, viewerToShow);

            return(MVCSearchController);
        }
Esempio n. 2
0
        public void ShowRelatedViewers(bool show)
        {
            lytlSubViewerContainer.Visibility =
                lytSepertator.Visibility      = show ? LayoutVisibility.Always : LayoutVisibility.Never;

            CommonAbstractEditorViewer <TEntity> editorViewer = (CommonAbstractEditorViewer <TEntity>)_editorViewer;

            if (editorViewer == null)
            {
                return;
            }
            RelatedViewers = editorViewer.GetRelatedViewers();

            if (RelatedViewers != null && RelatedViewers.Count > 0)
            {
                _CommonTabControl = new CommonTabControl_UC <TEntity>(BaseControllerObject);
                BaseControllerObject.EnableRelatedViewersButton(true);

                ParentMVCController.List_ChildrenControllers = new List <IMVCController <TEntity> >();

                foreach (IViewer relatedViewer in RelatedViewers)
                {
                    _tabControl = InitiaizeRelatedViewer(relatedViewer, pageIndex);

                    #region Initialize the Suitable MVC Controller

                    ParentMVCController.List_ChildrenControllers.Add(
                        (MVCController <TEntity>)
                        MVCControllerFactory.GetControllerFactory <TEntity>((ViewerName)relatedViewer.ViewerID, relatedViewer));

                    foreach (var mvcController in ParentMVCController.List_ChildrenControllers)
                    {
                        mvcController.BeforeCreatingNew();
                        mvcController.CreateNew();
                        mvcController.AfterCreateNew();
                        mvcController.ParentController = ParentMVCController;
                        mvcController.ActiveCollector.ParentActiveCollector = ParentMVCController.ActiveCollector;
                        mvcController.ActiveCollector.ParentActiveDBItem    =
                            (IDBCommon)mvcController.ParentController.ActiveCollector.ActiveDBItem;
                    }

                    #endregion

                    pageIndex++;
                }
            }

            if (_tabControl != null)
            {
                pnlSubViewerContainer.Controls.Add(_CommonTabControl);
                _CommonTabControl.Dock     = DockStyle.Fill;
                pnlSubViewerContainer.Dock = DockStyle.Fill;
                _tabControl.Dock           = DockStyle.Fill;
            }
        }
        private static MVCController <TEntity> GenerateEditorMVCController <TViewer>(TViewer viewerToShow, IDBCommon dbObjectToLoad,
                                                                                     EditorContainerType editorContainerType, ViewerName viewerName,
                                                                                     AbstractViewerType viewerType) where TViewer : IViewer
        {
            MVCEditorController =
                (MVCController <TEntity>)MVCControllerFactory.GetControllerFactory <TEntity>(viewerName, viewerToShow);

            switch (editorContainerType)
            {
            case EditorContainerType.Settings:
                if (MVCEditorController != null && BaseControllerObject != null && viewerType != AbstractViewerType.SearchViewer &&
                    (_baseEditorContainer != null || _baseSearchContainer != null))
                {
                    MVCEditorController.BeforeCreatingNew();
                    MVCEditorController.CreateNew();
                    MVCEditorController.AfterCreateNew();
                }

                break;

            case EditorContainerType.Regular:
                if (MVCEditorController != null)
                {
                    if (dbObjectToLoad != null)
                    {
                        MVCEditorController.BeforeEdit(dbObjectToLoad);
                        MVCEditorController.Edit(dbObjectToLoad);
                        MVCEditorController.AfterEdit(dbObjectToLoad);
                    }
                    else
                    {
                        MVCEditorController.BeforeCreatingNew();
                        MVCEditorController.CreateNew();
                        if (MVCEditorController.ActiveCollector.ActiveDBItem is TEntity)
                        {
                            ActiveDBEntity = (TEntity)MVCEditorController.ActiveCollector.ActiveDBItem;
                        }
                        MVCEditorController.AfterCreateNew();
                    }
                }

                break;
            }

            return(MVCEditorController);
        }