Пример #1
0
        private void comboBoxPostsFilter_SelectedIndexChanged(object i_Sender, EventArgs i_E)
        {
            comboBoxPostsFilter.Invoke(new Action(() => comboBoxPostsFilter.Enabled = false));
            eNumFilter filter = (eNumFilter)comboBoxPostsFilter.SelectedIndex;

            new Thread(() => fetchPosts(filter)).Start();
        }
        private void comboBoxCheckinFilter_SelectedIndexChanged(object i_Sender, EventArgs i_E)
        {
            setComboBoxEnabled(comboBoxCheckinFilter, false);
            eNumFilter filter = (eNumFilter)comboBoxCheckinFilter.SelectedIndex;

            listBoxCheckins.Items.Clear();
            pictureBoxCheckIn.Image = null;               // Reset Image
            webBrowserGoogleMaps.Navigate("about:blank"); // reset web browser url
            new Thread(() => fetchCheckins(filter)).Start();
        }
Пример #3
0
        public void InitFilterList(eNumFilter i_Filter)
        {
            this.ObjectList.Clear();
            foreach (TTT fbObject in r_FullObjectList)
            {
                if (fbObject.CreatedTime != null && !filterByDate(i_Filter, fbObject.CreatedTime.Value))
                {
                    break;
                }

                ObjectList.Add(fbObject);
            }
        }
Пример #4
0
        private void fetchPosts(eNumFilter i_Filter)
        {
            m_FilterdPostList.InitFilterList(i_Filter);
            if (m_FilterdPostList.ObjectList.Count == 0)
            {
                comboBoxPostsFilter.Invoke(new Action(() => MessageBox.Show("No Posts to retrieve in " + comboBoxPostsFilter.SelectedItem.ToString() + " :(")));
            }
            else
            { // two way data binding, update the filtered posts each time
                if (!listBoxPosts.InvokeRequired)
                {
                    postBindingSource.DataSource = m_FilterdPostList.ObjectList;
                }
                else
                {
                    listBoxPosts.Invoke(new Action(() => postBindingSource.DataSource = m_FilterdPostList.ObjectList));
                }

                Post popularPost = null;
                bool isException = false;

                foreach (Post post in m_FilterdPostList.ObjectList)
                {
                    if (!isException)
                    { // it wont work cuz facebook doesn't give permission so we create condition to avoid multiple exceptions catch
                        try
                        {
                            getMostPopularPost(ref popularPost, post);
                        }
                        catch (FacebookOAuthException)
                        {
                            MessageBox.Show("The app don't have auth to retrieve most popular post :(");
                            isException = true;
                        }
                    }
                }

                // find most popular post and insert it to the textbox
                if (popularPost?.CreatedTime != null)
                {
                    string postText = string.Format(
                        "{0} - {1}",
                        popularPost.CreatedTime.Value.ToString("dd/MM/yyyy"),
                        popularPost.Message);
                    textBoxMostPopularPost.Text = postText;
                }
            }

            comboBoxPostsFilter.Invoke(new Action(() => comboBoxPostsFilter.Enabled = true));
        }
        private void fetchCheckins(eNumFilter i_Filter)
        {
            m_FilterdCheckinList.InitFilterList(i_Filter);
            if (m_FilterdCheckinList.ObjectList.Count == 0)
            {
                setComboBoxEnabled(comboBoxSort, false);
                comboBoxCheckinFilter.Invoke(new Action(() => MessageBox.Show("No Checkins to retrieve in " + comboBoxCheckinFilter.SelectedItem.ToString() + " :(")));
            }
            else
            {
                insertToListBox(m_FilterdCheckinList.ObjectList);
            }

            setComboBoxEnabled(comboBoxCheckinFilter, true);
        }
Пример #6
0
        private bool filterByDate(eNumFilter i_FilterDate, DateTime i_Date)
        {
            DateTime now = DateTime.Now;

            switch (i_FilterDate)
            {
            case eNumFilter.AllTime:
                now = new DateTime(1970, 1, 1);
                break;

            case eNumFilter.ThisMonth:
                now = new DateTime(now.Year, now.Month, 1);
                break;

            case eNumFilter.ThisYear:
                now = new DateTime(now.Year, 1, 1);
                break;

            case eNumFilter.Today:
                break;
            }

            return(now.Date <= i_Date.Date);
        }