//================================================================================================// private void Modify_All_Images() { //Pour permet au bgColor de se mettre à jour Apercu(); //Fonction qui va créer les dossiers en fonction des noms GF.Create_Folders(Path + "Nouveau thème\\", GF.Get_Paths_Without_NameFile(List_Files_Names)); //On lit les noms d'images dans le constructeur foreach (string item in List_Files_Names) { ModifyOneImage(item, Folder_Theme_Path); } //Process.Start(Path + "Nouveau thème\\"); foreach (string item in List_Files_Names) { Move_File(item); } Directory.Delete(Path + "Nouveau thème\\", true); //Changement du fond du tchat ModifyColorXml(Folder_Theme_Path + "\\colors.xml"); Display_FMW(); Send_FMW_Instance(); GF.Play_Finish_Sound(); }
private void ModifyApercu()//nameImage avec l'extension de l'image (.png ou .jpg) ex : "img.png" { /*Si l'image à déjà été modifié 1 fois, un "e" à été ajouté, donc il va chercher dans "images/Theme1sur2e.png" au * lieu de "images/Theme1sur2.png" donc il ne va rien trouver d'où l'assignation*/ string nameImage = "Theme1sur2.png"; using (Bitmap bmp = new Bitmap(Path + "images\\" + nameImage)) { //get image dimension int width = bmp.Width; int height = bmp.Height; //red green blue image for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { //get pixel value Modify_Hls_Values(bmp, x, y); bmp.SetPixel(x, y, Color.FromArgb(AlphaImage, RougeImage, VertImage, BleuImage)); } } //Je ne peux pas écraser une image que mon programme utilise Image_Previsu_Name = GF.Get_New_Image_Previsu_Name(Image_Previsu_Name); bmp.Save(Path + "newImages\\" + Image_Previsu_Name); Img_Previ_Source1 = GF.Get_New_Image_Previsu_Name(Img_Previ_Source1); } }
//================================================================================================// public bool ModifyColorXml(string FilePath) { //Accepte en argument, le chemin d'accès vers le fichier à modifier, la ligne à laquelle modifier la valeur, la phrase qui va remplacer la ligne ObservableCollection <string> ListFile = new ObservableCollection <string>(); if (File.Exists(FilePath)) { string LigneEnCoursDeLecture; string LigneAModifier = "<entry key=\"chat.bgColor\">0x1c331b</entry>"; using (StreamReader sr = File.OpenText(FilePath)) { LigneEnCoursDeLecture = sr.ReadLine(); //S'il n'y a plus de ligne à lire, sr.Peek() renvoit -1 while (sr.Peek() != -1) { LigneEnCoursDeLecture = GF.Delete_Spaces_Before_First_Word(LigneEnCoursDeLecture); //On vérifie que la taille de la ligne est > 25 car sinon il y a une erreur avec le substring if (LigneEnCoursDeLecture.Length > 25) { string tmp1 = LigneEnCoursDeLecture.Substring(12, 12); string tmp2 = LigneAModifier.Substring(12, 12); if (tmp1 == tmp2) { //On modifie le bgColor car le tchat doit être + foncé que le thème présent Hls_To_Rgb_Tchat(); LigneEnCoursDeLecture = $"<entry key=\"chat.bgColor\">0x{BgColor.Substring(1)}</entry>";//Substring pour enlever le # de #123456 => 123456 } } ListFile.Add(LigneEnCoursDeLecture); LigneEnCoursDeLecture = sr.ReadLine(); } } File.Delete(FilePath); //ssss//StreamWriter rajoute une ligne vide à la fin du fichier colos.xml, c'est ce qui fait que le thème ne charge pas, trouver une solution using (StreamWriter StringWrite = File.CreateText(FilePath)) { foreach (string item in ListFile) { StringWrite.WriteLine(item); } StringWrite.WriteLine("</LangFile>"); } return(true); } return(false); }
public MainViewModel() { //0 - 360 TeinteUser = 0; MaxT = MaxTsl; MinT = 0; PasT = 0.5; SaturationUser = MaxTslSur2; //0 - 360 MaxS = MaxTsl; MinS = 0; PasS = 0.1; LuminositeUser = MaxTslSur2; //0 à 360 MaxL = MaxTsl * 0.65; MinL = MaxTsl * 0.35; PasL = 0.1; Image_Previsu_Name = "Theme1sur2.png"; Img_Previ_Source1 = GF.Get_Local_Path() + "newImages\\" + Image_Previsu_Name; Img_Previ_Source2 = GF.Get_Local_Path() + "images\\Theme2sur2.png"; Path = GF.Get_Local_Path(); List_Files_Names = new ObservableCollection <string>(); File_config_Txt_Path = GF.Get_Local_Path() + "config.txt"; //Pour que Folder_Theme_Path ne soit pas null, et que le comportement du bouton "modifier le theme" soit correct Folder_Theme_Path = ""; //Création du dossier s'il n'existe pas, si le dossier existe déjà, la fonction ignore la création et passe au dossier suivant à créer GF.Create_Folder(Path + "Nouveau thème\\"); BackgroundSource = Path + "images\\" + NomBackgroundImage; IconSource = Path + "images\\" + NomIcon; CountLoadedImage = "0"; GW.Moving_Window(GW.Get_MainWindow_Instance()); }
//================================================================================================// private void GoAppdataFolder() { GF.Go_AppData_Folder(); }
//================================================================================================// private void Browse_File_ImageName() { File_config_Txt_Path = GF.Browse_File(); }
//================================================================================================// //================================================================================================// //==============================Fonction d'action et de verification==============================// //================================================================================================// //================================================================================================// private void Browse_FolderSearch() { Folder_Theme_Path = GF.Browse_Folder(); }
//================================================================================================// private void Load_Files() { List_Files_Names = GF.Read_File_Content(File_config_Txt_Path); //Ajout du nombre d'images chargés dans la vue CountLoadedImage = (GF.Get_Number_Loaded_file_Into_folderPath(List_Files_Names, Folder_Theme_Path)).ToString(); }