private void AssociatedObject_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && initializing && !isEditing && sourceItem != null) { Point mousePos = e.GetPosition(null); Vector diff = StartPoint - mousePos; if (!(Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { return; } if ((SourceRowCoin != null && SourceRowCoin.IsEditing)) { return; } DragDropEffects dragdropeffects; floatingTip.Content = sourceItem.FullName; floatingTip.IsOpen = true; UpdateFloatingTipPosition(e.GetPosition((UIElement)sender)); dragdropeffects = DragDropEffects.Copy | DragDropEffects.Move; var sourceObject = new CoinTableCopy { SourceWorker = (Worker)((DataGrid)sender).DataContext, SourceCoinTable = sourceItem, SourceCoinTableIndex = sourceIndex }; DragDrop.DoDragDrop(this.AssociatedObject, sourceObject, dragdropeffects); floatingTip.IsOpen = false; sourceItem = null; isDragging = false; } }
private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DataGridRow sourceRow = null; var row = Helpers.FindAncestorWithExclusion((DependencyObject)e.OriginalSource, typeof(DataGridRow), 1, noGoCallerTypes1) as DataGridRow; if (row == null) { return; } if (row.DataContext is Coin) { SourceRowCoin = row; sourceRow = FindRow(row, rowName, noGoCallerTypes1); } else { sourceRow = row; } if (sourceRow == null) { return; } isEditing = sourceRow.IsEditing; if (isEditing || (SourceRowCoin != null && SourceRowCoin.IsEditing)) { return; } StartPoint = e.GetPosition(null); sourceIndex = sourceRow.GetIndex(); sourceItem = (CoinTable)sourceRow.Item; initializing = true; }
public CoinTable Clone() { CoinTable _coinTable = new CoinTable(Coins_CollectionChanged); foreach (var c in this.Coins) { _coinTable.Coins.Add(c.Clone()); } _coinTable.Power = this.Power; _coinTable.Fees = this.Fees; _coinTable.Switch = this.Switch; _coinTable.Path = this.Path; _coinTable.Arguments = this.Arguments; _coinTable.Notes = this.Notes; return(_coinTable); }
public CoinTable CloneNoEvents() { CoinTable _coinTable = new CoinTable(); _coinTable.Coins = new ObservableCollection <Coin>(); foreach (var c in this.Coins) { _coinTable.Coins.Add(c.Clone()); } _coinTable.Power = this.Power; _coinTable.Fees = this.Fees; _coinTable.Switch = this.Switch; _coinTable.Path = this.Path; _coinTable.Arguments = this.Arguments; _coinTable.Notes = this.Notes; return(_coinTable); }
public void CoinTableInsert(int index, CoinTable coinTable) { OnPropertyChanging("CoinList"); this.CoinList.Insert(index, coinTable); }
public static (decimal profit24, decimal revenue) CalculateProfit( CoinTable coinTable, Dictionary <string, WtmData> wtmDataDict, WtmData btc, WtmSettingsObject settings, decimal powerCost ) { decimal revenueAllCoins = 0; revenueAllCoins = 0; decimal coinRate = 0; decimal btcRate = 0; foreach (Coin coin in coinTable.Coins) { WtmData currentCoin = null; wtmDataDict.TryGetValue(coin.Name, out currentCoin); if (currentCoin == null) { continue; } if (settings.UseHistoricalAverage && currentCoin.HasAverage) { coinRate = currentCoin.AveragePrice; btcRate = btc != null ? btc.AveragePrice : 0; } else { string keyName; if (settings.Average24) { keyName = "exchange_rate24"; } else { keyName = "exchange_rate"; } string coinValue; currentCoin.Json.TryGetValue(keyName, out coinValue); if (coinValue != null) { coinRate = Helpers.StringToDecimal(coinValue); } string btcValue = null; btc?.Json.TryGetValue(keyName, out btcValue); if (btcValue != null) { btcRate = Helpers.StringToDecimal(btcValue); } } decimal ratio = (decimal)coin.Hashrate / (decimal)currentCoin.DefaultHashrate; decimal revenueOneCoin = 0; decimal estimatedRewards = Helpers.StringToDecimal(currentCoin.Json["estimated_rewards"]); revenueOneCoin = ratio * estimatedRewards * coinRate * btcRate; revenueAllCoins += revenueOneCoin; //totalHashrate += Convert.ToString(coin.Hashrate, CultureInfo.InvariantCulture) + "+"; //name += coin.Name + "+"; //algorithm += currentCoin.Json["algorithm"] + "+"; } decimal profit24 = 0; //name = name.TrimEnd('+'); profit24 = revenueAllCoins - (revenueAllCoins * (decimal)coinTable.Fees / 100) - (((decimal)coinTable.Power / 1000) * 24 * powerCost); return(profit24, revenueAllCoins); }