public MiningManager() { Application.CurrentCulture = new CultureInfo("en-US"); InitializeComponent(); timer1.Interval = 5 * 60 * 1000; logFile = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".log"; writeLog("start programm"); Coins.Add("XMR", new Coin("XMR", 1000000000000, "monero", "monero")); Coins.Add("KRB", new Coin("KRB", 1000000000000, "karbo", "karbowanec")); Coins.Add("SUMO", new Coin("SUMO", 1000000000, "sumokoin", "sumokoin")); Coins.Add("ETN", new Coin("ETN", 100, "electroneum", "electroneum")); Coins.Add("ITNS", new Coin("ITNS", 100000000, "intense", "intensecoin")); Coins.Add("FNO", new Coin("FNO", 1000000000000, "fonero")); int i = 0; foreach (Coin coin in Coins.Values) { Stats.Add(coin.symbol, new CoinStats()); CoinPanel panel = new CoinPanel(coin.symbol); panel.Location = new Point(0, 110 * i); mainPanel.Controls.Add(panel); i++; } }
private string getActiveCoin() { Dictionary <string, double> CoinRating = new Dictionary <string, double>(); Dictionary <string, double> WorkCoinRating = new Dictionary <string, double>(); foreach (Coin coin in Coins.Values) { CoinPanel panel = (CoinPanel)mainPanel.Controls[coin.symbol]; CoinConfig cfg = Config[coin.symbol]; CoinRating.Add(coin.symbol, panel.getRaiting()); } foreach (string coinSymbol in CoinRating.Keys) { CoinConfig cfg = Config[coinSymbol]; if (cfg.GPU != null && cfg.GPU.Length > 0 || cfg.CPU != null && cfg.CPU.Length > 0) { double rating = CoinRating[coinSymbol]; if (coinSymbol == ActiveCoin) { rating *= 1.1; } WorkCoinRating.Add(coinSymbol, rating); } } CoinRating = CoinRating.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); WorkCoinRating = WorkCoinRating.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); string newActiveCoin = null; if (WorkCoinRating.Count > 0) { newActiveCoin = WorkCoinRating.Last().Key; } fillCoinStatusPanel(CoinRating.Keys.ToArray <string>(), newActiveCoin); return(newActiveCoin); }
private void apply_Click(object sender, EventArgs e) { XMLConfig.Root.RemoveAll(); foreach (Coin coin in Coins.Values) { CoinPanel panel = (CoinPanel)mainPanel.Controls[coin.symbol]; Config[coin.symbol] = panel.getCoinConfig(); XMLConfig.Root.Add(Config[coin.symbol].toXML()); } XMLConfig.Save(configFile); setActiveCoin(); }
private void setStats() { foreach (Coin coin in Coins.Values) { CoinStats stats = Stats[coin.symbol]; CoinPanel panel = (CoinPanel)mainPanel.Controls[coin.symbol]; if (panel != null) { panel.setCoinStats(stats); } } setActiveCoin(); apply.Enabled = true; }
private void setActiveCoin() { string newActiveCoin = getActiveCoin(); if (newActiveCoin == null && ActiveCoin != null) { killMiners(); CoinPanel panel = (CoinPanel)mainPanel.Controls[ActiveCoin]; panel.setActive(false); writeLog("End mining " + ActiveCoin); ActiveCoin = newActiveCoin; } else if (newActiveCoin != null && !newActiveCoin.Equals(ActiveCoin) && LastChangeCoin < DateTime.Now.AddMinutes(-30)) { killMiners(); CoinPanel panel = (CoinPanel)mainPanel.Controls[newActiveCoin]; panel.setActive(true); if (ActiveCoin != null) { panel = (CoinPanel)mainPanel.Controls[ActiveCoin]; panel.setActive(false); writeLog("End mining " + ActiveCoin); } writeLog("Start mining " + newActiveCoin); CoinConfig cfg = Config[newActiveCoin]; if (cfg.GPU != null && cfg.GPU.Length > 0) { startProcess(cfg.GPU); } if (cfg.CPU != null && cfg.CPU.Length > 0) { startProcess(cfg.CPU); } LastChangeCoin = DateTime.Now; ActiveCoin = newActiveCoin; } }
private void MiningManager_Load(object sender, EventArgs e) { try { XMLConfig = XDocument.Load(configFile); } catch { XMLConfig = new XDocument(); XMLConfig.Add(new XElement("MiningManagerConfig")); } XElement root = XMLConfig.Root; foreach (Coin coin in Coins.Values) { CoinConfig config = new CoinConfig(root.Element(coin.symbol + "Config"), coin.symbol); Config.Add(coin.symbol, config); CoinPanel panel = (CoinPanel)mainPanel.Controls[coin.symbol]; panel.setCoinConfig(config); } }