public CellResponse Get(CellRequest request)
 {
     return(new CellResponse
     {
         Data = CellDomainModel.Instance.GetCellsByCondition(request.Name, request.Lac, request.Ci)
     });
 }
示例#2
0
        private void AppendColumn(CellRequest cellRequest)
        {
            int x = cellRequest.X;

            Plan.AddColumn.X++;
            Plan.AddRow.SpanX++;
            for (int i = 1; i <= Plan.AddColumn.SpanY; i++)
            {
                Plan.Cells.Add(new CellViewModel
                {
                    Text       = "Text",
                    Background = Brushes.Violet,
                    X          = x,
                    Y          = i,
                    SpanY      = 1
                });
            }

            Plan.Cells.Add(new CellViewModel
            {
                Style    = Application.Current.FindResource("DeleteButton") as Style,
                CellType = CellType.ColumnRemove,
                X        = x,
                Y        = 0,
                SpanX    = 1,
                SpanY    = 1
            });
        }
示例#3
0
        private void RemoveRow(CellRequest cellRequest)
        {
            //Remove row of the cell
            if (Plan.AddColumn.SpanY > 1)
            {
                int startY = cellRequest.Y;
                int maxY   = Plan.AddRow.Y;

                for (int y = startY; y <= maxY; y++)
                {
                    if (y == startY)
                    {
                        var cells = Plan.Cells.Where(x => x.Y == y && x != Plan.AddColumn).ToList();
                        for (int i = 0; i < cells.Count(); i++)
                        {
                            Plan.Cells.Remove(cells[i]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < Plan.Cells.Count; i++)
                        {
                            if (Plan.Cells[i].Y == y)
                            {
                                Plan.Cells[i].Y--;
                            }
                        }
                    }
                }
                Plan.AddColumn.SpanY--;
            }
        }
示例#4
0
        private void RemoveColumn(CellRequest cellRequest)
        {
            if (Plan.AddRow.SpanX > 1)
            {
                int startX = cellRequest.X;
                int maxX   = Plan.AddColumn.X;

                for (int x = startX; x <= maxX; x++)
                {
                    if (x == startX)
                    {
                        var cells = Plan.Cells.Where(c => c.X == x && c != Plan.AddRow).ToList();
                        for (int i = 0; i < cells.Count(); i++)
                        {
                            Plan.Cells.Remove(cells[i]);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < Plan.Cells.Count; i++)
                        {
                            if (Plan.Cells[i].X == x)
                            {
                                Plan.Cells[i].X--;
                            }
                        }
                    }
                }
                Plan.AddRow.SpanX--;
            }
        }
示例#5
0
        public List <Thing> GetForCell(IntVec3 cell, float radius, List <MeditationFocusOffsetPerBuilding> defs, Thing forThing = null)
        {
            CellRequest key = new CellRequest(cell, radius, defs, forThing);

            if (!requestCache.TryGetValue(key, out var value))
            {
                value = new List <Thing>();
                foreach (Thing t2 in GenRadial.RadialDistinctThingsAround(cell, map, radius, useCenter: false))
                {
                    if (defs.Any((MeditationFocusOffsetPerBuilding d) => d.building == t2.def) && t2.GetRoom() == cell.GetRoom(map) && t2 != forThing)
                    {
                        value.Add(t2);
                    }
                }
                value.SortBy(delegate(Thing t)
                {
                    float num = t.Position.DistanceTo(cell);
                    MeditationFocusOffsetPerBuilding meditationFocusOffsetPerBuilding = defs.FirstOrDefault((MeditationFocusOffsetPerBuilding d) => d.building == t.def);
                    if (meditationFocusOffsetPerBuilding != null)
                    {
                        num -= meditationFocusOffsetPerBuilding.offset * 100000f;
                    }
                    return(num);
                });
                requestCache[key] = value;
            }
            return(value);
        }
 public void AddRequest(UInt64 cellId, MyClipmap_CellData data, bool highPriority)
 {
     var cellRequest = new CellRequest() { CellId = cellId, Data = data };
     m_unsentRequests.Enqueue(cellRequest);
     
     data.State = CellState.Invalid;
     data.HighPriority = highPriority;
 }
            public void AddRequest(UInt64 cellId, MyClipmap_CellData data, bool highPriority)
            {
                var cellRequest = new CellRequest()
                {
                    CellId = cellId, Data = data
                };

                m_unsentRequests.Enqueue(cellRequest);

                data.State        = CellState.Invalid;
                data.HighPriority = highPriority;
            }
示例#8
0
        public async Task FlagAsync_WhenInvalidCellExceptionOcurrs_MustReturnError()
        {
            var request = new CellRequest {
                Board = _fixture.Create <Board>(),
                Cell  = _fixture.Create <CellCoordinates>()
            };

            A.CallTo(() => _service.FlagAsync(A <Board> ._, A <int> ._, A <int> ._))
            .Throws(new InvalidCellException(_resourceManager));

            var result = await _controller.FlagAsync(request) as ErrorResponse;

            Assert.AreEqual("error", result.Status);
            Assert.AreEqual(MSG_INVALIDCELL, result.Message);
        }
 public void AddRequest(UInt64 cellId, bool isHighPriority, Func<int> priorityFunc, Action<Color> ddraw)
 {
     m_cancelRequests.Remove(cellId);
     if (!m_sentRequests.Contains(cellId))
     {
         var cellRequest = new CellRequest() { CellId = cellId, PriorityFunc = priorityFunc, DebugDraw = ddraw };
         //if(isHighPriority)
         //    m_unsentRequests.Add(cellId, cellRequest);
         //else
         {
             var lod = MyCellCoord.UnpackLod(cellId);
             if (!m_unsentRequestsLow[lod].ContainsKey(cellId))
                 m_unsentRequestsLow[lod].Add(cellId, cellRequest);
         }
     }
 }
示例#10
0
        public async Task CheckAsync_GameNotStartedExceptionOcurrs_MustReturnError()
        {
            var request = new CellRequest
            {
                Board = _fixture.Create <Board>(),
                Cell  = _fixture.Create <CellCoordinates>()
            };

            A.CallTo(() => _service.CheckAsync(A <Board> ._, A <int> ._, A <int> ._))
            .Throws(new GameNotStartedException(_resourceManager));

            var result = await _controller.CheckAsync(request) as ErrorResponse;

            Assert.AreEqual("error", result.Status);
            Assert.AreEqual(MSG_GAMENOTSTARTED, result.Message);
        }
示例#11
0
        public async Task FlagAsync_WhenIsOK_MustReturnSuccess()
        {
            var board   = _fixture.Create <Board>();
            var request = new CellRequest
            {
                Board = board,
                Cell  = _fixture.Create <CellCoordinates>()
            };

            A.CallTo(() => _service.FlagAsync(A <Board> ._, A <int> ._, A <int> ._)).Returns(board);

            var result = await _controller.FlagAsync(request) as SuccessResponse <Board>;

            Assert.AreEqual("success", result.Status);
            Assert.AreEqual(board, result.Data);
        }
示例#12
0
        public async Task FlagAsync_WhenGenericExceptionOcurrs_MustReturnGenericError()
        {
            var request = new CellRequest
            {
                Board = _fixture.Create <Board>(),
                Cell  = _fixture.Create <CellCoordinates>()
            };

            A.CallTo(() => _service.FlagAsync(A <Board> ._, A <int> ._, A <int> ._))
            .Throws(new Exception());

            var result = await _controller.FlagAsync(request) as ErrorResponse;

            Assert.AreEqual("error", result.Status);
            Assert.AreEqual(MSG_DEFAULTERRORMESSAGE, result.Message);
        }
示例#13
0
        private void CellClick(object query)
        {
            CellRequest cellRequest = (CellRequest)query;

            if (cellRequest.CellType == CellType.RowAppend)
            {
                AppendRowCommand.Execute(cellRequest);
            }
            else if (cellRequest.CellType == CellType.ColumnAppend)
            {
                AppendColumnCommand.Execute(cellRequest);
            }
            else if (cellRequest.CellType == CellType.RowRemove)
            {
                RemoveRowCommand.Execute(cellRequest);
            }
            else if (cellRequest.CellType == CellType.ColumnRemove)
            {
                RemoveColumnCommand.Execute(cellRequest);
            }
        }
示例#14
0
 public void AddRequest(UInt64 cellId, bool isHighPriority, Func <int> priorityFunc, Action <Color> ddraw)
 {
     m_cancelRequests.Remove(cellId);
     if (!m_sentRequests.Contains(cellId))
     {
         var cellRequest = new CellRequest()
         {
             CellId = cellId, PriorityFunc = priorityFunc, DebugDraw = ddraw
         };
         //if(isHighPriority)
         //    m_unsentRequests.Add(cellId, cellRequest);
         //else
         {
             var lod = MyCellCoord.UnpackLod(cellId);
             if (!m_unsentRequestsLow[lod].ContainsKey(cellId))
             {
                 m_unsentRequestsLow[lod].Add(cellId, cellRequest);
             }
         }
     }
 }