예제 #1
0
        private void SaveParticipants(Topic t = null)
        {
            if (t == null)
            {
                t = EditedTopic;
            }
            if (t == null || EditedDiscussion == null)
            {
                return;
            }

            foreach (Topic top in EditedDiscussion.Topic)
            {
                top.Person.Clear();

                foreach (var p in tmpPersons)
                {
                    if (p.Name == "Name")
                    {
                        continue;
                    }

                    bool   prevExists;
                    Person prev = DaoUtils.PersonSingleton(p, out prevExists);

                    if (!top.Person.Contains(prev))
                    {
                        top.Person.Add(prev);
                    }
                }
            }

            PublicBoardCtx.Get().SaveChanges();
        }
예제 #2
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);
        }
        public PersonDiscConfigWnd(Discussion d, Person p)
        {
            InitializeComponent();

            this.WindowState = WindowState.Normal;
            this.Width       = 336;

            personSelector.onSelected += onPersonSelected;

            _d     = d;
            person = p;
            lblDiscussion.Content = "Discussion: " + d.Subject;

            int currentSide = DaoUtils.GetGeneralSide(p, d);

            if (currentSide != -1)
            {
                selector1.SelectedSide = currentSide;
            }
            else
            {
                selector1.SelectedSide = (int)SideCode.Neutral;
            }

            personSelector.Set(PublicBoardCtx.Get().Person, "Name");
        }
예제 #4
0
        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 btnDelete_Click(object sender, RoutedEventArgs e)
        {
            List <object> selected = new List <object>();

            foreach (var p in lstBxParticipants.SelectedItems)
            {
                selected.Add(p);
            }

            foreach (var p in selected)
            {
                Person pToDelete = p as Person;
                if (pToDelete == null)
                {
                    return;
                }

                BusyWndSingleton.Show("Deleting person...");
                try
                {
                    //remove the participant from UI
                    persons.Remove(pToDelete);
                    lstBxParticipants.Items.Refresh();
                    changesExist = true;
                    DaoUtils.deletePersonAndPoints(pToDelete);
                }
                finally
                {
                    BusyWndSingleton.Hide();
                }
            }
        }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            var ctx = PublicBoardCtx.Get();

            foreach (var p in persons)
            {
                bool   prevExists;
                Person prev = DaoUtils.PersonSingleton(p, out prevExists);
                if (!prevExists)
                {
                    try
                    {
                        ctx.AddToPerson(prev);
                    }
                    catch (Exception)
                    {
                        //persons in modified are ignored
                    }
                }
            }

            ctx.SaveChanges();

            if (changesExist)
            {
                _sharedClient.clienRt.SendUserAccPlusMinus();
            }

            Close();
        }
예제 #7
0
        //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);
        }
예제 #8
0
        //void EnsureNonNullDiscussion()
        //{
        //    if (EditedDiscussion == null)
        //        btnAddDiscussion_Click(null,null);
        //}

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (EditedDiscussion != null && Ctors.DiscussionExists(EditedDiscussion))
            {
                BusyWndSingleton.Show("Deleting discussion...");
                try
                {
                    if (SessionInfo.Get().discussion != null)
                    {
                        if (SessionInfo.Get().discussion.Id == EditedDiscussion.Id)
                        {
                            SessionInfo.Get().discussion = null;
                        }
                    }

                    DaoUtils.DeleteDiscussion(EditedDiscussion);
                    discussionSelector.Set(PublicBoardCtx.Get().Discussion, "Subject");
                    EditedDiscussion = null;
                }
                finally
                {
                    BusyWndSingleton.Hide();
                }
            }
        }
예제 #9
0
        //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);
        }
예제 #10
0
 private void UpdateLocalUnreadCountsOfOtherUser(DiscCtx ctx)
 {
     foreach (var ap in ArgPointsOfOtherUser)
     {
         ap.NumUnreadComments = DaoUtils.NumCommentsUnreadBy(ctx, ap.Ap.Id).Total();
     }
 }
