private void MultiplyHashrateCommand(object parameter)
        {
            var ct = parameter as CoinTable;

            if (ct == null)
            {
                return;
            }
            var window = new HashrateMultiplier();
            var vm     = new HashrateMultiplierVM(ct.Coins, Workers.DisplayCoinAs);

            window.DataContext = vm;
            var dialogresult = window.ShowDialog();

            if (dialogresult == false)
            {
                return;
            }
            SaveUndoRedo("WorkersAll");
            SaveUndoIsEnabled = false;
            foreach (var worker in Workers.WorkerList)
            {
                foreach (var coinTable in worker.CoinList)
                {
                    foreach (var coin in coinTable.Coins)
                    {
                        foreach (var coinPlus in vm.Coins)
                        {
                            if (coinPlus.Coin.Name != coin.Name || coinPlus.Multiplier == 1)
                            {
                                continue;
                            }
                            switch (coinPlus.Operation)
                            {
                            case "*":
                                coin.Hashrate *= coinPlus.Multiplier;
                                break;

                            case "/":
                                coin.Hashrate /= coinPlus.Multiplier;
                                break;
                            }
                            var i = HashrateMultiplierVM.RoundConverter(coinPlus.Rounding);
                            if (i >= 0)
                            {
                                coin.Hashrate = Math.Round(coin.Hashrate, i);
                            }
                        }
                    }
                }
            }
            SaveUndoIsEnabled = true;
        }
Beispiel #2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            double result = 0;

            try
            {
                result = (double)values[0];
            }
            catch (Exception)
            {
                return("Error");
            }
            string rounding = values[1] as string;
            var    i        = HashrateMultiplierVM.RoundConverter(rounding);

            if (i >= 0)
            {
                return(Math.Round(result, i).ToString());
            }
            else
            {
                return(result.ToString());
            }
        }