aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common/UI/Splash.xaml.cs
blob: edfacf0167fa8580439a87f62f3e2be8298caf94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Windows;
using MahApps.Metro.Controls;
using MediaBrowser.Common.Logging;
using MediaBrowser.Model.Progress;

namespace MediaBrowser.Common.UI
{
    /// <summary>
    /// Interaction logic for Splash.xaml
    /// </summary>
    public partial class Splash : MetroWindow
    {
        public Splash(Progress<TaskProgress> progress)
        {
            InitializeComponent();
            
            progress.ProgressChanged += progress_ProgressChanged;
            Loaded+=Splash_Loaded;
        }

        void progress_ProgressChanged(object sender, TaskProgress e)
        {
            // If logging has loaded, put a message in the log.
            if (Logger.LoggerInstance != null)
            {
                Logger.LogInfo(e.Description);
            }

            this.lblProgress.Content = e.Description;
            this.pbProgress.Value = (double)e.PercentComplete;
        }

        private void Splash_Loaded(object sender, RoutedEventArgs e)
        {
            // Setting this in markup throws an exception at runtime
            ShowTitleBar = false;

            imgLogo.Source = (Application.Current as BaseApplication).GetLogoImage();
        }
    }
}