示例#1
0
    //Can save or update passed coin
    public void SaveCoin(Coin coin)
    {
        //Select old coin
        var oldCoin = Coins.Where(c => c.ID == coin.ID).FirstOrDefault();

        //If there was no old coin, get last existing coin id, or zero if Coins list is empty
        if (oldCoin == null)
        {
            int lastId;
            if (Coins.Count != 0)
            {
                lastId = Coins.Count - 1;
            }
            else
            {
                lastId = 0;
            }
            coin.ID = lastId + 1;
            Coins.Add(coin);
        }
        else
        {
            int index = Coins.IndexOf(oldCoin);
            Coins[index] = coin;
        }
    }
示例#2
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            Coins.Clear();

            try
            {
                var data = new CoinService().GetAllCoins().Result;
                foreach (var value in data)
                {
                    Coins.Add(value);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#3
0
 public override void MakeChange(decimal Amount)
 {
     while (Amount >= 1.0M)
     {
         Coins.Add(new DollarCoin());
         Amount -= 1.0M;
     }
     while (Amount >= .50M)
     {
         Coins.Add(new HalfDollar());
         Amount -= 0.50M;
     }
     while (Amount >= .25M)
     {
         Coins.Add(new Quarter());
         Amount -= 0.25M;
     }
     while (Amount >= .10M)
     {
         Coins.Add(new Dime());
         Amount -= 0.10M;
     }
     while (Amount >= .05M)
     {
         Coins.Add(new Nickel());
         Amount -= 0.05M;
     }
     while (Amount > .00M)
     {
         Coins.Add(new Penny());
         Amount -= 0.01M;
     }
 }
示例#4
0
文件: Form1.cs 项目: sStamenkova/Fly
        public void generateTerain()
        {
            Random rnd = new Random();


            for (int i = 0; i < 4; i++)
            {
                //pipes
                int X = 500 + i * pipeDistanceX;
                int Y = rnd.Next(pipeMinHeight + pipeDistanceY, MAX_HEIGHT - (pipeMinHeight + pipeDistanceY));
                topTerrain.Add(new Tunnel(X, 0, Y - pipeDistanceY, Tunnel.TunnelType.Top));
                bottomTerrain.Add(new Tunnel(X, Y, MAX_HEIGHT - Y, Tunnel.TunnelType.Bottom));


                //coins
                int X1 = 300 + i * coinDistance;
                int Y1 = rnd.Next(pipeMinHeight, MAX_HEIGHT - pipeMinHeight);

                Coin.setCoins(ref X1, ref Y1);

                Coin c = new Coin(X1, Y1);
                if (i == 3)
                {
                    c.isPowerUP = true;
                }
                Coins.Add(c);
            }
        }
示例#5
0
        /// <summary>
        /// Load our coin details based on the coins in our portfolio. Then add these details to our portfolio!
        /// This way it is accesible in the PortfolioCoin.Coin and we can access it in our bindings
        /// </summary>
        /// <param name="coinIds"></param>
        /// <returns></returns>
        async Task LoadCoins(List <string> coinIds)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                //Coins.Clear();
                var coins = await App.ServiceManager.CoinService.GetCoinsByIds(coinIds);

                foreach (var coin in coins)
                {
                    // TODO: We do not get a render update with this, is the map correctly setting the coin? (I think so)
                    Debug.WriteLine("Adding: " + coin.Name);
                    PortfolioCoins[coin.CoinId].Coin = coin;
                    Coins.Add(coin);
                    Debug.WriteLine(PortfolioCoins[coin.CoinId].Coin.Name);
                }
                OnPropertyChanged("PortfolioCoins");
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#6
0
        internal (ICoinsView toRemove, ICoinsView toAdd) Undo(uint256 txId)
        {
            lock (Lock)
            {
                var allCoins = AsAllCoinsViewNoLock();
                var toRemove = new List <SmartCoin>();
                var toAdd    = new List <SmartCoin>();

                // remove recursively the coins created by the transaction
                foreach (SmartCoin createdCoin in allCoins.CreatedBy(txId))
                {
                    toRemove.AddRange(Remove(createdCoin));
                }
                // destroyed (spent) coins are now (unspent)
                foreach (SmartCoin destroyedCoin in allCoins.SpentBy(txId))
                {
                    if (SpentCoins.Remove(destroyedCoin))
                    {
                        Coins.Add(destroyedCoin);
                        toAdd.Add(destroyedCoin);
                    }
                }
                InvalidateSnapshot = true;
                return(new CoinsView(toRemove), new CoinsView(toAdd));
            }
        }
 //Adds a coin to the list
 public void AddCoin(ICoin c)
 {
     if (c != null)
     {
         Coins.Add(c);
     }
 }
示例#8
0
        public CoinUtility(IEnumerable <CoinType> coinTypes)
        {
            foreach (var coinType in coinTypes)
            {
                var coinTypeIndex = AddressUtilities.UnhardenNumber(coinType.Bip44AccountPath);

                //Seems like there are some coins on the KeepKey with the wrong index. I.e. they are actually Ethereum?
                if (Coins.ContainsKey(coinTypeIndex))
                {
                    continue;
                }

                AddressType addressType;

                switch (coinType.AddressType)
                {
                case 65535:
                    addressType = AddressType.Ethereum;
                    break;

                default:
                    addressType = AddressType.Bitcoin;
                    break;
                }

                Coins.Add(coinTypeIndex, new CoinInfo(coinType.CoinName, addressType, !IsLegacy && coinType.Segwit, AddressUtilities.UnhardenNumber(coinType.Bip44AccountPath)));
            }
        }
示例#9
0
    public void buy()
    {
        if (iap)
        {
            weaponIAP.checkBuy = true;
            coins.Add(iap.coins);
        }

        if (package)
        {
            if (package.weapons != null)
            {
                for (int i = 0; i < package.weapons.Length; i++)
                {
                    package.weapons[i].checkBuy = true;
                }

                loadData.SaveAndLoadWeapon();
            }

            if (package.skins != null)
            {
                for (int i = 0; i < package.skins.Length; i++)
                {
                    package.skins[i].checkBuy = true;
                }

                loadData.SaveAndLoadSkins();
            }
        }
    }
示例#10
0
 public override void MakeChange(decimal Amount)
 {
     while (Amount >= 500)
     {
         Coins.Add(new FiveHundredYen());
         Amount -= 500;
     }
     while (Amount >= 100)
     {
         Coins.Add(new HundredYen());
         Amount -= 100;
     }
     while (Amount >= 25)
     {
         Coins.Add(new FiftyYen());
         Amount -= 50;
     }
     while (Amount >= 10)
     {
         Coins.Add(new TenYen());
         Amount -= 10;
     }
     while (Amount >= 5)
     {
         Coins.Add(new FiveYen());
         Amount -= 5;
     }
     while (Amount > 0)
     {
         Coins.Add(new OneYen());
         Amount -= 1;
     }
 }
示例#11
0
        public bool TryAdd(SmartCoin coin)
        {
            var added = false;

            lock (Lock)
            {
                if (!SpentCoins.Contains(coin))
                {
                    added = Coins.Add(coin);
                    if (added)
                    {
                        if (ClustersByScriptPubKey.TryGetValue(coin.ScriptPubKey, out var cluster))
                        {
                            coin.Clusters = cluster;
                        }
                        else
                        {
                            ClustersByScriptPubKey.Add(coin.ScriptPubKey, coin.Clusters);
                        }
                        InvalidateSnapshot = true;
                    }
                }
            }
            return(added);
        }
示例#12
0
        async Task ExecuteLoadItemsCommand()
        {
            IsBusy = true;

            try
            {
                var result = await CoinsService.GetAllCoinsAsync();

                foreach (var x in result)
                {
                    Coins.Add(new CoinsModel.Value
                    {
                        nomeFormatado = x.nomeFormatado,
                        tipoMoeda     = x.tipoMoeda,
                        simbolo       = x.simbolo
                    });
                }
                LoadSelectedCoins();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#13
0
 public void AddToCustomerCoins(int [] cvA)
 {
     // Check if the CoinBox will be full with this addition
     if (!IsCoinBoxFull(cvA))
     {
         CustomerCoins.CoinVector = CustomerCoins.Add(cvA);
         this.CustomerCoinsValue  = CoinBoxCoins.ComputeCoinVectorValueInCents(CustomerCoins.CoinVector);
     }
 }
示例#14
0
        public void AddCoin(CoinDenomination denomination)
        {
            if (denomination == null)
            {
                throw new ArgumentNullException(nameof(denomination));
            }

            Coins.Add(denomination);
        }
示例#15
0
    public static void CoinAdd(int AddScore)
    {
        PlayerPrefs.SetInt("Coin", Coin + AddScore);
        CoinUp();
        onArchiments();
        Coins co = (Coins)GameObject.Find("coin_add").GetComponent("Coins");

        co.coins.text = "+" + AddScore.ToString();
        co.Add();
    }
示例#16
0
 public void BuyIAP()
 {
     foreach (IAP item in iap)
     {
         if (item.id == idToCheck)
         {
             weaponIAP.checkBuy = true;
             coins.Add(item.coins);
         }
     }
 }
示例#17
0
        public async Task LoadCoins()
        {
            Coins.Clear();
            foreach (PortfolioCoin p in PortfolioCoins)
            {
                var coin = await _http.GetFromJsonAsync <Coin>($"api/coin/{p.Coinid}");

                Coins.Add(coin);
            }
            CalcsChanged();
        }
示例#18
0
    private void RewardCoins(int awardCoins)
    {
        CurrentCoinsAmount += awardCoins;
        if (CoinsDeltaText)
        {
            CoinsDeltaText.text = "+" + awardCoins;
            CoinsDeltaText.gameObject.SetActive(true);
        }

        if (awardCoins > 0)
        {
            nameReward.text = "+ " + awardCoins;
            coins.Add(awardCoins);
        }

        imgRewards.sprite = LootTable[0].sprite;
        imgRewards.type   = Image.Type.Simple;
        imgRewards.SetNativeSize();
        imgRewards.type = Image.Type.Sliced;

        StartCoroutine(UpdateCoinsAmount());
    }
        public static Coins LoadTestData(
            this Coins coins,
            Guid realmRefId
            )
        {
            var rnd = new Random();

            coins.Add(
                new Coin()
            {
                SimpleName = $"Bucks [{Guid.NewGuid()}]"
            }
                );
            coins.Add(
                new Coin()
            {
                SimpleName = $"XP [{Guid.NewGuid()}]"
            }
                );

            return(coins);
        }
示例#20
0
        public bool TryAdd(SmartCoin coin)
        {
            var added = false;

            lock (Lock)
            {
                if (!SpentCoins.Contains(coin))
                {
                    added = Coins.Add(coin);
                    if (added)
                    {
                        if (ClustersByScriptPubKey.TryGetValue(coin.ScriptPubKey, out var cluster))
                        {
                            coin.Cluster = cluster;
                        }
                        else
                        {
                            ClustersByScriptPubKey.Add(coin.ScriptPubKey, coin.Cluster);
                        }

                        foreach (var spentOutPoint in coin.SpentOutputs)
                        {
                            var outPoint   = spentOutPoint;
                            var newCoinSet = new HashSet <SmartCoin> {
                                coin
                            };

                            // If we don't succeed to add a new entry to the dictionary.
                            if (!CoinsByOutPoint.TryAdd(outPoint, newCoinSet))
                            {
                                var previousCoinTxId = CoinsByOutPoint[outPoint].First().TransactionId;

                                // Then check if we're in the same transaction as the previous coins in the dictionary are.
                                if (coin.TransactionId == previousCoinTxId)
                                {
                                    // If we are in the same transaction, then just add it to value set.
                                    CoinsByOutPoint[outPoint].Add(coin);
                                }
                                else
                                {
                                    // If we aren't in the same transaction, then it's a conflict, so replace the old set with the new one.
                                    CoinsByOutPoint[outPoint] = newCoinSet;
                                }
                            }
                        }
                        InvalidateSnapshot = true;
                    }
                }
            }
            return(added);
        }
示例#21
0
        private void AddNewCoin(WindowCommandContext context)
        {
            try
            {
                Coins.Add(NewCoin);
                CoinsCollectionView.MoveCurrentTo(NewCoin);

                IsAddOpened = false;
                CoinsCollectionView.Refresh();
            }
            catch (Exception ex)
            {
                context.Window.ThrowUnknownErrorMessageBox(ex);
            }
        }
示例#22
0
        public void CreateCoins(Vector3 pos)
        {
            Vector3 startPos = pos + new Vector3(0.5f, -0.1f, 0.5f);
            Vector3 endPos   = pos + new Vector3(0.5f, 1.5f, 0.5f);

            Body coins = EntityFactory.CreateEntity <Body>("Coins", startPos);

            coins.AnimationQueue.Add(new EaseMotion(0.8f, coins.LocalTransform, endPos));
            Coins.Add(coins);
            AddBody(coins, false);
            SoundManager.PlaySound(ContentPaths.Audio.Oscar.sfx_ic_dwarf_stash_money, startPos);
            if (Faction != null)
            {
                Faction.World.ParticleManager.Trigger("puff", pos + new Vector3(0.5f, 1.5f, 0.5f), Color.White, 90);
            }
        }
示例#23
0
 public HashrateMultiplierVM(IList <Coin> coins, string displayCoinAs)
 {
     Apply = new RelayCommand(ApplyCommand, Apply_CanExecute);
     this.DisplayCoinAs = displayCoinAs;
     this.Coins         = new ObservableCollection <CoinPlus>();
     Operation          = Operations[0];
     foreach (var coin in coins)
     {
         var coinPlus = new CoinPlus()
         {
             Coin       = coin,
             Multiplier = 1,
             Operation  = this.Operation,
             Result     = coin.Hashrate,
             Rounding   = RoundingOptions[0]
         };
         Coins.Add(coinPlus);
     }
 }
示例#24
0
        public bool TryAdd(SmartCoin coin)
        {
            var added = false;

            lock (Lock)
            {
                if (!SpentCoins.Contains(coin))
                {
                    added = Coins.Add(coin);
                    coin.RegisterToHdPubKey();
                    if (added)
                    {
                        foreach (var outPoint in coin.Transaction.Transaction.Inputs.Select(x => x.PrevOut))
                        {
                            var newCoinSet = new HashSet <SmartCoin> {
                                coin
                            };

                            // If we don't succeed to add a new entry to the dictionary.
                            if (!CoinsByOutPoint.TryAdd(outPoint, newCoinSet))
                            {
                                var previousCoinTxId = CoinsByOutPoint[outPoint].First().TransactionId;

                                // Then check if we're in the same transaction as the previous coins in the dictionary are.
                                if (coin.TransactionId == previousCoinTxId)
                                {
                                    // If we are in the same transaction, then just add it to value set.
                                    CoinsByOutPoint[outPoint].Add(coin);
                                }
                                else
                                {
                                    // If we aren't in the same transaction, then it's a conflict, so replace the old set with the new one.
                                    CoinsByOutPoint[outPoint] = newCoinSet;
                                }
                            }
                        }
                        InvalidateSnapshot = true;
                    }
                }
            }
            return(added);
        }
示例#25
0
        public void updateDbDg()
        {
            var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
            var folderPath  = localFolder.Path;
            var filePath    = Path.Combine(folderPath, this.DBName);

            using (var db = new LiteDatabase(filePath))
            {
                var col  = db.GetCollection <Coin>("coins");
                var coin = Coins;
                col.Update(coin);
            }
            if (total != 0 && updateTotal)
            {
                Coins.Add(new Coin {
                    Name = "Суммы", profitUsd = sumUsd.ToString("F2") + " USD", Profit = sumBtc.ToString("F8"), Amount = total.ToString("F8"), Margin = totalMargin.ToString("F2") + "%"
                });
                updateTotal = false;
            }
            dataGrid.ItemsSource = null;
            dataGrid.ItemsSource = Coins;
        }
示例#26
0
        /// <summary>Update this exchange's set of trading pairs</summary>
        protected override Task UpdatePairsInternal(HashSet <string> coins)        // Worker thread context
        {
            Model.DataUpdates.Add(() =>
            {
                // Create cross-exchange pairs for each coin of interest
                foreach (var cd in SettingsData.Settings.Coins.Where(x => x.CreateCrossExchangePairs))
                {
                    var sym = cd.Symbol;

                    // Find the exchanges that have this coin
                    var exchanges = Exchanges.Where(x => x.Coins.ContainsKey(sym)).ToArray();

                    // Create trading pairs between the same currencies on different exchanges
                    for (int j = 0; j < exchanges.Length - 1; ++j)
                    {
                        for (int i = j + 1; i < exchanges.Length; ++i)
                        {
                            // Check whether the pair already exists
                            var exch0 = exchanges[j];
                            var exch1 = exchanges[i];
                            var pair  = Pairs[sym, exch0, exch1];
                            if (pair != null)
                            {
                                continue;
                            }

                            // If not, add it
                            pair = new TradePair(exch0.Coins[sym], exch1.Coins[sym], this);
                            Pairs.Add(pair);

                            // Add the coins
                            Coins.Add(pair.Base.SymbolWithExchange, pair.Base);
                            Coins.Add(pair.Quote.SymbolWithExchange, pair.Quote);
                        }
                    }
                }
            });
            return(Task.CompletedTask);
        }
 /// <summary>
 /// Called when customer inserted money is transferred to machine
 /// </summary>
 /// <param name="coin"></param>
 public void CoinInsertMachine(Coin coin)
 {
     //if empty
     if (Coins.Count == 0)
     {
         Coins.Add(coin);
     }
     else
     {
         //check if coins of the same value are in machine
         if (Coins.Where(x => x.Cents == coin.Cents).Count() == 0)
         {
             Coins.Add(coin);
         }
         else
         {
             //add to existing coins
             //insert of machine coin can have multipe coins of the same type at once.
             Coins.Where(x => x.Cents == coin.Cents).Single().Quantity += coin.Quantity;
         }
     }
 }
示例#28
0
        public void JPtoUSD(decimal Amount)
        {
            decimal NewAmount;

            NewAmount = Math.Round(Amount * 0.009151M, 2);
            while (NewAmount >= 1.0M)
            {
                Coins.Add(new DollarCoin());
                NewAmount -= 1.0M;
            }
            while (NewAmount >= .50M)
            {
                Coins.Add(new HalfDollar());
                NewAmount -= 0.50M;
            }
            while (NewAmount >= .25M)
            {
                Coins.Add(new Quarter());
                NewAmount -= 0.25M;
            }
            while (NewAmount >= .10M)
            {
                Coins.Add(new Dime());
                NewAmount -= 0.10M;
            }
            while (NewAmount >= .05M)
            {
                Coins.Add(new Nickel());
                NewAmount -= 0.05M;
            }
            while (NewAmount > .00M)
            {
                Coins.Add(new Penny());
                NewAmount -= 0.01M;
            }
        }
示例#29
0
        public void USDtoJP(decimal Amount)
        {
            decimal NewAmount;

            NewAmount = Math.Round(Amount * 109.2780M, 0);
            while (NewAmount >= 500M)
            {
                Coins.Add(new FiveHundredYen());
                NewAmount -= 500M;
            }
            while (NewAmount >= 100M)
            {
                Coins.Add(new HundredYen());
                NewAmount -= 100M;
            }
            while (NewAmount >= 50M)
            {
                Coins.Add(new FiftyYen());
                NewAmount -= 50M;
            }
            while (NewAmount >= 10M)
            {
                Coins.Add(new TenYen());
                NewAmount -= 10M;
            }
            while (NewAmount >= 5M)
            {
                Coins.Add(new FiveYen());
                NewAmount -= 5M;
            }
            while (NewAmount > 0M)
            {
                Coins.Add(new OneYen());
                NewAmount -= 1M;
            }
        }
示例#30
0
 public void AddCoin(ICoin coin)
 {
     Coins.Add(coin);
     NotifyObservers();
 }