Exemplo n.º 1
0
        private void ConfigureDevicesForNewUser()
        {
            CoinConfiguration coinConfiguration = engineConfiguration.CoinConfigurations.Single();

            for (int i = 0; i < devices.Count; i++)
            {
                DeviceConfiguration deviceConfiguration = new DeviceConfiguration()
                {
                    CoinSymbol = coinConfiguration.Coin.Symbol,
                    Enabled = true
                };

                deviceConfiguration.Assign(devices[i]);
                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
            }

            engineConfiguration.SaveDeviceConfigurations();
            UpdateMiningButtons();
        }
Exemplo n.º 2
0
        private void SetAllDevicesToCoin(CoinConfiguration coinConfiguration)
        {
            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                ListViewItem listViewItem = deviceListView.Items[i];

                Device device = devices[i];
                CryptoCoin currentCoin = knownCoins.SingleOrDefault(c => c.Name.Equals(listViewItem.SubItems["Coin"].Text));

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.Assign(device);

                if (coinConfiguration.Coin.Algorithm == CoinAlgorithm.Scrypt)
                {
                    if (device.Kind == DeviceKind.GPU)
                        deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                    else
                        deviceConfiguration.CoinSymbol = currentCoin == null ? String.Empty : currentCoin.Symbol;
                }
                else
                {
                    deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                }

                deviceConfiguration.Enabled = listViewItem.Checked;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
            }
        }
Exemplo n.º 3
0
        //each device needs to have a DeviceConfiguration
        //this will add any missing ones after populating devices
        //for instance if the user starts up the app with a new device
        private void AddMissingDeviceConfigurations()
        {
            foreach (Device device in devices)
            {
                DeviceConfiguration existingConfiguration = engineConfiguration.DeviceConfigurations.FirstOrDefault(
                    c => (c.Equals(device)));
                if (existingConfiguration == null)
                {
                    DeviceConfiguration newConfiguration = new DeviceConfiguration();

                    newConfiguration.Assign(device);

                    //if the user has BTC configured, default to that
                    string btcSymbol = "BTC";
                    bool hasBtcConfigured = engineConfiguration.CoinConfigurations.Exists(c => c.Enabled && c.Coin.Symbol.Equals(btcSymbol, StringComparison.OrdinalIgnoreCase));
                    if (hasBtcConfigured)
                        newConfiguration.CoinSymbol = btcSymbol;

                    newConfiguration.Enabled = true;
                    engineConfiguration.DeviceConfigurations.Add(newConfiguration);
                }
            }
        }
Exemplo n.º 4
0
        private List<DeviceConfiguration> CreateDeviceConfigurationForProfitableCoins(List<CoinInformation> allProfitableCoins, List<CoinInformation> sha256ProfitableCoins)
        {
            List<DeviceConfiguration> newConfiguration = new List<DeviceConfiguration>();
            CoinInformation profitableCoin = null;

            int gpuIterator = 0;
            int amuIterator = 0;

            for (int i = 0; i < devices.Count; i++)
            {
                Device device = devices[i];

                //there should be a 1-to-1 relationship of devices and device configurations
                DeviceConfiguration existingConfiguration = engineConfiguration.DeviceConfigurations[i];

                if (existingConfiguration.Enabled)
                {
                    profitableCoin = null;

                    if (device.Kind == DeviceKind.GPU)
                    {
                        //sha256 or scrypt
                        profitableCoin = ChooseCoinFromList(allProfitableCoins, gpuIterator);

                        gpuIterator++;
                        if (gpuIterator >= allProfitableCoins.Count())
                            gpuIterator = 0;
                    }
                    else if (sha256ProfitableCoins.Count > 0)
                    {
                        //sha256 only
                        profitableCoin = ChooseCoinFromList(sha256ProfitableCoins, amuIterator);

                        amuIterator++;
                        if (amuIterator >= sha256ProfitableCoins.Count())
                            amuIterator = 0;
                    }

                    DeviceConfiguration configEntry = new DeviceConfiguration();

                    configEntry.DeviceIndex = device.DeviceIndex;
                    configEntry.CoinSymbol = profitableCoin == null ? string.Empty : profitableCoin.Symbol;

                    newConfiguration.Add(configEntry);
                }
                else
                {
                    DeviceConfiguration configEntry = new DeviceConfiguration();

                    configEntry.DeviceIndex = device.DeviceIndex;
                    configEntry.CoinSymbol = existingConfiguration.CoinSymbol;
                    configEntry.Enabled = false;

                    newConfiguration.Add(configEntry);
                }
            }

            return newConfiguration;
        }
