void _scrollStateChecker_Tick(object sender, EventArgs e)
        {
            if (_webKitBrowser1.ScrollOffset != _prevLocalScrollState && !_skipNextScrollPosChange)
            {
                if (_mediator.CurrentTopicId != null && _mediator.ExplanationModeEnabled)
                {
                    var pers = SessionInfo.Get().person;
                    if (pers != null)
                    {
                        var lastSentScrollState = _webKitBrowser1.ScrollOffset;
                        UISharedRTClient.Instance.clienRt.SendBrowserScrolled(
                            new BrowserScrollPosition
                        {
                            ownerId = pers.Id,
                            topicId = (int)_mediator.CurrentTopicId,
                            X       = lastSentScrollState.X,
                            Y       = lastSentScrollState.Y
                        });
                    }
                }
            }

            _skipNextScrollPosChange = false;
            _prevLocalScrollState    = _webKitBrowser1.ScrollOffset;
        }
Beispiel #2
0
        private void OnCommentRead(CommentsReadEvent ev)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (ev.ArgPointId != ap.Id)
            {
                return;
            }

            if (ev.PersonId == SessionInfo.Get().person.Id)
            {
                var ctx = new DiscCtx(ConfigManager.ConnStr);
                UpdateLocalReadCounts(ctx, ap);
                new CommentNotificationDeferral(Dispatcher, ctx, lstBxComments1);
            }
            else
            {
                UpdateRemoteReadCounts(new DiscCtx(ConfigManager.ConnStr), ap);
            }
        }
Beispiel #3
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var src = value as Source;

            if (src == null)
            {
                return(Visibility.Hidden);
            }

            var currentPers = SessionInfo.Get().person;

            if (currentPers == null)
            {
                return(Visibility.Hidden);
            }

            if (src.RichText.ArgPoint.Person == null)
            {
                return(Visibility.Hidden);
            }

            if (src.RichText.ArgPoint.Person.Id == currentPers.Id)
            {
                return(Visibility.Visible);
            }

            return(Visibility.Hidden);
        }
Beispiel #4
0
        public PrivateCenter3(UISharedRTClient sharedClient, Main.OnDiscFrmClosing closing)
        {
            InitializeComponent();

            _closing      = closing;
            _sharedClient = sharedClient;

            theBadge.Hide();

            PrivateCenterCtx.DropContext();
            TimingCtx.Drop();

            SetListeners(true);

            Title2 = string.Format("{0} on {1} - private dashboard",
                                   SessionInfo.Get().person.Name,
                                   SessionInfo.Get().discussion.Subject);

            lstTopics.ItemsSource            = TopicsOfDiscussion;
            lstPoints.ItemsSource            = OwnArgPoints;
            lstOtherUsers.ItemsSource        = OtherUsers;
            lstBadgesOfOtherUser.ItemsSource = ArgPointsOfOtherUser;

            lblWelcome.Content = SessionInfo.Get().person.Name;

            _commentDismissalRecognizer         = new CommentDismissalRecognizer(bigBadgeScroller, OnDismiss);
            theBadge.CommentDismissalRecognizer = _commentDismissalRecognizer;

            initializing = true;
            DiscussionSelectionChanged();
            initializing = false;
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        public void HandleRecontext()
        {
            SetStyle();

            Opacity = DataContext == null ? 0 : 1;

            //Drawing.HandleRecontext();

            var ap = DataContext as ArgPoint;

            _commentDismissalRecognizer.Reset(ap);

            UpdateLocalReadCounts(DbCtx.Get(), ap);
            new CommentNotificationDeferral(Dispatcher, DbCtx.Get(), lstBxComments1);
            UpdateRemoteReadCounts(DbCtx.Get(), ap);

            if (DataContext == null)
            {
                EditingMode = false;
            }
            else
            {
                EditingMode = SessionInfo.Get().person.Id == ap.Person.Id;
            }

            BeginSrcNumberInjection();
            UpdateOrderedSources();
            BeginAttachmentNumberInjection();
            UpdateOrderedMedia();

            ///commentsViewer.ScrollToBottom();
        }
        //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();
                }
            }
        }
