using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Threading;
using System.Windows;
using TaskIt.ViewModels;

namespace TaskIt.Views
{
    public partial class Home
    {
        public Home()
        {
            InitializeComponent();
            Loaded += PageLoaded;
        }

        private void PageLoaded(object sender, RoutedEventArgs e)
        {
            CompositionInitializer.SatisfyImports(this);
            DataContext = ViewModel; 

            // TODO: Ross - Find a better way to do this...without it the nav button animation doesn't work properly when returning to the Home page
            var bw = new BackgroundWorker();
            bw.DoWork += ((obj, args) => Thread.Sleep(1000));
            bw.RunWorkerCompleted += WorkCompleted;
            bw.RunWorkerAsync();
        }

        private void WorkCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            LoadButtonsStoryboard.Begin();
        }

        [Import]
        public HomeViewModel ViewModel { get; set; }
    }
}