Exemplo n.º 1
0
        /// <summary>
        /// Triggered when the user intends to read more on a specific topic.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MoreButton_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            ForumModel.Datum datum = (ForumModel.Datum)btn.DataContext;


            if (datum != null)
            {
                ForumWindow forumWindow = new ForumWindow();
                string      bodyText    = datum.body.ToString();
                string      TitleText   = datum.title.ToString();
                string      dateText    = datum.created.date.ToString();
                string      userName    = datum.user.name.ToString();
                string      AvaterUrl   = datum.user.avatarUrl.ToString();

                forumWindow.headerTB.Text     = "A forum post by: " + userName;
                forumWindow.bodyTB.Text       = bodyText;
                forumWindow.titleText.Text    = TitleText;
                forumWindow.dateText.Text     = dateText;
                forumWindow.usernameText.Text = userName;
                forumWindow.userImage.Source  = new BitmapImage(new Uri(AvaterUrl));
                //Reformat the body of comments to remove html tags

                foreach (var m in datum.comment.data)
                {
                    string theBody = m.body;

                    string   reformatted = Regex.Replace(theBody, @"<[^>]*>", "");
                    DateTime dateTime    = new DateTime();
                    bool     dateParse   = DateTime.TryParse(m.created.date, out dateTime);
                    //string date = dat.created.date;
                    if (dateParse)
                    {
                        string convertedTime = Convert.ToDateTime(DateTime.Parse(dateTime.ToString())).ToString(("ddd, dd MMM yyyy hh:mm:tt"));
                        m.created.date = convertedTime;
                    }
                    m.body = reformatted.Replace("<p>", "").Replace("<b>", "").Replace("</b>", "").Replace("</p>", "");

                    m.LoggedInID = LoggedID;
                }
                //Pass slug to the forum
                forumWindow.PostSlug = datum.slug;
                //Pass the token from this page.
                forumWindow.Token = Token;
                forumWindow.commentsListBox.ItemsSource = datum.comment.data;
                forumWindow.Show();
            }
        }
Exemplo n.º 2
0
        private void ButtonForums_Click(object sender, RoutedEventArgs e)
        {
            //доступ к форуму - только если подключен интернет и есть браузер
            bool mayTorrent = ((IInfoComputer)_panel.Computer).GetLevel(Internet) > 0 && ((IInfoSoft)_panel.Soft).GetInfo(SoftBase.Parts.Browser) > 0;

            if (!mayTorrent)
            {
                MessageBox.Show("Для доступа к интернет-форуму должен быть подключен интернет и должен быть установлен любой браузер!", "Интернет-форум недоступен", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ForumWindow window = new ForumWindow(_panel.Forum);

            window.Owner = Window.GetWindow(this);
            window.ShowDialog();
        }