private void MenuItemCurrentPicture_Click(object sender, EventArgs e) { var TGAItem = (string)ImgSelector.SelectedItem; string TGAPartPath = string.Format(".\\graphics\\JackMyth\\{0}", TGAItem); if (System.IO.File.Exists(string.Format("{0}.tmc2.bak", TGAPartPath))) { File.Delete(string.Format("{0}.tga", TGAPartPath)); System.IO.File.Move(string.Format("{0}.tmc2.bak", TGAPartPath), string.Format("{0}.tga", TGAPartPath)); } if ((string)ImgSelector.SelectedItem == MainBG && Directory.Exists(".\\Customization\\Backup\\WebPageStyle")) { CopyDirectory(".\\Customization\\Backup\\WebPageStyle", ".\\"); } //MusicPlayerPanel { var m_TGA = new ImageTGA(".\\graphics\\JackMyth\\MusicPlayerImg.tga", true); ReplaceByMark(".\\resource\\layout\\musicplayerpanel.layout", "MusicPlayerLayout", String.Format("\r\n\t\t\t\t1=\"image(x1-{0},y1-{1},x1,y1-76,graphics/JackMyth/MusicPlayerImg)\"\r\n\t\t\t\t", m_TGA.Image.Width, m_TGA.Image.Height + 76), "//", ""); } TGAImageReplaceList.Remove((string)ImgSelector.SelectedItem); }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { //Image foreach (KeyValuePair <string, string> TGAReplaceItem in TGAImageReplaceList) { if (TGAReplaceItem.Value == "") { continue; } string TGAPartPath = string.Format(".\\graphics\\JackMyth\\{0}", TGAReplaceItem.Key); if (!System.IO.File.Exists(string.Format("{0}.tmc2.bak", TGAPartPath)) && File.Exists(string.Format("{0}.tga", TGAPartPath))) { System.IO.File.Copy(string.Format("{0}.tga", TGAPartPath), string.Format("{0}.tmc2.bak", TGAPartPath)); } var m_TGA = new ImageTGA(); m_TGA.Image = new System.Drawing.Bitmap(TGAReplaceItem.Value); System.IO.File.Delete(string.Format("{0}.tga", TGAPartPath)); m_TGA.SaveImage(string.Format("{0}.tga", TGAPartPath)); } //Collapsed Sidebar if (CollapsedSideBar.IsChecked == true) { BackupReplaceingFiles(".\\Customization\\Collapsed Sidebar", ".\\Customization\\Backup\\Collapsed Sidebar"); } else { if (System.IO.Directory.Exists(".\\Customization\\Backup\\Collapsed Sidebar")) { CopyDirectory(".\\Customization\\Backup\\Collapsed Sidebar", ".\\"); Directory.Delete(".\\Customization\\Backup\\Collapsed Sidebar", true); } } //WebPage Style string Base64ImgBak = GetContentByMark(".\\resource\\webkit.css", "Background"); if (System.IO.Directory.Exists(".\\Customization\\Backup\\WebPageStyle")) { File.Delete(".\\Customization\\Backup\\WebPageStyle\\.CustomizerCfg"); CopyDirectory(".\\Customization\\Backup\\WebPageStyle", ".\\"); Directory.Delete(".\\Customization\\Backup\\WebPageStyle", true); } Directory.CreateDirectory(".\\Customization\\Backup\\WebPageStyle\\resource"); File.Copy(".\\resource\\webkit.css", ".\\Customization\\Backup\\WebPageStyle\\resource\\webkit.css"); switch (WebPageStyle.SelectedIndex) { case 0: ReplaceByMark(".\\resource\\webkit.css", "BackgroundPos", string.Format("background-position: {0}px -81px;", (CollapsedSideBar.IsChecked == true ? -48 : -240).ToString())); ReplaceByMark(".\\resource\\webkit.css", "BackgroundSize", string.Format("background-size: calc(100vw + {0}px) calc(100vh + 130px);", (CollapsedSideBar.IsChecked == true ? 48 : 240).ToString())); break; case 1: ReplaceByMark(".\\resource\\webkit.css", "BackgroundPos", string.Format("background-position: {0}px -31px;", (CollapsedSideBar.IsChecked == true ? -48 : -240).ToString())); ReplaceByMark(".\\resource\\webkit.css", "BackgroundSize", string.Format("background-size: calc(100vw + {0}px) calc(100vh + 80px);", (CollapsedSideBar.IsChecked == true ? 48 : 240).ToString())); File.WriteAllText(".\\Customization\\Backup\\WebPageStyle\\.CustomizerCfg", "1"); break; case 2: ReplaceByMark(".\\resource\\webkit.css", "WebPageStyle", "\n"); File.WriteAllText(".\\Customization\\Backup\\WebPageStyle\\.CustomizerCfg", "2"); break; } //Blur and Brightness ReplaceByMark(".\\resource\\webkit.css", "GameListBlur", string.Format("filter: blur({0}px);", this.GameListBlur.Value.ToString())); ReplaceByMark(".\\resource\\webkit.css", "MainContent", string.Format("filter: blur({0}px) opacity({1}%);", this.MainContentBlur.Value.ToString(), this.MainContentBrightness.Value.ToString())); //Show LWD if (this.ShowLWD.IsChecked == true) { ReplaceByMark(".\\resource\\webkit.css", "LWD", "\r\n\tbox-shadow: 1px 0px 6px 1px #000000;\r\n\tbackground-color: #17191bFF!important;\r\n\t"); } else { ReplaceByMark(".\\resource\\webkit.css", "LWD", "\r\n\tbackground-color: #17191b00!important;\r\n\t"); } if (this.CollapsedSideBar.IsChecked == true) { for (int i = 0; i < 3; i++) { ReplaceByMark(".\\resource\\webkit.css", "CSide" + i.ToString(), "\r\n\tbackground-position: -48px -31px;\r\n\tbackground-size: calc(100% + 48px) calc(100% + 80px);\r\n\t"); } } else { for (int i = 0; i < 3; i++) { ReplaceByMark(".\\resource\\webkit.css", "CSide" + i.ToString(), "\r\n\tbackground-position: -240px -31px;\r\n\tbackground-size: calc(100% + 240px) calc(100% + 80px);\r\n\t"); } } //Special Image if (TGAImageReplaceList.Keys.Contains(MainBG)) { if (TGAImageReplaceList[MainBG] != "") { //Webkit Base64 //Backup First if (!Directory.Exists(".\\Customization\\Backup\\WebPageStyle")) { Directory.CreateDirectory(".\\Customization\\Backup\\WebPageStyle\\resource"); File.Copy(".\\resource\\webkit.css", ".\\Customization\\Backup\\WebPageStyle\\resource\\webkit.css"); File.WriteAllText(".\\Customization\\Backup\\WebPageStyle\\.CustomizerCfg", WebPageStyle.SelectedIndex.ToString()); } try { var fileInfo = new FileInfo(TGAImageReplaceList[MainBG]); if (fileInfo.Length > (500 * 1024)) { MessageBox.Show(Application.Current.FindResource("ImgTooBigWarning").ToString(), "TMC2", MessageBoxButton.OK, MessageBoxImage.Exclamation); } string Base64Img = ""; byte[] ImgBytes = File.ReadAllBytes(TGAImageReplaceList[MainBG]); Base64Img = "background:url(data:image/jpeg;base64," + Convert.ToBase64String(ImgBytes) + ");"; ReplaceByMark(".\\resource\\webkit.css", "Background", Base64Img); } catch (Exception) { } } } else { ReplaceByMark(".\\resource\\webkit.css", "Background", Base64ImgBak); } //MusicPlayerPanel { var m_TGA = new ImageTGA(".\\graphics\\JackMyth\\MusicPlayerImg.tga", true); ReplaceByMark(".\\resource\\layout\\musicplayerpanel.layout", "MusicPlayerLayout", String.Format("\r\n\t\t\t\t1=\"image(x1-{0},y1-{1},x1,y1-76,graphics/JackMyth/MusicPlayerImg)\"\r\n\t\t\t\t", m_TGA.Image.Width, m_TGA.Image.Height + 76), "//", ""); } //Font { replaceFont("BaseFont", "Segoe UI"); replaceFont("Light", "Segoe UI Light"); replaceFont("SemiLight", "Segoe UI Semilight"); replaceFont("SemiBold", "Segoe UI Semibold"); replaceFont("Bold", "Segoe UI Bold"); if (FontSettings.ContainsKey("STUIGlobal") && FontSettings["STUIGlobal"] != "") { ReplaceByMark(".\\resource\\webkit.css", "STUIFontGlobal", String.Format("\n\tfont-family:\"{0}\";\n\t", FontSettings["STUIGlobal"])); } else { ReplaceByMark(".\\resource\\webkit.css", "STUIFontGlobal", "\n\t"); } } //Font Color { replaceFontColor("Uninstalled"); replaceFontColor("Installed"); replaceFontColor("Running"); replaceFontColor("Updating"); replaceFontColor("GameListSectionHeader"); } //Webpage Brightness try //Maybe no background { string X16Value = Convert.ToString((int)(255 - this.WebPageBrightness.Value), 16); string Cnt = "background:linear-gradient(to right,#00000000 0%,#000000" + X16Value + " 2%);"; ReplaceByMark(".\\resource\\webkit.css", "WebBGBrightness", Cnt); } catch (Exception) { } if (Directory.Exists(".\\Customization\\Backup")) { string v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); File.Create(".\\Customization\\Backup\\" + v).Close(); } MessageBox.Show(Application.Current.FindResource("ApplySucceed").ToString()); }