public void SetId(int id)
 {
     this.postId = id;
     this.post   = this.postServive.GetPostViewModel(id);
     this.InitializeTextArea();
     this.Open();
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostDetailView"/> class.
 /// </summary>
 /// <param name="selectedPost">The selected post.</param>
 /// <param name="iPostViewModel">The i post view model.</param>
 public PostDetailView(Post selectedPost, IPostViewModel iPostViewModel)
 {
     InitializeComponent();
     _iPostViewModel = iPostViewModel;
     this.MainDataGrid.DataContext       = _iPostViewModel;
     this.MainDataGrid.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader;
 }
示例#3
0
        private void LoadPost()
        {
            this.post = this.postService.GetPostViewModel(this.postId);

            this.InitializeTextArea();
            this.Open();
        }
示例#4
0
 public void ViewLoaded(object vm)
 {
     _postViewModel = vm as IPostViewModel;
     if (_postViewModel != null && _id != null)
         _postViewModel.InitContent(_id, _page, _title);
     _id = null;
 }
 /// <summary>
 /// Фильтровать пост.
 /// </summary>
 /// <param name="post">Пост.</param>
 /// <returns>Результат фильтрации.</returns>
 public bool Filter(IPostViewModel post)
 {
     if (post?.Link == null || linkHash == null)
     {
         return false;
     }
     return linkHashService.GetLinkHash(post.Link) == linkHash;
 }
示例#6
0
 public void TestInitialize()
 {
     _iLogger        = new StubILogger();
     _postDAL        = new StubIPostDAL();
     _iMainViewModel = new MainViewModel(_postDAL, _iLogger);
     _iLayoutCreator = new LayoutCreator();
     _iPostViewModel = new PostViewModel(_iLogger, _iLayoutCreator);
 }
示例#7
0
 public void ViewLoaded(object vm)
 {
     _postViewModel = vm as IPostViewModel;
     if (_postViewModel != null && _id != null)
     {
         _postViewModel.InitContent(_id, _page, _title);
     }
     _id = null;
 }
示例#8
0
        public void CopyToClip()
        {
            StubILayoutCreator _iLayoutCreator = new StubILayoutCreator();

            _iPostViewModel = new PostViewModel(_iLogger, _iLayoutCreator);

            _iLayoutCreator.CreateLayoutString = (a) => { throw new Exception("Custom error", new Exception("innerException")); };

            _iPostViewModel.CopyToClip(Constants.Text, null);
        }
示例#9
0
 public ViewPostMenu(ILabelFactory labelFactory, ISession session,
                     IForumViewEngine forumViewEngine, IPostViewModel postViewModel,
                     ICommandFactory commandFactory, IPostService postService)
 {
     this.labelFactory   = labelFactory;
     this.session        = session;
     this.viewEngine     = forumViewEngine;
     this.post           = postViewModel;
     this.commandFactory = commandFactory;
     this.postService    = postService;
 }
示例#10
0
        /// <summary>
        /// Конструктор.
        /// </summary>
        /// <param name="parent">Родительская модель.</param>
        /// <param name="postData">Данные поста.</param>
        public PostMediaViewModel(IPostViewModel parent, PostTree postData) : base(parent)
        {
            var media = postData?.Media;
            if (media != null)
            {
                foreach (var model in media.Select(CreateModel).Where(model => model != null))
                {
                    Files.Add(model);
                }
            }

            PrimaryFile = Files.FirstOrDefault();
        }
 /// <summary>
 /// Фильтровать пост.
 /// </summary>
 /// <param name="post">Пост.</param>
 /// <returns>Результат фильтрации.</returns>
 public bool Filter(IPostViewModel post)
 {
     if (post?.Link == null)
     {
         return false;
     }
     var num = linkTransform.GetPostNum(post.Link);
     if (num == null)
     {
         return false;
     }
     return (post.Counter != null && post.Counter == Number) || num == Number;
 }
示例#12
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="parent">Родитель.</param>
 /// <param name="data">Данные.</param>
 public PostTags(IPostViewModel parent, PostTree data)
 {
     this.Parent = parent;
     var tagExt = data?.Extensions?.OfType<PostTreeTagsExtension>()?.FirstOrDefault();
     if (tagExt?.Tags != null)
     {
         foreach (var t in tagExt.Tags)
         {
             Tags.Add(t);
         }
         HasTags = Tags.Count > 0;
     }
 }
 /// <summary>
 /// Фильтровать пост.
 /// </summary>
 /// <param name="post">Пост.</param>
 /// <returns>Результат фильтрации.</returns>
 public bool Filter(IPostViewModel post)
 {
     var postText = post?.Text?.GetPlainText();
     if (postText == null)
     {
         return false;
     }
     if (string.IsNullOrWhiteSpace(Text))
     {
         return true;
     }
     var text = Text.Trim();
     if (text.StartsWith("/") && text.EndsWith("/") && text.Length > 2)
     {
         text = text.Remove(0, 1);
         text = text.Remove(text.Length - 1, 1);
         return post.Tags.Tags.Any(t => text.Equals(t, StringComparison.CurrentCultureIgnoreCase));
     }
     return 
         (post.Subject ?? "").IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
         postText.Any(t => t.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0) ||
         post.Tags.Tags.Any(t => text.Equals(t, StringComparison.CurrentCultureIgnoreCase));
 }
示例#14
0
 public void TestTearDown()
 {
     if (_iMainViewModel != null)
     {
         _iMainViewModel = null;
     }
     if (_postDAL != null)
     {
         _postDAL = null;
     }
     if (_iLogger != null)
     {
         _iLogger = null;
     }
     if (_iPostViewModel != null)
     {
         _iPostViewModel = null;
     }
     if (_iLayoutCreator != null)
     {
         _iLayoutCreator = null;
     }
 }
示例#15
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="parent">Родительская модель.</param>
 /// <param name="post">Пост.</param>
 public PostTextViewModel(IPostViewModel parent, PostTree post) : base(parent)
 {
     this.UniqueId = Guid.NewGuid();
     this.post = post;
     if (post?.Quotes != null)
     {
         var linkHash = ServiceLocator.Current.GetServiceOrThrow<ILinkHashService>();
         var linkTransform = ServiceLocator.Current.GetServiceOrThrow<ILinkTransformService>();
         var q = post.Quotes
             .Distinct(linkHash.GetComparer())
             .OrderBy(a => a, linkTransform.GetLinkComparer())
             .ToArray();
         foreach (var a in q)
         {
             HasQuotes = true;
             Quotes.Add(new QuoteViewModel()
             {
                 Parent = parent,
                 Name = linkTransform.GetBackLinkDisplayString(a),
                 Link = a
             });
         }
     }
 }
示例#16
0
 private void LoadPost()
 {
     this.post = this.postService.GetPostViewModel(this.postId);
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="parent">Родительская модель.</param>
 protected PostPartViewModelBase(IPostViewModel parent)
 {
     Parent = parent;
 }
示例#18
0
 private void PushCurrentLink(IPostViewModel si, BoardLinkBase l)
 {
     if (si?.Link != null)
     {
         var linkHash = ServiceLocator.Current.GetServiceOrThrow<ILinkHashService>();
         var oldHash = linkHash.GetLinkHash(si.Link);
         if (ViewModel?.FindPost(new LinkHashPostCollectionSearchQuery(oldHash)) == null)
         {
             return;
         }
         if (l != null)
         {
             var newHash = linkHash.GetLinkHash(l);
             if (newHash == oldHash)
             {
                 return;
             }
         }
         singleNavigationStack.Push(oldHash);
     }
 }
示例#19
0
 private void ScrollIntoView(IPostViewModel post)
 {
     MainList.ScrollIntoView(post);
 }
 public void SetId(int id)
 {
     this.post = this.postService.GetPostViewModel(id);
 }
 /// <summary>
 /// Показать тред.
 /// </summary>
 /// <param name="post">Пост.</param>
 public void ScrollIntoView(IPostViewModel post)
 {
     if (post == null)
     {
         return;
     }
     try
     {
         MainList.ScrollIntoView(post, ScrollIntoViewAlignment.Leading);
     }
     catch (Exception ex)
     {
         DebugHelper.BreakOnError(ex);
     }
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="postCollection">Коллекция постов.</param>
 /// <param name="post">Пост, с которого был совершён переход.</param>
 public ShowFullThreadEventArgs(IPostCollectionViewModel postCollection, IPostViewModel post)
 {
     PostCollection = postCollection;
     Post = post;
 }
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="post">Пост.</param>
 public ShowFullPostEventArgs(IPostViewModel post)
 {
     Post = post;
 }
示例#24
0
 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="postData">Данные.</param>
 /// <param name="parent">Родитель.</param>
 public PostNameViewModel(PostTree postData, IPostViewModel parent)
 {
     this.postData = postData;
     Parent = parent;
     TripCode = "";
     Name = "";
     AppHelpers.DispatchAction(SetData, false, 0);
 }
 public AddReplyMenu(ILabelFactory labelFactory, ITextAreaFactory textAreaFactory, IForumReader reader, ICommandFactory commandFactory, IPostService postService, bool error, IPostViewModel post)
 {
     this.labelFactory    = labelFactory;
     this.textAreaFactory = textAreaFactory;
     this.reader          = reader;
     this.commandFactory  = commandFactory;
     this.postService     = postService;
 }