Ejemplo n.º 1
0
        public NewsDetailsWindow(string newsUrl, string newsTitle, DateTime newsCreatedAt, int newsNumberOfComments)
        {
            InitializeComponent();

            NewsUrl       = newsUrl ?? "";
            textBox1.Text = newsTitle ?? "";
            textBox2.Text = KanonierzyParser.GetSingleNewsContent(newsUrl);
            label2.Text   = newsCreatedAt.ToString("MM/dd/yy HH:mm");
            label4.Text   = newsNumberOfComments.ToString();

            this.Select();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            List <News> news = KanonierzyParser.GetNewsPageForDate(DateTime.Now.Year, DateTime.Now.Month);

            foreach (var item in news)
            {
                item.Comments = KanonierzyParser.GetCommentsPageForNews(item.Url, 1);
                break;
            }

            news.ForEach(item => System.Console.WriteLine(item.ToString()));
            System.Console.ReadKey();
        }
Ejemplo n.º 3
0
 private void InitializeMainNews()
 {
     MainNews = KanonierzyParser.GetMainNews();
     if (MainNews != null)
     {
         mainNewsTitleTextBox.Text   = MainNews.Title;
         mainNewsContentTextBox.Text = MainNews.Content;
         mainNewsLabel2.Text         = MainNews.CreatedAt.ToString("MM/dd/yy HH:mm");
         mainNewsLabel4.Text         = MainNews.NumberOfComments.ToString();
     }
     else
     {
         MessageBox.Show("Error during fetching Main News", "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 4
0
        private void LoadNewsList()
        {
            newsListBox.Items.Clear();

            var yearItem      = newsYearComboBox1.SelectedItem;
            var selectedMonth = newsMonthComboBox2.SelectedIndex + 1;

            int.TryParse(yearItem.ToString(), out int selectedYear);
            int.TryParse(newsPageTextBox.Text.Trim(), out int selectedPage);
            newsPageTextBox.Text = "" + (selectedPage > 0 ? selectedPage : selectedPage + 1);
            News = KanonierzyParser.GetNewsPageForDate(selectedYear, selectedMonth, selectedPage);

            if (News != null)
            {
                foreach (var item in News)
                {
                    string newsRecord = item.CreatedAt.ToString("MM/dd/yy HH:mm")
                                        + "\t" + $"{item.Title}  (comments: {item.NumberOfComments})";
                    newsListBox.Items.Add(newsRecord);
                }
            }
        }
Ejemplo n.º 5
0
        private void CommentsDownloadBtn_Click(object sender, EventArgs e)
        {
            int.TryParse(commentsPageTextBox.Text.Trim(), out int selectedCommentPage);
            string commNewsUrl   = "";
            string commNewsTitle = "";

            if (tabControl.SelectedIndex == 0) // main news tab
            {
                if (MainNews != null && !string.IsNullOrEmpty(MainNews.Url))
                {
                    commNewsUrl   = MainNews.Url;
                    commNewsTitle = MainNews.Title;
                }
                else
                {
                    MessageBox.Show("There is no main news.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (tabControl.SelectedIndex == 1) // news archive tab
            {
                if (string.IsNullOrEmpty(SelectedNewsUrl))
                {
                    MessageBox.Show("Select news from the list.", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                commNewsUrl   = SelectedNewsUrl;
                commNewsTitle = SelectedNewsTitle;
            }

            var comments = KanonierzyParser.GetCommentsPageForNews(commNewsUrl, selectedCommentPage);

            commentsGrid.DataSource = comments;
            label5.Text             = $"{CommentsLabelText}\"{commNewsTitle}\"";
        }