public MainMenuButton(string _name, string _text, string _desc, int _position, string _type, string _target) : base(_name, _text, _desc, _position) { type = _type; target = _target; switch (type) { case "APP": // MessageBox.Show(_name); application.PATH = INIT.getpath(target); typeOfApp = _desc; break; default: target = _target; break; } }
public INI_Setting(string name, string text, string desc, int position, string defaultValue, string iniFilepath, string iniSection, string iniKey) : base(name, text, desc, defaultValue, position) { _iniFilepath = INIT.getpath(iniFilepath); _iniKey = iniKey; _iniSection = iniSection; if (!string.IsNullOrEmpty(_iniFilepath)) { IniManager _iniManager = new IniManager(_iniFilepath); if (!_iniSection.Equals("[NULL]")) { if (!_iniManager.isKeyExist(_iniKey) || !_iniManager.isSectionExist(_iniSection)) { if (!_iniKey.Contains(',')) { throw new INIDataNotFoundException(_iniSection, _iniKey, _iniFilepath); } else { List <string> substrings = iniKey.Split(',').ToList <string>(); foreach (string s in substrings) { if (!_iniManager.isKeyExist(s)) { throw new INIDataNotFoundException(_iniSection, _iniKey, _iniFilepath); } } } } } _currentValue = ""; _currentValue = _iniManager.getValueByKey(iniKey, iniSection); } }
public void act(object sender, MouseButtonEventArgs e) { switch (type) { case "APP": switch (typeOfApp) { case "GAME": try { new AppRunner(application.PATH).runApp(); } catch { throw new ApplicationNotFoundException(Path.GetFileNameWithoutExtension(application.PATH)); } break; case "OBSE_GAME": try { new OBSE_GAME_Runner(application.PATH).runApp(); } catch { throw new ApplicationNotFoundException(Path.GetFileNameWithoutExtension(application.PATH)); } break; case "CSE": try { new CSE_Runner(application.PATH).runApp(); } catch { throw new ApplicationNotFoundException(Path.GetFileNameWithoutExtension(application.PATH)); } break; default: try { new AppRunner(application.PATH).runApp(); } catch { throw new ApplicationNotFoundException(Path.GetFileNameWithoutExtension(application.PATH)); } break; } break; case "WINDOW": new CPWindow(target).ShowDialog(); break; case "HTTP": System.Diagnostics.Process.Start(INIT.getpath(target)); break; case "CP_UTIL": switch (target) { case "RESET": Utils.ResetSettings(); break; case "ENB_MANAGER": if (Directory.Exists(INIT.ENB_DIR)) { new ENB_MANAGER().ShowDialog(); } break; case "LO_MANAGER": new LO_MANAGER().ShowDialog(); break; case "UPDATER": try { UPDATER.TEMP_DB_SQLITE_FILE = INIT.RES_DIR + "TEMP.db"; UPDATER.TEMP_DB_CONNECTION_STRING = "Data Source=" + UPDATER.TEMP_DB_SQLITE_FILE; UPDATER.getnewBD(); } catch (NoInternetConnectionException) { return; } try { new UPDATER().ShowDialog(); } catch (gameBuildInvalidVersionForUpdateException ex) { MessageBox.Show(ex.Message); return; } break; default: break; } break; default: break; } }
public static void ResetSettings() { try { MessageBox.Show("настройки будут сброшены"); Logger.addLine(true, "Начат сброс настроек" + " : " + DateTime.Now.ToString()); registryFix(INIT.REGISTRY_HIVE, INIT.GAME_ROOT); string table = "RESET"; List <Tuple <string, string> > sourceToTargetList = new List <Tuple <string, string> >(); List <string> removeTargets = new List <string>(); List <string> dirsToCreate = new List <string>(); SQLiteManager mngr = new SQLiteManager(); DataTable data = mngr.getListItems(table); foreach (DataRow dtRow in data.Rows) { if ((dtRow[0].ToString().Equals("copy"))) { string source = INIT.getpath(dtRow[1].ToString()); string target = INIT.getpath(dtRow[2].ToString()); sourceToTargetList.Add(new Tuple <string, string>(source, target)); } else { if ((dtRow[0].ToString().Equals("remove"))) { string fileToRemove = INIT.getpath(dtRow[1].ToString()); removeTargets.Add(fileToRemove); } else { if ((dtRow[0].ToString().Equals("create_dir"))) { string dirToCreate = INIT.getpath(dtRow[1].ToString()); dirsToCreate.Add(dirToCreate); } } } } mngr.ConnectionClose(); FileManager.remove(removeTargets.ToArray()); foreach (string dirs in dirsToCreate) { FileManager.createDirectory(dirs); } foreach (Tuple <string, string> pair in sourceToTargetList) { FileManager.copyFiles(pair.Item1, pair.Item2); } MessageBox.Show("Сброс настроек произведен"); Logger.addLine(true, "Сброс настроек произведен" + " : " + DateTime.Now.ToString()); } catch (Exception) { Logger.addLine(false, "Сброс настроек произвеcти не удалось!" + " : " + DateTime.Now.ToString()); Logger.addLine(true, "Завершение приложения: " + DateTime.Now.ToString()); Environment.Exit(1); } }