//returns current person taken from the same context as entity is attached to public Person getPerson(object entity) { if (_person == null) { return(null); } if (entity == null) { entity = discussion; } //discussion not set if (entity == null) { return(_person); } if (IsAttachedTo(PrivateCenterCtx.Get(), entity)) { return(PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } else if (IsAttachedTo(PublicBoardCtx.Get(), entity)) { return(PublicBoardCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } else if (IsAttachedTo(DbCtx.Get(), entity)) { return(DbCtx.Get().Person.FirstOrDefault(p0 => p0.Id == _person.Id)); } return(_person); }
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); }
private void removeMedia_Click(object sender, RoutedEventArgs e) { var at = ((ContentControl)sender).DataContext as Attachment; var ap = DataContext as ArgPoint; ap.Attachment.Remove(at); var mediaData = at.MediaData; at.MediaData = null; ap.RecentlyEnteredMediaUrl = ""; if (mediaData != null) { PrivateCenterCtx.Get().DeleteObject(mediaData); } PrivateCenterCtx.Get().DeleteObject(at); ap.ChangesPending = true; UISharedRTClient.Instance.clienRt.SendStatsEvent( StEvent.MediaRemoved, ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); UpdateOrderedMedia(); BeginAttachmentNumberInjection(); }
//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); }
public CopyDlg(UISharedRTClient sharedClient, int topicToSelect) { InitializeComponent(); _sharedClient = sharedClient; var dId = SessionInfo.Get().discussion.Id; var disc = PrivateCenterCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == dId); var topics = disc.Topic; srcTopics = new ObservableCollection <Topic>(topics); dstTopics = new ObservableCollection <Topic>(topics); srcPoints = new ObservableCollection <ArgPoint>(); dstPoints = new ObservableCollection <ArgPoint>(); DataContext = this; //select topic that was selected in main board var selectedTopic = disc.Topic.FirstOrDefault(t0 => t0.Id == topicToSelect); lstSrcTopics.SelectedItem = selectedTopic; updateSrcPoints(selectedTopic); if (dstTopics.Count > 0) { lstDstTopics.SelectedIndex = 0; } }
private void LoginProcedures() { DaoUtils.EnsureModerExists(); LoginResult login = SessionInfo.Get().ExperimentMode ? LoginDriver.Run(LoginFlow.ForExperiment) : LoginDriver.Run(LoginFlow.Regular); if (login == null) { Application.Current.Shutdown(); return; } if (login.session != null && login.discussion != null) { lblSessionInfo.Content = SessionStr(login.session, login.discussion); } else { lblSessionInfo.Content = ""; } SessionInfo.Get().discussion = login.discussion; SessionInfo.Get().setPerson(login.person); _discWindows.mainWnd = this; avatar.DataContext = login.person; //start rt client sharedClient.start(login, PrivateCenterCtx.Get().Connection.DataSource, DeviceType.Wpf); SetListeners(sharedClient, true); }
//returns back recently deleted point (own), if there is one and its topic still exists private void TryUndo() { if (recentlyDeleted == null) { Console.Beep(); return; } var np = DaoUtils.clonePoint(PrivateCenterCtx.Get(), recentlyDeleted.point, recentlyDeleted.topic, recentlyDeleted.person, recentlyDeleted.point.Point); DaoUtils.DeleteArgPoint(PrivateCenterCtx.Get(), recentlyDeleted.point); recentlyDeleted = null; if (np == null) { return; } lstTopics.SelectedItem = null; lstTopics.SelectedItem = np.Topic; lstPoints.SelectedItem = new ArgPointExt(np); saveProcedure(null, -1); }
private void btnAttachScreenshot_Click_1(object sender, RoutedEventArgs e) { var ap = DataContext as ArgPoint; if (ap == null) { return; } var screenshotWnd = new ScreenshotCaptureWnd((System.Drawing.Bitmap b) => { var attach = AttachmentManager.AttachScreenshot(ap, b); if (attach != null) { var seldId = SessionInfo.Get().person.Id; attach.Person = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == seldId); ap.ChangesPending = true; UISharedRTClient.Instance.clienRt.SendStatsEvent( StEvent.ScreenshotAdded, ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); UpdateOrderedMedia(); BeginAttachmentNumberInjection(); } }); screenshotWnd.ShowDialog(); }
//returns lists of IDs of those of own points, which have been changed (added, removed, edited) private void GetChangeLists(out List <ArgPoint> created, out List <ArgPoint> edited, out List <ArgPoint> deleted) { created = new List <ArgPoint>(); edited = new List <ArgPoint>(); deleted = new List <ArgPoint>(); var ctx = PrivateCenterCtx.Get(); foreach (var ap in OwnArgPoints) { //if point is unnatached (removed in UI but preserved for UNDO), //for this method it's removed if (ap.Ap.Person == null || ap.Ap.Topic == null) { deleted.Add(ap.Ap); continue; } switch (ctx.ObjectStateManager.GetObjectStateEntry(ap.Ap).State) { case EntityState.Added: created.Add(ap.Ap); break; case EntityState.Deleted: deleted.Add(ap.Ap); break; case EntityState.Modified: edited.Add(ap.Ap); break; } } foreach (var ap in ArgPointsOfOtherUser) { //if point is unnatached (removed in UI but preserved for UNDO), //for this method it's removed if (ap.Ap.Person == null || ap.Ap.Topic == null) { deleted.Add(ap.Ap); continue; } switch (ctx.ObjectStateManager.GetObjectStateEntry(ap.Ap).State) { case EntityState.Added: created.Add(ap.Ap); break; case EntityState.Deleted: deleted.Add(ap.Ap); break; case EntityState.Modified: edited.Add(ap.Ap); break; } } }
private static Person getFreshCurrentPerson() { var p = SessionInfo.Get().person; if (p == null) { return(null); } return(PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == p.Id)); }
private void onStructChanged(int activeTopic, int initiaterId, DeviceType devType) { if (initiaterId == SessionInfo.Get().person.Id&& devType == DeviceType.Wpf) { return; } BusyWndSingleton.Show("Fetching changes..."); try { //save selected topic int topicUnderSelectionId = -1; var sel = lstTopics.SelectedItem as Topic; if (sel != null) { topicUnderSelectionId = sel.Id; } //save selected list of points var selectedAp = theBadge.DataContext as ArgPoint; ForgetDBDiscussionState(); DiscussionSelectionChanged(); //select previously selected topic if (topicUnderSelectionId != -1) { lstTopics.SelectedItem = PrivateCenterCtx.Get().Topic.FirstOrDefault(t0 => t0.Id == topicUnderSelectionId); } //select previously selected point if (selectedAp != null) { //own list if (selectedAp.Person.Id == SessionInfo.Get().person.Id) { lstPoints.SelectedItem = null; lstPoints.SelectedItem = OwnArgPoints.FirstOrDefault(ap0 => ap0.Ap.Id == selectedAp.Id); } else { lstOtherUsers.SelectedItem = OtherUsers.FirstOrDefault(u0 => u0.Pers.Id == selectedAp.Person.Id); lstBadgesOfOtherUser.SelectedItem = ArgPointsOfOtherUser.FirstOrDefault(ap0 => ap0.Ap.Id == selectedAp.Id); } } } finally { BusyWndSingleton.Hide(); } }
private void copyArgPointTo(ArgPoint ap, Topic t) { var pointCopy = DaoUtils.clonePoint(PrivateCenterCtx.Get(), ap, t, SessionInfo.Get().person, ap.Point + "_Copy"); operationPerformed = true; Close(); }
void HandleRecontext() { var ap = DataContext as ArgPoint; SetStyle(); if (DataContext == null) { Opacity = 0; } else { Opacity = 1; } //Drawing.HandleRecontext(); if (DataContext == null) { EditingMode = false; } else { if (ap != null) { EditingMode = SessionInfo.Get().person.Id == ap.Person.Id; } } UpdateOrderedSources(); UpdateOrderedMedia(); BeginSrcNumberInjection(); BeginAttachmentNumberInjection(); if (ap != null) { UpdateLocalReadCounts(PrivateCenterCtx.Get(), ap); UpdateRemoteReadCounts(PrivateCenterCtx.Get(), ap); new CommentNotificationDeferral(Dispatcher, PrivateCenterCtx.Get(), lstBxComments); } if (ap != null) { DaoUtils.RemoveDuplicateComments(ap); } if (CommentDismissalRecognizer != null) { CommentDismissalRecognizer.Reset(DataContext as ArgPoint); CommentDismissalRecognizer.CheckScrollState(); } }
private void UpdateBadgesOfOtherUser(int personId, int topicId) { ArgPointsOfOtherUser.Clear(); var q = from ap in PrivateCenterCtx.Get().ArgPoint where ap.Person.Id == personId && ap.Topic.Id == topicId select ap; foreach (var ap in q) { ArgPointsOfOtherUser.Add(new ArgPointExt(ap)); } if (_otherUserSelectedManually && ArgPointsOfOtherUser.Count > 0) { theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = ArgPointsOfOtherUser.First().Ap; } UpdateLocalUnreadCountsOfOtherUser(TimingCtx.GetFresh()); }
public void btnRemoveComment_Click(object sender, RoutedEventArgs e) { var c = DataContext as Comment; if (c == null) { return; } var ap = c.ArgPoint; c.ArgPoint = null; c.Person = null; ap.ChangesPending = true; //RaiseCommentEditLockChanged(false); RaiseCommentRemoved(c); try { foreach (var commentPersonReadEntry in c.ReadEntry.ToArray()) { PrivateCenterCtx.Get().DeleteObject(commentPersonReadEntry); } PrivateCenterCtx.Get().Comment.DeleteObject(c); } catch { //doesn't exist in content } ap.ChangesPending = true; UISharedRTClient.Instance.clienRt.SendStatsEvent( StEvent.CommentRemoved, ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); }
private void UpdateOtherUsers(int discussionId, int ownId) { OtherUsers.Clear(); var q = from p in PrivateCenterCtx.Get().Person where p.Topic.Any(t0 => t0.Discussion.Id == discussionId) && !p.Name.StartsWith(DaoUtils.MODER_SUBNAME) && p.Id != ownId select p; foreach (var p in q) { OtherUsers.Add(new PersonExt(p)); } if (OtherUsers.Count > 0) { _otherUserSelectedManually = false; lstOtherUsers.SelectedIndex = 0; _otherUserSelectedManually = true; UpdateOtherUsersDots(PrivateCenterCtx.Get()); } }
private Discussion selectedDiscussion() { int currentDiscId = SessionInfo.Get().discussion.Id; return(PrivateCenterCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == currentDiscId)); }
void OnDismiss(ArgPoint ap) { //Console.Beep(); CommentDismissalRecognizer.pushDismissal(ap, PrivateCenterCtx.Get()); }
private void onStorageWndClosed(object sender, EventArgs e) { var ap = DataContext as ArgPoint; if (ap == null) { return; } if (_storageWnd == null) { return; } if (_storageWnd.filesToAttach != null) { foreach (StorageSelectionEntry entry in _storageWnd.filesToAttach) { try { var attach = AttachmentManager.AttachCloudEntry(ap, entry); var seldId = SessionInfo.Get().person.Id; attach.Person = PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == seldId); ap.ChangesPending = true; var ev = StEvent.ArgPointTopicChanged; switch ((AttachmentFormat)attach.Format) { case AttachmentFormat.Bmp: case AttachmentFormat.Jpg: case AttachmentFormat.Png: ev = StEvent.ImageAdded; break; case AttachmentFormat.Pdf: ev = StEvent.PdfAdded; break; } if (ev != StEvent.ArgPointTopicChanged) { UISharedRTClient.Instance.clienRt.SendStatsEvent( ev, ap.Person.Id, ap.Topic.Discussion.Id, ap.Topic.Id, DeviceType.Wpf); } } catch (Discussions.AttachmentManager.IncorrectAttachmentFormat) { } } UpdateOrderedMedia(); BeginAttachmentNumberInjection(); } _storageWnd.fileViewCallback -= onCloudViewerRequest; _storageWnd.Closed -= onStorageWndClosed; _storageWnd = null; }
/// <summary> /// Default constructor. /// </summary> public Main() { InitializeComponent(); //special case of screenshot mode if (SessionInfo.Get().ScreenshotMode) { var discId = SessionInfo.Get().screenDiscId; PrivateCenterCtx.sharedClient = sharedClient; PublicBoardCtx.sharedClient = sharedClient; SessionInfo.Get().discussion = PrivateCenterCtx.Get().Discussion.FirstOrDefault(d => d.Id == discId); SessionInfo.Get().setPerson(PrivateCenterCtx.Get().Person.FirstOrDefault(p => p.Name == "moderator")); var loginRes = new LoginResult(); loginRes.devType = DeviceType.Wpf; loginRes.discussion = SessionInfo.Get().discussion; loginRes.person = SessionInfo.Get().person; sharedClient.start(loginRes, PrivateCenterCtx.Get().Connection.DataSource, DeviceType.Wpf); this.Hide(); sharedClient.clienRt.onJoin += () => { PublicCenter pubCenter = new PublicCenter(UISharedRTClient.Instance, () => { }, SessionInfo.Get().screenTopicId, SessionInfo.Get().screenDiscId ); pubCenter.Show(); pubCenter.Hide(); Task <PublicCenter.ScreenshoReports> t = pubCenter.FinalSceneScreenshots(); t.GetAwaiter().OnCompleted(() => { pubCenter.Close(); pubCenter = null; var reports = t.Result; Utils.ScreenshotPackToMetaInfo(reports, SessionInfo.Get().screenMetaInfo); Application.Current.Shutdown(); }); }; return; } lblVersion.Content = Utils2.VersionString(); DataContext = this; PrivateCenterCtx.sharedClient = sharedClient; PublicBoardCtx.sharedClient = sharedClient; avatar.pointDown = AvatarPointDown; foreach (EventViewModel evm in DaoUtils.GetRecentEvents()) { RecentEvents.Insert(0, evm); } LoginProcedures(); lstBxPlayers.ItemsSource = UsersStatus; }