Beispiel #1
0
        /// <summary>
        /// Exports the state of the entity to a new instance of <see cref="UserInfo"/>.
        /// </summary>
        /// <returns>A new instance of <see cref="UserInfo"/> with the current state of the entity.</returns>
        internal UserInfo ToUserInfo()
        {
            var accounts   = Accounts.Select(a => a.ToAccountInfo()).ToList();
            var watchlists = Watchlists.Select(a => a.ToWatchlistInfo()).ToList();

            return(new UserInfo(Id, Email, DisplayName, GravatarUrl, Level, accounts, watchlists));
        }
        private async void DeleteList()
        {
            var res = await Dialog.ShowMessageAsync(this, "Warning", "This watchlist will be deleted. Are you sure?",
                                                    MessageDialogStyle.AffirmativeAndNegative);

            if (res == MessageDialogResult.Affirmative)
            {
                File.Delete(WatchListPath);
                GetWatchlists();
                SelectedWatchlist = Watchlists.First().Content.ToString();
            }
        }
        public void GetWatchlists()
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Inside MMA\\settings\\watchlists";

            Directory.CreateDirectory(path);
            var files = Directory.GetFiles(path);

            if (files.Length == 0)
            {
                File.Create(path + "\\My Watchlist");
                files = new[] { path + "\\My Watchlist" };
            }
            for (var i = 0; i < files.Length; i++)
            {
                files[i] = files[i].Substring(files[i].LastIndexOf("\\")).TrimStart('\\');
            }
            List <string> missingFiles = new List <string>();

            if (files.Length != Watchlists.Count)
            {
                foreach (var item in Watchlists)
                {
                    if (!files.Contains(item.Content))
                    {
                        missingFiles.Add(item.Content.ToString());
                    }
                }
            }
            Watchlists.RemoveWhere(x => missingFiles.Contains(x.Content));
            WatchlistMenuItems = new ObservableCollection <MenuItem>();
            foreach (var name in files)
            {
                if (!Watchlists.Select(x => x.Content).Contains(name))
                {
                    Dispatcher.Invoke(() => Watchlists.Add(new ComboBoxItem
                    {
                        Content = name
                    }));
                }
                WatchlistMenuItems.Add(new MenuItem
                {
                    Header           = name,
                    Command          = AddToAnotherWatchlist,
                    CommandParameter = name
                });
            }
        }
Beispiel #4
0
        // <Summary>
        // GetRestWatchlists
        // </Summary>
        public async void GetRestWatchlists()
        {
            try
            {
                UpdateWatchlistsMessage("Retrieving watchlists");
                var response = await igRestApiClient.listOfWatchlists();

                if (response && (response.Response.watchlists != null))
                {
                    Watchlists.Clear();
                    foreach (var wl in response.Response.watchlists)
                    {
                        var wm = new IgPublicApiData.WatchlistModel();
                        wm.WatchlistId   = wl.id;
                        wm.WatchlistName = wl.name;
                        wm.Editable      = wl.editable;
                        wm.Deletable     = wl.deleteable;

                        Watchlists.Add(wm);
                    }

                    if (Watchlists.Count >= 1)
                    {
                        GetWatchlistMarketsCommand.IsEnabled = true;
                        WatchlistIndex = 0;
                    }

                    // Let's get the instruments for the 1st watchlist in the list.

                    WatchlistIndex = 0;
                    GetRestWatchlistMarkets();
                }
                else
                {
                    UpdateWatchlistsMessage("GetRestWatchlists : no watchlists returned from server");
                }
            }
            catch (Exception ex)
            {
                UpdateWatchlistsMessage(ex.Message);
            }
        }