Esempio n. 1
0
        /// <summary>
        /// Button for transferring data to the necessary window for individual blog posts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //testing xaml reader and writer functions

            Button button = sender as Button;

            Datum data = (Datum)button.DataContext;

            if (data != null)
            {
                try
                {
                    //Using the forum window instead.
                    //I love the layout more.
                    BlogDetailsWindow blogDetailsWindow = new BlogDetailsWindow();

                    blogDetailsWindow.headerTB.Text = "A blog post by: " + data.user.name;
                    //Clean the title and body
                    string theTitle     = data.title;
                    string theBody      = data.body;
                    string cleanedTitle = Regex.Replace(theTitle, @"<[^>]*>", "");
                    string cleanedBody  = Regex.Replace(theBody, @"<[^>]*>", "");

                    blogDetailsWindow.titleText.Text = cleanedTitle;
                    blogDetailsWindow.bodyTB.Text    = cleanedBody;

                    blogDetailsWindow.userImage.Source  = new BitmapImage(new Uri(data.user.avatarUrl));
                    blogDetailsWindow.dateText.Text     = data.created.date;
                    blogDetailsWindow.usernameText.Text = data.user.name;

                    foreach (var dat in data.comment.data)
                    {
                        string comment = Regex.Replace(dat.body, @"<[^>]*>", "");
                        dat.body = comment;
                        DateTime dateTime  = new DateTime();
                        bool     dateParse = DateTime.TryParse(dat.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"));
                            dat.created.date = convertedTime;
                        }
                        //Pass in the ID of the logged in user.
                        dat.LoggedInID = LoggedID;
                    }
                    //Pass the slug
                    blogDetailsWindow.PostSlug = data.slug;
                    //pass the token
                    blogDetailsWindow.Token = Token;

                    blogDetailsWindow.commentsListBox.ItemsSource = data.comment.data;

                    blogDetailsWindow.Show();
                }
                catch (Exception b) { MessageBox.Show(b.Message); }
            }
        }
        /// <summary>
        /// Event triggered when the user clicks to see more post.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            Datum data = btn.DataContext as Datum;

            if (data != null)
            {
                try
                {
                    BlogDetailsWindow blogDetailsWindow = new BlogDetailsWindow();

                    blogDetailsWindow.headerTB.Text = "A status post by: " + data.user.name;
                    //Clean the title and body
                    string theTitle     = data.title;
                    string theBody      = data.body;
                    string cleanedTitle = Regex.Replace(theTitle, @"<[^>]*>", "");
                    string cleanedBody  = Regex.Replace(theBody, @"<[^>]*>", "");

                    blogDetailsWindow.titleText.Text = cleanedTitle;
                    blogDetailsWindow.bodyTB.Text    = cleanedBody;

                    blogDetailsWindow.userImage.Source  = new BitmapImage(new Uri(data.user.avatarUrl));
                    blogDetailsWindow.dateText.Text     = data.created.date;
                    blogDetailsWindow.usernameText.Text = data.user.name;

                    foreach (var dat in data.comment.data)
                    {
                        DateTime dateTime  = new DateTime();
                        bool     dateParse = DateTime.TryParse(dat.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"));
                            dat.created.date = convertedTime;
                        }
                        string comment = Regex.Replace(dat.body, @"<[^>]*>", "");
                        dat.body = comment;
                        //Pass in the ID of the logged in user.
                        dat.LoggedInID = LoggedID;
                    }
                    //Pass the token,important
                    blogDetailsWindow.Token = Token;
                    //Pass the slug
                    blogDetailsWindow.PostSlug = data.slug;

                    blogDetailsWindow.commentsListBox.ItemsSource = data.comment.data;

                    blogDetailsWindow.Show();
                }
                catch (Exception t)
                {
                    MessageBox.Show("A problem occured. Please try again in a few moments. " + t.Message);
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            AfricoderJobsFeed.Datum data = btn.DataContext as AfricoderJobsFeed.Datum;
            //Load up the category window.
            CategoryDetailsWindow categoryDetailsWindow = new CategoryDetailsWindow();

            if (data != null)
            {
                BlogDetailsWindow blogDetailsWindow = new BlogDetailsWindow();

                blogDetailsWindow.headerTB.Text = "A job post by: " + data.user.name;
                //Clean the title and body
                string theTitle     = data.title;
                string theBody      = data.body;
                string cleanedTitle = Regex.Replace(theTitle, @"<[^>]*>", "");
                string cleanedBody  = Regex.Replace(theBody, @"<[^>]*>", "");

                blogDetailsWindow.titleText.Text = cleanedTitle;
                blogDetailsWindow.bodyTB.Text    = cleanedBody;

                blogDetailsWindow.userImage.Source  = new BitmapImage(new Uri(data.user.avatarUrl));
                blogDetailsWindow.dateText.Text     = data.created.date;
                blogDetailsWindow.usernameText.Text = data.user.name;

                foreach (var dat in data.comment.data)
                {
                    string comment = Regex.Replace(dat.body, @"<[^>]*>", "");
                    dat.body = comment;
                    DateTime dateTime  = new DateTime();
                    bool     dateParse = DateTime.TryParse(dat.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"));
                        dat.created.date = convertedTime;
                    }
                    //Pass in the ID of the logged in user.
                    dat.LoggedInID = LoggedId;
                }
                //Pass the slug
                blogDetailsWindow.PostSlug = data.slug;
                //pass the token
                blogDetailsWindow.Token = Token;
                blogDetailsWindow.commentsListBox.ItemsSource = data.comment.data;

                blogDetailsWindow.Show();
            }
        }