private void btnAddPoint_Click(object sender, RoutedEventArgs e) { Topic t = lstTopics.SelectedItem as Topic; if (t == null) { return; } BusyWndSingleton.Show("Creating new argument..."); try { int orderNumber = OwnArgPoints.Any() ? OwnArgPoints.Last().Ap.OrderNumber + 1 : 1; var np = DaoUtils.NewPoint(lstTopics.SelectedItem as Topic, orderNumber); if (np != null) { theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = np; t.ArgPoint.Add(np); } UpdatePointsOfTopic(lstTopics.SelectedItem as Topic); ArgPointExt newArgPointExt = OwnArgPoints.FirstOrDefault(i => i.Ap == np); lstPoints.SelectedItem = newArgPointExt; saveProcedure(null, -1); } finally { BusyWndSingleton.Hide(); } }
private void lstTopics_SelectionChanged(object sender, SelectionChangedEventArgs e) { OwnArgPoints.Clear(); theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = null; Topic st = lstTopics.SelectedItem as Topic; SessionInfo.Get().currentTopicId = (st == null) ? -1 : st.Id; if (st == null) { return; } UpdateOtherUsers(st.Discussion.Id, SessionInfo.Get().person.Id); //update points of other users var otherPers = lstOtherUsers.SelectedItem as PersonExt; if (otherPers != null) { UpdateBadgesOfOtherUser(otherPers.Pers.Id, st.Id); } UpdatePointsOfTopic(st); }
private void UpdatePointsOfTopic(Topic t) { OwnArgPoints.Clear(); if (t == null) { theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = null; return; } int selfId = SessionInfo.Get().person.Id; foreach (var ap in t.ArgPoint.Where(ap0 => ap0.Person.Id == selfId).OrderBy(ap0 => ap0.OrderNumber)) { OwnArgPoints.Add(new ArgPointExt(ap)); } UpdateLocalUnreadCountsOwn(TimingCtx.GetFresh()); if (OwnArgPoints.Count > 0) { lstPoints.SelectedItem = OwnArgPoints.First(); theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = OwnArgPoints.First().Ap; } else { theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = null; } }
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 OnCommentRead(CommentsReadEvent ev) { theBadge.HandleCommentRead(ev); var topic = lstTopics.SelectedItem as Topic; if (topic != null && topic.Id == ev.TopicId) { bool changedPointOwnedByOtherUser = false; var changedPointExt = OwnArgPoints.FirstOrDefault(ap => ap.Ap.Id == ev.ArgPointId); if (changedPointExt == null) { changedPointExt = ArgPointsOfOtherUser.FirstOrDefault(ap => ap.Ap.Id == ev.ArgPointId); changedPointOwnedByOtherUser = true; } TimingCtx.Drop(); var ctx = TimingCtx.GetFresh(); //if the changed point is our own point if (changedPointExt != null) { changedPointExt.NumUnreadComments = DaoUtils.NumCommentsUnreadBy( ctx, changedPointExt.Ap.Id).Total(); if (changedPointOwnedByOtherUser) { UpdateOtherUsersDots(ctx, changedPointExt.Ap.Person.Id); } else { UpdateLocalUnreadCountsOwn(ctx); } } } }
private void DiscussionSelectionChanged() { OwnArgPoints.Clear(); TopicsOfDiscussion.Clear(); if (!initializing) { theBadge.RemoveFocusFromInputControls(); theBadge.DataContext = null; } var dis = selectedDiscussion(); if (dis == null) { return; } //badges of other users ArgPointsOfOtherUser.Clear(); UpdateTopicsOfDiscussion(dis); UpdateOtherUsers(dis.Id, SessionInfo.Get().person.Id); }