private void refreshWaterReflect() { FuncMisc.refreshComboBox(comboBoxWaterReflectTAB, new List <double>() { 512, 1024, 2048 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Water", "iWaterReflectWidth"), false, comboBoxWaterReflect_SelectedIndexChanged); }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // public static void refreshTrackBar(TrackBar trackbar, string file, string section, string parameter, int division, Label label) { if (FuncParser.keyExists(file, section, parameter)) { trackbar.Enabled = true; int readINT = FuncParser.intRead(file, section, parameter); if (division != -1) { readINT = readINT / division; } if (readINT >= trackbar.Minimum && readINT <= trackbar.Maximum) { if (division != -1) { label.Text = (readINT * division).ToString(); } else { label.Text = readINT.ToString(); } trackbar.Value = readINT; } else { label.Text = "N/A"; } } else { label.Text = "N/A"; trackbar.Enabled = false; } }
private void refreshDecals() { FuncMisc.refreshComboBox(comboBoxDecalsTAB, new List <double>() { 0, 20, 50, 100 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iMaxDecalsPerFrame"), false, comboBoxDecals_SelectedIndexChanged); }
private void refreshAA() { FuncMisc.refreshComboBox(comboBoxAATAB, new List <double>() { 0, 2, 4, 8 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iMultiSample"), false, comboBoxAA_SelectedIndexChanged); }
private void refreshLODObjects() { FuncMisc.refreshComboBox(comboBoxLODObjectsTAB, new List <double>() { 12500, 25000, 40000, 75000 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "TerrainManager", "fTreeLoadDistance"), false, comboBoxLODObjects_SelectedIndexChanged); }
private void refreshTextures() { FuncMisc.refreshComboBox(comboBoxTexturesTAB, new List <double>() { 0, 1, 2 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iTexMipMapSkip"), false, comboBoxTextures_SelectedIndexChanged); }
private void refreshShadow() { FuncMisc.refreshComboBox(comboBoxShadowResTAB, new List <double>() { 512, 1024, 2048, 4096 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iShadowMapResolution"), false, comboBoxShadowRes_SelectedIndexChanged); }
private void refreshAF() { FuncMisc.refreshComboBox(comboBoxAFTAB, new List <double>() { 0, 2, 4, 8, 16 }, FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iMaxAnisotropy"), false, comboBoxAF_SelectedIndexChanged); }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// private void enableDisableButtons() { if (updatesFound) { if (stopDownload) { comboBox1.Enabled = false; button_AboutUpdate.Enabled = false; button_CvsU.Text = buttonCvsU_TS; } else { comboBox1.Enabled = true; button_AboutUpdate.Enabled = true; label5.Text = label5_T + FuncParser.convertFileSize(FuncParser.intRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_filesize")); if (updateInstall) { button_CvsU.Enabled = false; button_CvsU.Text = buttonCvsU_TI; } else { button_CvsU.Enabled = true; button_CvsU.Text = buttonCvsU_TU; } } } else { comboBox1.Enabled = false; button_AboutUpdate.Enabled = false; label5.Text = ""; if (stopDownload) { button_CvsU.Text = buttonCvsU_TS; } else { button_CvsU.Text = buttonCvsU_TC; } } if (updatesCPFound) { if (stopDownload) { button_UpdateCP.Enabled = false; } else { button_UpdateCP.Enabled = true; button_UpdateCP.Text = buttonUpdateCP_TE; } } else { button_UpdateCP.Enabled = false; button_UpdateCP.Text = buttonUpdateCP_TN; } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // private void enableDisableButtons() { if (updatesFound) { if (stopDownload) { comboBox_Updates.Enabled = false; button_AboutUpdate.Enabled = false; button_CheckUpdate.Text = textStop; } else { comboBox_Updates.Enabled = true; button_AboutUpdate.Enabled = true; label5.Text = textSize + FuncParser.convertFileSize(FuncParser.intRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_filesize")); if (updateInstall) { button_CheckUpdate.Enabled = false; button_CheckUpdate.Text = textInstalled; } else { button_CheckUpdate.Enabled = true; button_CheckUpdate.Text = textUpdate; } } } else { comboBox_Updates.Enabled = false; button_AboutUpdate.Enabled = false; label5.Text = ""; if (stopDownload) { button_CheckUpdate.Text = textStop; } else { button_CheckUpdate.Text = textCheck; } } if (updatesCPFound) { if (stopDownload) { button_UpdateCP.Enabled = false; } else { button_UpdateCP.Enabled = true; button_UpdateCP.Text = textUpdate; } } else { button_UpdateCP.Enabled = false; button_UpdateCP.Text = textNoUpdate; } }
public static void restoreENBAdapter() { if (File.Exists(FormENB.pathENBLocalINI)) { int value = FuncParser.intRead(FormMain.pathSkyrimINI, "Display", "iAdapter"); FuncParser.iniWrite(FormENB.pathENBLocalINI, "MULTIHEAD", "VideoAdapterIndex", value.ToString()); FuncParser.iniWrite(FormENB.pathENBLocalINI, "MULTIHEAD", "ForceVideoAdapterIndex", (value > 0).ToString().ToLower()); } }
private void refreshMemory() { if (File.Exists(FormMain.pathENBLocalINI)) { comboBox_Memory.Enabled = true; FuncMisc.refreshComboBox(comboBox_Memory, new List <double>() { 64, 128, 256, 384, 512, 640, 768, 896, 1024 }, FuncParser.intRead(FormMain.pathENBLocalINI, "MEMORY", "ReservedMemorySizeMb"), false, comboBox_Memory_SelectedIndexChanged); } else { comboBox_Memory.SelectedIndex = -1; comboBox_Memory.Enabled = false; } }
private void refreshAF() { af = FuncMisc.refreshButton(button_AF, FormMain.pathENBLocalINI, "ENGINE", "ForceAnisotropicFiltering", null, false); if (af) { FuncMisc.refreshComboBox(comboBox_AF, new List <double>() { 0, 2, 4, 8, 16 }, FuncParser.intRead(FormMain.pathENBLocalINI, "ENGINE", "MaxAnisotropy"), false, comboBox_AF_SelectedIndexChanged); } else { comboBox_AF.SelectedIndex = -1; } comboBox_AF.Enabled = af; }
private void refreshFPS() { fps = FuncMisc.refreshButton(button_FPS, FormMain.pathENBLocalINI, "LIMITER", "EnableFPSLimit", null, false); if (fps) { FuncMisc.refreshComboBox(comboBox_FPS, new List <double>() { 30, 60, 75, 90, 120, 144, 240 }, FuncParser.intRead(FormMain.pathENBLocalINI, "LIMITER", "FPSLimit"), false, comboBox_FPS_SelectedIndexChanged); } else { comboBox_FPS.SelectedIndex = -1; } comboBox_FPS.Enabled = fps; }
private void refreshScreenIndex() { Screen[] screens = Screen.AllScreens; if (screens.Count() > 1) { comboBoxScreenTAB.Items.Clear(); for (int i = 0; i < screens.Count(); i++) { comboBoxScreenTAB.Items.Add(i.ToString()); } } int value = FuncParser.intRead(FormMain.pathSkyrimINI, "Display", "iAdapter"); if (value > -1 && value < comboBoxScreenTAB.Items.Count) { comboBoxScreenTAB.SelectedIndexChanged -= comboBoxScreen_SelectedIndexChanged; comboBoxScreenTAB.SelectedIndex = value; comboBoxScreenTAB.SelectedIndexChanged += comboBoxScreen_SelectedIndexChanged; } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // public static void refreshNumericUpDown(NumericUpDown numeric, string file, string section, string parametr, EventHandler onchange) { int value = FuncParser.intRead(file, section, parametr); if (onchange != null) { numeric.ValueChanged -= onchange; } if (value >= numeric.Minimum && value <= numeric.Maximum) { numeric.Value = value; } else { numeric.Value = numeric.Minimum; } if (onchange != null) { numeric.ValueChanged += onchange; } }
private void setAspectRatioFiles() { if (comboBoxResolutionTAB.SelectedIndex != -1) { double[] arlist = new double[] { 1.3, 1.4, 1.7, 1.8, 2.5 }; double ar = (double)screenListW[comboBoxResolutionTAB.SelectedIndex] / screenListH[comboBoxResolutionTAB.SelectedIndex]; int arl = FuncParser.intRead(FormMain.pathLauncherINI, "General", "AspectRatio"); for (int i = 0; i < arlist.Length; i++) { if (ar <= arlist[i]) { if (arl != i) { FuncMisc.unpackRAR(FormMain.pathLauncherFolder + @"CPFiles\System\AR(" + i.ToString() + ").rar"); FuncParser.iniWrite(FormMain.pathLauncherINI, "General", "AspectRatio", i.ToString()); FuncMisc.wideScreenMods(); } break; } } } }
// ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- // public static void wideScreenMods() { if (FuncParser.intRead(FormMain.pathLauncherINI, "General", "AspectRatio") == 4) { if (File.Exists(FormMain.pathDataFolder + "Frostfall.esp") && (!File.Exists(FormMain.pathDataFolder + "Frostfall-WS.esp") || !File.Exists(FormMain.pathDataFolder + "Frostfall-WS.bsa"))) { unpackArhive(FormMain.pathSystemFolder + "AR(4)FF", true); } if (File.Exists(FormMain.pathDataFolder + "DisableFastTravel.bsa") && new FileInfo(FormMain.pathDataFolder + "DisableFastTravel.bsa").Length != 45717) { unpackArhive(FormMain.pathSystemFolder + "AR(4)DFT", true); } } else { FuncFiles.deleteAny(FormMain.pathDataFolder + "Frostfall-WS.esp"); FuncFiles.deleteAny(FormMain.pathDataFolder + "Frostfall-WS.bsa"); if (File.Exists(FormMain.pathDataFolder + "DisableFastTravel.bsa") && new FileInfo(FormMain.pathDataFolder + "DisableFastTravel.bsa").Length != 45701) { unpackArhive(FormMain.pathModsFolder + "DisableFastTravel", true); } } }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// public static void wideScreenMods() { if (FuncParser.intRead(FormMain.pathLauncherINI, "General", "AspectRatio") == 4) { if (File.Exists(FormMain.pathGameFolder + @"Data\Frostfall.esp") && (!File.Exists(FormMain.pathGameFolder + @"Data\Frostfall-WS.esp") || !File.Exists(FormMain.pathGameFolder + @"Data\Frostfall-WS.bsa"))) { unpackRAR(FormMain.pathLauncherFolder + @"CPFiles\System\AR(4)FF.rar"); } if (File.Exists(FormMain.pathGameFolder + @"Data\DisableFastTravel.bsa") && new FileInfo(FormMain.pathGameFolder + @"Data\DisableFastTravel.bsa").Length != 45717) { unpackRAR(FormMain.pathLauncherFolder + @"CPFiles\System\AR(4)DFT.rar"); } } else { FuncFiles.deleteAny(FormMain.pathGameFolder + @"Data\Frostfall-WS.esp"); FuncFiles.deleteAny(FormMain.pathGameFolder + @"Data\Frostfall-WS.bsa"); if (File.Exists(FormMain.pathGameFolder + @"Data\DisableFastTravel.bsa") && new FileInfo(FormMain.pathGameFolder + @"Data\DisableFastTravel.bsa").Length != 45701) { unpackRAR(FormMain.pathLauncherFolder + @"CPFiles\DisableFastTravel.rar"); } } }
private void refreshScreenResolution() { screenListW.Clear(); screenListH.Clear(); comboBoxResolutionTAB.Items.Clear(); addResolution(FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iSize W"), FuncParser.intRead(FormMain.pathSkyrimPrefsINI, "Display", "iSize H")); bool fail = false; try { var scope = new ManagementScope(); var query = new ObjectQuery("SELECT * FROM CIM_VideoControllerResolution"); using (var searcher = new ManagementObjectSearcher(scope, query)) { var results = searcher.Get(); foreach (var result in results) { addResolution(FuncParser.stringToInt(result["HorizontalResolution"].ToString()), FuncParser.stringToInt(result["VerticalResolution"].ToString())); } } } catch { fail = true; } if (fail || comboBoxResolutionTAB.Items.Count < 2) { foreach (string line in FuncResolutions.Resolutions()) { int divider = line.IndexOf("/"); addResolution(FuncParser.stringToInt(line.Remove(divider)), FuncParser.stringToInt(line.Remove(0, divider + 1))); } } comboBoxResolutionTAB.SelectedIndex = 0; setAspectRatioFiles(); }
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(); }
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 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 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(); }
private bool checkUpdateFile(bool fromDL) { if (File.Exists(pathUpdateFolder + "file" + numberSelectFile + ".rar") && File.Exists(pathUpdateFolder + nameUpdateInfo) && File.Exists(FormMain.pathLauncherFolder + "UnRAR.exe")) { if (new FileInfo(pathUpdateFolder + "file" + numberSelectFile + ".rar").Length == FuncParser.intRead(pathUpdateFolder + nameUpdateInfo, "Update_" + numberSelectFile, "update_file_filesize")) { return(true); } else { if (fromDL) { MessageBox.Show(textNoSyncWithUI); } FuncFiles.deleteAny(pathUpdateFolder + "file" + numberSelectFile + ".rar"); } } else { if (fromDL) { MessageBox.Show(textNoTools); } } return(false); }
//////////////////////////////////////////////////////ГРАНИЦА ФУНКЦИИ////////////////////////////////////////////////////////////// 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(); }