Exemple #1
0
 /// <summary>
 /// Updates the details of the reply.
 /// </summary>
 /// <param name="memberId"></param>
 /// <param name="content"></param>
 /// <param name="status"></param>
 public void UpdateDetails(Guid memberId, string content, PostStatusType status)
 {
     ModifiedBy = memberId;
     ModifiedOn = DateTime.UtcNow;
     Content    = content;
     Status     = status;
 }
 public ActivityData(
     string id, string html = null, string text = null, StyleElement parsedText = null, bool? isEditable = null, Uri postUrl = null,
     int? commentLength = null, CommentData[] comments = null,
     DateTime? postDate = null,
     DateTime? editDate = null,
     ServiceType serviceType = null, PostStatusType? status = null, IAttachable attachedContent = null,
     ProfileData owner = null, DateTime? getActivityDate = null,
     ActivityUpdateApiFlag updaterTypes = ActivityUpdateApiFlag.Unloaded)
 {
     LoadedApiTypes = updaterTypes;
     Id = id;
     IsEditable = isEditable;
     Html = html;
     Text = text;
     ParsedText = parsedText;
     CommentLength = commentLength;
     Comments = comments;
     PostUrl = postUrl;
     PostDate = postDate;
     EditDate = editDate;
     GetActivityDate = getActivityDate;
     PostStatus = status;
     Owner = owner;
     AttachedContent = attachedContent;
     ServiceType = serviceType;
 }
Exemple #3
0
 /// <summary>
 /// Updates the details of the topic.
 /// </summary>
 /// <param name="memberId"></param>
 /// <param name="title"></param>
 /// <param name="slug"></param>
 /// <param name="content"></param>
 /// <param name="status"></param>
 public void UpdateDetails(Guid memberId, string title, string slug, string content, PostStatusType status)
 {
     ModifiedBy = memberId;
     ModifiedOn = DateTime.UtcNow;
     Title      = title;
     Slug       = slug;
     Content    = content;
     Status     = status;
 }
 public CommentData(string id, string activityId, string html, DateTime commentDate, DateTime editDate,
     ProfileData owner, PostStatusType status)
 {
     CommentId = id;
     ActivityId = activityId;
     Html = html;
     PostDate = commentDate;
     EditDate = editDate;
     Status = status;
     Owner = owner;
 }
Exemple #5
0
 private Post(Guid id, Guid?topicId, Guid forumId, Guid memberId, string title, string slug, string content, PostStatusType status)
 {
     Id        = id;
     TopicId   = topicId;
     ForumId   = forumId;
     CreatedBy = memberId;
     Title     = title;
     Slug      = slug;
     Content   = content;
     Status    = status;
     CreatedOn = DateTime.UtcNow;
 }
        public void Update_details()
        {
            var sut = Fixture.Create <Post>();

            var                  userId  = Guid.NewGuid();
            const string         content = "Blah blah blah...";
            const PostStatusType status  = PostStatusType.Draft;

            sut.UpdateDetails(userId, content, status);

            Assert.AreEqual(userId, sut.ModifiedBy, nameof(sut.ModifiedBy));
            Assert.AreEqual(content, sut.Content, nameof(sut.Content));
            Assert.AreEqual(status, sut.Status, nameof(sut.Status));
        }
Exemple #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PostStatusType result = PostStatusType.Premoderating;

            if (value is int intValue)
            {
                result = (PostStatusType)((byte)intValue);
            }
            else if (value is PostStatusType typeValue)
            {
                result = typeValue;
            }

            return(result);
        }
        public void New()
        {
            var                  topicId = Guid.NewGuid();
            var                  forumId = Guid.NewGuid();
            var                  userId  = Guid.NewGuid();
            const string         content = "Blah blah blah...";
            const PostStatusType status  = PostStatusType.Draft;

            var sut = Post.CreateReply(topicId, forumId, userId, content, status);

            Assert.AreEqual(topicId, sut.TopicId, nameof(sut.TopicId));
            Assert.AreEqual(forumId, sut.ForumId, nameof(sut.ForumId));
            Assert.AreEqual(userId, sut.CreatedBy, nameof(sut.CreatedBy));
            Assert.AreEqual(content, sut.Content, nameof(sut.Content));
            Assert.AreEqual(status, sut.Status, nameof(sut.Status));
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            PostStatusType result = PostStatusType.Premoderating;

            if (value is int intValue)
            {
                result = (PostStatusType)((byte)intValue);
            }
            else if (value is PostStatusType typeValue)
            {
                result = typeValue;
            }

            return(result != PostStatusType.Published
                ? Visibility.Visible
                : Visibility.Collapsed);
        }
