Пример #1
0
        private void HideNewsLabels()
        {
            UrlNews1.Hide();
            UrlNews2.Hide();
            UrlNews3.Hide();

            NewsSummary1.Hide();
            NewsSummary2.Hide();
            NewsSummary3.Hide();

            label1.Hide();
            label2.Hide();
        }
Пример #2
0
        private async Task updateNews(string symbol)
        {
            UrlNews1.LinkVisited = false;
            UrlNews2.LinkVisited = false;
            UrlNews3.LinkVisited = false;
            links.Clear();
            try
            {
                GroupBox_Top_Today.Text = $"Recent News ({symbol})";
                //UrlNews1.MaximumSize = new Size(320, 0);
                List <NewsDto> list = new List <NewsDto>();
                list.AddRange(await API.GetNews(symbol, 3));

                foreach (var dto in list)
                {
                    links.Add(dto.Url);
                }

                if (list.Count == 3)
                {
                    UrlNews1.Text = list[0].Headline;
                    UrlNews2.Text = list[1].Headline;
                    UrlNews3.Text = list[2].Headline;

                    NewsSummary1.Text =
                        list[0].Summary != "No summary available." ? list[0].Summary : "       " + list[0].Summary;
                    NewsSummary2.Text =
                        list[1].Summary != "No summary available." ? list[1].Summary : "       " + list[1].Summary;
                    NewsSummary3.Text =
                        list[2].Summary != "No summary available." ? list[2].Summary : "       " + list[2].Summary;

                    label1.Show();
                    label2.Show();
                    UrlNews1.Show();
                    NewsSummary1.Show();
                    UrlNews2.Show();
                    NewsSummary2.Show();
                    UrlNews3.Show();
                    NewsSummary3.Show();
                }
                else if (list.Count == 2)
                {
                    UrlNews1.Text = list[0].Headline;
                    UrlNews2.Text = list[1].Headline;

                    NewsSummary1.Text = list[0].Summary != "No summary available." ? list[0].Summary : "       " + list[0].Summary;
                    NewsSummary2.Text = list[1].Summary != "No summary available." ? list[1].Summary : "       " + list[0].Summary;

                    label1.Show();
                    UrlNews1.Show();
                    NewsSummary1.Show();
                    UrlNews2.Show();
                    NewsSummary2.Show();
                    UrlNews3.Hide();
                    NewsSummary3.Hide();
                }
                else if (list.Count == 1)
                {
                    UrlNews1.Text     = list[0].Headline;
                    NewsSummary1.Text = list[0].Summary != "No summary available." ? list[0].Summary : "       " + list[0].Summary;

                    UrlNews1.Show();
                    NewsSummary1.Show();
                    UrlNews2.Hide();
                    NewsSummary2.Hide();
                    UrlNews3.Hide();
                    NewsSummary3.Hide();
                }
            }
            catch (System.Net.WebException e)
            {
                MessageBox.Show(e.Message);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error " + e.Message);
            }
        }