예제 #11
0
        void SaveProcedure()
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (DateTime.Now.Subtract(_lastSave).TotalMilliseconds < 100)
            {
                return;
            }

            _lastSave = DateTime.Now;

            var lastComment = ap.Comment.LastOrDefault();

            //finalize edited comment
            if (!string.IsNullOrWhiteSpace(txtNewComment.Text) &&
                DaoUtils.NEW_COMMENT != txtNewComment.Text)
            {
                if (lastComment == null || (lastComment != null && txtNewComment.Text != lastComment.Text))
                {
                    DaoUtils.HandleCommentCommit(txtNewComment.Text, ap);
                    //txtNewComment.Text = DaoUtils.NEW_COMMENT;
                    txtNewComment.Text = "";
                }
            }

            if (!ap.ChangesPending)
            {
                return;
            }

            ap.ChangesPending = false;

            //save changes
            try
            {
                DbCtx.Get().SaveChanges();
            }
            catch
            {
            }

            if (_sharedClient != null)
            {
                _sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                     SessionInfo.Get().person.Id,
                                                     ap.Topic.Discussion.Id,
                                                     ap.Topic.Id,
                                                     DeviceType.Wpf);

                _sharedClient.clienRt.SendArgPointChanged(ap.Id, ap.Topic.Id, SessionInfo.Get().person.Id);
            }
        }
예제 #12
0
        void UpdateRemoteReadCounts(DiscCtx ctx, ArgPoint ap)
        {
            if (ap == null)
            {
                return;
            }

            txtCommentSeenBy.Text = DaoUtils.RecentCommentReadBy(ctx, ap.Id);
        }
예제 #13
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (richText == null)
            {
                return;
            }

            DaoUtils.AddSource("new source", richText);
        }
예제 #14
0
        private void UpdateLocalReadCounts(DiscCtx ctx, ArgPoint ap)
        {
            if (ap == null)
            {
                return;
            }

            SetNumUnreadComments(DaoUtils.NumCommentsUnreadBy(ctx, ap.Id));
        }
예제 #15
0
        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");
                }
            }
        }
예제 #16
0
        private void UpdateLocalReadCounts(DiscCtx ctx, ArgPoint ap)
        {
            if (ap == null)
            {
                return;
            }

            SetNumUnreadComments(DaoUtils.NumCommentsUnreadBy(ctx, ap.Id).Total());
            new CommentNotificationDeferral(Dispatcher, ctx, lstBxComments);
        }
예제 #17
0
        private void addSource_Click(object sender, RoutedEventArgs e)
        {
            if (EditedDiscussion == null)
            {
                return;
            }

            DaoUtils.EnsureBgExists(EditedDiscussion);
            DaoUtils.AddSource(EditedDiscussion.Background);
        }
예제 #18
0
        public void SaveChanges()
        {
            Discussion discussion = DataContext as Discussion;

            if (discussion != null)
            {
                DaoUtils.EnsureBgExists(discussion);
                //discussion.Background.Text = txtBxBackground.Text;
            }
        }
예제 #19
0
        private void btnAddSource_Click(object sender, RoutedEventArgs e)
        {
            ArgPoint ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            DaoUtils.AddSource("New source", ap.Description);
        }
예제 #20
0
        private void copyArgPointTo(ArgPoint ap, Topic t)
        {
            var pointCopy = DaoUtils.clonePoint(PrivateCenterCtx.Get(),
                                                ap,
                                                t,
                                                SessionInfo.Get().person,
                                                ap.Point + "_Copy");

            operationPerformed = true;

            Close();
        }
예제 #21
0
        private void SaveDiscussion()
        {
            if (_d == null)
            {
                return;
            }

            DaoUtils.EnsureBgExists(_d);
            _d.Background.Text = "";
            _d.HtmlBackground  = plainHtml.Text;
            PublicBoardCtx.Get().SaveChanges();
        }
예제 #22
0
        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();
            }
        }
예제 #23
0
        private void btnAddSrc_Click(object sender, RoutedEventArgs e)
        {
            var d = DataContext as Discussion;

            if (d == null)
            {
                return;
            }

            DaoUtils.AddSource(txtSource.Text, d.Background);
            BeginDeferredItemTemplateHandle();
            UpdateOrderedSources();
        }