Exemple #10
0
        public void Update_details()
        {
            var sut = Fixture.Create <Post>();

            var                  userId  = Guid.NewGuid();
            const string         title   = "Updated Topic";
            const string         slug    = "my-topic-slug";
            const string         content = "Blah blah blah...";
            const PostStatusType status  = PostStatusType.Draft;

            sut.UpdateDetails(userId, title, slug, content, status);

            Assert.AreEqual(userId, sut.ModifiedBy, nameof(sut.ModifiedBy));
            Assert.AreEqual(title, sut.Title, nameof(sut.Title));
            Assert.AreEqual(slug, sut.Slug, nameof(sut.Slug));
            Assert.AreEqual(content, sut.Content, nameof(sut.Content));
            Assert.AreEqual(status, sut.Status, nameof(sut.Status));
        }
Exemple #11
0
        public void New()
        {
            var                  forumId = Guid.NewGuid();
            var                  userId  = Guid.NewGuid();
            const string         title   = "New Topic";
            const string         slug    = "my-topic-slug";
            const string         content = "Blah blah blah...";
            const PostStatusType status  = PostStatusType.Draft;

            var sut = Post.CreateTopic(forumId, userId, title, slug, content, status);

            Assert.AreEqual(forumId, sut.ForumId, nameof(sut.ForumId));
            Assert.AreEqual(userId, sut.CreatedBy, nameof(sut.CreatedBy));
            Assert.AreEqual(title, sut.Title, nameof(sut.Title));
            Assert.AreEqual(slug, sut.Slug, nameof(sut.Slug));
            Assert.AreEqual(content, sut.Content, nameof(sut.Content));
            Assert.AreEqual(status, sut.Status, nameof(sut.Status));
        }
Exemple #12
0
        //called by client app when user composes message
        public void AddLocalClientPostToUI(PostItem item, PostStatusType postStatus)
        {
            InvokeOnMainThread(() => {
                Console.WriteLine("Adding post, ChatBubbleY is {0}", ChatBubbleY);

                ChatBubbleViewExtension postBubble =
                    CreateChatBubble(item, postStatus);

                if (postStatus == PostStatusType.SendingPost)
                {
                    Console.WriteLine("Adding post w body {0} to pending list", item.Body);
                    PendingPosts.Add(item);
                    postBubble.Alpha    = 0.5f;
                    postBubble.PostData = item;
                    PendingPostBubbles.Add(postBubble);
                }

                ChatScrollView.ContentSize = new CGSize(ChatScrollView.ContentSize.Width,
                                                        ChatBubbleY + TextField.Frame.Height + SmileyButton.Frame.Height + 100);
                Console.WriteLine("Added post, ChatBubbleY is {0}", ChatBubbleY);
            });
        }