Exemplo n.º 5
0
        private void SaveListViewValuesToConfiguration()
        {
            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                ListViewItem listViewItem = deviceListView.Items[i];

                //pull this from coin configurations, not known coins, may not be in CoinChoose
                string coinValue = listViewItem.SubItems["Coin"].Text;
                CryptoCoin coin = null;
                if (!String.IsNullOrEmpty(coinValue))
                    coin = engineConfiguration.CoinConfigurations.Single(c => c.Coin.Name.Equals(coinValue, StringComparison.OrdinalIgnoreCase)).Coin;

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.Assign(devices[i]);

                deviceConfiguration.Enabled = listViewItem.Checked;
                deviceConfiguration.CoinSymbol = coin == null ? string.Empty : coin.Symbol;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);

            }
        }
Exemplo n.º 6
0
        private void SaveViewModelValuesToConfiguration()
        {
            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                DeviceViewModel viewModel = localViewModel.Devices[i];

                //pull this from coin configurations, not known coins, may not be in CoinChoose
                CryptoCoin coin = viewModel.Coin;

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.Assign(viewModel);

                deviceConfiguration.Enabled = viewModel.Enabled;
                deviceConfiguration.CoinSymbol = coin == null ? string.Empty : coin.Symbol;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
            }
        }
Exemplo n.º 7
0
        private void SetAllDevicesToCoinLocally(string coinSymbol)
        {
            bool wasMining = miningEngine.Mining;
            StopMiningLocally();

            CoinConfiguration coinConfiguration = engineConfiguration.CoinConfigurations.SingleOrDefault(c => c.Coin.Symbol.Equals(coinSymbol));

            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                DeviceViewModel viewModel = localViewModel.Devices[i];

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();
                deviceConfiguration.Assign(viewModel);

                if (viewModel.Kind == DeviceKind.NET)
                {
                    //assume BTC for Network Devices (for now)
                    deviceConfiguration.CoinSymbol = "BTC";
                    deviceConfiguration.Enabled = true;
                }
                else
                {

                    if (coinConfiguration.Coin.Algorithm == CoinAlgorithm.Scrypt)
                    {
                        if (viewModel.Kind == DeviceKind.GPU)
                            deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                        else
                            deviceConfiguration.CoinSymbol = viewModel.Coin == null ? String.Empty : viewModel.Coin.Name;
                    }
                    else
                    {
                        deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                    }

                    deviceConfiguration.Enabled = viewModel.Enabled;
                }

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
            }

            localViewModel.ApplyDeviceConfigurationModels(engineConfiguration.DeviceConfigurations,
                engineConfiguration.CoinConfigurations);

            engineConfiguration.StrategyConfiguration.AutomaticallyMineCoins = false;

            engineConfiguration.SaveDeviceConfigurations();
            engineConfiguration.SaveStrategyConfiguration();

            RefreshListViewFromViewModel();

            AutoSizeListViewColumns();

            if (wasMining)
                StartMiningLocally();
            else
                //so the Start button becomes enabled if we now have a valid config
                UpdateMiningButtons();
        }
