コード例 #1
0
        private async Task UpdateItem(AddonConfigItem item, Action done)
        {
            var source  = new CurseAddonSource();
            var zipPath = await source.GetZipFile(item);

            if (!string.IsNullOrWhiteSpace(zipPath))
            {
                ZipFile.ExtractToDirectory(zipPath, extractPath);
                CopyFiles(extractPath, path);
            }

            done?.Invoke();
        }
コード例 #2
0
        private async void btnCheckCurse_Click(object sender, RoutedEventArgs e)
        {
            var addons = ConfigManager.GetConfig();

            if (addons == null || addons.Items.Count == 0)
            {
                return;
            }

            var loadingScreen = new LoadingScreen(addons.Items.Count)
            {
                Owner = this
            };

            loadingScreen.Show();
            var source = new CurseAddonSource();

            try
            {
                await source.RefreshConfig(addons, () => loadingScreen.Increment());
            }
            catch (Exception ex)
            {
                loadingScreen.Close();
                MessageBox.Show(ex.Message, "Broken", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            dgAddons.ItemsSource = addons.Items;
            dgAddons.Items.Refresh();

            ConfigManager.SetConfig(addons);

            loadingScreen.Close();
            MessageBox.Show("Update complete", "Finished", MessageBoxButton.OK, MessageBoxImage.Information);
        }