public SComment(Comment comment) { Id = comment.Id; Text = comment.Text; ArgPointId = comment.ArgPoint.Id; PersonId = comment.Person.Id; }
public CommentRoutedEventArgs(RoutedEvent routedEvent, Comment c, CommentUC control, bool requiresDataRecontext) : base(routedEvent) { Comment = c; CommentControl = control; this.RequiresDataRecontext = requiresDataRecontext; }
public VisualCommentsHelper(Dispatcher disp, ItemContainerGenerator gen, Comment placeholder) { _gen = gen; _placeholder = placeholder; disp.BeginInvoke(new Action(DeferredFocusSet), System.Windows.Threading.DispatcherPriority.Background, null); }
public static Comment NewComment(string c, Person p) { Comment res = new Comment(); res.Text = c; res.Person = p; return res; }
public void AddComment(SComment comment) { using (var ctx = new DiscCtx(ConfigManager.ConnStr)) { var argPoint = ctx.ArgPoint.FirstOrDefault(ap => ap.Id == comment.ArgPointId); if (argPoint == null) return; var person = ctx.Person.FirstOrDefault(ap => ap.Id == comment.PersonId); if (person == null) return; var newComment = new Comment {ArgPoint = argPoint, Person = person, Text = comment.Text}; argPoint.Comment.Add(newComment); ctx.SaveChanges(); } }
private void RaisePlaceholderFocus(Comment comment) { if (placeholderFocus != null) placeholderFocus(comment); }
private void RaiseCommentRemoved(Comment c) { if (CommentRemoved != null) CommentRemoved(c); }
void ParseTextAndBuildHyperlinkedText(Comment c) { lblText.Inlines.Clear(); if (c == null || c.Text==null) return; var runs = HyperlinkSplitter.Split(c.Text); foreach (var run in runs) { var trimmed = run.Trim(); if (HyperlinkValidator.IsMatch(trimmed)) { var hyperLink = new Hyperlink {NavigateUri = new Uri(trimmed)}; hyperLink.Inlines.Add(new Run(run)); hyperLink.Click += hyperLink_Click; hyperLink.TouchDown += hyperLink_Click; lblText.Inlines.Add(hyperLink); } else { lblText.Inlines.Add(run); } } }
private void checkRemovability(Comment c) { if (c == null) return; btnRemoveComment.Visibility = Visibility.Hidden; if (c.Person == null) { if (c.Text != DaoUtils.NEW_COMMENT) btnRemoveComment.Visibility = Visibility.Visible; } else if (SessionInfo.Get().person.Id == c.Person.Id) { btnRemoveComment.Visibility = Visibility.Visible; } }
private void checkReadonly(Comment c) { if (c == null) return; var commentFilled = c.Person!=null && c.Text != DaoUtils.NEW_COMMENT && !string.IsNullOrWhiteSpace(c.Text); if (commentFilled) { txtBxText.Visibility = Visibility.Collapsed; lblText.Visibility = Visibility.Visible; } }
public static ArgPoint clonePoint(DiscCtx ctx, ArgPoint ap, Topic topic, Person owner, String name) { var top = ctx.Topic.FirstOrDefault(t0 => t0.Id == topic.Id); if (top == null) return null; var ownPoints = top.ArgPoint.Where(p0 => p0.Person.Id == owner.Id); int orderNr = 1; foreach (var pt in ownPoints) { if (pt.OrderNumber > orderNr) orderNr = pt.OrderNumber; } var pointCopy = DaoUtils.NewPoint(top, orderNr + 1); pointCopy.Point = name; pointCopy.Description.Text = ap.Description.Text; foreach (var src in ap.Description.Source) { var newSrc = new Source {Text = src.Text}; pointCopy.Description.Source.Add(newSrc); } foreach (var cmt in ap.Comment) { if (cmt.Person == null) continue; var comment = new Comment(); comment.Text = cmt.Text; var commentPersonId = cmt.Person.Id; comment.Person = ctx.Person.FirstOrDefault(p0 => p0.Id == commentPersonId); pointCopy.Comment.Add(comment); } var ownId = SessionInfo.Get().person.Id; var self = ctx.Person.FirstOrDefault(p0 => p0.Id == ownId); foreach (var media in ap.Attachment) { var attach = new Attachment(); attach.ArgPoint = pointCopy; attach.Format = media.Format; attach.Link = media.Link; attach.Name = media.Name; attach.Title = media.Title; attach.VideoEmbedURL = media.VideoEmbedURL; attach.VideoLinkURL = media.VideoLinkURL; attach.VideoThumbURL = media.VideoThumbURL; attach.OrderNumber = media.OrderNumber; if (media.Thumb != null) attach.Thumb = (byte[])media.Thumb.Clone(); if (media.MediaData != null && media.MediaData.Data != null) { var mediaClone = new MediaData(); mediaClone.Data = (byte[])media.MediaData.Data.Clone(); attach.MediaData = mediaClone; } attach.Person = self; } pointCopy.Person = self; pointCopy.Topic = top; return pointCopy; }
/// <summary> /// Deprecated Method for adding a new object to the Comment EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToComment(Comment comment) { base.AddObject("Comment", comment); }
private void CommentUC_OnCommentRemovedEvent(Comment c) { SaveProcedure(); }
void FocusCommentTextBox(Comment comment) { DependencyObject editedContainer = lstBxComments1.ItemContainerGenerator.ContainerFromItem(comment); if (editedContainer != null) { var commentTextbox = Utils.FindChild<TextBox>(editedContainer); if (commentTextbox != null) commentTextbox.Focus(); } }
public static bool HandleCommentCommit(string comment, ArgPoint ap) { if (string.IsNullOrWhiteSpace(comment) || NEW_COMMENT==comment) return false; ap.ChangesPending = true; var c = new Comment {Text = comment}; //inject author var commentAuthor = SessionInfo.Get().getPerson(ap); var res = InjectAuthorOfComment(c, commentAuthor); ap.Comment.Add(c); if (c.Text != _recentStatsEventSubmittedComment) { UISharedRTClient.Instance.clienRt.SendStatsEvent( StEvent.CommentAdded, SessionInfo.Get().person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); _recentStatsEventSubmittedComment = c.Text; } return res; }
/// <summary> /// Create a new Comment object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="text">Initial value of the Text property.</param> public static Comment CreateComment(global::System.Int32 id, global::System.String text) { Comment comment = new Comment(); comment.Id = id; comment.Text = text; return comment; }
private void placeholderFocus(Comment comment) { new VisualCommentsHelper(this.Dispatcher, lstBxComments.ItemContainerGenerator, comment); }
public CommentExt(Comment comment) { _comment = comment; }
//static void RemovePlaceholders(ArgPoint ap) //{ // if (ap == null) // return; // var placeholderComment = // ap.Comment.FirstOrDefault(c0 => c0.Text == NewComment || string.IsNullOrWhiteSpace(c0.Text)); // if (placeholderComment != null) // placeholderComment.ArgPoint.Comment.Remove(placeholderComment); //} //public static bool IsPlaceholder(Comment c) //{ // return (c.Text == NewComment || string.IsNullOrWhiteSpace(c.Text)); //} //public static Comment EnsureCommentPlaceholderExists(ArgPoint ap) //{ // if (ap == null) // return null; // RemovePlaceholders(ap); // bool needNewPlaceholder = false; // if (ap.Comment.Count == 0) // { // needNewPlaceholder = true; // } // else // { // var placeholderComment = // ap.Comment.FirstOrDefault(c0 => c0.Text == NewComment || string.IsNullOrWhiteSpace(c0.Text)); // needNewPlaceholder = (placeholderComment == null); // //if (placeholderComment != null) // //{ // // placeholderComment.Person = null; // // placeholderComment.Text = DaoUtils.NEW_COMMENT; //in case of comment was whitespace // //} // } // if (needNewPlaceholder) // { // var c = new Comment(); // c.Text = NewComment; // ap.Comment.Add(c); // return c; // } // return null; //} //returns true if changes owner public static bool InjectAuthorOfComment(Comment c, Person commentAuthor) { bool changed = false; if (c != null) { if ((c.Person == null && commentAuthor != null) || (c.Person != null && commentAuthor == null)) { changed = true; } else changed = c.Person.Id != commentAuthor.Id; c.Person = commentAuthor; } return changed; }