Exemplo n.º 1
0
        public Overlap(bool itemsChanged, ViewPortState old, ViewPortState anew)
        {
            if (itemsChanged ||                                                                //cannot make asumptions about order of rows as it could change due to sorting, insers, removal
                anew.LastVisibleRowOrMinusOneIfEmpty < old.FirstVisibleRowOrMinusOneIfEmpty || //new is entirely before old
                anew.FirstVisibleRowOrMinusOneIfEmpty > old.LastVisibleRowOrMinusOneIfEmpty)   //old is entirely before new

            {
                ToPreTrim = old.IsEmpty ?
                            Range.CreateEmpty()
                    :
                            Range.Create(old.FirstVisibleRow, old.LastVisibleRow);
                ToPrepend = Range.CreateEmpty();

                ToPostTrim = Range.CreateEmpty();
                ToAppend   = anew.IsEmpty ?
                             Range.CreateEmpty()
                    :
                             Range.Create(anew.FirstVisibleRow, anew.LastVisibleRow);
                return;
            }

            //partially or entirely contained

            var overlapStart = anew.FirstVisibleRow - old.FirstVisibleRow;
            var overlapEnd   = anew.LastVisibleRow - old.LastVisibleRow;

            //new range starts later?
            ToPreTrim = overlapStart > 0 ?
                        Range.Create(old.FirstVisibleRow, old.FirstVisibleRow + overlapStart - 1)
                :
                        Range.CreateEmpty();

            //new range begins earlier?
            //handles case: when scroll is at bottom and then many (but not all) rows are deleted (f.e. grouping disabled) then wrong overlap would be calculated otherwise
            ToPrepend = overlapStart < 0 && anew.FactVisibleRowsCount > 0 ?
                        Range.Create(anew.FirstVisibleRow, old.FirstVisibleRow - 1)
                :
                        Range.CreateEmpty();

            //new range ends earlier?
            ToPostTrim = overlapEnd < 0 ?
                         Range.Create(old.LastVisibleRow + overlapEnd + 1, old.LastVisibleRow)
                :
                         Range.CreateEmpty();

            //new range ends later?
            ToAppend = overlapEnd > 0 && anew.FactVisibleRowsCount > 0 ?
                       Range.Create(old.LastVisibleRow + 1, anew.LastVisibleRow)
                :
                       Range.CreateEmpty();
        }
Exemplo n.º 2
0
        public ViewPortState ToViewPortState(Point viewPortSize)
        {
            var aliveTankDtos = AllTanks.Where(t => !t.IsDead).Select(t => t.ToDto()).ToList();
            var aliveShellDtos = AllShells.Where(t => !t.IsDead).Select(t => t.ToDto()).ToList();

            var viewPortState = new ViewPortState();
            viewPortState.Tanks = aliveTankDtos;
            viewPortState.Shells = aliveShellDtos;

            var mapper = new CartesianMapper(viewPortSize);

            viewPortState.Tanks.ForEach(t => t.Point = mapper.CartesianToScreen(t.Point));
            viewPortState.Shells.ForEach(t => t.Point = mapper.CartesianToScreen(t.Point));

            return viewPortState;
        }
Exemplo n.º 3
0
        public ViewPortState ToViewPortState(Point viewPortSize)
        {
            var aliveTankDtos  = AllTanks.Where(t => !t.IsDead).Select(t => t.ToDto()).ToList();
            var aliveShellDtos = AllShells.Where(t => !t.IsDead).Select(t => t.ToDto()).ToList();

            var viewPortState = new ViewPortState();

            viewPortState.Tanks  = aliveTankDtos;
            viewPortState.Shells = aliveShellDtos;

            var mapper = new CartesianMapper(viewPortSize);

            viewPortState.Tanks.ForEach(t => t.Point  = mapper.CartesianToScreen(t.Point));
            viewPortState.Shells.ForEach(t => t.Point = mapper.CartesianToScreen(t.Point));

            return(viewPortState);
        }
Exemplo n.º 4
0
        public void Tick(ViewPortState viewPortState)
        {
            IHubContext context = GlobalHost.ConnectionManager.GetHubContext <ViewPortHub>();

            context.Clients.All.tick(viewPortState);
        }