using System.Collections; using System.Collections.Generic; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; using Caliburn.Composition; using Caliburn.Events.Aggregation; using Caliburn.Events.Brokering; using Caliburn.Metadata; using Caliburn.Modules; using Caliburn.PlatformCapabilities; using Caliburn.Services; using Caliburn.StateManagement; using Caliburn.Testability; using Caliburn.Views; namespace Caliburn.Configuration { public class DefaultConfiguration : IConfiguration { protected readonly FakeContainer _container = new FakeContainer(); public virtual void Prepare() { _container.Register(typeof(IPresenterManager), new PresenterManager()); _container.Register(typeof(IViewManager), new ViewManager()); _container.Register(typeof(IPlatformCapabilities), new WindowsCapabilities()); _container.Register(typeof(IEventBroker), new EventBroker()); _container.Register(typeof(IEventAggregator), new EventAggregator()); _container.Register(typeof(IModuleManager), new ModuleManager(new FolderBasedModuleLocator())); _container.Register(typeof(IShellState), new ShellState(new BinaryStateSerializer())); _container.Register(typeof(ICompositeManager), new CompositeManager()); } public virtual IContainer CreateContainer() { return _container; } public virtual IList GetElementDefaults() { return ElementDefaults; } public static readonly IList ElementDefaults = new List() { new ElementDefaults("Click", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("TextChanged", (c) => c.Text, (c,o) => c.Text = o.ToString()), new ElementDefaults("Click", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Click", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("TextChanged", (c) => c.Document, (c,o) => c.Document = (FlowDocument)o), new ElementDefaults("PasswordChanged", (c) => c.Password, (c,o) => c.Password = o.ToString()), new ElementDefaults("DataContextChanged", (c) => c.Text, (c,o) => c.Text = o.ToString()), new ElementDefaults("SelectedItemChanged", (c) => c.SelectedItem, (c,o) => c.ItemsSource = (IEnumerable)o), new ElementDefaults("Click", (c) => c.IsChecked, (c,o) => c.IsChecked = (bool)o), new ElementDefaults("Click", (c) => c.IsChecked, (c,o) => c.IsChecked = (bool)o), new ElementDefaults("Click", (c) => c.IsChecked, (c,o) => c.IsChecked = (bool)o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("Loaded", (c) => c.DataContext, (c,o) => c.DataContext = o), new ElementDefaults("SelectionChanged", (c) => { if (c.SelectionMode == SelectionMode.Extended || c.SelectionMode == SelectionMode.Multiple) return c.SelectedItems; else return c.SelectedItem; }, (c,o) => c.ItemsSource = (IEnumerable)o), new ElementDefaults("SelectionChanged", (c) => { if (c.IsEditable) return c.Text; else return c.SelectedItem; }, (c,o) => c.ItemsSource = (IEnumerable)o), new ElementDefaults("SelectionChanged", (c) => { if (c.SelectionMode == SelectionMode.Extended || c.SelectionMode == SelectionMode.Multiple) return c.SelectedItems; else return c.SelectedItem; }, (c,o) => c.ItemsSource = (IEnumerable)o) }; } }