예제 #24
0
        private void PaletteOwnerChanged(int owner)
        {
            if (owner != -1)
            {
                if (editCtx != null)
                {
                    editCtx.SceneMgr.FinishFreeDrawing();
                }

                palette._ownerId           = owner;
                palette.bdr.BorderBrush    = new SolidColorBrush(DaoUtils.UserIdToColor(owner));
                inkPalette.bdr.BorderBrush = new SolidColorBrush(DaoUtils.UserIdToColor(owner));
            }
        }
예제 #25
0
        private void btnRemoveTopic_Click(object sender, RoutedEventArgs e)
        {
            Topic t = EditedTopic;

            if (t == null || EditedDiscussion == null)
            {
                return;
            }

            if (t != null)
            {
                EditedDiscussion.Topic.Remove(t);
                DaoUtils.removePersonsAndTopic(t);
            }
        }
예제 #26
0
        private void btnRemovePoint_Click(object sender, RoutedEventArgs e)
        {
            if (DateTime.Now.Subtract(_recentRemovalStamp).TotalSeconds < 2.0)
            {
                return;
            }
            _recentRemovalStamp = DateTime.Now;

            ArgPoint ap;
            Topic    t;

            getPointAndTopic(out ap, out t);
            if (ap == null)
            {
                return;
            }
            if (ap.Person.Id != SessionInfo.Get().person.Id)
            {
                return;
            }

            BusyWndSingleton.Show("Removing argument...");
            try
            {
                if (ap.Topic != null)
                {
                    Topic t1 = ap.Topic;

                    recentlyDeleted        = new PointRemoveRecord();
                    recentlyDeleted.person = ap.Person;
                    recentlyDeleted.point  = ap;
                    recentlyDeleted.topic  = ap.Topic;

                    PublicBoardCtx.DropContext();
                    DaoUtils.UnattachPoint(ap);

                    RenumberPointsAfterDeletion(t1, SessionInfo.Get().person.Id);

                    UpdatePointsOfTopic(t1);

                    saveProcedure(ap, t1.Id);
                }
            }
            finally
            {
                BusyWndSingleton.Hide();
            }
        }
예제 #27
0
        private void UpdateOtherUsersDots(DiscCtx ctx, int singleUserId = -1)
        {
            if (_otherUsersDots.IsDuplicate())
            {
                return;
            }
            _otherUsersDots.RecordEvent();

            var topic = lstTopics.SelectedItem as Topic;

            if (topic == null)
            {
                return;
            }

            List <int> usersWithUnreadComments;

            if (singleUserId == -1)
            {
                usersWithUnreadComments = DaoUtils.SubsetOfPersonsWithDots(ctx,
                                                                           OtherUsers.Select(u0 => u0.Pers.Id).ToArray(),
                                                                           topic.Id);
            }
            else
            {
                usersWithUnreadComments = DaoUtils.SubsetOfPersonsWithDots(ctx,
                                                                           new [] { singleUserId },
                                                                           topic.Id);
            }

            foreach (var otherUser in OtherUsers)
            {
                if (singleUserId != -1 && otherUser.Pers.Id != singleUserId)
                {
                    continue;
                }

                otherUser.HasPointsWithUnreadComments =
                    usersWithUnreadComments != null &&
                    usersWithUnreadComments.Contains(otherUser.Pers.Id);
            }
        }
예제 #28
0
        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);
                    }
                }
            }
        }
예제 #29
0
        void AttachSource()
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            string url = txtSource.Text.Trim();

            if (ap.Description.Source.FirstOrDefault(s => s.Text == url) != null)
            {
                return;
            }

            if (Validators.UriOk(url))
            {
                DaoUtils.AddSource(txtSource.Text, ap.Description);
                ap.ChangesPending = true;
                UISharedRTClient.Instance.clienRt.SendStatsEvent(
                    StEvent.SourceAdded,
                    ap.Person.Id,
                    ap.Topic.Discussion.Id,
                    ap.Topic.Id,
                    DeviceType.Wpf);

                UpdateOrderedSources();
                BeginSrcNumberInjection();
            }
            else if (!string.IsNullOrWhiteSpace(txtSource.Text) &&
                     txtSource.Text != ap.RecentlyEnteredSource)
            {
                ErrMessages.InvalidUrl();
            }
        }
예제 #30
0
        /// <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;
        }