Exemple #13
0
        ChatBubbleViewExtension CreateChatBubble(PostItem post, PostStatusType postStatus)
        {
            bool IsLocal = false;

            if (postStatus == PostStatusType.SendingPost || postStatus == PostStatusType.PreviousPost)
            {
                IsLocal = true;
            }

            Console.WriteLine("postStatus is {0}, IsLocal is {1}", postStatus.ToString(), IsLocal);

            //base measurements
            var    verticalImageAdjustment = 5f;
            var    ChatAreaSpacing         = 10f;
            var    ImageDimension          = 22f;
            nfloat labelSpacing            = 5;
            var    ChatBubbleWidth         = 200; //use DecideChatBubbleWidth(
            var    ChatBubbleHeight        = 100; //heightDiff *1.5f;

            //dependent measurements
            ChatBubbleY += ChatBubbleHeight + ChatAreaSpacing;
            labelWidth   = ChatBubbleWidth - (ChatBubbleWidth - (labelSpacing * 2));
            labelHeight  = ChatBubbleHeight - (ChatBubbleHeight - (labelSpacing * 2));

            var ImageAndBubbleFrame = new CGRect(0, ChatBubbleY, ChatScrollView.Frame.Width, ChatBubbleHeight);
            var ImageX      = IsLocal ? ImageAndBubbleFrame.Width - ChatAreaSpacing - ImageDimension : ChatAreaSpacing;
            var ChatBubbleX = IsLocal ? ImageX - ChatBubbleWidth - ChatAreaSpacing : ImageDimension + (ChatAreaSpacing * 2);

            //profile pic
            var ProfileImageView = new UIImageView();

            ProfileImageView.Image       = UIImage.FromFile("profilepics/people.png");
            ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFill;
            ProfileImageView.Frame       = new CGRect(ImageX,
                                                      verticalImageAdjustment,
                                                      ImageDimension,
                                                      ImageDimension);

            //chat bubble without the profile pic
            var ChatFrame = new CGRect(ChatBubbleX,
                                       0,
                                       ChatBubbleWidth,
                                       ChatBubbleHeight);
            var ChatMessage = new UIView();

            ChatMessage.BackgroundColor    = UIColor.White;
            ChatMessage.Layer.CornerRadius = 12;
            ChatMessage.Frame = ChatFrame;

            //this is the username
            var TitleLabel = new UILabel(new CGRect(labelSpacing, labelSpacing, labelWidth, labelHeight));

            TitleLabel.TextColor     = UIColor.LightGray;
            TitleLabel.TextAlignment = UITextAlignment.Left;
            TitleLabel.Font          = UIFont.SystemFontOfSize(14);
            TitleLabel.Text          = post.Title;
            TitleLabel.SizeToFit();

            //message content
            var BodyLabel = new UILabel(new CGRect(labelSpacing, TitleLabel.Frame.Height + (labelSpacing * 2), labelWidth, labelHeight));

            BodyLabel.TextColor = UIColor.Black;
            BodyLabel.Text      = post.Body;
            BodyLabel.Font      = UIFont.SystemFontOfSize(15);
            BodyLabel.SizeToFit();
            BodyLabel.Lines         = 50;
            BodyLabel.LineBreakMode = UILineBreakMode.WordWrap;

            //time message was sent
            var TimeStampLabel = new UILabel(new CGRect(ChatBubbleWidth - (labelWidth * 4), ChatBubbleHeight - labelHeight - (labelSpacing * 2)
                                                        , labelWidth, labelHeight));

            TimeStampLabel.TextAlignment = UITextAlignment.Left;
            TimeStampLabel.Font          = UIFont.SystemFontOfSize(12);
            TimeStampLabel.Text          = string.Format("{0}:{1}", DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes);
            TimeStampLabel.TextColor     = UIColor.LightGray;
            TimeStampLabel.SizeToFit();

            //add message text into one bubble view
            ChatMessage.AddSubview(TitleLabel);
            ChatMessage.BringSubviewToFront(TitleLabel);
            ChatMessage.AddSubview(BodyLabel);
            ChatMessage.BringSubviewToFront(BodyLabel);
            ChatMessage.AddSubview(TimeStampLabel);
            ChatMessage.BringSubviewToFront(TimeStampLabel);
            ChatMessage.SizeToFit();

            //add image and text bubble together
            //this is the chat bubble containing text and the profile pic
            var ImageAndBubbleViewContainer = new ChatBubbleViewExtension();

            ImageAndBubbleViewContainer.BackgroundColor = UIColor.Clear;
            ImageAndBubbleViewContainer.Frame           = ImageAndBubbleFrame;
            ImageAndBubbleViewContainer.AddSubview(ProfileImageView);
            ImageAndBubbleViewContainer.BringSubviewToFront(ProfileImageView);
            ImageAndBubbleViewContainer.AddSubview(ChatMessage);
            ImageAndBubbleViewContainer.BringSubviewToFront(ChatMessage);

            //add image and text bubble to chat window
            ChatScrollView.AddSubview(ImageAndBubbleViewContainer);
            ChatScrollView.BringSubviewToFront(ImageAndBubbleViewContainer);

            return(ImageAndBubbleViewContainer);
        }
Exemple #14
0
 /// <summary>
 /// Creates a new reply with the given values including the unique identifier.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="topicId"></param>
 /// <param name="forumId"></param>
 /// <param name="memberId"></param>
 /// <param name="content"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public static Post CreateReply(Guid id, Guid topicId, Guid forumId, Guid memberId, string content, PostStatusType status)
 {
     return(new Post(id, topicId, forumId, memberId, null, null, content, status));
 }
Exemple #15
0
 /// <summary>
 /// Creates a new topic with the given values including the unique identifier.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="forumId"></param>
 /// <param name="memberId"></param>
 /// <param name="title"></param>
 /// <param name="slug"></param>
 /// <param name="content"></param>
 /// <param name="status"></param>
 /// <returns></returns>
 public static Post CreateTopic(Guid id, Guid forumId, Guid memberId, string title, string slug, string content, PostStatusType status)
 {
     return(new Post(id, null, forumId, memberId, title, slug, content, status));
 }