예제 #1
0
        private void AddCoinsByAlgorithmCommand(object obj)
        {
            var algoSelector = new AlgorithmSelector();
            var vm           = new AlgorithmSelectorVM();

            vm.DisplayCoinAs         = Workers.DisplayCoinAs;
            algoSelector.DataContext = vm;
            var dialogResult = algoSelector.ShowDialog();

            if (dialogResult == false)
            {
                return;
            }
            var wtmDict    = WtmCoins.ToDictionary(x => x.Name, y => y.Status);
            var coinTables = new ObservableCollection <CoinTable>();

            foreach (var algo in vm.Algorithms)
            {
                foreach (var coin in algo.Coins)
                {
                    string status = null;
                    wtmDict.TryGetValue(coin.Name, out status);
                    if (coin.IsChecked && coin.Show)
                    {
                        coinTables.Add(new CoinTable(new ObservableCollection <Coin> {
                            new Coin {
                                Name = coin.Name, Symbol = coin.Symbol, Hashrate = vm.Hashrate, Algorithm = algo.Name, Status = status
                            }
                        }, 0, 0, false, string.Empty, string.Empty, string.Empty));
                    }
                }
            }
            if (coinTables.Count == 0)
            {
                return;
            }

            if (vm.Option == AlgorithmSelectorVM.WorkerOptions.AddToExisting)
            {
                var worker = Workers.WorkerList.FirstOrDefault(x => x.Name == vm.SelectedWorker);
                if (worker != null)
                {
                    worker.RaiseProperychanging("CoinList");
                    foreach (var ct in coinTables)
                    {
                        worker.CoinList.Add(ct.Clone());
                    }
                    worker.RaiseProperychanged("CoinList");
                }
            }
            if (vm.Option == AlgorithmSelectorVM.WorkerOptions.AddToNew)
            {
                var worker = new Worker("NEW WORKER", "", new ObservableCollection <string>(), new ObservableCollection <CoinTable>(coinTables));
                Workers.WorkerListAdd(worker);
            }
        }
        private void UpdateCoinStatus()
        {
            var wtmDict = WtmCoins.ToDictionary(x => x.Name, y => y.Status);

            foreach (var worker in Workers.WorkerList)
            {
                foreach (var coinTable in worker.CoinList)
                {
                    foreach (var coin in coinTable.Coins)
                    {
                        string status = null;
                        wtmDict.TryGetValue(coin.Name, out status);
                        coin.Status = status;
                    }
                }
            }
        }