// Use this for initialization void Start() { cm = GetComponent<ConfigManager> ();//Gets the ConfigManager //float Duration = (float)Double.Parse(cm.Load ("Duration"));//Stores the lifespan of the puffer cloud float Duration = 1.0f; Lifetime = Time.time + Duration;//Sets the delete timer to the future }
void ApplicationSettings(ConfigManager config) { config.appName = EditorGUILayout.TextField("App Name", config.appName); EditorGUILayout.LabelField("Nome do App exibido nas PopUps nativas", EditorStyles.whiteMiniLabel); config.appId = EditorGUILayout.IntField("App ID", config.appId); EditorGUILayout.LabelField("ID do App na database", EditorStyles.whiteMiniLabel); config.appVersion = EditorGUILayout.FloatField("App Version", config.appVersion); EditorGUILayout.LabelField("Versão do App (float)", EditorStyles.whiteMiniLabel); config.appProtocol = EditorGUILayout.TextField("App Protocol", config.appProtocol).Replace(":", "").Replace("/", ""); EditorGUILayout.LabelField("Protocolo do App (ex: utgbase://)", EditorStyles.whiteMiniLabel); EditorGUILayout.Space(); config.headerObject = (GameObject) EditorGUILayout.ObjectField("Header", config.headerObject, typeof(GameObject)); EditorGUILayout.LabelField("Objeto Header", EditorStyles.whiteMiniLabel); EditorGUILayout.Space(); config.loading = (GameObject) EditorGUILayout.ObjectField("Loading Dialog", config.loading, typeof(GameObject)); config.messageOk = (GameObject) EditorGUILayout.ObjectField("Message Ok Dialog", config.messageOk, typeof(GameObject)); config.messageOkCancel = (GameObject) EditorGUILayout.ObjectField("Message Ok Cancel Dialog", config.messageOkCancel, typeof(GameObject)); config.inviteAllScroll = (UIScrollList) EditorGUILayout.ObjectField("Invite 'all' ScrollList ", config.inviteAllScroll, typeof(UIScrollList)); config.invitePlayingScroll = (UIScrollList) EditorGUILayout.ObjectField("Invite 'playing' ScrollList", config.invitePlayingScroll, typeof(UIScrollList)); EditorGUILayout.LabelField("Janelas padrao", EditorStyles.whiteMiniLabel); config.appInitialCoins = EditorGUILayout.IntField("Initial Coins Number", config.appInitialCoins); }
private void AtFolder_ReturnsSelf() { var configManager = new ConfigManager() .WithLocalMachineScope(); Assert.IsType<ConfigManager>( configManager.AtFolder("2ED1FA2A-62B3-46E4-BB02-24008FA4373A")); }
public void TestInstanceClassWithoutKey() { InstanceConfig config = new InstanceConfig(); ConfigManager configManager = new ConfigManager(); configManager.Register(config); configManager.RegisterProvider(new ConfigurationProviderAppConfig()); configManager.Update(); Assert.AreEqual("xx1", config.Test1); Assert.AreEqual(99, config.SubObject1.TestInt1); Assert.IsNotNull(config.IntValues); Assert.IsNotNull(config.StringValues); Assert.AreEqual("x", config.StringValues["ValX"]); Assert.AreEqual("y", config.StringValues["ValY"]); Assert.AreEqual("z", config.StringValues["ValZ"]); Assert.AreEqual(3, config.StringValues.Count); Assert.AreEqual(1, config.IntValues["Val1"]); Assert.AreEqual(2, config.IntValues["Val2"]); Assert.AreEqual(3, config.IntValues["Val3"]); Assert.AreEqual(3, config.IntValues.Count); }
public ConfigImplementationSelectorItem( ConfigManager configManager, PluginCluster pluginCluster ) : base(configManager) { _cluster = pluginCluster; SelectItem = new VMCommand( OnSelectItem, CanSelectItem ); OpenEditor = new VMCommand( StartPluginEditor, () => CanOpenEditor ); }
public static void AddSettings(ConfigManager config, string key, string value, ServerSettings.Type type) { if (key.IsEmpty()) return; int duplicated = -1; ConfigManager.CachedServerSettings newSetting = new ConfigManager.CachedServerSettings(); newSetting.key = key; newSetting.setting = new ServerSettings.Serializable(value, type); for(int i = 0; i < config.serverSettings.Length; i++) { ConfigManager.CachedServerSettings setting = config.serverSettings[i]; if (setting.key == key) { duplicated = i; break; } } if (!(duplicated >= 0)) { Array.Resize(ref config.serverSettings, config.serverSettings.Length + 1); config.serverSettings[config.serverSettings.Length - 1] = newSetting; Array.Sort(config.serverSettings, delegate(ConfigManager.CachedServerSettings a, ConfigManager.CachedServerSettings b) { return a.key.CompareTo(b.key); } ); return; } config.serverSettings[duplicated] = newSetting; }
// Use this for initialization void Start() { cm = GameObject.Find ("Configuration").GetComponent <ConfigManager>();// GetComponent<ConfigManager> (); pm = GameObject.Find("Player").GetComponent<PlayerManager>(); pufferSlider.maxValue = (float)Double.Parse(cm.Load ("MaxPufferCharge"));; breathSlider.maxValue = (float)Double.Parse(cm.Load ("MaxBreath")); }
public xEmulateForm(string[] args) { InitializeComponent(); Singleton<InfoTextManager>.Instance.Init(ref infoText); Singleton<InputManager>.Instance.Init(); Singleton<DxInputManager>.Instance.Init(this); Singleton<XimDyn>.Instance.Init(); m_commandParser = CommandParser.Instance; m_ximulator = new Ximulator(this); m_configManager = ConfigManager.Instance; m_varManager = VarManager.Instance; if (args.Length == 0 || !m_configManager.LoadConfig(args[0])) { m_configManager.LoadDefaultConfig(); } this.cbGame.Items.AddRange(GamesManager.GameNames); if(System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) this.version.Text = "Version: "+System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); this.drawSticksCenter = new Vector2(this.mouseDisplayRect.Location.X + this.mouseDisplayRect.Size.Width / 2, this.mouseDisplayRect.Location.Y + this.mouseDisplayRect.Size.Height / 2); drawSticksSize = this.mouseDisplayRect.Size.Height; SyncUI(); SetTooltips(); commandBox.Focus(); }
public void SetUp() { _configManager = ConfigManager.GetInstance(); if (_configManager.GetConfigFile(XmlConfigFile) == null) _configManager.Load(XmlConfigFile); }
public static ConfigManager GetInstance() { if (instance == null) { instance = (ConfigManager) FindObjectOfType(typeof(ConfigManager)); } return instance; }
public UserCredentialsForm(ConfigManager manager) { this._manager = manager; InitializeComponent(); textBox_Password.PasswordChar = '*'; comboBox_Department.SelectedIndex = 0; }
public void GuestAndHostEnvTests() { Stream configStream = Assembly.GetExecutingAssembly().GetManifestResourceStream( "RemoteInstallUnitTests.TestConfigs.MinimumCopy.config"); string configFileName = Path.GetTempFileName(); using (StreamReader everythingReader = new StreamReader(configStream)) { File.WriteAllText(configFileName, everythingReader.ReadToEnd()); } ConfigManager configManager = new ConfigManager(configFileName, new NameValueCollection()); Assert.AreEqual(1, configManager.Configuration.CopyFiles.Count); /* <copyfiles destpath="windows\${hostenv.PROCESSOR_ARCHITECTURE}\${env.PROCESSOR_ARCHITECTURE}\systemfiles"> <copyfile file="${guestenv.ProgramFiles(x86)}\system.ini" /> </copyfiles> */ CopyFileConfig copyFileConfig = configManager.Configuration.CopyFiles[0]; Console.WriteLine("{0}: {1} => {2}", copyFileConfig.Name, copyFileConfig.File, copyFileConfig.DestinationPath); string pa = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE"); Assert.AreEqual(string.Format("system dot ini ({0})", pa), copyFileConfig.Name); Assert.AreEqual(@"${guestenv.ProgramFiles(x86)}\system.ini", copyFileConfig.File); Assert.AreEqual(string.Format(@"windows\{0}\{1}\systemfiles", "${hostenv.PROCESSOR_ARCHITECTURE}", pa), copyFileConfig.DestinationPath); File.Delete(configFileName); }
public void TestComplexSave() { var baseConfig = CreateTestConfig("configbase.xml"); var userConfig = new Configuration() { FilePath = Path.Combine(Path.GetDirectoryName(baseConfig.FilePath), "config.xml"), Parent = "configbase.xml" }; baseConfig.ChildConfigurations.Add(userConfig); userConfig.Parameters.Add(new Parameter() { Name = "TestParam", Value = "uservalue", ValueComesFromConfiguration = userConfig }); ConfigManager.SaveConfig(baseConfig); ConfigManager.SaveConfig(userConfig); var man = new ConfigManager(userConfig.FilePath); man.Load(); var param = man.Config.Parameters.FirstOrDefault(p => p.Name == "TestParam"); param.Value = "testnewvalue"; man.Save(); man.Load(); param = man.Config.Parameters.FirstOrDefault(p => p.Name == "TestParam"); Assert.IsTrue(param.Value == "testnewvalue"); }
// Use this for initialization public void setupTab(ConfigManager config, List<ConfigManager.Child> list) { cM = config; cam = Camera.main; clusterStart = 0; playerStart= 0; selectedCluster =""; selectedPlayer =""; demographics = list; clusterScroll.scrollValue = 0; playerScroll.scrollValue = 0; completed = new Dictionary<string, bool>(); foreach(ConfigManager.Child c in demographics){ bool complete =false; if(c.lastCompleted>=6) complete = true; completed.Add(c.Cluster+c.ID, complete); } updateLists(); }
static void Main(string[] args) { //App name, this is what the folder will be called in Appdata\Local\<appNameSpace> string appNamespace = "Json2Config.Net"; //Creates the config folder & config.json ConfigManager burgerCfg = new ConfigManager(appNamespace, "burgerCfg"); ConfigManager securityCfg = new ConfigManager(appNamespace, "securityCfg"); //Get the objects ready Store myStore = new Store(); myStore.Name = "Bobs Burgers"; Product product1 = new Product() { Name = "Cheese Burgers", Price = 7.99 }; Product product2 = new Product() { Name = "Pizza", Price = 12.49 }; myStore.Products.Add(product1); myStore.Products.Add(product2); //Save the objects! burgerCfg.SaveConfig(myStore); Company myCompany = new Company(); myCompany.CompanyId = 1; myCompany.CompanyName = "Jacks Security Folk"; Client client1 = new Client() { ClientId = 1, Name = "Bobs Burgers", WebsiteUrl = "BobsBurgers.biz" }; myCompany.Clients.Add(client1); securityCfg.SaveConfig(myCompany); }
public void SetUp() { _configManager = ConfigManager.GetInstance(); _configManager.Load(@"test_files\AccuracyTest.ini"); _namespaces[0] = _configManager.GetNamespace("AccuracyNamespace1"); _namespaces[1] = _configManager.GetNamespace("AccuracyNamespace2"); }
private void MainForm_Load(object sender, EventArgs e) { loader = new ConfigManager(ConstFields.CONFIGRATION_FILE_NAME); if (_printerInfo != null) { UpdateGridView(_printerInfo); } }
//Instance public static ConfigManager getInstance() { if (manager == null) { //第一次调用的时候 创建单例对象 manager = new ConfigManager(); } return manager; }
public MainForm() { _config = ConfigManager<ConfigMappings>.Resolve("settings.ini"); _tileSets = new Dictionary<string, Image>(); InitializeComponent(); InitialiseRows(); InitialiseTileSets(); }
public static ConfigManager GetInstance() { if (instance == null) { instance = new ConfigManager(); } return instance; }
void Set_SomeKeysAndValues_GetAndEqual(string key, object value, DataProtectionScope scope) { string result = new ConfigManager() .WithScope(scope) .Set(key, value) .Get<string>(key); Assert.Equal(result, value); }
public IConfigLoaderProduct InitializeConfigurationLoader(StorageType type, ConfigManager manager) { switch (type) { case StorageType.Db: { return new DbConfigLoaderProduct(manager); } case StorageType.Xml: { return new XmlConfigLoaderProduct(manager); } default: throw new ConfigurationComponentException(this, -1, "Unable to determine where the configuration data should be loaded from?"); } }
static void Main() { ConfigManager configManager1 = new ConfigManager(); configManager1.LoadConfig(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DirectJobForm()); }
public static void DrawShopItems(ConfigManager config) { for(int i = 0 ; i < config.shopItems.Length ; i++) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label("Shop Item"); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); config.shopItems[i].hide = !EditorGUILayout.BeginToggleGroup("Show", config.shopItems[i].hide); config.shopItems[i].type = (ShopItemType) EditorGUILayout.EnumPopup("Item Type", config.shopItems[i].type); config.shopItems[i].id = EditorGUILayout.TextField("ID",config.shopItems[i].id); config.shopItems[i].name = EditorGUILayout.TextField("Item Name", config.shopItems[i].name); config.shopItems[i].coinPrice = EditorGUILayout.IntField("Coin price",config.shopItems[i].coinPrice); config.shopItems[i].description = EditorGUILayout.TextField("Description", config.shopItems[i].description); config.shopItems[i].image = (Texture) EditorGUILayout.ObjectField("Image",config.shopItems[i].image,typeof(Texture)); config.shopItems[i].arraySize = EditorGUILayout.IntField("Items Inside Pack",config.shopItems[i].arraySize); if(config.shopItems[i].itemsWithin.Length < config.shopItems[i].arraySize) { //Debug.Log("aha yeye"); for(int m = 0 ; m <= (config.shopItems[i].arraySize - config.shopItems[i].itemsWithin.Length) ; m++) { config.shopItems[i].itemsWithin.Add(new ShopItem(), ref config.shopItems[i].itemsWithin); } } else if(config.shopItems[i].itemsWithin.Length > config.shopItems[i].arraySize) { //Debug.Log("aha yaye"); for(int m = 0 ; m <= (config.shopItems[i].itemsWithin.Length - config.shopItems[i].arraySize) ; m++) { config.shopItems[i].itemsWithin.Remove(config.shopItems[i].itemsWithin.Length-1, ref config.shopItems[i].itemsWithin); } } foreach(ShopItem iw in config.shopItems[i].itemsWithin) { iw.id = EditorGUILayout.TextField("ID", iw.id); //iw.forFree = EditorGUILayout.Toggle("For Free",iw.forFree); iw.count = EditorGUILayout.IntField("Count",iw.count); EditorGUILayout.Separator(); } EditorGUILayout.EndToggleGroup(); if(GUILayout.Button("Delete Shop Item")) { config.shopItems.Remove(i, ref config.shopItems); } EditorGUILayout.LabelField("-".Multiply(500)); } }
public static ConfigManager GetInstance() { if(instance == null) { GameObject go = new GameObject(); instance = go.AddComponent<ConfigManager>(); } return instance; }
static void Main(string[] args) { var p = @"D:\temp\foo.config.json"; using (var m = new ConfigManager<FooConfig>(p)) { m.GetConfig().Dump(); m.ConfigChanged += (s, e) => { e.Config.Dump(); }; Console.ReadKey(); } }
// Use this for initialization void Start() { cm = GetComponent<ConfigManager>(); yCenter = transform.position.y; yMove = 0f; pm = GameObject.Find("Player").GetComponent<PlayerManager>(); pufferRecharge = (float)Double.Parse(cm.Load ("pufferRecharge")); pufferscore = Int32.Parse(cm.Load ("pufferscore")); }
public SubViewModel( ConfigManager configManager ) : base( configManager ) { DisplayName = "Sub view"; this.AddProperty( "Bool property", this, ( o ) => o.BoolProperty ); this.AddLink( SpecificVM ); this.AddLink( ProfilesVM ); }
public ConfigCurrentItemTestsViewModel( ConfigManager configManager ) : base( configManager ) { DisplayName = "CurrentItemConfig usages"; this.AddLink( ProfilesNoNotifyVM ); this.AddLink( ProfilesAutoSetVM ); this.AddLink( ProfilesVM ); }
public PrintingOptionsForm() { InitializeComponent(); Loader = new ConfigManager(ConstFields.CONFIGRATION_FILE_NAME); foreach (Tuple<string, bool> command in Loader.GetAllPrintingOptions()) { this.checkedListBox_PrintingOptions.Items.Add(command.Item1); this.checkedListBox_PrintingOptions.SetItemChecked( this.checkedListBox_PrintingOptions.Items.Count - 1, command.Item2); } }
private void AlgorithmSettingsContextMenu_Closed(object sender, RoutedEventArgs e) { ConfigManager.CommitBenchmarksForDevice(_algorithmContainer.ComputeDevice); }
private void SetVersion() { VersionLabel.Text = VersionLabel.Text.Replace("[VERSION]", ConfigManager.GetVersion()); VERSION = ConfigManager.GetVersion(); }
private void TrackSelectionCheckBox_CheckedChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.TrackSelection, TrackSelectionCheckBox.Checked.ToString()); }
protected void Page_Load(object sender, EventArgs e) { this.reloginPageUrl = ConfigManager.GetReloginPageUrl(); modifyPasswordPageUrl = ConfigurationManager.AppSettings["ModifyPasswordPageUrl"]; }
/// <summary> /// Method to expand tokens within a string /// </summary> /// <param name="tokenizedString">String with one of these tokens {env}, {app}, {machine}, {user} </param> /// <returns>A string with tokens expanded</returns> /// <remarks> /// <para>{env} - active environment</para> /// <para>{app} - application key</para> /// <para>{machine} - machine name</para> /// <para>{user} - user name</para> /// <para>{ts} - timestamp format tokens (</para> /// </remarks> public static string ReplaceTokens(string tokenizedString) { return(ConfigManager.ResolveKeyTokens(tokenizedString)); }
/// <summary> /// To restore the strategy state. /// </summary> /// <param name="strategy">Strategy.</param> /// <param name="storage">Market data storage.</param> /// <remarks> /// This method is used to load statistics, orders and trades. The data storage shall include the following parameters: 1. Settings (SettingsStorage) � statistics settings. 2. Statistics(SettingsStorage) � saved state of statistics. 3. Orders (IDictionary[Order, IEnumerable[MyTrade]]) � orders and corresponding trades. 4. Positions (IEnumerable[Position]) � strategy positions. If any of the parameters is missing, data will not be restored. /// </remarks> public static void LoadState(this Strategy strategy, SettingsStorage storage) { if (strategy == null) { throw new ArgumentNullException(nameof(strategy)); } if (storage == null) { throw new ArgumentNullException(nameof(storage)); } var settings = storage.GetValue <SettingsStorage>("Settings"); if (settings != null && settings.Count != 0) { var connector = strategy.Connector ?? ConfigManager.TryGetService <IConnector>(); if (connector != null && settings.Contains("security")) { strategy.Security = connector.LookupById(settings.GetValue <string>("security")); } if (connector != null && settings.Contains("portfolio")) { strategy.Portfolio = connector.Portfolios.FirstOrDefault(p => p.Name == settings.GetValue <string>("portfolio")); } var id = strategy.Id; strategy.Load(settings); if (strategy.Id != id) { throw new InvalidOperationException(LocalizedStrings.Str1404); } } var statistics = storage.GetValue <SettingsStorage>("Statistics"); if (statistics != null) { foreach (var parameter in strategy.StatisticManager.Parameters.Where(parameter => statistics.ContainsKey(parameter.Name))) { parameter.Load(statistics.GetValue <SettingsStorage>(parameter.Name)); } } var orders = storage.GetValue <IDictionary <Order, IEnumerable <MyTrade> > >("Orders"); if (orders != null) { foreach (var pair in orders) { strategy.AttachOrder(pair.Key, pair.Value); } } var positions = storage.GetValue <IEnumerable <KeyValuePair <Tuple <SecurityId, string>, decimal> > >("Positions"); if (positions != null) { strategy.PositionManager.Positions = positions; } }
public IActionResult Index() { return(View(new LandingViewModel(this.ServerName) { AppList = AppViewModelFactory.FromApps(userApps: _appRepo.ListAll(), builtInApps: ConfigManager.ListAll()) })); }
private void LiveMidiCheckBox_CheckedChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.LiveMidi, LiveMidiCheckBox.Checked.ToString()); }
private void InitRadioButtons() { ActionManager.AutoConsoleMode consoleMode = ActionManager.AutoConsoleModeFromString(ConfigManager.GetProperty(PropertyItem.ConsoleOpenMode)); switch (consoleMode) { case ActionManager.AutoConsoleMode.New: NewAutoConsoleRadio.Checked = true; OldAutoConsoleRadio.Checked = false; OffAutoConsoleRadio.Checked = false; return; case ActionManager.AutoConsoleMode.Old: NewAutoConsoleRadio.Checked = false; OldAutoConsoleRadio.Checked = true; OffAutoConsoleRadio.Checked = false; return; case ActionManager.AutoConsoleMode.Off: NewAutoConsoleRadio.Checked = false; OldAutoConsoleRadio.Checked = false; OffAutoConsoleRadio.Checked = true; return; } }
private void NoteCountNumeric_ValueChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.AvaliableNoteCount, (NoteCountNumeric.Value).ToString()); }
private void NoteCooldownNumeric_ValueChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.NoteCooldown, NoteCooldownNumeric.Value.ToString()); }
private void LowestNoteNumeric_ValueChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.LowestNoteId, LowestNoteNumeric.Value.ToString()); }
private void NoteConversionMode_SelectedIndexChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.NoteConversionMode, NoteConversionMode.SelectedIndex.ToString()); }
private void OnlineSyncCheckBox_CheckedChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.OnlineSync, OnlineSyncCheckBox.Checked.ToString()); }
private void EnableChanged(object sender, RoutedEventArgs e) { ConfigManager.CommitBenchmarksForDevice(_algorithmContainer.ComputeDevice); }
// This is a single shot _benchmarkTimer private void StartupTimer_Tick(object sender, EventArgs e) { StartupTimer.Stop(); StartupTimer = null; // Internals Init // TODO add loading step MinersSettingsManager.Init(); if (!Helpers.InternalCheckIsWow64()) { MessageBox.Show(International.GetText("Form_Main_x64_Support_Only"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.OK); this.Close(); return; } // 3rdparty miners check scope #1 { // check if setting set if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.NOT_SET) { // Show TOS Form tos = new Form_3rdParty_TOS(); tos.ShowDialog(this); } } // Query Avaliable ComputeDevices ComputeDeviceManager.Query.QueryDevices(LoadingScreen); _isDeviceDetectionInitialized = true; ///////////////////////////////////////////// /////// from here on we have our devices and Miners initialized ConfigManager.AfterDeviceQueryInitialization(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SaveConfig")); // All devices settup should be initialized in AllDevices devicesListViewEnableControl1.ResetComputeDevices(ComputeDeviceManager.Avaliable.AllAvaliableDevices); // set properties after devicesListViewEnableControl1.SaveToGeneralConfig = true; LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_CheckLatestVersion")); MinerStatsCheck = new Timer(); MinerStatsCheck.Tick += MinerStatsCheck_Tick; MinerStatsCheck.Interval = ConfigManager.GeneralConfig.MinerAPIQueryInterval * 1000; SMAMinerCheck = new Timer(); SMAMinerCheck.Tick += SMAMinerCheck_Tick; SMAMinerCheck.Interval = ConfigManager.GeneralConfig.SwitchMinSecondsFixed * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); if (ComputeDeviceManager.Group.ContainsAMD_GPUs) { SMAMinerCheck.Interval = (ConfigManager.GeneralConfig.SwitchMinSecondsAMD + ConfigManager.GeneralConfig.SwitchMinSecondsFixed) * 1000 + R.Next(ConfigManager.GeneralConfig.SwitchMinSecondsDynamic * 1000); } UpdateCheck = new Timer(); UpdateCheck.Tick += UpdateCheck_Tick; UpdateCheck.Interval = 1000 * 3600; // every 1 hour UpdateCheck.Start(); UpdateCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashSMA")); SMACheck = new SystemTimer(); SMACheck.Elapsed += SMACheck_Tick; SMACheck.Interval = 60 * 1000 * 2; // every 2 minutes SMACheck.Start(); // increase timeout if (Globals.IsFirstNetworkCheckTimeout) { while (!Helpers.WebRequestTestGoogle() && Globals.FirstNetworkCheckTimeoutTries > 0) { --Globals.FirstNetworkCheckTimeoutTries; } } SMACheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetBTCRate")); BitcoinExchangeCheck = new Timer(); BitcoinExchangeCheck.Tick += BitcoinExchangeCheck_Tick; BitcoinExchangeCheck.Interval = 1000 * 3601; // every 1 hour and 1 second BitcoinExchangeCheck.Start(); BitcoinExchangeCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_GetNiceHashBalance")); BalanceCheck = new Timer(); BalanceCheck.Tick += BalanceCheck_Tick; BalanceCheck.Interval = 61 * 1000 * 5; // every ~5 minutes BalanceCheck.Start(); BalanceCheck_Tick(null, null); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetEnvironmentVariable")); Helpers.SetDefaultEnvironmentVariables(); LoadingScreen.IncreaseLoadCounterAndMessage(International.GetText("Form_Main_loadtext_SetWindowsErrorReporting")); Helpers.DisableWindowsErrorReporting(ConfigManager.GeneralConfig.DisableWindowsErrorReporting); LoadingScreen.IncreaseLoadCounter(); if (ConfigManager.GeneralConfig.NVIDIAP0State) { LoadingScreen.SetInfoMsg(International.GetText("Form_Main_loadtext_NVIDIAP0State")); try { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "nvidiasetp0state.exe"; psi.Verb = "runas"; psi.UseShellExecute = true; psi.CreateNoWindow = true; Process p = Process.Start(psi); p.WaitForExit(); if (p.ExitCode != 0) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state returned error code: " + p.ExitCode.ToString()); } else { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state all OK"); } } catch (Exception ex) { Helpers.ConsolePrint("NICEHASH", "nvidiasetp0state error: " + ex.Message); } } LoadingScreen.FinishLoad(); bool runVCRed = !MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit; // standard miners check scope { // check if download needed if (!MinersExistanceChecker.IsMinersBinsInit() && !ConfigManager.GeneralConfig.DownloadInit) { Form_Loading downloadUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.StandardDlSetup)); SetChildFormCenter(downloadUnzipForm); downloadUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMinersBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit) { // all good ConfigManager.GeneralConfig.DownloadInit = true; ConfigManager.GeneralConfigFileCommit(); } } // 3rdparty miners check scope #2 { // check if download needed if (ConfigManager.GeneralConfig.Use3rdPartyMiners == Use3rdPartyMiners.YES) { if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit() && !ConfigManager.GeneralConfig.DownloadInit3rdParty) { Form_Loading download3rdPartyUnzipForm = new Form_Loading(new MinersDownloader(MinersDownloadManager.ThirdPartyDlSetup)); SetChildFormCenter(download3rdPartyUnzipForm); download3rdPartyUnzipForm.ShowDialog(); } // check if files are mising if (!MinersExistanceChecker.IsMiners3rdPartyBinsInit()) { var result = MessageBox.Show(International.GetText("Form_Main_bins_folder_files_missing"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { ConfigManager.GeneralConfig.DownloadInit3rdParty = false; ConfigManager.GeneralConfigFileCommit(); Process PHandle = new Process(); PHandle.StartInfo.FileName = Application.ExecutablePath; PHandle.Start(); Close(); return; } } else if (!ConfigManager.GeneralConfig.DownloadInit3rdParty) { // all good ConfigManager.GeneralConfig.DownloadInit3rdParty = true; ConfigManager.GeneralConfigFileCommit(); } } } if (runVCRed) { Helpers.InstallVcRedist(); } // no bots please if (ConfigManager.GeneralConfigHwidLoadFromFile() && !ConfigManager.GeneralConfigHwidOK()) { var result = MessageBox.Show("NiceHash Miner has detected change of hardware ID. If you did not download and install NiceHash Miner, your computer may be compromised. In that case, we suggest you to install an antivirus program or reinstall your Windows.\r\n\r\nContinue with NiceHash Miner?", //International.GetText("Form_Main_msgbox_anti_botnet_msgbox"), International.GetText("Warning_with_Exclamation"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.No) { Close(); return; } else { // users agrees he installed it so commit changes ConfigManager.GeneralConfigFileCommit(); } } else { if (ConfigManager.GeneralConfig.AutoStartMining) { // well this is started manually as we want it to start at runtime IsManuallyStarted = true; if (StartMining(true) != StartMiningReturnType.StartMining) { IsManuallyStarted = false; StopMining(); } } } }
void Start() { ConfigManager.CreateInstance(); TrajectoryManager.CreateInstance(); }
private StartMiningReturnType StartMining(bool showWarnings) { if (textBoxBTCAddress.Text.Equals("")) { if (showWarnings) { DialogResult result = MessageBox.Show(International.GetText("Form_Main_DemoModeMsg"), International.GetText("Form_Main_DemoModeTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.Yes) { DemoMode = true; labelDemoMode.Visible = true; labelDemoMode.Text = International.GetText("Form_Main_DemoModeLabel"); } else { return(StartMiningReturnType.IgnoreMsg); } } else { return(StartMiningReturnType.IgnoreMsg);; } } else if (!VerifyMiningAddress(true)) { return(StartMiningReturnType.IgnoreMsg); } if (Globals.NiceHashData == null) { if (showWarnings) { MessageBox.Show(International.GetText("Form_Main_msgbox_NullNiceHashDataMsg"), International.GetText("Error_with_Exclamation"), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(StartMiningReturnType.IgnoreMsg); } // Check if there are unbenchmakred algorithms bool isBenchInit = true; bool hasAnyAlgoEnabled = false; foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { if (cdev.Enabled) { foreach (var algo in cdev.GetAlgorithmSettings()) { if (algo.Enabled == true) { hasAnyAlgoEnabled = true; if (algo.BenchmarkSpeed == 0) { isBenchInit = false; break; } } } } } // Check if the user has run benchmark first if (!isBenchInit) { /*DialogResult result = MessageBox.Show(International.GetText("EnabledUnbenchmarkedAlgorithmsWarning"), * International.GetText("Warning_with_Exclamation"), * MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); * if (result == System.Windows.Forms.DialogResult.Yes) {*/ BenchmarkForm = new Form_Benchmark( BenchmarkPerformanceType.Standard, true); SetChildFormCenter(BenchmarkForm); BenchmarkForm.ShowDialog(); BenchmarkForm = null; InitMainConfigGUIData(); /*} else if (result == System.Windows.Forms.DialogResult.No) { * // check devices without benchmarks * foreach (var cdev in ComputeDeviceManager.Avaliable.AllAvaliableDevices) { * if (cdev.Enabled) { * bool Enabled = false; * foreach (var algo in cdev.GetAlgorithmSettings()) { * if (algo.BenchmarkSpeed > 0) { * Enabled = true; * break; * } * } * cdev.Enabled = Enabled; * } * } * } else { * return StartMiningReturnType.IgnoreMsg; * }*/ return(StartMiningReturnType.ShowNoMining); } else { textBoxBTCAddress.Enabled = false; textBoxWorkerName.Enabled = false; comboBoxLocation.Enabled = false; buttonBenchmark.Enabled = false; buttonStartMining.Enabled = false; buttonSettings.Enabled = false; devicesListViewEnableControl1.IsMining = true; buttonStopMining.Enabled = true; ConfigManager.GeneralConfig.BitcoinAddress = textBoxBTCAddress.Text.Trim(); ConfigManager.GeneralConfig.FullWorkerName = textBoxFullWorkerName.Text.Trim(); if (ConfigManager.GeneralConfig.FullWorkerName.Length > 15) { ConfigManager.GeneralConfig.WorkerName = ConfigManager.GeneralConfig.FullWorkerName.Substring(ConfigManager.GeneralConfig.FullWorkerName.Length - 15, 15); } else { ConfigManager.GeneralConfig.WorkerName = ConfigManager.GeneralConfig.FullWorkerName; } ConfigManager.GeneralConfig.ServiceLocation = comboBoxLocation.SelectedIndex; InitFlowPanelStart(); ClearRatesALL(); var btcAdress = DemoMode ? Globals.DemoUser : textBoxBTCAddress.Text.Trim(); var isMining = MinersManager.StartInitialize(this, Globals.MiningLocation[comboBoxLocation.SelectedIndex], textBoxWorkerName.Text.Trim(), btcAdress); if (!DemoMode) { ConfigManager.GeneralConfigFileCommit(); } SMAMinerCheck.Interval = 100; SMAMinerCheck.Start(); MinerStatsCheck.Start(); return(isMining ? StartMiningReturnType.StartMining : StartMiningReturnType.ShowNoMining); } }
private void mnuShowComments_Click(object sender, EventArgs e) { ConfigManager.Config.Debug.Debugger.ShowCommentsInLabelList = mnuShowComments.Checked; ConfigManager.ApplyChanges(); this.UpdateLabelList(); }
private void CancelButton_Click(object sender, EventArgs e) { ConfigManager.Refresh(); this.Close(); }
private void load(Storage storage, GameHost host, FrameworkConfigManager frameworkConfig) { interactive = host.Window != null; config = new TestBrowserConfig(storage); exit = host.Exit; showLogOverlay = frameworkConfig.GetBindable <bool>(FrameworkSetting.ShowLogOverlay); rateBindable = new BindableDouble(1) { MinValue = 0, MaxValue = 2, }; var rateAdjustClock = new StopwatchClock(true); var framedClock = new FramedClock(rateAdjustClock); Children = new Drawable[] { leftContainer = new Container { RelativeSizeAxes = Axes.Y, Size = new Vector2(test_list_width, 1), Children = new Drawable[] { new Box { Colour = Color4.DimGray, RelativeSizeAxes = Axes.Both }, new FillFlowContainer { Direction = FillDirection.Vertical, RelativeSizeAxes = Axes.Both, Children = new Drawable[] { searchTextBox = new TextBox { OnCommit = delegate { var firstVisible = leftFlowContainer.FirstOrDefault(b => b.IsPresent); if (firstVisible != null) { LoadTest(firstVisible.TestType); } }, Height = 20, RelativeSizeAxes = Axes.X, PlaceholderText = "type to search" }, new ScrollContainer { Padding = new MarginPadding { Top = 3, Bottom = 20 }, RelativeSizeAxes = Axes.Both, ScrollbarOverlapsContent = false, Child = leftFlowContainer = new SearchContainer <TestCaseButton> { Padding = new MarginPadding(3), Direction = FillDirection.Vertical, Spacing = new Vector2(0, 5), AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, } } } } } }, mainContainer = new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = test_list_width }, Children = new Drawable[] { toolbar = new Toolbar { RelativeSizeAxes = Axes.X, Height = 50, Depth = -1, }, testContentContainer = new Container { Clock = framedClock, RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 50 }, Child = compilingNotice = new Container { Alpha = 0, Anchor = Anchor.Centre, Origin = Anchor.Centre, Masking = true, Depth = float.MinValue, CornerRadius = 5, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black, }, new SpriteText { TextSize = 30, Text = @"Compiling new version..." } }, } } } } }; searchTextBox.Current.ValueChanged += newValue => leftFlowContainer.SearchTerm = newValue; backgroundCompiler = new DynamicClassCompiler <TestCase> { CompilationStarted = compileStarted, CompilationFinished = compileFinished, CompilationFailed = compileFailed }; try { backgroundCompiler.Start(); } catch { //it's okay for this to fail for now. } foreach (Assembly asm in assemblies) { toolbar.AssemblyDropdown.AddDropdownItem(asm.GetName().Name, asm); } toolbar.AssemblyDropdown.Current.ValueChanged += updateList; toolbar.RunAllSteps.Current.ValueChanged += v => runTests(null); toolbar.RateAdjustSlider.Current.BindTo(rateBindable); rateBindable.ValueChanged += v => rateAdjustClock.Rate = v; rateBindable.TriggerChange(); }
public override void Dispose() { ConfigManager.GetService <IStudioCommandService>().UnRegister <PositionCommand>(this); PositionsPanel.Dispose(); AlertBtn.Dispose(); }
/// <summary> /// Initializes a new instance of the <see cref="AlertService"/>. /// </summary> /// <param name="dumpDir">Temp files directory.</param> public AlertService(string dumpDir) { if (dumpDir.IsEmpty()) { throw new ArgumentNullException("dumpDir"); } ThreadingHelper .Thread(() => { try { var player = new MediaPlayer(); var fileName = Path.Combine(dumpDir, "alert.mp3"); if (!File.Exists(fileName)) { Properties.Resources.Alert.Save(fileName); } player.Open(new Uri(fileName, UriKind.RelativeOrAbsolute)); var logManager = ConfigManager.GetService <LogManager>(); using (var speech = new SpeechSynthesizer()) using (var client = new NotificationClient()) using (player.MakeDisposable(p => p.Close())) { while (!IsDisposed) { Tuple <AlertTypes, string, string, DateTime> alert; if (!_alerts.TryDequeue(out alert)) { break; } try { switch (alert.Item1) { case AlertTypes.Sound: player.Play(); break; case AlertTypes.Speech: speech.Speak(alert.Item2); break; case AlertTypes.Popup: GuiDispatcher.GlobalDispatcher.AddAction(() => new AlertPopupWindow { Title = alert.Item2, Message = alert.Item3, Time = alert.Item4 }.Show()); break; case AlertTypes.Sms: client.SendSms(alert.Item2); break; case AlertTypes.Email: client.SendEmail(alert.Item2, alert.Item3); break; case AlertTypes.Log: logManager.Application.AddWarningLog(() => LocalizedStrings.Str3033Params .Put(alert.Item4, alert.Item2, Environment.NewLine + alert.Item3)); break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception ex) { ex.LogError(); } } } } catch (Exception ex) { ex.LogError(); } }) .Name("Alert thread") .Launch(); }
private void ctrlCodeViewer_TextZoomChanged(object sender, EventArgs e) { _config.TextZoom = this.ctrlCodeViewer.TextZoom; ConfigManager.ApplyChanges(); }
private void PlaylistCheckBox_CheckedChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.PlayList, PlaylistCheckBox.Checked.ToString()); }
private void mnuInstallHdPack_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.SetFilter(ResourceHelper.GetMessage("FilterZipFiles")); if (ofd.ShowDialog(this) == DialogResult.OK) { try { using (FileStream stream = File.Open(ofd.FileName, FileMode.Open)) { ZipArchive zip = new ZipArchive(stream); //Find the hires.txt file ZipArchiveEntry hiresEntry = null; foreach (ZipArchiveEntry entry in zip.Entries) { if (entry.Name == "hires.txt") { hiresEntry = entry; break; } } if (hiresEntry != null) { using (Stream entryStream = hiresEntry.Open()) { using (StreamReader reader = new StreamReader(entryStream)) { string hiresData = reader.ReadToEnd(); RomInfo romInfo = InteropEmu.GetRomInfo(); //If there's a "supportedRom" tag, check if it matches the current ROM Regex supportedRomRegex = new Regex("<supportedRom>([^\\n]*)"); Match match = supportedRomRegex.Match(hiresData); if (match.Success) { if (!match.Groups[1].Value.ToUpper().Contains(InteropEmu.GetRomInfo().Sha1.ToUpper())) { MesenMsgBox.Show("InstallHdPackWrongRom", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } //Extract HD pack try { string targetFolder = Path.Combine(ConfigManager.HdPackFolder, romInfo.GetRomName()); if (Directory.Exists(targetFolder)) { //Warn if the folder already exists if (MesenMsgBox.Show("InstallHdPackConfirmOverwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, targetFolder) != DialogResult.OK) { return; } } else { Directory.CreateDirectory(targetFolder); } string hiresFileFolder = hiresEntry.FullName.Substring(0, hiresEntry.FullName.Length - "hires.txt".Length); foreach (ZipArchiveEntry entry in zip.Entries) { //Extract only the files in the same subfolder as the hires.txt file (and only if they have a name & size > 0) if (!string.IsNullOrWhiteSpace(entry.Name) && entry.Length > 0 && entry.FullName.StartsWith(hiresFileFolder)) { entry.ExtractToFile(Path.Combine(targetFolder, entry.Name), true); } } } catch (Exception ex) { MesenMsgBox.Show("InstallHdPackError", MessageBoxButtons.OK, MessageBoxIcon.Error, ex.ToString()); return; } } //Turn on HD Pack support automatically after installation succeeds ConfigManager.Config.VideoInfo.UseHdPacks = true; ConfigManager.ApplyChanges(); ConfigManager.Config.ApplyConfig(); if (MesenMsgBox.Show("InstallHdPackConfirmReset", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { //Power cycle game if the user agrees InteropEmu.PowerCycle(); } } } else { MesenMsgBox.Show("InstallHdPackInvalidPack", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { //Invalid file (file missing, not a zip file, etc.) MesenMsgBox.Show("InstallHdPackInvalidZipFile", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void mnuAutoRefresh_Click(object sender, EventArgs e) { ConfigManager.Config.DebugInfo.PpuAutoRefresh = this.mnuAutoRefresh.Checked; ConfigManager.ApplyChanges(); }
private void ApplyButton_Click(object sender, EventArgs e) { ConfigManager.SaveConfig(); this.Close(); }
private void SoundEffectsCheckBox_CheckedChanged(object sender, EventArgs e) { ConfigManager.SetProperty(PropertyItem.SoundEffects, SoundEffectsCheckBox.Checked.ToString()); }
/// <summary> /// 保存配置 /// </summary> /// <param name="config"></param> public bool SaveConfig(Config config) { return(ConfigManager.SaveConfig(config)); }