public void Register(object dataList) { IDataListView handler = FactoryCatalog.GetFactory(dataList).GetAdapter(dataList); views.Add(dataList, handler); Register(handler); }
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; } }
// Отображает форму в зависимости от типа действия (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); }
// Возвращает дочернее 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); }
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(); // 更新相关命令项的状态 }
// Отображает форму в зависимости от типа сущности и типа действия (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; } }
/// <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)); }
/// <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)); }
public CompanyForm(ActionType type, ICompany entity, IDataListView <ICompany> viewContext) : base(type, entity, viewContext) { InitializeComponent(); }
public void UnRegister(IDataListView handler) { Guard.ArgumentNotNull(handler, "Data grid view handler"); handler.Enter -= OnEnter; handler.Leave -= OnLeave; }
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; }
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) { }
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; }
public BaseVacancyForm(ActionType type, IVacancy entity, IDataListView <IVacancy> viewContext) : base(type, entity, viewContext) { }
public FacultyForm(MainMDIForm main, ActionType type, IFaculty entity, IDataListView <IFaculty> viewContext) : base(type, entity, viewContext) { InitializeComponent(); this.Main = main; }
public BasePreferentialCategory(ActionType type, IPreferentialCategory entity, IDataListView <IPreferentialCategory> viewContext) : base(type, entity, viewContext) { }
/// <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; }
// Отображает дочернее 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); }
public BaseCompanyForm(ActionType type, ICompany entity, IDataListView <ICompany> viewContext) : base(type, entity, viewContext) { }
public VacancyForm(ActionType type, IVacancy entity, IDataListView <IVacancy> viewContext) : base(type, entity, viewContext) { InitializeComponent(); }
public StudentForm(ActionType type, IStudent entity, IDataListView <IStudent> viewContext) : base(type, entity, viewContext) { InitializeComponent(); }