public static void ENBCheck(bool fromENBMenu) { if (File.Exists(FormMain.gameFolder + "d3d9.dll")) { FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "iMaxAnisotropy", "1"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "iMultiSample", "1"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "bFXAAEnabled", "0"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "bFloatPointRenderTarget", "1"); FuncParser.iniWrite(FormMain.iniSkyrim, "Display", "bAllowScreenshot", "0"); } else if (fromENBMenu) { FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "iMaxAnisotropy", "16"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "iMultiSample", "1"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "bFXAAEnabled", "1"); FuncParser.iniWrite(FormMain.iniSkyrimPrefs, "Display", "bFloatPointRenderTarget", "0"); FuncParser.iniWrite(FormMain.iniSkyrim, "Display", "bAllowScreenshot", "1"); } if (FuncParser.stringRead(FormMain.iniSkyrimPrefs, "Display", "bFull Screen") == "0") { setBorderless("true"); } else { setBorderless("false"); } if (FuncParser.stringRead(FormMain.iniSkyrim, "Display", "iPresentInterval") == "1") { setVsync("true"); } else { setVsync("false"); } }
private void refrashAF() { af = FuncMisc.RefreshButton(buttonAF, enbLocal, "ENGINE", "ForceAnisotropicFiltering", null, false); if (af) { comboBox2.Enabled = true; string value = FuncParser.stringRead(enbLocal, "ENGINE", "MaxAnisotropy"); if (value == "0") { comboBox2.SelectedIndex = 0; } else if (value == "2") { comboBox2.SelectedIndex = 1; } else if (value == "4") { comboBox2.SelectedIndex = 2; } else if (value == "8") { comboBox2.SelectedIndex = 3; } else if (value == "16") { comboBox2.SelectedIndex = 4; } } else { comboBox2.Enabled = false; comboBox2.SelectedIndex = -1; } }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void button_ClearDirectory_Click(object sender, EventArgs e) { label1.Focus(); DialogResult dialogResult = MessageBox.Show(clearDirectory, confirmTitle, MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { FuncFiles.deleteAny(pathMyDoc + "Logs"); FuncFiles.deleteAny(pathMyDoc + "SKSE"); if (FuncParser.stringRead(pathSkyrimINI, "Papyrus", "bEnableLogging") == "1") { FuncFiles.creatDirectory(pathMyDoc + "Logs"); } if (Directory.Exists(pathMyDoc + "Saves")) { foreach (string line in Directory.GetFiles(pathMyDoc + "Saves", "*.bak")) { FuncFiles.deleteAny(line); } } FuncFiles.deleteAny(pathGameFolder + @"..\Skyrim Mods"); FuncClear.clearGameFolder(); FuncClear.emptyFolder(pathGameFolder); } }
public static bool refreshButton(Button button, string file, string section, string parameter, string value, bool invert) { if (FuncParser.keyExists(file, section, parameter)) { button.Enabled = true; string readString = FuncParser.stringRead(file, section, parameter); bool toggle = false; toggle = readString != null && (readString == value || readString == "1" || string.Equals(readString, "true", StringComparison.OrdinalIgnoreCase)); toggle = invert ? !toggle : toggle; if (toggle) { button.BackgroundImage = Properties.Resources.buttonToggleOn; } else { button.BackgroundImage = Properties.Resources.buttonToggleOff; } return(toggle); } else { button.BackgroundImage = Properties.Resources.buttonToggleDisable; button.Enabled = false; return(false); } }
public static bool RefreshButton(Button button, string file, string section, string parameter, string value, bool invert) { if (File.Exists(file)) { string readString = FuncParser.stringRead(file, section, parameter); button.Enabled = true; if (value != null) { if (readString == value) { button.BackgroundImage = Properties.Resources.buttonToggleOn; return(true); } else { button.BackgroundImage = Properties.Resources.buttonToggleOff; return(false); } } if (readString == "1" || readString == "true") { if (invert) { button.BackgroundImage = Properties.Resources.buttonToggleOff; return(false); } else { button.BackgroundImage = Properties.Resources.buttonToggleOn; return(true); } } else if (readString == "0" || readString == "false") { if (invert) { button.BackgroundImage = Properties.Resources.buttonToggleOn; return(true); } else { button.BackgroundImage = Properties.Resources.buttonToggleOff; return(false); } } else { button.BackgroundImage = Properties.Resources.buttonToggleOff; return(false); } } else { button.BackgroundImage = Properties.Resources.buttonToggleDisable; button.Enabled = false; return(false); } }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void refreshFileList() { if (Directory.Exists(pathENBfolder)) { foreach (string line in Directory.GetFiles(pathENBfolder, "*.rar").OrderBy(f => f)) { listBox1.Items.Add(Path.GetFileName(line)); } string last = FuncParser.stringRead(FormMain.pathLauncherINI, "ENB", "LastPreset"); if (last != null && listBox1.Items.Contains(last)) { listBox1.SelectedItem = last; } } }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { numberSelectFile = realIndex[comboBox1.SelectedIndex]; if (checkUpdateVersion(numberSelectFile)) { updateInstall = true; comboBox1.SelectedIndexChanged -= comboBox1_SelectedIndexChanged; comboBox1.Items[comboBox1.SelectedIndex] = installedUpdate + FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file"); comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged; } else { updateInstall = false; } EnableDisableButtons(); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void refreshFileList() { if (Directory.Exists(FormMain.pathENBFolder)) { foreach (string line in Directory.EnumerateFiles(FormMain.pathENBFolder)) { if (FormMain.archiveExt.Exists(s => s.Equals(Path.GetExtension(line), StringComparison.OrdinalIgnoreCase))) { listBox1.Items.Add(Path.GetFileName(line)); } } string last = FuncParser.stringRead(FormMain.pathLauncherINI, "ENB", "LastPreset"); if (last != null && listBox1.Items.Contains(last)) { listBox1.SelectedItem = last; } } }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void buttonCheckU_Click(object sender, EventArgs e) { if (stopDownload) { client.CancelAsync(); stopDownload = false; EnableDisableButtons(); } else { stopDownload = true; EnableDisableButtons(); if (updatesFound) { string line = FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_warning"); if (line != null) { MessageBox.Show(line); line = null; } if (checkUpdateFile(false)) { unpackUpdates(); } else { FuncFiles.Delete(updateFolder + "file" + numberSelectFile + ".rar"); downloadFileName = "file" + numberSelectFile + ".rar"; downloadFileType = "UpdateG"; client_DownloadProgressStart(); } } else { FuncFiles.Delete(updateFolder + nameUpdateInfo); downloadFileName = nameUpdateInfo; downloadFileType = "CheckU"; realIndexI.Clear(); realIndex.Clear(); installPreLoad.Clear(); client_DownloadProgressStart(); } } }
public FormWidget() { InitializeComponent(); if (FormMain.numberStyle > 1) { ImageBackgroundImage(); } if (FormMain.langTranslate != "RU") { LangTranslateEN(); } if (FuncParser.stringRead(FormMain.iniLauncher, "General", "HideWebButtons") == "true") { ClientSize = new System.Drawing.Size(221, 60); label2.Size = new System.Drawing.Size(221, 60); pictureBox4.Visible = false; buttonUpdates.Visible = false; } }
private void unpackUpdates(bool readyDL) { for (int i = 1; i <= 200; i++) { if (FuncParser.keyExists(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_delete_file_" + i.ToString())) { FuncFiles.deleteAny(FormMain.pathGameFolder + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_delete_file_" + i.ToString())); } else { break; } } FuncMisc.unpackRAR(pathUpdateFolder + "file" + numberSelectFile + ".rar"); FuncParser.iniWrite(FormMain.pathLauncherINI, "Updates", "Update_" + numberSelectFile + "_Version", FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_version")); comboBox_Updates_SelectedIndexChanged(this, new EventArgs()); if (readyDL) { stopDownload = false; enableDisableButtons(); } }
private void refreshFPS() { fps = FuncMisc.RefreshButton(buttonFPS, enbLocal, "LIMITER", "EnableFPSLimit", null, false); if (fps) { comboBox1.Enabled = true; string value = FuncParser.stringRead(enbLocal, "LIMITER", "FPSLimit"); if (value == "30.0") { comboBox1.SelectedIndex = 0; } else if (value == "60.0") { comboBox1.SelectedIndex = 1; } } else { comboBox1.Enabled = false; comboBox1.SelectedIndex = -1; } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void button_Uninstall_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { if (FuncMisc.dialogResult(textDeleteMod)) { string file = FormMain.pathModsFolder + listBox1.SelectedItem.ToString().Replace(".rar", ".txt"); if (File.Exists(file)) { foreach (string line in File.ReadLines(file)) { if (line.StartsWith("[")) { break; } else if (line.Length > 0) { FuncFiles.deleteAny(FormMain.pathGameFolder + line); } } if (FuncParser.keyExists(file, "UNINSTALL", "UNPACK")) { FuncMisc.unpackRAR(FormMain.pathGameFolder + FuncParser.stringRead(file, "UNINSTALL", "UNPACK")); } } else { MessageBox.Show(textNoUninstalFile); } } } else { MessageBox.Show(textNoFileSelect); } }
public static void restoreENBVideoMemory() { if (File.Exists(FormENB.pathENBLocalINI)) { FuncParser.iniWrite(FormENB.pathENBLocalINI, "MEMORY", "VideoMemorySizeMb", FuncParser.stringRead(FormMain.pathLauncherINI, "ENB", "MemorySizeMb")); } }
public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(pathLauncherFolder); if (!Directory.Exists(pathDataFolder)) { MessageBox.Show(@"Панель Управления должна располагаться по адресу: Директория Игры\Любая Папка\" + Environment.NewLine + Environment.NewLine + @"The Control Panel should be located at: Game Directory\Any Folder\"); Environment.Exit(0); } string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 0) { foreach (string line in arguments) { if (line.StartsWith("-s=", StringComparison.OrdinalIgnoreCase)) { argsStartsWith = line.Remove(0, 3); } else if (line.StartsWith("-w=", StringComparison.OrdinalIgnoreCase)) { argsWaitBefore = FuncParser.stringToInt(line.Remove(0, 3)); } } arguments = null; } if (File.Exists(pathLauncherINI)) { FuncParser.iniWrite(pathLauncherINI, "General", "Version_CP", panelFileVersion); int wLeft = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowLeft"); int wTop = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowTop"); if (wLeft < 0 || wTop < 0) { StartPosition = FormStartPosition.CenterScreen; } else { if (wLeft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { wLeft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } if (wTop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { wTop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } StartPosition = FormStartPosition.Manual; Location = new Point(wLeft, wTop); } settingsPreset = FuncParser.intRead(pathLauncherINI, "General", "SettingsPreset"); if (settingsPreset < 0 || settingsPreset > 3) { settingsPreset = 2; } numberStyle = FuncParser.intRead(pathLauncherINI, "General", "NumberStyle"); if (numberStyle < 1 || numberStyle > 2) { numberStyle = 1; } if (string.Equals(FuncParser.stringRead(pathLauncherINI, "General", "Language"), "EN", StringComparison.OrdinalIgnoreCase)) { langTranslate = "EN"; setLangTranslateEN(); } else { setLangTranslateRU(); } maxFPS = FuncParser.intRead(pathLauncherINI, "Game", "MaxFPS"); if (maxFPS < 30 || maxFPS > 240) { maxFPS = 60; } if (!FuncParser.keyExists(pathLauncherINI, "Game", "ZFighting")) { FuncParser.iniWrite(pathLauncherINI, "Game", "ZFighting", "false"); } int nearDistance = FuncParser.intRead(pathLauncherINI, "Game", "NearDistance"); if (nearDistance < 15 || nearDistance > 25) { FuncParser.iniWrite(pathLauncherINI, "Game", "NearDistance", "18"); } customFont = FuncParser.stringRead(pathLauncherINI, "Font", "CP_Font"); if (customFont != null) { var ifc = new InstalledFontCollection(); for (int i = ifc.Families.Length - 1; i >= 0; i--) { if (ifc.Families[i].Name == customFont) { FuncMisc.supportStrikeOut(customFont); FuncMisc.setFormFont(this); break; } else if (i == 0) { customFont = null; } } ifc = null; } } else { setLangTranslateRU(); StartPosition = FormStartPosition.CenterScreen; closeControlPanel(this, new EventArgs()); } if (!File.Exists(pathSkyrimPrefsINI) || !File.Exists(pathSkyrimINI)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(closeControlPanel); refreshStyle(); }
public static void restoreENBBorderless() { if (File.Exists(FormENB.pathENBLocalINI)) { FuncParser.iniWrite(FormENB.pathENBLocalINI, "WINDOW", "ForceBorderless", (FuncParser.stringRead(FormMain.pathSkyrimPrefsINI, "Display", "bFull Screen") == "0").ToString().ToLower()); } }
public static void restoreENBVSync() { if (File.Exists(FormENB.pathENBLocalINI)) { FuncParser.iniWrite(FormENB.pathENBLocalINI, "ENGINE", "EnableVSync", (FuncParser.stringRead(FormMain.pathSkyrimINI, "Display", "iPresentInterval") == "1").ToString().ToLower()); } }
public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(pathLauncherFolder); if (File.Exists(pathLauncherINI)) { if (panelFileVersion != FuncParser.stringRead(pathLauncherINI, "General", "Version_CP")) { FuncParser.iniWrite(pathLauncherINI, "General", "Version_CP", panelFileVersion); } int wLeft = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowLeft"); int wTop = FuncParser.intRead(pathLauncherINI, "General", "POS_WindowTop"); if (wLeft < 0 || wTop < 0) { StartPosition = FormStartPosition.CenterScreen; } else { if (wLeft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { wLeft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } if (wTop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { wTop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } StartPosition = FormStartPosition.Manual; Location = new Point(wLeft, wTop); } settingsPreset = FuncParser.intRead(pathLauncherINI, "General", "SettingsPreset"); if (settingsPreset < 0 || settingsPreset > 3) { settingsPreset = 2; } numberStyle = FuncParser.intRead(pathLauncherINI, "General", "NumberStyle"); if (numberStyle < 1 || numberStyle > 2) { numberStyle = 1; } if (FuncParser.stringRead(pathLauncherINI, "General", "Language").ToUpper() == "EN") { langTranslate = "EN"; setLangTranslateEN(); } else { setLangTranslateRU(); } predictFPS = FuncParser.intRead(pathLauncherINI, "Game", "PredictFPS"); if (predictFPS < 30 || predictFPS > 240) { predictFPS = 60; } if (!FuncParser.keyExists(pathLauncherINI, "Game", "ZFighting")) { FuncParser.iniWrite(pathLauncherINI, "Game", "ZFighting", "0"); } int nearDistance = FuncParser.intRead(pathLauncherINI, "Game", "NearDistance"); if (nearDistance < 15 || nearDistance > 25) { FuncParser.iniWrite(pathLauncherINI, "Game", "NearDistance", "18"); } customFont = FuncParser.stringRead(pathLauncherINI, "Font", "CP_Font"); if (customFont != null) { var ifc = new InstalledFontCollection(); for (int i = ifc.Families.Length - 1; i >= 0; i--) { if (ifc.Families[i].Name == customFont) { FuncMisc.supportStrikeOut(customFont); FuncMisc.setFormFont(this); break; } else if (i == 0) { customFont = null; } } ifc = null; } } else { setLangTranslateRU(); StartPosition = FormStartPosition.CenterScreen; OnProcessExit(this, new EventArgs()); } if (!File.Exists(pathSkyrimPrefsINI) || !File.Exists(pathSkyrimINI)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); refreshStyle(); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void button_Install_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { FuncMisc.toggleButtons(this, false); listBox1.Enabled = false; FuncClear.removeENB(); FuncMisc.unpackArhive(FormMain.pathENBFolder + listBox1.SelectedItem.ToString(), false); FuncParser.iniWrite(FormMain.pathLauncherINI, "ENB", "LastPreset", listBox1.SelectedItem.ToString()); FuncParser.iniWrite(FormMain.pathENBLocalINI, "MEMORY", "VideoMemorySizeMb", FuncParser.stringRead(FormMain.pathLauncherINI, "ENB", "MemorySizeMb")); listBox1.Enabled = true; FuncMisc.toggleButtons(this, true); refreshAllValue(); } else { MessageBox.Show(textNoFile); } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void button_Install_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { FuncMisc.toggleButtons(this, false); listBox1.Enabled = false; FuncClear.removeENB(); FuncMisc.unpackRAR(FormMain.pathENBFolder + listBox1.SelectedItem.ToString()); listBox1.Enabled = true; FuncMisc.toggleButtons(this, true); FuncParser.iniWrite(FormMain.pathLauncherINI, "ENB", "LastPreset", listBox1.SelectedItem.ToString()); FuncParser.iniWrite(FormMain.pathENBLocalINI, "MEMORY", "VideoMemorySizeMb", FuncParser.stringRead(FormMain.pathLauncherINI, "ENB", "MemorySizeMb")); refreshAllValue(); if (listBox1.SelectedItem.ToString().IndexOf("boost", StringComparison.OrdinalIgnoreCase) >= 0 || listBox1.SelectedItem.ToString().IndexOf("lite", StringComparison.OrdinalIgnoreCase) >= 0) { FuncMisc.unpackRAR(FormMain.pathSystemFolder + "ENB Vision.rar"); } } else { MessageBox.Show(textNoFile); } }
public FormMain() { InitializeComponent(); Directory.SetCurrentDirectory(FormMain.launcherFolder); if (File.Exists(iniLauncher)) { if (FuncParser.keyExists(iniLauncher, "Position", "POS_WindowTop") && FuncParser.keyExists(iniLauncher, "Position", "POS_WindowLeft")) { int Wleft = -1; int Wtop = -1; Wleft = FuncParser.intRead(iniLauncher, "Position", "POS_WindowLeft"); Wtop = FuncParser.intRead(iniLauncher, "Position", "POS_WindowTop"); if (Wleft > (Screen.PrimaryScreen.Bounds.Width - Size.Width)) { Wleft = Screen.PrimaryScreen.Bounds.Width - Size.Width; } else if (Wleft < 0) { Wleft = 0; } if (Wtop > (Screen.PrimaryScreen.Bounds.Height - Size.Height)) { Wtop = Screen.PrimaryScreen.Bounds.Height - Size.Height; } else if (Wtop < 0) { Wtop = 0; } StartPosition = FormStartPosition.Manual; Location = new Point(Wleft, Wtop); } else { StartPosition = FormStartPosition.CenterScreen; } if (FuncParser.keyExists(iniLauncher, "General", "Language")) { if (FuncParser.stringRead(iniLauncher, "General", "Language") == "RU") { SetLangTranslateRU(true); } else { langTranslate = "EN"; SetLangTranslateEN(); } } string version = FuncParser.stringRead(iniLauncher, "General", "Version_CP"); if (FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion != version) { FuncParser.iniWrite(iniLauncher, "General", "Version_CP", FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion); } numberStyle = FuncParser.intRead(iniLauncher, "General", "NumberStyle"); if (numberStyle < 1 && numberStyle > 2) { numberStyle = 1; } } else { SetLangTranslateRU(true); StartPosition = FormStartPosition.CenterScreen; OnProcessExit(this, new EventArgs()); } if (!File.Exists(iniSkyrimPrefs) || !File.Exists(iniSkyrim)) { resetSettings(); } AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit); RefreshStyle(); }
private void unpackUpdates() { FuncMisc.UnPackRAR(updateFolder + "file" + numberSelectFile + ".rar"); if (File.Exists(updateFolder + "Update_" + numberSelectFile + ".bat")) { Process.Start(updateFolder + "Update_" + numberSelectFile + ".bat"); } FuncParser.iniWrite(FormMain.iniLauncher, "Updates", "Update_" + numberSelectFile + "_Version", FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_version")); comboBox1_SelectedIndexChanged(this, new EventArgs()); }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (stopDownload) { if (File.Exists(updateFolder + nameUpdateInfo)) { if (downloadFileType == "CheckU") { int CountComboBox = FuncParser.intRead(updateFolder + nameUpdateInfo, "General", "numbers_files_update"); if (CountComboBox > 0) { for (int i = 1; i <= CountComboBox; i++) { comboBox1.SelectedIndexChanged -= comboBox1_SelectedIndexChanged; if (checkUpdateVersion(i)) { realIndexI.Add(i); installPreLoad.Add(installedUpdate + FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } else { realIndex.Add(i); comboBox1.Items.Add(installedUpdateN + FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged; } for (int i = 0; i < realIndexI.Count; i++) { realIndex.Add(realIndexI[i]); comboBox1.Items.Add(installPreLoad[i]); } if (comboBox1.Items.Count > 0) { comboBox1.SelectedIndex = 0; } updatesFound = true; label4.Text = CountComboBox.ToString(); } else { updatesFound = false; label4.Text = label4_T; } string line = FuncParser.stringRead(updateFolder + nameUpdateInfo, "General", "version_control_panel"); if (line != null) { var result = new Version(FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).ProductVersion).CompareTo(new Version(line)); if (result < 0) { updatesCPFound = true; } else { updatesCPFound = false; } } } if (downloadFileType == "UpdateG") { if (checkUpdateFile(true)) { unpackUpdates(); } } if (downloadFileType == "UpdateCP") { string version1 = FileVersionInfo.GetVersionInfo(updateFolder + nameControlPanel).ProductVersion; if (version1 == FuncParser.stringRead(updateFolder + nameUpdateInfo, "General", "version_control_panel")) { StreamWriter writer = new StreamWriter(FormMain.launcherFolder + "Update.bat"); writer.WriteLine("@Echo off"); writer.WriteLine("mode con:cols=50 lines=10"); writer.WriteLine("color 0E"); writer.WriteLine("cd %~dp0 >nul 2>nul"); writer.WriteLine("SET CP_S=" + FormMain.launcherFolder + nameControlPanel); writer.WriteLine("SET CP_U=" + updateFolder + nameControlPanel); writer.WriteLine("Echo Please Wait 5 second before start update."); writer.WriteLine("TIMEOUT /T 2 /NOBREAK > nul"); writer.WriteLine("IF EXIST \"%CP_U%\" ("); writer.WriteLine("Echo -Update file found."); writer.WriteLine("TIMEOUT /T 1 /NOBREAK > nul"); writer.WriteLine("Echo -Deleted old file control panel."); writer.WriteLine("del \"%CP_S%\" /Q >nul 2>nul"); writer.WriteLine("TIMEOUT /T 1 /NOBREAK > nul"); writer.WriteLine("Echo -Trying move new file control panel."); writer.WriteLine("move /Y \"%CP_U%\" \"%CP_S%\" >nul 2>nul"); writer.WriteLine("TIMEOUT /T 1 /NOBREAK > nul"); writer.WriteLine("Echo -Expectation launching new control panel."); writer.WriteLine("start \"Run new file\" \"%CP_S%\" >nul 2>nul"); writer.WriteLine(") else ("); writer.WriteLine("Echo -Update file not found..."); writer.WriteLine("TIMEOUT /T 5 /NOBREAK > nul"); writer.WriteLine(")"); writer.WriteLine("Echo -Ready. Closing."); writer.WriteLine("TIMEOUT /T 2 /NOBREAK > nul"); writer.WriteLine("del \"" + FormMain.launcherFolder + "Update.bat\" /Q >nul 2>nul"); writer.Close(); Process.Start(FormMain.launcherFolder + "Update.bat"); Application.Exit(); } else { MessageBox.Show(notSyncWithUI); FuncFiles.Delete(updateFolder + nameControlPanel); } } } else { updatesFound = false; updatesCPFound = false; } } stopDownload = false; progressBar1.Value = 0; EnableDisableButtons(); }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void aboutU_Click(object sender, EventArgs e) { MessageBox.Show(FuncParser.stringRead(updateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_discription")); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (stopDownload) { if (File.Exists(pathUpdateFolder + nameUpdateInfo)) { if (downloadFileType == "CheckU") { int CountComboBox = FuncParser.intRead(pathUpdateFolder + nameUpdateInfo, "General", "numbers_files_update"); if (CountComboBox > 0) { for (int i = 1; i <= CountComboBox; i++) { comboBox_Updates.SelectedIndexChanged -= comboBox_Updates_SelectedIndexChanged; if (checkUpdateVersion(i)) { realIndexI.Add(i); installPreLoad.Add(textInstalled + " / " + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } else { realIndex.Add(i); comboBox_Updates.Items.Add(textAvailable + " / " + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + i, "update_file")); } comboBox_Updates.SelectedIndexChanged += comboBox_Updates_SelectedIndexChanged; } for (int i = 0; i < realIndexI.Count; i++) { realIndex.Add(realIndexI[i]); comboBox_Updates.Items.Add(installPreLoad[i]); } if (comboBox_Updates.Items.Count > 0) { comboBox_Updates.SelectedIndex = 0; } updatesFound = true; label4.Text = CountComboBox.ToString(); } else { updatesFound = false; label4.Text = textNoUpdate; } string line = FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "General", "version_control_panel"); if (line != null) { var result = new Version(FormMain.panelFileVersion).CompareTo(new Version(line)); updatesCPFound = result < 0; } } if (downloadFileType == "UpdateG") { if (checkUpdateFile(true)) { unpackUpdates(false); } } if (downloadFileType == "UpdateCP") { string version1 = FileVersionInfo.GetVersionInfo(pathUpdateFolder + nameControlPanel).ProductVersion; if (version1 == FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "General", "version_control_panel")) { FuncMisc.writeToFile(FormMain.pathLauncherFolder + "Update.bat", new List <string>() { "@Echo off", "mode con:cols=50 lines=10", "color 0E", "cd %~dp0", "SET CP_S=" + FormMain.pathLauncherExecuting, "SET CP_U=" + pathUpdateFolder + nameControlPanel, "Echo Please Wait 5 second before start update.", "TIMEOUT /T 2 /NOBREAK >nul 2>nul", "IF EXIST \"%CP_U%\" (", "Echo -Update file found.", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Delete old file control panel.", "del \"%CP_S%\" /Q >nul 2>nul", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Move new file control panel.", "move /Y \"%CP_U%\" \"%CP_S%\" >nul 2>nul", "TIMEOUT /T 1 /NOBREAK >nul 2>nul", "Echo -Expectation launching new control panel.", "start \"Run new file\" \"%CP_S%\" >nul 2>nul", ") else (", "Echo -Update file not found...", "TIMEOUT /T 5 /NOBREAK >nul 2>nul", ")", "Echo -Closing.", "TIMEOUT /T 2 /NOBREAK >nul 2>nul", "del \"" + FormMain.pathLauncherFolder + "Update.bat\" /Q >nul 2>nul" }); FuncMisc.runProcess(FormMain.pathLauncherFolder + "Update.bat", null, null, this, true, false); Application.Exit(); } else { MessageBox.Show(textNoSyncWithUI); FuncFiles.deleteAny(pathUpdateFolder + nameControlPanel); } } } else { updatesFound = false; updatesCPFound = false; } } stopDownload = false; progressBar1.Value = 0; enableDisableButtons(); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void button_CheckUpdate_Click(object sender, EventArgs e) { if (stopDownload) { client.CancelAsync(); stopDownload = false; enableDisableButtons(); } else { stopDownload = true; enableDisableButtons(); if (updatesFound) { string line1 = FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_warning"); bool confirm = false; bool request = false; if (line1 != null) { if (FuncMisc.dialogResult(textPleaseRead + line1 + Environment.NewLine + Environment.NewLine + textContinue)) { confirm = true; } line1 = null; } else { confirm = true; } if (confirm) { string line2 = FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_request_update"); if (line2 != null) { if (FuncParser.doubleRead(pathUpdateFolder + nameUpdateInfo, "Update_" + line2, "update_file_version") <= FuncParser.doubleRead(FormMain.pathLauncherINI, "Updates", "Update_" + line2 + "_Version")) { request = true; } else { MessageBox.Show(textRequiredVersion + FuncParser.stringRead(pathUpdateFolder + nameUpdateInfo, "Update_" + line2, "update_file")); } line2 = null; } else { request = true; } } if (confirm && request) { if (checkUpdateFile(false)) { unpackUpdates(true); } else { FuncFiles.deleteAny(pathUpdateFolder + "file" + numberSelectFile + ".rar"); downloadFileName = "file" + numberSelectFile + ".rar"; downloadFileType = "UpdateG"; client_DownloadProgressStart(); } } else { stopDownload = false; enableDisableButtons(); } } else { FuncFiles.deleteAny(pathUpdateFolder + nameUpdateInfo); downloadFileName = nameUpdateInfo; downloadFileType = "CheckU"; realIndexI.Clear(); realIndex.Clear(); installPreLoad.Clear(); client_DownloadProgressStart(); } } }