|
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using Signum.Entities;
using System.Windows.Threading;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Signum.Utilities.DataStructures;
using Signum.Utilities;
namespace Signum.Windows
{
public partial class AdminWindow: AdminBase
{
public static readonly DependencyProperty MainControlProperty =
DependencyProperty.Register("MainControl", typeof(Control), typeof(AdminWindow), new UIPropertyMetadata((d,e)=>((AdminWindow)d).MainControlChanged(e)));
public Control MainControl
{
get { return (Control)GetValue(MainControlProperty); }
set { SetValue(MainControlProperty, value); }
}
Type type;
ObservableCollection<IdentifiableEntity> list;
public AdminWindow(Type adminType)
{
if (!typeof(IdentifiableEntity).IsAssignableFrom(adminType))
throw new ArgumentException(Properties.Resources.TypeArgumentMustInherit0.Formato(typeof(IdentifiableEntity).Name));
this.type = adminType;
Common.SetTypeContext(this, new TypeContext(typeof(List<>).MakeGenericType(adminType)));
this.InitializeComponent();
this.Loaded += new RoutedEventHandler(AdminWindow_Loaded);
}
public AdminWindow()
{
this.InitializeComponent();
this.Loaded += new RoutedEventHandler(AdminWindow_Loaded);
}
void AdminWindow_Loaded(object sender, RoutedEventArgs e)
{
entityList.Create = Navigator.FindSettings(type).TryCS(c => c.IsCreable(true)) ?? false;
Retrieve();
}
private void MainControlChanged(DependencyPropertyChangedEventArgs e)
{
leftNavigationPanel.IHasQuickLinks = e.NewValue as IHaveQuickLinks;
}
public override Button GetSaveButton()
{
return this.btSave;
}
public override object GetEntities()
{
return list.ToList();
}
public override void SetEntities(object value)
{
list = new ObservableCollection<IdentifiableEntity>((List<IdentifiableEntity>)value);
}
public override void UpdateInterface()
{
this.DataContext = list;
}
public override void RetrieveEntities()
{
list = new ObservableCollection<IdentifiableEntity>(Server.RetrieveAll(type));
}
public override object SaveEntities(object value)
{
return Server.SaveList((List<IdentifiableEntity>)value);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.
www.signumframework.com
I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...