Esempio n. 1
0
        public FolderViewModel(MarketViewModel market, FolderModel model)
        {
            if (market == null)
            {
                throw new ArgumentNullException(nameof(market));
            }

            _market = market;
            Model   = model;

            DeleteCommand        = new RelayCommand(() => _market?.DeleteFolder(this), () => !_market.Active);
            StartCommand         = new RelayCommand(() => { }, () => false);
            StopCommand          = new RelayCommand(() => { }, () => false);
            AddSymbolCommand     = new RelayCommand <SymbolViewModel>(m => DoAddSymbol(m), m => !_market.Active && MarketSymbols.View.Cast <object>().FirstOrDefault() != null);
            RemoveSymbolsCommand = new RelayCommand <IList>(m => DoRemoveSymbols(m), m => !_market.Active && SelectedSymbol != null);
            ExportFolderCommand  = new RelayCommand(() => DoExportFolder(), () => !_market.Active);

            DataFromModel();

            MarketSymbols.Filter += (object sender, FilterEventArgs e) =>
            {
                if (e.Item is SymbolViewModel marketSymbol)
                {
                    e.Accepted = marketSymbol.Active && !Symbols.Any(m => m.Model.Name.Equals(marketSymbol.Model.Name, StringComparison.OrdinalIgnoreCase));
                }
            };

            MarketSymbols.Source = _market.Symbols;
        }
Esempio n. 2
0
        public ListViewModel(MarketViewModel market, ListModel model)
        {
            Market = market ?? throw new ArgumentNullException(nameof(market));
            Model  = model;

            DeleteCommand        = new RelayCommand(() => Market?.DeleteList(this), () => !IsBusy && !Market.Active);
            StartCommand         = new RelayCommand(() => { }, () => false);
            StopCommand          = new RelayCommand(() => { }, () => false);
            AddSymbolCommand     = new RelayCommand <SymbolViewModel>(m => DoAddSymbol(m), m => !IsBusy && !Market.Active && MarketSymbols.View.Cast <object>().FirstOrDefault() != null);
            RemoveSymbolsCommand = new RelayCommand <IList>(m => DoRemoveSymbols(m), m => !IsBusy && !Market.Active && SelectedSymbol != null);
            ExportListCommand    = new RelayCommand(() => DoExportList(), () => !IsBusy && !Market.Active);

            DataFromModel();

            MarketSymbols.Filter += (object sender, FilterEventArgs e) =>
            {
                if (e.Item is SymbolViewModel marketSymbol)
                {
                    e.Accepted = marketSymbol.Active &&
                                 !Symbols.Any(m => m.Model.Id.Equals(marketSymbol.Model.Id, StringComparison.OrdinalIgnoreCase));
                }
            };

            MarketSymbols.Source = Market.Symbols;
            Debug.Assert(IsUiThread(), "Not UI thread!");
        }
Esempio n. 3
0
        private void SetPreferences()
        {
            if (accountPreferences != null &&
                accountPreferences.Preferences != null &&
                Symbols != null &&
                Symbols.Any())
            {
                if (accountPreferences.Preferences.FavouriteSymbols != null &&
                    accountPreferences.Preferences.FavouriteSymbols.Any())
                {
                    Func <Symbol, string, Symbol> f = ((s, p) =>
                    {
                        s.IsFavourite = true;
                        return(s);
                    });

                    (from s in Symbols join fs in accountPreferences.Preferences.FavouriteSymbols on s.Name equals fs.ToString() select f(s, fs)).ToList();

                    ShowFavourites = accountPreferences.Preferences.ShowFavourites;

                    if (!string.IsNullOrWhiteSpace(accountPreferences.Preferences.SelectedSymbol))
                    {
                        var symbol = Symbols.FirstOrDefault(s => s.Name.Equals(accountPreferences.Preferences.SelectedSymbol));
                        if (symbol != null)
                        {
                            SelectedSymbol = symbol;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public string LookupCoin(string CoinId)
        {
            string CleanId = CoinId.Replace(" ", String.Empty);

            if (Symbols.Any(x => x.Symbol.ToLower() == CleanId.ToLower()))
            {
                CleanId = Symbols.FirstOrDefault(x => x.Symbol.ToLower() == CleanId.ToLower()).Id;
            }
            List <Coin> Items = null;
            string      json  = null;

            try
            {
                json = LookUpClient.DownloadString(TickerURL + CleanId.ToLower());
            }
            catch (WebException) { }

            if (json != null)
            {
                try
                {
                    Items = JsonConvert.DeserializeObject <List <Coin> >(json);
                }
                catch (JsonSerializationException) { }
            }

            if (Items != null)
            {
                return(Items.Find(x => x.Id.ToLower() == CleanId.ToLower()).ShowInfo(_client));
            }
            else
            {
                return("Coin does not exist in the CMC database");
            }
        }
Esempio n. 5
0
        /* This function matches the trace to a possible transmit or receive trace */
        internal string GetRealTrace(string trace)
        {
            String retString = trace;

            if (Symbols.Any(p => p.Value.Contains(trace)))
            {
                retString = Symbols.First(p => p.Value.Contains(trace)).Value;
            }

            return(retString);
        }
Esempio n. 6
0
 private void SetPreferences()
 {
     if (AccountPreferences != null &&
         AccountPreferences.Preferences != null &&
         Symbols.Any())
     {
         if (AccountPreferences.Preferences.FavouriteSymbols != null &&
             AccountPreferences.Preferences.FavouriteSymbols.Any())
         {
             if (!string.IsNullOrWhiteSpace(AccountPreferences.Preferences.SelectedSymbol))
             {
                 var symbol = Symbols.FirstOrDefault(s => s.ExchangeSymbol.Equals(AccountPreferences.Preferences.SelectedSymbol, StringComparison.OrdinalIgnoreCase));
                 if (symbol != null)
                 {
                     SelectedSymbol = symbol;
                 }
             }
         }
     }
 }
Esempio n. 7
0
 public bool IsInCurrentScope(string identifier) => Symbols.Any(s => s.Identifier == identifier);
Esempio n. 8
0
 public bool ApplicableToSymbol(string symbol)
 {
     return(Symbols.Any(s => s.Equals(symbol)));
 }