Ejemplo n.º 1
0
        /// <summary>
        /// Performs the installation in the Castle.Windsor.IWindsorContainer.
        /// </summary>
        /// <param name="container"></param>
        /// <param name="store"></param>
        public void Install(IWindsorContainer container,
                            IConfigurationStore store)
        {
            try
            {
                string fullPath = System.Reflection.Assembly.GetAssembly(typeof(Installers)).Location;
                string dir      = System.IO.Path.GetDirectoryName(fullPath);

                // register components in this DLL and make them available here
                container.Install(FromAssembly.Named(System.IO.Path.Combine(dir, "Settings.dll")));
                container.Install(FromAssembly.Named(System.IO.Path.Combine(dir, "XmlExplorerVMLib.dll")));
            }
            catch (Exception exp)
            {
                Logger.Error(exp);
            }

            container.Register(Component.For <IAppearanceManager>()
                               .Instance(AppearanceManager.GetInstance()).LifestyleSingleton());

            // Register settings service component to help castle satisfy dependencies on it
            container
            .Register(Component.For <IAppLifeCycleViewModel>()
                      .ImplementedBy <AppLifeCycleViewModel>().LifestyleSingleton());

            // Register settings service component to help castle satisfy dependencies on it
            container
            .Register(Component.For <IThemesManagerViewModel>()
                      .ImplementedBy <ThemesManagerViewModel>().LifestyleSingleton());

            // Register application viewmodel to help castle satisfy dependencies on it
            container
            .Register(Component.For <IAppViewModel>()
                      .ImplementedBy <AppViewModel>().LifestyleSingleton());
        }
        /// <summary>
        /// Loads service objects into the ServiceContainer on startup of application.
        /// </summary>
        /// <returns>Returns the current <seealso cref="ServiceContainer"/> instance
        /// to let caller work with service container items right after creation.</returns>
        public static ServiceContainer InjectServices()
        {
            var appearance = AppearanceManager.GetInstance();

            ServiceContainer.Instance.AddService <ISettingsManager>(SettingsManager.GetInstance(appearance.CreateThemeInfos()));
            ServiceContainer.Instance.AddService <IAppearanceManager>(appearance);

            return(ServiceContainer.Instance);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads service objects into the ServiceContainer on startup of application.
        /// </summary>
        /// <returns>Returns the current <seealso cref="ServiceContainer"/> instance
        /// to let caller work with service container items right after creation.</returns>
        public static ServiceContainer InjectServices()
        {
            ServiceContainer.Instance.AddService <IContentDialogService>(ContentDialogService.Instance);
            ServiceContainer.Instance.AddService <IVMManager>(VMManagerService.Instance);
            ServiceContainer.Instance.AddService <IFileManager>(FileManagerService.Instance);

            var appearance = AppearanceManager.GetInstance();

            ServiceContainer.Instance.AddService <ISettingsManager>(SettingsManager.GetInstance(appearance.CreateThemeInfos()));
            ServiceContainer.Instance.AddService <IAppearanceManager>(appearance);

            ServiceContainer.Instance.AddService <IExplorer>(new Explorer());

            return(ServiceContainer.Instance);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// By default, we are configured to use MEF
        /// </summary>
        protected override void Configure()
        {
            try
            {
                var splashScreen = new SplashScreen(Assembly.GetAssembly(typeof(AppBootstrapper)), "daxstudio-splash.png");
                splashScreen.Show(true);

                // Tell Caliburn Micro how to find controls in Fluent Ribbon

                /*
                 * defaultElementLookup = BindingScope.GetNamedElements;
                 * BindingScope.GetNamedElements = new Func<System.Windows.DependencyObject, IEnumerable<System.Windows.FrameworkElement>>(
                 *  k =>
                 *  {
                 *      List<FrameworkElement> namedElements = new List<FrameworkElement>();
                 *      namedElements.AddRange(defaultElementLookup(k));
                 *      Fluent.Ribbon ribbon = LookForRibbon(k);
                 *      if (null != ribbon)
                 *          AppendRibbonNamedItem(ribbon, namedElements);
                 *      return namedElements;
                 *  }
                 *  );
                 */

                ConventionManager.AddElementConvention <Fluent.Spinner>(Fluent.Spinner.ValueProperty, "Value", "ValueChanged");

                // TODO - do I need to replace these conventions ??
                //ConventionManager.AddElementConvention<NumericUpDownLib.DoubleUpDown>(NumericUpDownLib.DoubleUpDown.ValueProperty, "Value", "ValueChanged");

                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.DoubleUpDown>(Xceed.Wpf.Toolkit.DoubleUpDown.ValueProperty, "Value", "ValueChanged");
                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.IntegerUpDown>(Xceed.Wpf.Toolkit.IntegerUpDown.ValueProperty, "Value", "ValueChanged");
                //ConventionManager.AddElementConvention<Xceed.Wpf.Toolkit.WatermarkTextBox>(Xceed.Wpf.Toolkit.WatermarkTextBox.TextProperty, "Text", "TextChanged");

                // Add Fluent Ribbon resovler
                BindingScope.AddChildResolver <Fluent.Ribbon>(FluentRibbonChildResolver);


                // Fixes the default datetime format in the results listview
                // from: https://stackoverflow.com/questions/1993046/datetime-region-specific-formatting-in-wpf-listview
                FrameworkElement.LanguageProperty.OverrideMetadata(
                    typeof(FrameworkElement),
                    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

                var catalog = new AggregateCatalog(
                    AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType <ComposablePartCatalog>()
                    );
                //_container = new CompositionContainer(catalog,true);
                _container = new CompositionContainer(catalog);
                var batch = new CompositionBatch();



                batch.AddExportedValue <IWindowManager>(new WindowManager());
                batch.AddExportedValue <IEventAggregator>(new EventAggregator());
                batch.AddExportedValue <Func <DocumentViewModel> >(() => _container.GetExportedValue <DocumentViewModel>());
                batch.AddExportedValue <Func <IWindowManager, IEventAggregator, DocumentViewModel> >(
                    (w, e) => _container.GetExportedValue <DocumentViewModel>());
                batch.AddExportedValue(_container);
                batch.AddExportedValue(catalog);

                ISettingProvider settingProvider = SettingsProviderFactory.GetSettingProvider();

                batch.AddExportedValue <ISettingProvider>(settingProvider);

                // add support for MLib themes
                batch.AddExportedValue <IAppearanceManager>(AppearanceManager.GetInstance());

                _container.Compose(batch);

                // Add AvalonDock binding convetions
                AvalonDockConventions.Install();

                //var settingFactory = _container.GetExport<Func<ISettingProvider>>();



                ConfigureKeyBindingConvention();

                // TODO - not working
                //VisibilityBindingConvention.Install();

                // Enable Caliburn.Micro debug logging
                //LogManager.GetLog = type => new DebugLogger(type);

                // Add Application object to MEF catalog
                _container.ComposeExportedValue <Application>("System.Windows.Application", Application.Current);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }