Ejemplo n.º 1
0
        public void Register(object dataList)
        {
            IDataListView handler = FactoryCatalog.GetFactory(dataList).GetAdapter(dataList);

            views.Add(dataList, handler);
            Register(handler);
        }
Ejemplo n.º 2
0
        public MainFormPresenter(IMainFormView mainFormView,
                                 IDataListView employeesDataListView,
                                 IDataListView tasksDataListView,
                                 IDataListView assignedTasksDataListView,
                                 ISystemInformationService systemInformationService,
                                 IMenuCommand[] commands)
        {
            this.mainFormView = mainFormView;
            this.commands     = commands;

            menuView = mainFormView.MenuView;
            menuView.SetCommands(commands);

            employeesDataListView = mainFormView.EmployeesDataListView;
            employeesDataListView.SetTitle(MenuOption.Employees.GetAttribute <MenuOptionAttribute>().Name);
            employeesDataListView.SetTag(MenuOption.Employees);
            employeesDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            tasksDataListView = mainFormView.TasksDataListView;
            tasksDataListView.SetTitle(MenuOption.Tasks.GetAttribute <MenuOptionAttribute>().Name);
            tasksDataListView.SetTag(MenuOption.Tasks);
            tasksDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            assignedTasksDataListView = mainFormView.AssignedTasksDataListView;
            assignedTasksDataListView.SetTitle(MenuOption.AssignedTasks.GetAttribute <MenuOptionAttribute>().Name);
            assignedTasksDataListView.SetTag(MenuOption.AssignedTasks);
            assignedTasksDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            mainFormView.KeyUp += MainFormViewOnKeyUp;

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                mainFormView.BackColor = Color.White;
            }
        }
Ejemplo n.º 3
0
        // Отображает форму в зависимости от типа действия (ActionType).
        public void ShowFormByActionType <U, T>(ActionType type, U entity, IDataListView <U> viewContext) where U : class, IIdentifiable where T : MDIChild <U>
        {
            if (type == ActionType.View)
            {
                ShowViewDialog <U, T>(entity);
                return;
            }

            ShowMDIChild <U, T>(entity, type, viewContext);
        }
Ejemplo n.º 4
0
        // Возвращает дочернее MDI окно в зависимости от значений переданных параметров.
        private T GetMDIChild <U, T>(U entity, ActionType type, IDataListView <U> viewContext) where U : class, IIdentifiable where T : MDIChild <U>
        {
            var form = this.MdiChildren.FirstOrDefault(i => (i is MDIChild <U>) && (i as MDIChild <U>).Type == type && (i as MDIChild <U>).ID == entity?.ID) as T;

            if (form == null)
            {
                form = Activator.CreateInstance(typeof(T), new object[] { type, entity, viewContext }) as T;
            }

            return(form);
        }
Ejemplo n.º 5
0
        private void OnEnter(object sender, EventArgs e)
        {
            Microsoft.Practices.CompositeUI.Utility.Guard.TypeIsAssignableFromType(sender.GetType(), typeof(IDataListView), "sender");

            // 获得当前视图的控制器
            handler = null;
            IDataListView view = sender as IDataListView;

            if (view != null)
            {
                handler = view.DataListHandler;
            }
            UpdateCommandStatus(); // 更新相关命令项的状态
        }
