Exemplo n.º 1
0
        internal async void FinishPhaseLoad(CommentViewModel viewModel)
        {
            try
            {
                var body = viewModel.Body;
                var loadToken = LoadCancelSource.Token;
                var markdown = await SnooStreamViewModel.SystemServices.RunAsyncIdle(() =>
                {
                    try
                    {
                        var markdownInner = SnooStreamViewModel.MarkdownProcessor.Process(body);
						return markdownInner;
                    }
                    catch (Exception)
                    {
                        //TODO log this failure
						return null;
                    }
                }, loadToken);


                if (loadToken.IsCancellationRequested)
                    return;

                contentControl.ContentTemplate = Resources["markdownTemplate"] as DataTemplate;
				contentControl.Content = markdown.MarkdownDom;
                
                LoadPhase = 3;
            }
            catch (TaskCanceledException)
            {
                return;
            }
        }
        public void GotoReplyToComment(ViewModelBase currentContext, CommentViewModel source)
        {
            var commentsViewModel = currentContext as CommentsViewModel;
            if (commentsViewModel != null)
            {
				commentsViewModel.CurrentlyFocused = commentsViewModel.AddReplyComment(source.Thing.Name);
				Messenger.Default.Send<FocusChangedMessage>(new FocusChangedMessage(commentsViewModel));
            }
        }
			public CommentLinkViewModel(CommentViewModel context, string url, string title)
			{
                Context = context;
				AuthorFlairText = context.Thing.AuthorFlairText;
				Author = context.Thing.Author;
				Subreddit = context.Thing.Subreddit;
				Title = title;
				Url = url;
				CreatedUTC = context.Thing.CreatedUTC;
				Id = context.Thing.Id;
				Votable = context.Votable;
				GotoWeb = new RelayCommand(() =>
					{
						SnooStreamViewModel.NavigationService.NavigateToWeb(Url);
					});
				GotoComments = new RelayCommand(() => 
					{
						var localTemp = Url;
						SnooStreamViewModel.NavigationService.GoBack();
					});
				GotoUserDetails = context.GotoUserDetails;
				LazyContent = new Lazy<ContentViewModel>(() => SnooStream.ViewModel.Content.ContentViewModel.MakeContentViewModel(url, title, this, null));
			}
		public void ShowDecendents(CommentViewModel parent)
		{
			var insertionPoint = FlatComments.IndexOf(parent) + 1;
			foreach (var vmb in Decendents(parent.Id).Reverse())
			{
				FlatComments.Insert(insertionPoint, vmb);
			}
		}
        public void RemoveComment(CommentViewModel commentViewModel)
        {
            var commentShell = _comments[commentViewModel.Id];
            var parentShell = commentViewModel.Parent != null ? _comments[commentViewModel.Parent.Id] : null;
            
            if (parentShell == null)
            {   
                if(commentShell.PriorSibling == null)
                    _firstChild = commentShell.NextSibling;
            }
            else
            {
                if(commentShell.PriorSibling == null)
                    parentShell.FirstChild = commentShell.NextSibling;   
            }

            if (commentShell.PriorSibling != null)
                _comments[commentShell.PriorSibling].NextSibling = commentShell.NextSibling;

            if (commentShell.NextSibling != null)
                _comments[commentShell.NextSibling].PriorSibling = commentShell.PriorSibling;

            _comments.Remove(commentViewModel.Id);
            FlatComments.Remove(commentViewModel);
        }
 public void GotoEditComment(ViewModelBase currentContext, CommentViewModel source)
 {
     source.IsEditing = true;
 }
        public void GotoFullComments(ViewModelBase currentContext, CommentViewModel source)
        {

        }