Beispiel #8
0
        private void updateStopWatch(Topic displayedTopic, TimeSpan passedSinceLastUpdate)
        {
            var  discId    = SessionInfo.Get().discussion.Id;
            var  freshDisc = PublicBoardCtx.Get().Discussion.FirstOrDefault(d0 => d0.Id == discId);
            bool needSave  = false;

            foreach (var topic in freshDisc.Topic)
            {
                if (!topic.Running)
                {
                    if (topic.Id == displayedTopic.Id)
                    {
                        stopWatch.Text = TimeSpan.FromSeconds((double)topic.CumulativeDuration).ToString();
                    }
                    continue;
                }

                needSave = true;
                topic.CumulativeDuration += passedSinceLastUpdate.Seconds;

                if (topic.Id == displayedTopic.Id)
                {
                    stopWatch.Text = TimeSpan.FromSeconds((double)topic.CumulativeDuration).ToString();
                }
            }
            if (needSave)
            {
                PublicBoardCtx.Get().SaveChanges();
            }
        }
Beispiel #9
0
        void CheckSendMatrix()
        {
            if (!ExplanationModeMediator.Inst.ExplanationModeEnabled)
            {
                return;
            }

            if (_attachId == NO_ATTACHMENT)
            {
                return;
            }

            var tr  = GetTransform();
            var mat = new ImageViewerMatrix
            {
                ImageAttachmentId = _attachId,
                M11     = tr.M11,
                M12     = tr.M12,
                M21     = tr.M21,
                M22     = tr.M22,
                OffsetX = tr.OffsetX,
                OffsetY = tr.OffsetY,
                OwnerId = SessionInfo.Get().person.Id,
                TopicId = _topicId
            };

            UISharedRTClient.Instance.clienRt.SendManipulateImageViewer(mat);
        }
Beispiel #10
0
        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();
        }
Beispiel #11
0
        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;
            }
        }
Beispiel #12
0
        private void btnConfirm_Click_1(object sender, RoutedEventArgs e)
        {
            var dstTopic = lstDstTopics.SelectedItem as Topic;

            if (dstTopic == null)
            {
                MessageDlg.Show("Target topic not selected");
                return;
            }

            BusyWndSingleton.Show("Copying points...");
            try
            {
                var ownId  = SessionInfo.Get().person.Id;
                var discId = SessionInfo.Get().discussion.Id;
                foreach (var ap in dstPoints)
                {
                    copyArgPointTo(ap, dstTopic);
                }

                PrivateCenterCtx.SaveChangesIgnoreConflicts();

                _sharedClient.clienRt.SendNotifyStructureChanged(dstTopic.Id, ownId, DeviceType.Wpf);
                var srcTopic = lstSrcTopics.SelectedItem as Topic;
                _sharedClient.clienRt.SendStatsEvent(StEvent.ArgPointTopicChanged, ownId, discId, srcTopic.Id,
                                                     DeviceType.Wpf); //src
                _sharedClient.clienRt.SendStatsEvent(StEvent.ArgPointTopicChanged, ownId, discId, dstTopic.Id,
                                                     DeviceType.Wpf); //dst
            }
            finally
            {
                BusyWndSingleton.Hide();
            }
        }
Beispiel #13
0
        private void UpdateTopicsOfDiscussion(Discussion d)
        {
            TopicsOfDiscussion.Clear();

            if (d == null)
            {
                return;
            }

            int selfId             = SessionInfo.Get().person.Id;
            var topicsOfDiscussion = d.Topic;

            foreach (Topic t in topicsOfDiscussion)
            {
                if (t.Person.Any(p0 => p0.Id == selfId))
                {
                    TopicsOfDiscussion.Add(t);
                }
            }

            if (TopicsOfDiscussion.Count > 0)
            {
                lstTopics.SelectedIndex = 0;
            }
        }
Beispiel #14
0
        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;
            }
        }
Beispiel #15
0
 private void ForgetDBDiscussionState()
 {
     //forget cached state
     PublicBoardCtx.DropContext();
     _discussion = SessionInfo.Get().discussion;
     DataContext = this;
 }
Beispiel #16
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);
        }
Beispiel #17
0
 private void OnCommentRead(CommentsReadEvent ev)
 {
     if (ev.TopicId == _doc.TopicId && ev.PersonId == SessionInfo.Get().person.Id)
     {
         //if a comment is read by us in the topic of scene, update the badge to trigger notifications dot
         ReloadBadgeContexts();
     }
 }
