private void SetStyle() { if (DataContext != null && DataContext is ArgPoint) { ArgPoint p = (ArgPoint)DataContext; //root.Background = new SolidColorBrush(Utils.IntToColor(p.Person.Color)); lblColor.Fill = new SolidColorBrush(Utils.IntToColor(p.Person.Color)); switch ((SideCode)p.SideCode) { case SideCode.Pros: stkHeader.Background = DiscussionColors.prosBrush; break; case SideCode.Cons: stkHeader.Background = DiscussionColors.consBrush; break; case SideCode.Neutral: stkHeader.Background = DiscussionColors.neutralBrush; break; default: throw new NotSupportedException(); } lblPerson.Content = p.Person.Name; } }
private void ArgPointNode(Section s, ArgPoint ap) { //arg.point header table var t = s.AddTable().TableDefaults(ap.Person.Color); var c0 = t.AddColumn(0.2 * ContentWidth()); var c1 = t.AddColumn(0.8 * ContentWidth()); var r1 = t.AddRow(); r1.Format.Font.Bold = true; r1.Cells[0].AddParagraph().AddBold("Point #" + ap.OrderNumber); r1.Cells[1].AddParagraph(ap.Point); //var r0 = t.AddRow(); //r0.Cells[0].AddParagraph("Author"); //r0.Cells[1].AddParagraph(ap.Person.Name); //description var descr = s.AddParagraph(ap.Description.Text); descr.Format.Shading.Color = new MigraDoc.DocumentObjectModel.Color((uint)ap.Person.Color); descr.AlignWithTable(); //point's media MediaTable(s, ap.Attachment, ap.Person.Color); //point's sources SourcesTable(s, ap.Description.Source, ap.Person.Color); //point's comments CommentsTable(s, ap.Comment, ap.Person.Color); }
private void Attach(object sender, ExecutedRoutedEventArgs args) { ArgPoint ap = DataContext as ArgPoint; if (ap == null) { return; } //if ((string)args.Parameter == "Remove selected") //{ // Attachment a = lstBxAttachments.SelectedItem as Attachment; // if (a != null) // ap.Attachment.Remove(a); //} //else { Attachment a = new Attachment(); ImageSource src = AttachmentManager.ProcessAttachCmd(ap, AttachCmd.ATTACH_IMG_OR_PDF, ref a); if (src != null) { a.Person = getFreshCurrentPerson(); } } }
//publish/unpublish private void SurfaceCheckBox_Click(object sender, RoutedEventArgs e) { ArgPoint ap = (((SurfaceCheckBox)sender).DataContext) as ArgPoint; if (ap == null) { return; } Topic t; ArgPoint ap1; getPointAndTopic(out ap1, out t); if (t == null) { return; } if (((SurfaceCheckBox)sender).IsChecked.Value) { ap.SharedToPublic = true; } else { if (PrivateCenterCtx.Get().ObjectStateManager.GetObjectStateEntry(ap).State == EntityState.Modified || PrivateCenterCtx.Get().ObjectStateManager.GetObjectStateEntry(ap).State == EntityState.Unchanged) { PrivateCenterCtx.Get().Refresh(RefreshMode.StoreWins, ap); DaoUtils.UnpublishPoint(ap); } } saveProcedure(null, -1); }
private void clusterStatsResponse(ClusterStatsResponse resp, bool ok) { if (!ok) { ++_clusterReportsGenerated; if (ClustersAndLinksDone()) { finalizeReport(); } return; } //generate list of ArgPoints var argPoints = new ArgPoint[resp.points.Length]; for (int i = 0; i < resp.points.Length; i++) { var pointId = resp.points[i]; argPoints[i] = _ctx.ArgPoint.FirstOrDefault(ap0 => ap0.Id == pointId); } var topic = _ctx.Topic.FirstOrDefault(t0 => t0.Id == resp.topicId); var initialOwner = _ctx.Person.FirstOrDefault(p0 => p0.Id == resp.initialOwnerId); var report = new ClusterReport(topic, resp.clusterId, resp.clusterShId, resp.clusterTextTitle, argPoints, initialOwner); _clusterReports.Add(report); ++_clusterReportsGenerated; if (ClustersAndLinksDone()) { finalizeReport(); } }
public static Attachment AttachCloudEntry(ArgPoint Point, StorageSelectionEntry selEntry) { var a = new Attachment { Name = selEntry.Title }; try { a.Format = (int)GetImgFmt(selEntry.Title); //may throw exception in case of unsupported file format } catch (Exception) { throw new IncorrectAttachmentFormat(); } a.MediaData = DaoUtils.CreateMediaData(AnyFileToBytes(selEntry.PathName)); a.Title = "";// selEntry.Title; a.Link = selEntry.Title; if (a.Format == (int)AttachmentFormat.Pdf) { a.Thumb = TryCreatePdfThumb(selEntry.PathName); } if (Point != null) { a.ArgPoint = Point; } return(a); }
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); }
public static ArgPoint NewArgPoint(string Point) { ArgPoint res = new ArgPoint(); res.Point = Point; return(res); }
public static ArgPoint NewPoint(Topic t, int orderNumber) { if (t == null) { return(null); } //create new point ArgPoint pt = new ArgPoint(); pt.Point = "Your title here/タイトル"; pt.RecentlyEnteredSource = "Your web url link here/URLリンク"; pt.RecentlyEnteredMediaUrl = "Your media link here/画像URLリンク"; DaoUtils.EnsurePtDescriptionExists(pt); pt.Description.Text = NEW_DESCRIPTION; pt.Topic = PrivateCenterCtx.Get().Topic.FirstOrDefault(t0 => t0.Id == t.Id); int selfId = SessionInfo.Get().person.Id; var pers = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == selfId); pt.Person = pers; pt.SharedToPublic = true; pt.SideCode = DaoUtils.GetGeneralSide(SessionInfo.Get().person, SessionInfo.Get().discussion); pt.OrderNumber = orderNumber; return(pt); }
void SetStyle() { if (DataContext != null && DataContext is ArgPoint) { ArgPoint p = (ArgPoint)DataContext; mask.Background = new SolidColorBrush(Utils.IntToColor(p.Person.Color)); switch ((SideCode)p.SideCode) { case SideCode.Pros: lblSide.Content = "PROS"; lblSide.Background = DiscussionColors.prosBrush; break; case SideCode.Cons: lblSide.Content = "CONS"; lblSide.Background = DiscussionColors.consBrush; break; case SideCode.Neutral: lblSide.Content = "NEUTRAL"; lblSide.Background = DiscussionColors.neutralBrush; break; default: throw new NotSupportedException(); } lblPerson.Content = p.Person.Name; } }
private void ShowLargeBadgeView(ArgPoint ap) { scene.IsHitTestVisible = false; blockWorkingAreaTransforms = true; if (_lbv == null) { _lbv = new LargeBadgeView(); } var ArgPointId = ap.Id; DbCtx.DropContext();//it can become stale while modal view was closed. _lbv.DataContext = DbCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == ArgPointId); _lbv.SetRt(UISharedRTClient.Instance); //mainGrid.Children.Add(_lbv); int indexOfLaserScene = mainGrid.Children.IndexOf(laserScene); if (!mainGrid.Children.Contains(_lbv)) { mainGrid.Children.Insert(indexOfLaserScene, _lbv); } ResizeLargeBadgeView(); _lbv.HorizontalAlignment = HorizontalAlignment.Center; _lbv.VerticalAlignment = VerticalAlignment.Center; }
private void UpdateLocalReadCounts(DiscCtx ctx, ArgPoint ap) { if (ap == null) { return; } SetNumUnreadComments(DaoUtils.NumCommentsUnreadBy(ctx, ap.Id)); }
void UpdateRemoteReadCounts(DiscCtx ctx, ArgPoint ap) { if (ap == null) { return; } txtCommentSeenBy.Text = DaoUtils.RecentCommentReadBy(ctx, ap.Id); }
private void AllArgPoints() { var s = _document.AddSection(); PdfTools2.SectionHeader(s.AddParagraph("Argument points")); foreach (var pers in _session.Person) { if (pers == null) { MessageDlg.Show("skipping a null person in session"); continue; } bool personValid = true; ArgPoint invalidAp = null; foreach (var ap in pers.ArgPoint) { if (ap.Topic == null) { personValid = false; invalidAp = ap; } } if (!personValid) { MessageDlg.Show( string.Format( "{0}'s arg.point \"{1}\" has null (undefined) topic. Skipping the arg.point in report", pers.Name, invalidAp.Point)); continue; } var para = s.AddParagraph().AddBold("Argument points of " + pers.Name); var argPointsOf = DaoUtils.ArgPointsOf(pers, _discussion, _topic); if (argPointsOf.Count() > 0) { foreach (var ap in argPointsOf) { if (!ap.SharedToPublic) { continue; } ArgPointNode(s, ap); s.AddParagraph("\n\n"); } } else { s.AddParagraph("<No arguments>\n\n"); } } }
private void UpdateLocalReadCounts(DiscCtx ctx, ArgPoint ap) { if (ap == null) { return; } SetNumUnreadComments(DaoUtils.NumCommentsUnreadBy(ctx, ap.Id).Total()); new CommentNotificationDeferral(Dispatcher, ctx, lstBxComments); }
private void ArgPointTableLine(Table t, ArgPoint point, bool indent) { var r = t.AddRow(); Paragraph p = r.Cells[0].AddParagraph(string.Format("Arg.point#{0}: {1}", point.OrderNumber, point.Point)); r.Cells[0].Shading.Color = new MigraDoc.DocumentObjectModel.Color((uint)point.Person.Color); if (indent) { p.LeftParaIndent(20); } }
private void btnAddSource_Click(object sender, RoutedEventArgs e) { ArgPoint ap = DataContext as ArgPoint; if (ap == null) { return; } DaoUtils.AddSource("New source", ap.Description); }
public static void SaveChangesIgnoreConflicts() { int nAttempts = 0; bool saveFailed; ArgPoint conflictedArgPoint = null; do { saveFailed = false; try { Get().SaveChanges(); } catch (OptimisticConcurrencyException ex) { saveFailed = true; Comment[] addedConflictedComments = ex.StateEntries.Where(se => se.State == EntityState.Modified && (se.Entity as DbModel.Comment) != null) .Select(se => se.Entity) .Cast <Comment>() .ToArray(); if ((ex.StateEntries.Any() && addedConflictedComments.Length == 0) || (addedConflictedComments.Length > 0) ) { //if placeholder comment is in the conflict Get().Refresh(RefreshMode.StoreWins, ex.StateEntries.Where(se => se.Entity != null).Select(se => se.Entity)); } else { //detach conflicted comments to prevent their modification by the Refresh() call foreach (var addedConflictedComment in addedConflictedComments) { conflictedArgPoint = addedConflictedComment.ArgPoint; Get().Detach(addedConflictedComment); } if (conflictedArgPoint != null) { Get().Refresh(RefreshMode.StoreWins, conflictedArgPoint); foreach (var comment in addedConflictedComments) { Get().AddToComment(comment); } } } } } while (saveFailed && ++nAttempts < 6); }
public static Attachment GetFirstAttachment(ArgPoint pt) { if (pt != null && pt.Attachment.Count > 0) { return(pt.Attachment.First()); } else { return(null); } }
public static void EnsurePtDescriptionExists(ArgPoint point) { if (point == null) { return; } if (point.Description == null) { point.Description = new RichText(); } }
public static void RemoveDuplicateComments(ArgPoint ap) { var emptyComments = ap.Comment.Where(c0 => c0.Text == NEW_COMMENT); if (emptyComments.Count() > 1) { for (int i = 0; i < emptyComments.Count() - 1; i++) { ap.Comment.Remove(emptyComments.ElementAt(i)); } } }
void Init(ArgPoint ap) { Id = ap.Id; Point = ap.Point; SideCode = ap.SideCode; SharedToPublic = ap.SharedToPublic; RecentlyEnteredSource = ap.RecentlyEnteredSource; RecentlyEnteredMediaUrl = ap.RecentlyEnteredMediaUrl; OrderNumber = ap.OrderNumber; PersonId = ap.Person.Id; Description = ap.Description.Text; }
private void copyArgPointTo(ArgPoint ap, Topic t) { var pointCopy = DaoUtils.clonePoint(PrivateCenterCtx.Get(), ap, t, SessionInfo.Get().person, ap.Point + "_Copy"); operationPerformed = true; Close(); }
public static void ReportMediaOpened(StEvent ev, ArgPoint ap) { if (ap == null) { return; } UISharedRTClient.Instance.clienRt.SendStatsEvent(ev, SessionInfo.Get().person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); }
private void getPointAndTopic(out ArgPoint ap, out Topic t) { t = null; ap = null; t = lstTopics.SelectedItem as Topic; if (t == null) { return; } ap = theBadge.DataContext as ArgPoint; }
private void _commentReader_Tick(object sender, EventArgs e) { StopTimer(); //if point is new and has not been saved if (_recentPoint == null || _recentPoint.Topic == null) { return; } _onDismiss(_recentPoint); _recentPoint = null;//only single notification per arg.point during reading corridor }
public static Attachment AttachLocalFile(ArgPoint Point) { var filterSb = new StringBuilder(); filterSb.Append("Local file|"); filterSb.Append("*.jpg;*.jpeg;*.bmp;*.png;"); filterSb.Append("*.docx;*.docm;*.dotx;*.dotm;*.doc;*.rtf;*.odt;"); filterSb.Append("*.xlsx;*.xlsm;*.xlsb;*.xltx;*.xltm;*.xls;*.xlt"); filterSb.Append("*.pptx;*.ppt;*.pptm;*.ppsx;*.pps;*.potx;*.pot*;*.potm;*.odp"); return(AttachAsBlob(filterSb.ToString(), AttachmentFormat.None, true, Point)); }
//if Url!=null, uses it. otherwice asks for URL private static Attachment AttachFromYoutube(ArgPoint Point, string Url) { string URLToUse = Url; if (URLToUse == null) { InpDialog dlg = new InpDialog(); dlg.ShowDialog(); URLToUse = dlg.Answer; if (URLToUse == null || !URLToUse.StartsWith("http://")) { return(null); } } BusyWndSingleton.Show("Processing Youtube attachment..."); Attachment res = new Attachment(); try { YouTubeInfo videoInfo = YouTubeProvider.LoadVideo(URLToUse); if (videoInfo == null) { return(null); } res.Format = (int)AttachmentFormat.Youtube; res.VideoEmbedURL = videoInfo.EmbedUrl; res.VideoThumbURL = videoInfo.ThumbNailUrl; res.VideoLinkURL = videoInfo.LinkUrl; res.Link = videoInfo.LinkUrl; res.Title = videoInfo.VideoTitle; res.Name = URLToUse; res.Thumb = ImageToBytes(GetYoutubeThumb(videoInfo.ThumbNailUrl), new JpegBitmapEncoder()); if (Point != null) { Point.Attachment.Add(res); } ///PublicBoardCtx.Get().SaveChanges(); } finally { BusyWndSingleton.Hide(); } return(res); }
public ZoomWindow(ArgPoint ap) { InitializeComponent(); // Add handlers for window availability events AddWindowAvailabilityHandlers(); largeBadgeView.DataContext = ap; largeBadgeView.SetRt(UISharedRTClient.Instance); UISharedRTClient.Instance.clienRt.SendStatsEvent(StEvent.BadgeZoomIn, SessionInfo.Get().person.Id, SessionInfo.Get().discussion.Id, ap.Topic.Id, DeviceType.Wpf); }
private Comment addCommentRequest() { ArgPoint ap = DataContext as ArgPoint; if (ap == null) { return(null); } var c = new DbModel.Comment(); c.Text = DaoUtils.NEW_COMMENT; c.Person = SessionInfo.Get().getPerson(ap); ap.Comment.Add(c); return(c); }