public void PopulateMiners(List<MinerProcess> localMiners, List<NetworkDevices.NetworkDevice> networkMiners, MinerFormViewModel viewModel) { populatingMiners = true; string previousSelection = (string)minerComboBox.SelectedItem; minerComboBox.Items.Clear(); apiContexts.Clear(); foreach (MinerProcess localMiner in localMiners) { string devicePath = String.Format("{0}:{1}", localMiner.ApiContext.IpAddress, localMiner.ApiContext.Port); minerComboBox.Items.Add(String.Format("{0} ({1})", localMiner.Miner.Name, devicePath)); apiContexts.Add(new Xgminer.Api.ApiContext(localMiner.ApiContext.Port, localMiner.ApiContext.IpAddress)); } if (minerComboBox.Items.Count > 0) { minerComboBox.Items.Add("-"); apiContexts.Add(null); } foreach (NetworkDevices.NetworkDevice networkMiner in networkMiners) { string devicePath = String.Format("{0}:{1}", networkMiner.IPAddress, networkMiner.Port); DeviceViewModel deviceModel = viewModel.Devices.SingleOrDefault(d => d.Path.Equals(devicePath)); //the Network Device may be offline //null check as view models may not yet be populated if ((deviceModel != null) && deviceModel.Visible) { string minerName = viewModel.GetFriendlyDeviceName(devicePath, devicePath); minerComboBox.Items.Add(String.Format("{0} ({1})", minerName, devicePath)); apiContexts.Add(new Xgminer.Api.ApiContext(networkMiner.Port, networkMiner.IPAddress)); } } if ((minerComboBox.SelectedItem == null) && (minerComboBox.Items.Count > 0)) minerComboBox.SelectedIndex = 0; if (!String.IsNullOrEmpty(previousSelection)) { int previousSelectionIndex = minerComboBox.Items.IndexOf(previousSelection); if (previousSelectionIndex >= 0) minerComboBox.SelectedIndex = previousSelectionIndex; } populatingMiners = false; }
public ApiConsoleControl(List<MinerProcess> localMiners, List<NetworkDevices.NetworkDevice> networkMiners, MinerFormViewModel viewModel) { InitializeComponent(); inputTextBox.Enabled = false; PopulateMiners(localMiners, networkMiners, viewModel); }
private void GetRemoteApplicationModels(Instance instance) { PerformRemoteCommand(instance, service => { Remoting.Data.Transfer.Device[] devices; PoolGroup[] configurations; bool mining, hasChanges, dynamicIntensity; //set some safe defaults in case the call fails RemoteViewModel = new MinerFormViewModel(); service.GetApplicationModels(GetSendingSignature(instance), out devices, out configurations, out mining, out hasChanges, out dynamicIntensity); RemoteInstanceMining = mining; RemoteViewModel.HasChanges = hasChanges; RemoteViewModel.DynamicIntensity = dynamicIntensity; SaveDeviceTransferObjects(devices); SaveCoinTransferObjects(configurations); }); }
private static double GetTotalHashrate(MinerFormViewModel viewModel, string algorithm, bool includeNetworkDevices) { double result = 0.00; //only include Visible devices foreach (DeviceViewModel device in viewModel.Devices.Where(d => d.Visible)) { if ((device.Coin != null) && (device.Coin.Algorithm.Equals(algorithm, StringComparison.OrdinalIgnoreCase)) && //optionally filter out Network Devices (includeNetworkDevices || (device.Kind != DeviceKind.NET))) result += device.CurrentHashrate; } return result; }
public ApplicationViewModel() { coinStatsTimer.Elapsed += coinStatsTimer_Tick; restartTimer.Elapsed += restartTimer_Tick; networkRestartTimer.Elapsed += networkRestartTimer_Tick; networkScanTimer.Elapsed += networkScanTimer_Tick; SetupNetworkRestartTimer(); SetupNetworkScanTimer(); RemoteViewModel = new MinerFormViewModel(); }
private void RemoveListViewItemsMissingFromViewModel(MinerFormViewModel viewModelToView) { for (int i = deviceListView.Items.Count - 1; i >= 0; i--) { DeviceViewModel listModel = (DeviceViewModel)deviceListView.Items[i].Tag; if (!viewModelToView.Devices.Contains(listModel) || !listModel.Visible) deviceListView.Items.RemoveAt(i); //Network Device detection disabled if (!app.ApplicationConfiguration.NetworkDeviceDetection && (listModel.Kind == DeviceKind.NET)) deviceListView.Items.RemoveAt(i); } }