Beispiel #18
0
        public SourceBot()
        {
            _topic = SessionInfo.Get().discussion.Topic.First();
            _rnd   = new Random();

            _enabled = true;
            RunAsync().GetAwaiter().OnCompleted(() => {});
        }
Beispiel #19
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);
            }
        }
Beispiel #20
0
        private void OnSeriesEnd(ZoomDirection direction)
        {
            var ev = direction == ZoomDirection.In ? StEvent.SceneZoomedIn : StEvent.SceneZoomedOut;

            UISharedRTClient.Instance.clienRt.SendStatsEvent(ev,
                                                             SessionInfo.Get().person.Id,
                                                             SessionInfo.Get().discussion.Id,
                                                             topicNavPanel.selectedTopic.Id,
                                                             DeviceType.Wpf);
        }
Beispiel #21
0
        private static Person getFreshCurrentPerson()
        {
            var p = SessionInfo.Get().person;

            if (p == null)
            {
                return(null);
            }

            return(PrivateCenterCtx.Get().Person.FirstOrDefault(p0 => p0.Id == p.Id));
        }
Beispiel #22
0
        private void selectBigBadge(ArgPointExt ap)
        {
            if (ap == null)
            {
                return;
            }

            theBadge.EditingMode = ap.Ap.Person.Id == SessionInfo.Get().person.Id;
            theBadge.RemoveFocusFromInputControls();
            theBadge.DataContext = ap.Ap;
        }
Beispiel #23
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();
        }
Beispiel #24
0
        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();
            }
        }
Beispiel #25
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();
            }
        }
Beispiel #26
0
 void CheckSendImgStateRequest()
 {
     if (ExplanationModeMediator.Inst.ExplanationModeEnabled && _attachId != NO_ATTACHMENT)
     {
         UISharedRTClient.Instance.clienRt.SendImageViewerStateRequest(
             new ImageViewerStateRequest
         {
             ImageAttachmentId = _attachId,
             OwnerId           = SessionInfo.Get().person.Id,
             TopicId           = _topicId
         });
     }
 }
Beispiel #27
0
        public void SelectCurrentUser()
        {
            var currId = SessionInfo.Get().person.Id;

            foreach (Person pers in lstBxPlayers.Items)
            {
                if (pers.Id == currId)
                {
                    lstBxPlayers.SelectedItem = pers;
                    return;
                }
            }
        }
Beispiel #28
0
        public override int SaveChanges(SaveOptions options)
        {
            var si = SessionInfo.Get();

            if (sharedClient != null && si.currentTopicId != -1 && si.discussion != null)
            {
                //added
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Added))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        ((ArgPoint)entry.Entity).ChangesPending = false;
                        sharedClient.clienRt.SendStatsEvent(StEvent.BadgeCreated,
                                                            si.person.Id, si.discussion.Id, si.currentTopicId,
                                                            DeviceType.Wpf);
                    }
                }

                //edited
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Modified))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        ((ArgPoint)entry.Entity).ChangesPending = false;
                        sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                            SessionInfo.Get().person.Id,
                                                            si.discussion.Id,
                                                            si.currentTopicId,
                                                            DeviceType.Wpf);
                    }
                }

                //sources/comments/media modified
                foreach (ObjectStateEntry entry in ObjectStateManager.GetObjectStateEntries(EntityState.Unchanged))
                {
                    if (entry.Entity is ArgPoint)
                    {
                        var ap = (ArgPoint)entry.Entity;
                        if (ap.ChangesPending)
                        {
                            ap.ChangesPending = false;
                            sharedClient.clienRt.SendStatsEvent(StEvent.BadgeEdited,
                                                                si.person.Id, si.discussion.Id, si.currentTopicId,
                                                                DeviceType.Wpf);
                        }
                    }
                }
            }

            return(base.SaveChanges(options));
        }
Beispiel #29
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();
            }
        }
Beispiel #30
0
        private void RefreshUsersStatus()
        {
            UsersStatus.Clear();

            //fresh each time!
            var discCtx = new DiscCtx(Discussions.ConfigManager.ConnStr);

            foreach (var p in discCtx.Person)
            {
                UsersStatus.Insert(0, p);
            }

            Dispatcher.BeginInvoke(new Action(() => { ValidateButtons(SessionInfo.Get()); }),
                                   System.Windows.Threading.DispatcherPriority.Background,
                                   null);
        }