コード例 #1
0
        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;
        }
コード例 #2
0
        private void ArgPointChanged(int ArgPointId, int topicId, PointChangedType change, int personId)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            if (ArgPointId != ap.Id)
            {
                return; //not our point
            }
            if (change != PointChangedType.Modified)
            {
                return;
            }

            //save edited comment
            //string editedCommentText = null;
            //var editedComment = ap.Comment.FirstOrDefault(c => c.Person == null &&
            //                                                   c.Text != DaoUtils.NEW_COMMENT);
            //if (editedComment != null)
            //    editedCommentText = editedComment.Text;

            //using db ctx here from login engine, not to spoil others
            DbCtx.DropContext();
            var ap2 = DbCtx.Get().ArgPoint.FirstOrDefault(p0 => p0.Id == ArgPointId);

            //BadgesCtx.DropContext();

            DataContext = null;

            //restore edited comment
            //if (!string.IsNullOrWhiteSpace(editedCommentText))
            //{
            //    var placeholder = ap2.Comment.FirstOrDefault(c => c.Person == null);
            //    if (placeholder != null)
            //    {
            //        placeholder.Text = editedCommentText;
            //        placeholder.Person = null;

            //        ////restore focus
            //        Dispatcher.BeginInvoke(
            //            DispatcherPriority.Background,
            //            (Action) (() => FocusCommentTextBox(placeholder))
            //            );
            //    }
            //}

            DataContext = ap2;

            scrollViewer.ScrollToBottom();
        }
コード例 #3
0
        //static bool NameUnique(string Name, Session session)
        //{
        //    var sessionId = session.Id;
        //    DbCtx.DropContext();
        //    var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0=>p0.Name==Name && p0.Session != null && p0.Session.Id == sessionId);
        //    return outrunnerPerson == null;
        //}

        private static bool placeAlreadyBusy(Session session, Seat seat)
        {
            var sessionId = session.Id;
            var seatId    = seat.Id;

            DbCtx.DropContext();
            var outrunnerPerson = DbCtx.Get().Person.FirstOrDefault(p0 => p0.Online &&
                                                                    p0.Session != null &&
                                                                    p0.Session.Id == sessionId &&
                                                                    p0.Seat != null && p0.Seat.Id == seatId);

            //only if outrunner person exists and online, the place is busy
            return(outrunnerPerson != null);
        }
コード例 #4
0
        //if given seat was not used in current session, and user takes the seat, new user is created in DB.
        //if user takes seat that was used in this session, then no new user is created. instead, the user
        //is recognized as the same user who took the seat in current session, though during second login user
        //enters name again (effectively changing name)
        private static Person RegisterOrLogin(string name, Discussion discussion, Session session, Seat seat)
        {
            //was the seat taken by some user?
            var sessionId = session.Id;
            var seatId    = seat.Id;

            DbCtx.DropContext();
            var outrunnerPerson =
                DbCtx.Get().Person.FirstOrDefault(p0 => p0.Session != null && p0.Session.Id == sessionId &&
                                                  p0.Seat != null && p0.Seat.Id == seatId);

            //the user already took the place, just change name
            if (outrunnerPerson != null)
            {
                outrunnerPerson.Name = name;

                //do we need general side ?
                var ctx             = DbCtx.Get();
                var previousGenSide = ctx.GeneralSide.FirstOrDefault(gs0 => gs0.Discussion.Id == discussion.Id &&
                                                                     gs0.Person.Id == outrunnerPerson.Id);
                if (previousGenSide == null)
                {
                    //the person takes part in this discussion first time, create general
                    //side of the person in this discussion
                    var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                    outrunnerPerson.GeneralSide.Add(
                        CreateGeneralSide(
                            outrunnerPerson,
                            disc,
                            (int)SideCode.Neutral
                            )
                        );

                    //assign person to all topics of selected discussion
                    foreach (var topic in disc.Topic)
                    {
                        outrunnerPerson.Topic.Add(topic);
                    }
                }

                DbCtx.Get().SaveChanges();

                return(outrunnerPerson);
            }
            else
            {
                //seat was not used in this session, create new user
                var ctx = DbCtx.Get();
                var p   = new Person();
                p.Name    = name;
                p.Session = ctx.Session.FirstOrDefault(s0 => s0.Id == session.Id);
                p.Seat    = ctx.Seat.FirstOrDefault(s0 => s0.Id == seat.Id);

                var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussion.Id);
                p.GeneralSide.Add(CreateGeneralSide(p, disc, (int)SideCode.Neutral));

                //person inherits color of seat
                p.Color = p.Seat.Color;

                p.Email = "no-email";

                //assign person to all topics of selected discussion
                foreach (var topic in disc.Topic)
                {
                    p.Topic.Add(topic);
                }

                ctx.AddToPerson(p);
                DbCtx.Get().SaveChanges();
                return(p);
            }
        }
コード例 #5
0
 void ReloadBadgeContexts()
 {
     DbCtx.DropContext();
     DocTools.ToggleBadgeContexts(_doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.Badge));
 }