Example #1
0
 /// <summary>
 /// Vérifier si la verrsion locale et la version web correspondent
 /// </summary>
 /// <param name="p_Addon"></param>
 /// <returns></returns>
 private bool NewerVersionAvailable(Addon p_Addon)
 {
     return(p_Addon.Local != p_Addon.Web);
 }
Example #2
0
        /// <summary>
        /// Extraire un addon à partir du dossier Temp
        /// </summary>
        /// <param name="p_Addon"></param>
        internal void ExtractAddon(Addon p_Addon)
        {
            try
            {
                // Extraire le zip dans le dossier Temp/AddonFolderName
                // Vérifier si les dossiers existent déjà, les enlever si besoin est
                // copier les dossier extraits

                // Racine du dossier temp
                var l_TempDirectory = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Temp");
                // Nom du zip/du dossier temp du addon
                var l_AddonZipName = Regex.Replace(p_Addon.Nom, "[^A-Za-z0-9()]", "");
                // emplacement du dossier temp du addon
                var l_AddonTempFolder = Path.Combine(l_TempDirectory, l_AddonZipName);
                // Dossier ou sont les addons de wow
                var l_AddonsFolder = Base.MainSettings["WoWPath"];

                if (Directory.Exists(l_AddonTempFolder))
                {
                    Directory.Delete(l_AddonTempFolder, true);
                }

                ZipFile.ExtractToDirectory(Path.Combine(l_TempDirectory, l_AddonZipName) + ".zip", l_AddonTempFolder);

                // Exception to pull ElvUI out of the master folder
                if (p_Addon.Nom == "ElvUI")
                {
                    var l_ElvUiDirectory = Directory.GetDirectories(l_AddonTempFolder)[0];
                    //Now Create all of the directories
                    foreach (var l_DirectoryPath in Directory.GetDirectories(l_ElvUiDirectory, "*", SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(l_DirectoryPath.Replace(l_ElvUiDirectory, l_AddonTempFolder));
                    }

                    //Copy all the files & Replaces any files with the same name
                    foreach (var l_CurrentPath in Directory.GetFiles(l_ElvUiDirectory, "*.*", SearchOption.AllDirectories))
                    {
                        File.Copy(l_CurrentPath, l_CurrentPath.Replace(l_ElvUiDirectory, l_AddonTempFolder), true);
                    }

                    // retirer le dossier temporaire
                    Directory.Delete(l_ElvUiDirectory, true);
                }

                Thread.Sleep(1000);

                //// Créer le dossier cible
                var l_TargetDirectory = Path.Combine(l_AddonsFolder, l_AddonZipName);
                if (!Directory.Exists(l_TargetDirectory))
                {
                    Directory.CreateDirectory(l_TargetDirectory);
                }

                // Copier
                var l_Directories = Directory.GetDirectories(l_AddonTempFolder, "*");
                foreach (var l_CurrentPath in l_Directories)
                {
                    if (!Directory.Exists(l_CurrentPath.Replace(l_AddonTempFolder, l_AddonsFolder)))
                    {
                        Directory.CreateDirectory(l_CurrentPath.Replace(l_AddonTempFolder, l_AddonsFolder));
                    }
                    CopyAll(l_CurrentPath, l_CurrentPath.Replace(l_AddonTempFolder, l_AddonsFolder));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur ExtractAddons: " + ex.Message);
            }
        }
Example #3
0
 /// <summary>
 /// Met à jour les variables des addons disponibles dans le dropdown
 /// </summary>
 /// <param name="p_NewAddon"></param>
 /// <param name="p_Addon"></param>
 /// <returns></returns>
 private Addon UpdateAddon(Addon p_NewAddon, Addon p_Addon)
 {
     p_Addon.Local = GetAddonVersion(p_NewAddon);
     p_Addon.Web   = p_NewAddon.Web;
     return(p_Addon);
 }