public MainWindow()
 {
     InitializeComponent();
     _versions = new VersionList("versions.json", this);
     VersionList.ItemsSource         = _versions;
     _userVersionDownloaderLoginTask = new Task(() => {
         _userVersionDownloader.EnableUserAuthorization();
     });
     Dispatcher.Invoke(async() => {
         try {
             await _versions.LoadFromCache();
         } catch (Exception e) {
             Debug.WriteLine("List cache load failed:\n" + e.ToString());
         }
         try {
             await _versions.DownloadList();
         } catch (Exception e) {
             Debug.WriteLine("List download failed:\n" + e.ToString());
         }
     });
 }
        public MainWindow()
        {
            InitializeComponent();
            ShowBetasCheckbox.DataContext = this;
            ShowInstalledVersionsOnlyCheckbox.DataContext = this;

            if (File.Exists(PREFS_PATH))
            {
                UserPrefs = JsonConvert.DeserializeObject <Preferences>(File.ReadAllText(PREFS_PATH));
            }
            else
            {
                UserPrefs = new Preferences();
                RewritePrefs();
            }

            _versions = new VersionList("versions.json", IMPORTED_VERSIONS_PATH, this);
            VersionList.ItemsSource = _versions;
            var view = CollectionViewSource.GetDefaultView(VersionList.ItemsSource) as CollectionView;

            view.Filter = VersionListFilter;
            _userVersionDownloaderLoginTask = new Task(() => {
                _userVersionDownloader.EnableUserAuthorization();
            });
            Dispatcher.Invoke(async() => {
                try {
                    await _versions.LoadFromCache();
                } catch (Exception e) {
                    Debug.WriteLine("List cache load failed:\n" + e.ToString());
                }
                try {
                    await _versions.DownloadList();
                } catch (Exception e) {
                    Debug.WriteLine("List download failed:\n" + e.ToString());
                }
                await _versions.LoadImported();
            });
            ThemesController.SetTheme(GetThemeEnum(UserPrefs.Theme));
        }
        public MainWindow()
        {
            _versions = new VersionList("versions.json", IMPORTED_VERSIONS_PATH, VERSIONS_API, this, VersionEntryPropertyChanged);
            InitializeComponent();
            ShowInstalledVersionsOnlyCheckbox.DataContext = this;


            if (File.Exists(PREFS_PATH))
            {
                UserPrefs = JsonConvert.DeserializeObject <Preferences>(File.ReadAllText(PREFS_PATH));
            }
            else
            {
                UserPrefs = new Preferences();
                RewritePrefs();
            }

            var versionListViewRelease = Resources["versionListViewRelease"] as CollectionViewSource;

            versionListViewRelease.Filter += new FilterEventHandler((object sender, FilterEventArgs e) => {
                var v      = e.Item as Version;
                e.Accepted = v.VersionType == VersionType.Release && (v.IsInstalled || v.IsStateChanging || !(ShowInstalledVersionsOnlyCheckbox.IsChecked ?? false));
            });
            versionListViewRelease.Source  = _versions;
            ReleaseVersionList.DataContext = versionListViewRelease;
            _versionListViews.Add(versionListViewRelease);

            var versionListViewBeta = Resources["versionListViewBeta"] as CollectionViewSource;

            versionListViewBeta.Filter += new FilterEventHandler((object sender, FilterEventArgs e) => {
                var v      = e.Item as Version;
                e.Accepted = v.VersionType == VersionType.Beta && (v.IsInstalled || v.IsStateChanging || !(ShowInstalledVersionsOnlyCheckbox.IsChecked ?? false));
            });
            versionListViewBeta.Source  = _versions;
            BetaVersionList.DataContext = versionListViewBeta;
            _versionListViews.Add(versionListViewBeta);

            var versionListViewPreview = Resources["versionListViewPreview"] as CollectionViewSource;

            versionListViewPreview.Filter += new FilterEventHandler((object sender, FilterEventArgs e) => {
                var v      = e.Item as Version;
                e.Accepted = v.VersionType == VersionType.Preview && (v.IsInstalled || v.IsStateChanging || !(ShowInstalledVersionsOnlyCheckbox.IsChecked ?? false));
            });
            versionListViewPreview.Source  = _versions;
            PreviewVersionList.DataContext = versionListViewPreview;
            _versionListViews.Add(versionListViewPreview);

            var versionListViewImported = Resources["versionListViewImported"] as CollectionViewSource;

            versionListViewImported.Filter += new FilterEventHandler((object sender, FilterEventArgs e) => {
                var v      = e.Item as Version;
                e.Accepted = v.VersionType == VersionType.Imported;
            });

            versionListViewImported.Source  = _versions;
            ImportedVersionList.DataContext = versionListViewImported;
            _versionListViews.Add(versionListViewImported);

            _userVersionDownloaderLoginTask = new Task(() => {
                _userVersionDownloader.EnableUserAuthorization();
            });
            Dispatcher.Invoke(LoadVersionList);
        }