Exemplo n.º 8
0
        private void SetAllDevicesToCoin(CoinConfiguration coinConfiguration)
        {
            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                DataGridViewRow gridRow = deviceGridView.Rows[i];
                Device device = devices[i];
                CryptoCoin currentCoin = knownCoins.SingleOrDefault(c => c.Name.Equals(gridRow.Cells[coinColumn.Index].Value));

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.DeviceIndex = device.DeviceIndex;

                if (coinConfiguration.Coin.Algorithm == CoinAlgorithm.Scrypt)
                {
                    if (device.Kind == DeviceKind.GPU)
                        deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                    else
                        deviceConfiguration.CoinSymbol = currentCoin == null ? String.Empty : currentCoin.Symbol;
                }
                else
                {
                    deviceConfiguration.CoinSymbol = coinConfiguration.Coin.Symbol;
                }

                object cellValue = gridRow.Cells[enabledColumn.Index].Value;
                deviceConfiguration.Enabled = cellValue == null ? true : (bool)cellValue;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
            }
        }
Exemplo n.º 9
0
 //each device needs to have a DeviceConfiguration
 //this will add any missing ones after populating devices
 //for instance if the user starts up the app with a new device
 private void AddMissingDeviceConfigurations()
 {
     foreach (Device device in devices)
     {
         DeviceConfiguration existingConfiguration = engineConfiguration.DeviceConfigurations.SingleOrDefault(
             c => (c.DeviceIndex == device.DeviceIndex));
         if (existingConfiguration == null)
         {
             DeviceConfiguration newConfiguration = new DeviceConfiguration();
             newConfiguration.DeviceIndex = device.DeviceIndex;
             newConfiguration.Enabled = true;
             engineConfiguration.DeviceConfigurations.Add(newConfiguration);
         }
     }
 }
Exemplo n.º 10
0
        private void SaveGridValuesToConfiguration()
        {
            deviceGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                DataGridViewRow gridRow = deviceGridView.Rows[i];

                //pull this from coin configurations, not known coins, may not be in CoinChoose
                string gridRowValue = (string)gridRow.Cells[coinColumn.Index].Value;
                CryptoCoin coin = null;
                if (!String.IsNullOrEmpty(gridRowValue))
                    coin = engineConfiguration.CoinConfigurations.Single(c => c.Coin.Name.Equals(gridRowValue)).Coin;

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.DeviceIndex = devices[i].DeviceIndex;
                deviceConfiguration.CoinSymbol = coin == null ? string.Empty : coin.Symbol;
                object cellValue = gridRow.Cells[enabledColumn.Index].Value;
                deviceConfiguration.Enabled = cellValue == null ? true : (bool)cellValue;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);

            }
        }
Exemplo n.º 11
0
        private void SaveGridValuesToConfiguration()
        {
            deviceGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);

            engineConfiguration.DeviceConfigurations.Clear();

            for (int i = 0; i < devices.Count; i++)
            {
                DataGridViewRow gridRow = deviceGridView.Rows[i];
                CryptoCoin coin = knownCoins.SingleOrDefault(c => c.Name.Equals(gridRow.Cells[coinColumn.Index].Value));

                DeviceConfiguration deviceConfiguration = new DeviceConfiguration();

                deviceConfiguration.DeviceIndex = i;
                deviceConfiguration.CoinSymbol = coin == null ? string.Empty : coin.Symbol;
                object cellValue = gridRow.Cells[enabledColumn.Index].Value;
                deviceConfiguration.Enabled = cellValue == null ? true : (bool)cellValue;

                engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);

            }
        }
Exemplo n.º 12
0
 //each device needs to have a DeviceConfiguration
 //this will add any missing ones after populating devices
 //for instance if the user starts up the app with a new device
 private void AddMissingDeviceConfigurations()
 {
     for (int i = engineConfiguration.DeviceConfigurations.Count; i < devices.Count; i++)
     {
         DeviceConfiguration deviceConfiguration = new DeviceConfiguration();
         deviceConfiguration.DeviceIndex = devices[i].DeviceIndex;
         deviceConfiguration.Enabled = true;
         engineConfiguration.DeviceConfigurations.Add(deviceConfiguration);
     }
 }