// contructor public ConfigImport() { // populate config info from database _Paths = Paths.GetPaths(); _ConfigNetplaySettings = ConfigNetplaySettings.GetNetplay(); _ConfigServerSettings = new ConfigServerSettings(); // ConfigServerSettings.GetServer(100); _ConfigBaseSettings = ConfigBaseSettings.GetConfig(2000000000); _ConfigGbSettings = ConfigBaseSettings.GetConfig(2000000001); _ConfigGbaSettings = ConfigBaseSettings.GetConfig(2000000002); _ConfigLynxSettings = ConfigBaseSettings.GetConfig(2000000003); _ConfigMdSettings = ConfigBaseSettings.GetConfig(2000000004); _ConfigGgSettings = ConfigBaseSettings.GetConfig(2000000005); _ConfigNgpSettings = ConfigBaseSettings.GetConfig(2000000006); _ConfigPceSettings = ConfigBaseSettings.GetConfig(2000000007); _ConfigPcfxSettings = ConfigBaseSettings.GetConfig(2000000008); _ConfigPsxSettings = ConfigBaseSettings.GetConfig(2000000009); _ConfigSmsSettings = ConfigBaseSettings.GetConfig(2000000010); _ConfigNesSettings = ConfigBaseSettings.GetConfig(2000000011); _ConfigSnesSettings = ConfigBaseSettings.GetConfig(2000000012); _ConfigSsSettings = ConfigBaseSettings.GetConfig(2000000013); _ConfigVbSettings = ConfigBaseSettings.GetConfig(2000000014); _ConfigWswanSettings = ConfigBaseSettings.GetConfig(2000000015); _ConfigSnes_faustSettings = ConfigBaseSettings.GetConfig(2000000016); _ConfigPce_fastSettings = ConfigBaseSettings.GetConfig(2000000017); if (VersionChecker.Instance.CurrentMedVerDesc.MajorINT > 0) { MednafenConfigName = @"mednafen.cfg"; } else { MednafenConfigName = @"\mednafen-09x.cfg"; } }
public static void PopulateServers(DataGrid lvServers) { // get all servers var servers = ConfigServerSettings.GetServers() .Where(a => a.netplay__host != null && a.netplay__gamekey != null && a.netplay__password != null && a.netplay__port != null).ToList(); if (servers == null || servers.Count == 0) { return; } // get selected server id GlobalSettings gs = GlobalSettings.GetGlobals(); int sid = gs.serverSelected.Value; List <ServersListView> list = new List <ServersListView>(); // populate list foreach (var s in servers) { ServersListView srv = new ServersListView(); srv.ID = s.ConfigServerId; srv.Name = s.ConfigServerDesc; srv.Host = s.netplay__host; srv.Port = s.netplay__port.Value; srv.Password = s.netplay__password; srv.Gamekey = s.netplay__gamekey; if (sid == srv.ID) { srv.Selected = true; } else { srv.Selected = false; } list.Add(srv); } lvServers.ItemsSource = list; }
public static void InitialSeed() { // check whether initial seed needs to continue bool doSeed = false; using (var db = new MyDbContext()) { var se = db.GlobalSettings.FirstOrDefault(); if (se == null || se.databaseGenerated == false) { doSeed = true; } } if (doSeed == true) { /* * // Create systems * List<GameSystem> gSystems = GameSystem.GetGameSystemDefaults(); * using (var context = new MyDbContext()) * { * var gameData = context.GameSystem.AsNoTracking().ToList(); * foreach (var newEntry in gSystems) * { * var idLookup = (from e in gameData * where e.systemId == newEntry.systemId * select e).FirstOrDefault(); * * if (idLookup == null) * { * // entry doesnt exist - insert * context.GameSystem.Add(newEntry); * } * else * { * // entry exists - update * context.GameSystem.Update(newEntry); * } * } * context.SaveChanges(); * } */ // populate Versions table Versions version = Versions.GetVersionDefaults(); using (var context = new MyDbContext()) { context.Versions.Add(version); context.SaveChanges(); } // default netplay settings ConfigNetplaySettings npSettings = ConfigNetplaySettings.GetNetplayDefaults(); using (var context = new MyDbContext()) { context.ConfigNetplaySettings.Add(npSettings); context.SaveChanges(); } // default ConfigBaseSettings population ConfigBaseSettings cfbs = ConfigBaseSettings.GetConfigDefaults(); cfbs.ConfigId = 2000000000; // base configuration using (var context = new MyDbContext()) { context.ConfigBaseSettings.Add(cfbs); context.SaveChanges(); } // create system specific configs (set to disabled by default) List <GSystem> gamesystems = GSystem.GetSystems(); using (var gsContext = new MyDbContext()) { // iterate through each system and create a default config for them - setting them to disabled, setting their ID to 2000000000 + SystemID // and setting their systemident to systemid foreach (GSystem System in gamesystems) { int def = 2000000000; ConfigBaseSettings c = ConfigBaseSettings.GetConfigDefaults(); c.ConfigId = def + System.systemId; c.systemIdent = System.systemId; c.isEnabled = false; // add to databsae gsContext.ConfigBaseSettings.Add(c); gsContext.SaveChanges(); } } // Populate Servers List <ConfigServerSettings> servers = ConfigServerSettings.GetServerDefaults(); using (var context = new MyDbContext()) { context.ConfigServerSettings.AddRange(servers); context.SaveChanges(); } // Create General Settings Entry GlobalSettings gs = GlobalSettings.GetGlobalDefaults(); using (var context = new MyDbContext()) { context.GlobalSettings.Add(gs); context.SaveChanges(); } // create Paths entry Paths paths = new Paths { pathId = 1 }; using (var context = new MyDbContext()) { context.Paths.Add(paths); context.SaveChanges(); } //add test rom data /* * List<Game> roms = new List<Game> * { * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 3, hidden = false, isFavorite = true }, * new Game { gameName = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 8), gamePath = ".\\", systemId = 10, hidden = false, isFavorite = false } * }; * using (var context = new MyDbContext()) * { * * context.Game.AddRange(roms); * context.SaveChanges(); * } */ // initial seeding complete. mark GeneralSettings table so that regeneration does not occur GlobalSettings set; using (var context = new MyDbContext()) { set = (from a in context.GlobalSettings where a.settingsId == 1 select a).FirstOrDefault <GlobalSettings>(); } if (set != null) { set.databaseGenerated = true; } using (var dbCtx = new MyDbContext()) { dbCtx.Entry(set).State = EntityState.Modified; dbCtx.SaveChanges(); } } }
/// <summary> /// Save settings based on settings group /// </summary> /// <param name="settingGroup"></param> public static void SaveSettings(SettingGroup settingGroup) { MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); switch (settingGroup) { case SettingGroup.BiosPaths: ConfigBaseSettings.SaveBiosPaths(); break; case SettingGroup.GamePaths: TextBox tbPathMednafen = (TextBox)mw.FindName("tbPathMednafen"); TextBox tbPathGb = (TextBox)mw.FindName("tbPathGb"); TextBox tbPathGba = (TextBox)mw.FindName("tbPathGba"); TextBox tbPathGg = (TextBox)mw.FindName("tbPathGg"); TextBox tbPathLynx = (TextBox)mw.FindName("tbPathLynx"); TextBox tbPathMd = (TextBox)mw.FindName("tbPathMd"); TextBox tbPathNes = (TextBox)mw.FindName("tbPathNes"); TextBox tbPathSnes = (TextBox)mw.FindName("tbPathSnes"); TextBox tbPathNgp = (TextBox)mw.FindName("tbPathNgp"); TextBox tbPathPce = (TextBox)mw.FindName("tbPathPce"); TextBox tbPathPcfx = (TextBox)mw.FindName("tbPathPcfx"); TextBox tbPathSms = (TextBox)mw.FindName("tbPathSms"); TextBox tbPathVb = (TextBox)mw.FindName("tbPathVb"); TextBox tbPathWswan = (TextBox)mw.FindName("tbPathWswan"); Paths.SavePathSettings(tbPathMednafen, tbPathGb, tbPathGba, tbPathGg, tbPathLynx, tbPathMd, tbPathNes, tbPathSnes, tbPathNgp, tbPathPce, tbPathPcfx, tbPathSms, tbPathVb, tbPathWswan); break; case SettingGroup.GlobalSettings: GlobalSettings gs = GlobalSettings.GetGlobals(); Slider slFanrtsPerHost = (Slider)mw.FindName("slFanrtsPerHost"); Slider slScreenshotsPerHost = (Slider)mw.FindName("slScreenshotsPerHost"); ComboBox comboImageTooltipSize = (ComboBox)mw.FindName("comboImageTooltipSize"); gs.maxFanarts = slFanrtsPerHost.Value; gs.maxScreenshots = slScreenshotsPerHost.Value; gs.imageToolTipPercentage = Convert.ToDouble(comboImageTooltipSize.SelectedValue); GlobalSettings.SetGlobals(gs); break; case SettingGroup.MednafenPaths: ConfigBaseSettings.SaveMednafenPaths(); break; case SettingGroup.NetplaySettings: TextBox tbNetplayNick = (TextBox)mw.FindName("tbNetplayNick"); Slider slLocalPlayersValue = (Slider)mw.FindName("slLocalPlayersValue"); Slider slConsoleLinesValue = (Slider)mw.FindName("slConsoleLinesValue"); Slider slConsoleScaleValue = (Slider)mw.FindName("slConsoleScaleValue"); RadioButton resOne = (RadioButton)mw.FindName("resOne"); RadioButton resTwo = (RadioButton)mw.FindName("resTwo"); RadioButton resThree = (RadioButton)mw.FindName("resThree"); RadioButton resFour = (RadioButton)mw.FindName("resFour"); RadioButton resFive = (RadioButton)mw.FindName("resFive"); ConfigNetplaySettings.SaveNetplaySettings(tbNetplayNick, slLocalPlayersValue, slConsoleLinesValue, slConsoleScaleValue, resOne, resTwo, resThree, resFour, resFive); break; case SettingGroup.ServerSettings: TextBox tbServerDesc = (TextBox)mw.FindName("tbServerDesc"); TextBox tbHostname = (TextBox)mw.FindName("tbHostname"); Slider slServerPort = (Slider)mw.FindName("slServerPort"); TextBox tbPassword = (TextBox)mw.FindName("tbPassword"); TextBox tbGameKey = (TextBox)mw.FindName("tbGameKey"); ConfigServerSettings.SaveCustomServerSettings(tbServerDesc, tbHostname, slServerPort, tbPassword, tbGameKey); break; default: break; } }
internal ConfigServerProperties(ConfigServerState?provisioningState, AppPlatformErrorInfo error, ConfigServerSettings configServer) { ProvisioningState = provisioningState; Error = error; ConfigServer = configServer; }
/// <summary> /// Check if the config server settings are valid. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serviceName'> /// The name of the Service resource. /// </param> /// <param name='configServerSettings'> /// Config server settings to be validated /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ConfigServerSettingsValidateResult> BeginValidateAsync(this IConfigServersOperations operations, string resourceGroupName, string serviceName, ConfigServerSettings configServerSettings, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginValidateWithHttpMessagesAsync(resourceGroupName, serviceName, configServerSettings, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Check if the config server settings are valid. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group that contains the resource. You can obtain /// this value from the Azure Resource Manager API or the portal. /// </param> /// <param name='serviceName'> /// The name of the Service resource. /// </param> /// <param name='configServerSettings'> /// Config server settings to be validated /// </param> public static ConfigServerSettingsValidateResult BeginValidate(this IConfigServersOperations operations, string resourceGroupName, string serviceName, ConfigServerSettings configServerSettings) { return(operations.BeginValidateAsync(resourceGroupName, serviceName, configServerSettings).GetAwaiter().GetResult()); }