コード例 #1
0
ファイル: WatchList.cs プロジェクト: fleabix/LatestChatty-WP7
        public bool AddOrRemove(Comment c)
        {
            bool remove = false;
            foreach (Comment cs in Comments)
            {
                if (cs.id == c.id)
                {
                    Comments.Remove(cs);
                    remove = true;
                    break;
                }
            }

            if (remove == false)
            {
                Comments.Add(c);
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs("Comments"));
            }

            return !remove;
        }
コード例 #2
0
ファイル: Comment.cs プロジェクト: fleabix/LatestChatty-WP7
        public Comment(XElement x, int thisstoryid)
        {
            reply_count = (int)x.Attribute("reply_count");
            date = ((string)x.Attribute("date")).Substring(0,19);
            id = (int)x.Attribute("id");
            author = (string)x.Attribute("author");
            body = StripHTML(((string)x.Element("body")).Trim());
            category = (PostCategory)Enum.Parse(typeof(PostCategory), ((string)x.Attribute("category")).Trim(), true);
            preview = ((string)x.Attribute("preview")).Trim();
            storyid = thisstoryid;

            List<XElement> comments = x.Element("comments").Elements("comment").ToList();
            Comments = new ObservableCollection<Comment>();
            if (comments.Count() > 0)
            {
                foreach (XElement xchild in comments)
                {
                    Comment child = new Comment(xchild, thisstoryid);
                    Comments.Add(child);
                }
            }
        }
コード例 #3
0
        public NestedListBoxItem GetChild(Comment c)
        {
            NestedListBox List = GetTemplateChild("List") as NestedListBox;

            NestedListBoxItem item = (NestedListBoxItem)(List.ItemContainerGenerator.ContainerFromItem(c));
            if (item != null)
            {
                return item;
            }
            else
            {
                for (int i = 0; i < List.Items.Count; i++)
                {
                    item = (NestedListBoxItem)(List.ItemContainerGenerator.ContainerFromIndex(i));
                    item = item.GetChild(c);
                    if (item != null)
                    {
                        return item;
                    }
                }
            }
            return null;
        }
コード例 #4
0
        protected void UpdateViewer(object sender, EventArgs e)
        {
            bool found = false;
            Comment c = _c;
            NestedListBoxItem item = (NestedListBoxItem)(CommentsList.ItemContainerGenerator.ContainerFromItem(c));
            if (item != null)
            {
                item.NestedListBoxItem_Click(null, new RoutedEventArgs());
            }
            else
            {
                for (int i = 0; i < CommentsList.Items.Count; i++)
                {
                    item = (NestedListBoxItem)(CommentsList.ItemContainerGenerator.ContainerFromIndex(i));
                    item = item.GetChild(c);
                    if (item != null)
                    {
                        found = true;
                        break;
                    }
                }
            }

            if (found)
            {
                item.NestedListBoxItem_Click(null, new RoutedEventArgs());
            }
            CompositionTarget.Rendering -= UpdateViewer;
            _c = null;
        }
コード例 #5
0
 public void SelectedCommentChanged(Comment newSelection)
 {
     ShowComment(newSelection);
 }
コード例 #6
0
 void ThreadCreated(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     try
     {
         _thread.PropertyChanged -= ThreadCreated;
         _c = _thread.GetComment(_comment);
         ShowComment(_c);
         ProgressBar.Visibility = Visibility.Collapsed;
         CompositionTarget.Rendering += UpdateViewer;
     }
     catch(Exception)
     {
     }
 }
コード例 #7
0
 private void ShowComment(Comment c)
 {
     _comment = c.id;
     CommentHeader.DataContext = c;
     CommentViewer.NavigateToString(CoreServices.Instance.AddCommentHTML(c.body));
     if (CoreServices.Instance.IsOnWatchedList(c))
     {
         _PinButton.IconUri = new Uri("/Images/sticky_notes.png", UriKind.Relative);
         _PinButton.Text = "Unpin Thread";
     }
     else
     {
         _PinButton.IconUri = new Uri("/Images/PinIcon.png", UriKind.Relative);
         _PinButton.Text = "Pin Thread";
     }
     shouldStartWebBrowser = true;
 }
コード例 #8
0
        // When page is navigated to set data context to selected item in list
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string sStory = "";
            if (NavigationContext.QueryString.TryGetValue("Story", out sStory))
            {
                _story = int.Parse(sStory);
            }
            else
            {
                NavigationService.GoBack();
            }

            if (CoreServices.Instance.ReplyToContext != null)
            {
                _reply = CoreServices.Instance.ReplyToContext;
                DataContext = _reply;
            }
            else
            {
                CommentReplyBox.Visibility = Visibility.Collapsed;
            }

            if (CoreServices.Instance.LoginVerified == false)
            {
                Login.Visibility = Visibility.Visible;
            }
        }
コード例 #9
0
 public bool IsOnWatchedList(Comment c)
 {
     return WatchList.IsOnWatchList(c);
 }
コード例 #10
0
 public bool AddOrRemoveWatch(Comment c)
 {
     return WatchList.AddOrRemove(c);
 }
コード例 #11
0
ファイル: WatchList.cs プロジェクト: fleabix/LatestChatty-WP7
 public bool IsOnWatchList(Comment c)
 {
     foreach (Comment cs in Comments)
     {
         if (cs.id == c.id)
         {
             return true;
         }
     }
     return false;
 }
コード例 #12
0
ファイル: WatchList.cs プロジェクト: fleabix/LatestChatty-WP7
 public void Add(Comment c)
 {
     Comments.Add(c);
 }
コード例 #13
0
ファイル: WatchList.cs プロジェクト: fleabix/LatestChatty-WP7
 public void Remove(Comment c)
 {
     Comments.Remove(c);
 }