Esempio n. 1
0
        public async void DeleteAddonFromLibrary(int SelectedAddonIndex)
        {
            AddonMetaData addon = MainView.LocalAddons[SelectedAddonIndex];

            if (addon != null)
            {
                if (addon.IsEnabled)
                {
                    bool result = await MainWindow.ShowMessageDialogYesNo("Do you want to uninstall this addon?", string.Format("The addon has been removed from the library but is still installed\n Select yes to uninstall the addon or no to keep it installed", addon.Name));

                    if (result)
                    {
                        UninstallAddon(addon);
                    }
                }

                if (File.Exists(addon.ZipName) && !Statics.CheckIfFileIsReadOnly(addon.ZipName))
                {
                    MainView.StatusMessage = string.Format("Removed {0} Ver. {1} from the addon library", addon.Name, addon.Version);
                    File.Delete(addon.ZipName);
                    Providers[addon.ProviderType].PostDelete(addon); // cleaning up git repos
                    // Let the file watcher take care of updating the list?
                }
            }
        }
Esempio n. 2
0
        // Do the real updating
        public bool _UpdateAddon(AddonMetaData addon)
        {
            try
            {
                if (Statics.CheckIfFileIsReadOnly(addon.ZipName))
                {
                    App.Current.Dispatcher.Invoke((Action) delegate
                    {
                        MainWindow.ShowAlert("Addon Update Error", "The addons zip is marked as read only. Addon:  " + addon.Name);
                    });

                    return(false);
                }
                if (addon.DownloadURL != null && new Version(addon.Version) < new Version(addon.AvailableVersion))
                {
                    bool isInstalled = addon.IsEnabled;
                    if (isInstalled)
                    {
                        addon.IsEnabled = false; // The observable takes care of the actions
                        AddonsToRenableAfterUpdate.Add(addon.Name);
                    }

                    addon.IsUpdating = true;
                    Providers[addon.ProviderType].Update(addon);
                    addon.IsUpdating = false;
                    //if (isInstalled)
                    //addon.IsEnabled = isInstalled;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                // MessageBox.Show(e.Message);

                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    MainWindow.ShowAlert("Addon Update Error", "There was an error updating this addon " + addon.Name);
                });

                return(false);
            }
        }