using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
using DevToolManager.CodeModel;
using Microsoft.Practices.Unity;
using StatusBar.ViewModel;
using System.Windows;

namespace StatusBar
{
    public class StatusBarModule : IModule
    {
        private readonly IRegionManager regionManager;
        private readonly IShell shell;
        private readonly IUnityContainer unityContainer;

        public StatusBarModule(IUnityContainer unityContainer)
        {
            this.unityContainer = unityContainer;

            this.shell = unityContainer.Resolve<IShell>();
            this.regionManager = unityContainer.Resolve<IRegionManager>();
        }

        public void Initialize()
        {
            Uri resourceLocator = new Uri("/StatusBar;component/Resources/StatusBarResources.xaml",
                System.UriKind.Relative);
            ResourceDictionary resource = Application.LoadComponent(resourceLocator)
                as ResourceDictionary;
            Application.Current.Resources.MergedDictionaries.Add(resource);

            unityContainer.RegisterType<StatusBarViewModel>();

            //StatusBarView view = new StatusBarView();
            //view.DataContext = unityContainer.Resolve<StatusBarViewModel>();
            //this.regionManager.Regions["StatusRegion"].Add(view);

            this.regionManager.Regions["StatusRegion"].Add(unityContainer.Resolve<StatusBarViewModel>());
        }
    }
}
