Esempio n. 1
0
        private void favorit_Click(object sender, EventArgs e)
        {
            // Add/Remove from favorits. depending on situation and change text on menu item accordinlgy
            ApplicationBarMenuItem mi = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;

            if (mi == null)
            {
                return;
            }
            if (StoryRepository.CheckStoryTitle(value.post.title, true))
            {
                if (StoryRepository.RemoveStory(value.post.title, true))
                {
                    mi.Text = AddToFavoritsString;
                }
            }
            else
            {
                StoryRepository.RemoveStory(value.post.title, true);
                if (StoryRepository.AddNewStory(value.post.title,
                                                value.post.date != null ? DateTime.Parse(value.post.date) : DateTime.Now,
                                                value.post.url,
                                                value.post.content, true, null) > 0)
                {
                    Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50));
                    mi.Text = RemoveFromFavoritsString;
                }
            }
        }
Esempio n. 2
0
        private void favorit_Click(object sender, EventArgs e)
        {
            // Add/Remove from favorits. depending on situation and change text on menu item accordinlgy
            ApplicationBarMenuItem mi = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;

            if (mi == null)
            {
                return;
            }
            if (StoryRepository.CheckStoryTitle(value.post.title))
            {
                if (StoryRepository.RemoveStory(value.post.title))
                {
                    mi.Text = AddToFavoritsString;
                }
            }
            else
            {
                if (StoryRepository.AddNewStory(value.post.title,
                                                DateTime.Parse(value.post.date),
                                                value.post.url,
                                                value.post.content, null) > 0)
                {
                    mi.Text = RemoveFromFavoritsString;
                }
            }
        }
Esempio n. 3
0
 public bool AddFavorite(string title,
                         DateTime publishedDate,
                         string link,
                         string details)
 {
     try
     {
         StoryRepository.AddNewStory(title, publishedDate, link, details, StoreFavorit);
         return(true);
     }
     catch (Exception e)
     {
     }
     return(false);
 }
Esempio n. 4
0
        public bool AddFavorite(string title,
                                DateTime publishedDate,
                                string link,
                                string details)
        {
            try
            {
                StoryRepository.RemoveStory(title, true);
                StoryRepository.AddNewStory(title, publishedDate, link, details, true, StoreFavorit);
                Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50));
                return(true);
            }
            catch (Exception e)
            {
            }

            return(false);
        }
Esempio n. 5
0
        private void webClient_OpenReadCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }
            Dispatcher.BeginInvoke(() =>
            {
                value          = JsonConvert.DeserializeObject <PostRoot>(e.Result);
                var caption    = value.post.title.Split('.', '!', '?');
                tbCaption.Text = caption[0];
                // Need some smarter trim here, for O.Henry for example
                if (caption.Length > 1)
                {
                    tbCaptionAuthor.Text = value.post.title.Replace(caption[0], "").Trim(new char[] { '.', '!', '?' });
                }
                //if (NavigationContext.QueryString["b"] != null)
                //{
                //    value.post.content = "<div style='background-color:black;color:white;margin:0;padding:0'>" + value.post.content + "</div>";
                //ContentWebBrowser.Background = new SolidColorBrush(Colors.Black);
                //}

                ShowReadDuration(value.post.content);
                ContentWebBrowser.NavigateToString(InjectedString(value.post.content));
                pi.IsVisible = false;

                // Save downloaded story to HISTORY
                StoryRepository.AddNewStory(value.post.title,
                                            DateTime.Parse(value.post.date),
                                            value.post.url,
                                            value.post.content, false, null);

                ApplicationBarMenuItem mi = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
                if (mi != null)
                {
                    mi.Text = StoryRepository.CheckStoryTitle(value.post.title, true) ? RemoveFromFavoritsString : AddToFavoritsString;
                }
            });
        }