public virtual EntityViewer GetViewer <TEntity>() where TEntity : class, IEntity, new() { IEntityQueryable <TEntity> context = EntityBuilder.GetContext <TEntity>(); EntityMetadata metadata = EntityAnalyzer.GetMetadata <TEntity>(); EntityViewModel <TEntity> model = new EntityViewModel <TEntity>(context.OrderBy()); model.Headers = metadata.ViewProperties; model.UpdateItems(); EntityViewer viewer = new EntityViewer(this); viewer.Model = model; WpfViewButton createButton = new WpfViewButton(); createButton.Name = "Create"; createButton.Command = new EntityCommand(new EntityCommand.ExecuteDelegate(t => { viewer.NavigationService.Navigate(GetEditor <TEntity>(context.Create())); })); model.Buttons = new EntityViewButton[] { createButton }; return(viewer); }
public virtual async Task <EntityViewer> GetViewer() { EntityViewModel <TEntity> model = await GetViewModel(EntityQueryable.OrderBy(), 1, 20); EntityViewer viewer = new EntityViewer(); viewer.Model = model; return(viewer); }
private static void ModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EntityViewer viewer = (EntityViewer)d; if (e.NewValue == null) { viewer.NavigatePageCommand = null; viewer.ChangePageSizeCommand = null; } else { viewer.NavigatePageCommand = new NavigatePageCommand((EntityViewModel)e.NewValue); viewer.ChangePageSizeCommand = new ChangePageSizeCommand((EntityViewModel)e.NewValue); } }
private static void ModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { EntityViewer viewer = (EntityViewer)d; if (e.NewValue == null) { viewer.NavigatePageCommand = null; viewer.ChangePageSizeCommand = null; viewer.EntityViewCommand = null; viewer.EntityItemCommand = null; } else { IEntityViewModel model = (IEntityViewModel)e.NewValue; viewer.NavigatePageCommand = new ViewerNavigatePageCommand(viewer.ServiceProvider); viewer.ChangePageSizeCommand = new ViewerChangePageSizeCommand(viewer.ServiceProvider); viewer.EntityViewCommand = new ViewerEntityViewCommand(viewer.ServiceProvider); viewer.EntityItemCommand = new ViewerEntityItemCommand(viewer.ServiceProvider); viewer.Title = "列表 " + model.Metadata.Name; } }
public void SetTarget(IServiceProvider provider) { EntityViewer viewer = (EntityViewer)provider.GetService(typeof(EntityViewer)); InvokeDelegate = GetInvokeDelegate(viewer); }
public ViewerNavigatePageCommand(IServiceProvider serviceProvider) : base(serviceProvider) { _Viewer = (EntityViewer)serviceProvider.GetService(typeof(EntityViewer)); }
public ViewerChangePageSizeCommand(IServiceProvider serviceProvider) : base(serviceProvider) { _Viewer = (EntityViewer)serviceProvider.GetService(typeof(EntityViewer)); }