Ejemplo n.º 6
0
        // Отображает форму в зависимости от типа сущности и типа действия (ActionType).
        public void ShowFormByType <U>(ActionType type, U entity, IDataListView <U> viewContext = null) where U : class, IIdentifiable
        {
            var nullEntity = typeof(U);

            if (entity is IVacancy || nullEntity == typeof(IVacancy))
            {
                ShowFormByActionType <IVacancy, VacancyForm>(type, entity as IVacancy, viewContext as IDataListView <IVacancy>);
                return;
            }

            if (entity is IStudent || nullEntity == typeof(IStudent))
            {
                ShowFormByActionType <IStudent, StudentForm>(type, entity as IStudent, viewContext as IDataListView <IStudent>);
                return;
            }

            if (entity is ICompany || nullEntity == typeof(ICompany))
            {
                ShowFormByActionType <ICompany, CompanyForm>(type, entity as ICompany, viewContext as IDataListView <ICompany>);
                return;
            }

            if (entity is IStudentCompany || nullEntity == typeof(IStudentCompany))
            {
                ShowFormByActionType <IStudentCompany, StudentCompanyForm>(type, entity as IStudentCompany, viewContext as IDataListView <IStudentCompany>);
                return;
            }

            if (entity is ISpecialization || typeof(ISpecialization).IsAssignableFrom(nullEntity))
            {
                var form = new SpecializationForm(this, type, entity as ISpecialization, viewContext as IDataListView <ISpecialization>);
                form.ShowDialog();
                return;
            }

            if (entity is IFaculty || typeof(IFaculty).IsAssignableFrom(nullEntity))
            {
                var form = new FacultyForm(this, type, entity as IFaculty, viewContext as IDataListView <IFaculty>);
                form.ShowDialog();
                return;
            }

            if (entity is IPreferentialCategory || typeof(IPreferentialCategory).IsAssignableFrom(nullEntity))
            {
                var form = new PreferentialCategoryForm(this, type, entity as IPreferentialCategory, viewContext as IDataListView <IPreferentialCategory>);
                form.ShowDialog();
                return;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// See <see cref="IBuilderStrategy.TearDown"/> for more information.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public override object TearDown(IBuilderContext context, object item)
        {
            WorkItem workItem = StrategyUtility.GetWorkItem(context, item);

            if (workItem != null)
            {
                IDataListViewService dataService = workItem.Services.Get <IDataListViewService>();

                if (dataService != null && item is IDataListView)
                {
                    IDataListView handler = item as IDataListView;
                    dataService.UnRegister(handler);
                }
            }

            return(base.TearDown(context, item));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// See <see cref="IBuilderStrategy.BuildUp"/> for more information.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="typeToBuild"></param>
        /// <param name="existing"></param>
        /// <param name="idToBuild"></param>
        /// <returns></returns>
        public override object BuildUp(IBuilderContext context, Type typeToBuild, object existing, string idToBuild)
        {
            WorkItem workItem = StrategyUtility.GetWorkItem(context, existing);

            if (workItem != null)
            {
                IDataListViewService dataService = workItem.Services.Get <IDataListViewService>();

                // 如果视图实现了数据列表服务则在系统中注册它
                if (dataService != null && existing is IDataListView)
                {
                    IDataListView handler = existing as IDataListView;
                    dataService.Register(handler);
                }
            }

            return(base.BuildUp(context, typeToBuild, existing, idToBuild));
        }
Ejemplo n.º 9
0
 public CompanyForm(ActionType type, ICompany entity, IDataListView <ICompany> viewContext) : base(type, entity, viewContext)
 {
     InitializeComponent();
 }
Ejemplo n.º 10
0
 public void UnRegister(IDataListView handler)
 {
     Guard.ArgumentNotNull(handler, "Data grid view handler");
     handler.Enter -= OnEnter;
     handler.Leave -= OnLeave;
 }
Ejemplo n.º 11
0
 public void Register(IDataListView handler)
 {
     Guard.ArgumentNotNull(handler, "Data grid view handler");
     handler.Enter += new EventHandler(OnEnter);
     handler.Leave += new EventHandler(OnLeave);
 }
        public PreferentialCategoryForm(MainMDIForm main, ActionType type, IPreferentialCategory entity, IDataListView <IPreferentialCategory> viewContext) : base(type, entity, viewContext)
        {
            InitializeComponent();

            this.Main = main;
        }
Ejemplo n.º 13
0
 public BaseFacultyForm(ActionType type, IFaculty entity, IDataListView <IFaculty> viewContext) : base(type, entity, viewContext)
 {
 }
 public BaseSpecializationForm(ActionType type, ISpecialization entity, IDataListView <ISpecialization> viewContext) : base(type, entity, viewContext)
 {
 }
Ejemplo n.º 15
0
 public BaseStudentForm(ActionType type, IStudent entity, IDataListView <IStudent> viewContext) : base(type, entity, viewContext)
 {
 }
        /// <summary>
        /// Предоставляет модальное окно для редактирования (добавления) информации о профиле подготовки.
        /// </summary>
        /// <param name="main">Главное окно программы</param>
        /// <param name="type">Тип действия (редактирование или добавление)</param>
        /// <param name="entity">Экземпляр класса, реализующего интерфейс <c>ISpecialization</c></param>
        /// <param name="viewContext">Экземпляр класса, реализующего интерфейс <c>IDataListView</c></param>
        public SpecializationForm(MainMDIForm main, ActionType type, ISpecialization entity, IDataListView <ISpecialization> viewContext) : base(type, entity, viewContext)
        {
            InitializeComponent();

            this.Main = main;
        }
Ejemplo n.º 17
0
 public BaseVacancyForm(ActionType type, IVacancy entity, IDataListView <IVacancy> viewContext) : base(type, entity, viewContext)
 {
 }
Ejemplo n.º 18
0
        public FacultyForm(MainMDIForm main, ActionType type, IFaculty entity, IDataListView <IFaculty> viewContext) : base(type, entity, viewContext)
        {
            InitializeComponent();

            this.Main = main;
        }
Ejemplo n.º 19
0
 public BasePreferentialCategory(ActionType type, IPreferentialCategory entity, IDataListView <IPreferentialCategory> viewContext) : base(type, entity, viewContext)
 {
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Предоставляет класс, содержащий методы, предназначенные для дочерних MDI окон для редактирования, удаления, просмотра и добавления данных.
 /// </summary>
 /// <param name="type">Тип действия</param>
 /// <param name="entity">Объект сущности</param>
 /// <param name="viewContext">Контекст из которого был открыт данный экземпляр окна.</param>
 public MDIChild(ActionType type, T entity, IDataListView <T> viewContext) : this(type, entity)
 {
     this.ViewContext = viewContext;
 }
Ejemplo n.º 21
0
 public void Register(IDataListView handler)
 {
     Guard.ArgumentNotNull(handler, "Data grid view handler");
     handler.Enter += new EventHandler(OnEnter);
     handler.Leave += new EventHandler(OnLeave);
 }
Ejemplo n.º 22
0
        // Отображает дочернее MDI окно для редактирования / добавления записей.
        public void ShowMDIChild <U, T>(U entity, ActionType type, IDataListView <U> viewContext) where U : class, IIdentifiable where T : MDIChild <U>
        {
            var form = GetMDIChild <U, T>(entity, type, viewContext);

            ShowFormAsMDIChild(form);
        }
Ejemplo n.º 23
0
 public void UnRegister(IDataListView handler)
 {
     Guard.ArgumentNotNull(handler, "Data grid view handler");
     handler.Enter -= OnEnter;
     handler.Leave -= OnLeave;
 }
Ejemplo n.º 24
0
 public BaseCompanyForm(ActionType type, ICompany entity, IDataListView <ICompany> viewContext) : base(type, entity, viewContext)
 {
 }
Ejemplo n.º 25
0
 public VacancyForm(ActionType type, IVacancy entity, IDataListView <IVacancy> viewContext) : base(type, entity, viewContext)
 {
     InitializeComponent();
 }
Ejemplo n.º 26
0
 public StudentForm(ActionType type, IStudent entity, IDataListView <IStudent> viewContext) : base(type, entity, viewContext)
 {
     InitializeComponent();
 }