private void StartGeneration(object input) { Cells.Clear(); IsRunning = true; mGenerator.GenerateA() .MediumDungeon() .ABitRandom() .SomewhatSparse() .WithMediumChanceToRemoveDeadEnds() .WithSmallSizeRooms() .WithLargeNumberOfRooms() .AndTellMeWhenItsDone(map => { Dispatcher.Invoke(DispatcherPriority.DataBind, new Action(() => { Map = map; Width = map.Width; if (Cells.Count == 0) { for (int i = 0; i < map.Height; i++) { for (var j = 0; j < map.Width; j++) { Cells.Add(map.GetCell(i, j)); } } } Width = map.Width; })); IsRunning = false; }); }
private void OnGenerateGrid(object p) { Cells.Clear(); StrokeColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(StrokeSet)); FillColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString(FillSet)); GenGrid(); }
public void AnotherGrid() { NbGoodRes = 0; bool ok; do { Cells.Clear(); HorizontalTargets.Clear(); VerticalTargets.Clear(); InitializeResults(GridSize); ok = true; InitializeCells(GridSize); LinkCellsToResults(GridSize); foreach (var item in HorizontalTargets) { if (item.Result == 0) { ok = false; } } foreach (var item in VerticalTargets) { if (item.Result == 0) { ok = false; } } } while (!ok); SetBitsTo0(); _eventAggregator.GetEvent <OnStartTimerEvent>().Publish(new OnStartTimerEventArgs()); }
void workCheck_DoWork(object sender, DoWorkEventArgs e) { try { workCheck.ReportProgress(0, "开始处理..."); Workbook w1 = new Workbook(txt1.Text); Workbook w2 = new Workbook(txt2.Text); Cells c1 = w1.Worksheets[excuteSingle1].Cells; Cells c2 = w2.Worksheets[excuteSingle2].Cells; DataTable table1 = c1.ExportDataTable(0, 0, c1.MaxDataRow + 1, c1.MaxDataColumn + 1, true); DataTable table2 = c2.ExportDataTable(0, 0, c2.MaxDataRow + 1, c2.MaxDataColumn + 1, true); table1.PrimaryKey = new DataColumn[] { table1.Columns[key1 - 1] }; table2.PrimaryKey = new DataColumn[] { table2.Columns[key2 - 1] }; for (int i = 0; i < table1.Rows.Count; i++) { DataRow result = table2.Rows.Find(table1.Rows[i][key1 - 1]); if (result == null) { table1.Rows.RemoveAt(i); i--; } } c1.Clear(); c1.ImportDataTable(table1, true, 0, 0, table1.Rows.Count, table1.Columns.Count); w1.Save(txtResult.Text); workCheck.ReportProgress(0, "处理完成"); } catch (Exception ex) { workCheck.ReportProgress(0, ex.Message); } }
private void CellsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var patternCell in e.NewItems.OfType <PatternCell>()) { Cells.Add(new PatternCellViewModel(patternCell)); } } if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (var patternCell in e.OldItems.OfType <PatternCell>()) { var cellToRemove = Cells.FirstOrDefault(c => c.Cell == patternCell); if (cellToRemove != null) { Cells.Remove(cellToRemove); } } } if (e.Action == NotifyCollectionChangedAction.Reset) { Cells.Clear(); } }
/// <summary> /// Delete the path, make it disappear /// </summary> public List <Cell> DeleteItself() { List <Cell> removedCells = new List <Cell> (); // Prevent 1 path to be deleted if (Cells.Count <= 1) { return(removedCells); } foreach (var c in Cells) { removedCells.Add(c); if (c.IsPathStartOrEnd == false) { c.Path = null; } else { // Do not lose information for the start and end c.Path = new Path(c, ExpectedLength); } } Cells.Clear(); return(removedCells); }
public void RandomLife() { Cells.Clear(); var rnd = new Random(); int t = rnd.Next(0, 50); for (int x = 0; x < Width / Cell.Size; x++) { for (int y = 0; y < Height / Cell.Size; y++) { int r = rnd.Next(0, 100); if (r <= t) { var c = new Cell(Cells, false) { Position = new Point(x * Cell.Size, y * Cell.Size) }; if (!Cells.ContainsKey(c.Position)) { Cells.Add(c.Position, c); } } } } Invalidate(); }
public void Clear() { Cells.Clear(); SelectedIndex = -1; SelectedItem = null; last_correct_selected = -1; }
private void RejuvenateCells(int columns) { Cells.Clear(); for (var i = 0; i < columns; ++i) { Cells.Add(Factory.Instance.GetNewCell()); } }
/// <summary> /// Raises the hide event. /// </summary> /// <param name="disposeCells">If set to <c>true</c> dispose cells.</param> public void OnHide(bool disposeCells = true) { if (disposeCells) { Cells.Clear(); CellsEmpty = true; } }
public void GenerateGrid(GenerateGridEventArgs args) { switch (args.DifficultyName) { case "Easy": GridSize = 4; cellSize = 50; fontSize = 22; resFontSize = 22; break; case "Normal": GridSize = 6; cellSize = 32; fontSize = 20; resFontSize = 18; break; case "Expert": GridSize = 8; cellSize = 23; fontSize = 14; resFontSize = 7; break; default: break; } NbGoodRes = 0; bool ok; do { Cells.Clear(); HorizontalTargets.Clear(); VerticalTargets.Clear(); InitializeResults(GridSize); ok = true; InitializeCells(GridSize); LinkCellsToResults(GridSize); foreach (var item in HorizontalTargets) { if (item.Result == 0) { ok = false; } } foreach (var item in VerticalTargets) { if (item.Result == 0) { ok = false; } } } while (!ok); SetBitsTo0(); }
private void DestroyCells() { foreach (var cell in this.cellContainer.GetComponentsInChildren <BoardCell>()) { DestroyImmediate(cell.gameObject, true); } Cells.Clear(); }
private void ResetListOfCells(Cell[,] nextGenCells) { Cells.Clear(); for (int c = 1; c <= Columns; c++) { for (int r = 1; r <= Rows; r++) { Cells.Add(nextGenCells[c - 1, r - 1]); } } }
private void Initialize() { Cells.Clear(); foreach (var column in TreeGrid.Columns) { var cell = new Cell(this, column) { Content = column.CellTemplate?.LoadContent() }; Cells.Add(cell); } }
private void CreateMap() { Cells.Clear(); int numCellX = (int)Math.Ceiling(ActualWidth / 50) + 2; int numCellY = (int)Math.Ceiling(ActualHeight / 50) + 2; Enumerable.Range(0, numCellY).SelectMany(y => Enumerable.Range(0, numCellX).Select(x => new MapCell(x, y))) .ToList() .ForEach(cell => Cells.Add(cell)); }
public ViewModel() { GenerateCommand = new RelayCommand(StartGeneration); RefreshCommand = new RelayCommand(o => { var cells = Cells.ToList(); Cells.Clear(); foreach (var cell in cells) { Cells.Add(cell); } }); }
public void Update() { Dictionary <int, LinkedList <HCell> > copy = new Dictionary <int, LinkedList <HCell> >(Cells); Cells.Clear(); foreach (KeyValuePair <int, LinkedList <HCell> > entry in copy) { foreach (HCell cell in entry.Value) { this.Add(cell); } } }
// win in one step for convenient testing private void CellsAscending() { var orderedCells = Cells.OrderBy(item => Convert.ToByte(item.Text)).ToList(); Cells.Clear(); foreach (var cell in orderedCells) { cell.Row = orderedCells.IndexOf(cell) / LengthRowColumn; cell.Column = orderedCells.IndexOf(cell) % LengthRowColumn; Cells.Add(cell); } Cells[LengthRowColumn * LengthRowColumn - 2].Column = LengthRowColumn - 1; _clearCell = new Tuple <int, int>(LengthRowColumn - 2, LengthRowColumn - 1); }
/// <summary> /// 使用指定的数组填充单元格 /// </summary> /// <param name="array"></param> public void FillCellData(int[,] array) { Cells.Clear(); if (array.GetLength(0) < Rows || array.GetLength(1) < Columns) { throw new ArgumentException($"{nameof(array)}长度小于密保卡要求行数或列数"); } for (int row = 0; row < Rows; row++) { for (int col = 0; col < Columns; col++) { var cell = new CardCell(row, col, array[row, col]); Cells.Add(cell); } } }
public void Dispose() { if (_decorator != null) { _decorator.Dispose(); _decorator = null; } if (_hightLightDecorator != null) { _hightLightDecorator.Dispose(); _hightLightDecorator = null; } if (_cellDecorator != null) { _cellDecorator.Dispose(); _cellDecorator = null; } if (_cellHightLightDecorator != null) { _cellHightLightDecorator.Dispose(); _cellHightLightDecorator = null; } Table = null; if (Siblings != null) { Siblings.Clear(); Siblings = null; } if (Cells != null) { foreach (var cell in Cells.ToArray()) { cell.Dispose(); } Cells.Clear(); Cells = null; } TextAlign = null; TextFunc = null; HighlightFunc = null; Hud = null; }
public void SetButtonGridUp() { // If there is a size change. if (Cells.Count == 0 || Cells.Count != _model.ActiveTableSize * _model.ActiveTableSize) { Cells.Clear(); for (Int32 i = 0; i < _model.ActiveTableSize; ++i) { for (Int32 j = 0; j < _model.ActiveTableSize; ++j) { //TODO: Only create the new ones? It seams even harder then in WFA. Cells.Add(new ReversiCell(new DelegateCommand(param => MakePutDown(Convert.ToInt32(param))), i, j, ((i * _model.ActiveTableSize) + j))); } } } _tableSizeOfCells = _model.ActiveTableSize; OnPropertyChanged("TableSizeOfCells"); }
public void CreateCells(DataGridView dataGridView) { if (dataGridView == null) { throw new ArgumentNullException("DataGridView is null."); } if (dataGridView.Rows.Contains(this)) { throw new InvalidOperationException("The row already exists in the DataGridView."); } Cells.Clear(); foreach (DataGridViewColumn column in dataGridView.Columns) { if (column.CellTemplate == null) { throw new InvalidOperationException("Cell template not set in column: " + column.Index.ToString() + "."); } Cells.Add((DataGridViewCell)column.CellTemplate.Clone()); } }
/// <summary> /// Create Cells /// </summary> public bool CreateCells() { try { Cells.Clear(); for (int i = 0; i < CellCount; ++i) { Cells.Add(new Cell("Line" + i, new List <TimeFrame>(), 0, 0, new List <TimeFrame>(), 0, new Dictionary <double, int>())); } #if DEBUG Debug.Print("Cell size is " + Cells.Count); #endif return(true); } catch (Exception ex) { Debug.Print(ex.Message); return(false); } }
void workCheck_DoWork(object sender, DoWorkEventArgs e) { try { ExportTableOptions opts = new ExportTableOptions(); opts.ExportAsString = true; workCheck.ReportProgress(0, "开始处理..."); string[] listAllExcel = DirFileHelper.GetFileNames(txtSource.Text, "*.xls", true); Workbook template = new Workbook(); Cells TemplateCells = template.Worksheets[0].Cells; foreach (var item in listAllExcel) { Workbook workbook = new Workbook(item); foreach (var sheet in workbook.Worksheets) { workCheck.ReportProgress(0, "开始处理:" + item + "/" + sheet.Name); if (!IsExcuteSheet(sheet.Name)) { workCheck.ReportProgress(0, "此sheet名称不在待处理表中,将忽略...---" + sheet.Name); continue; } Cells cells = sheet.Cells; DataTable table = cells.ExportDataTable(StartRow - 1, 0, cells.MaxDataRow - StartRow - EndRow + 3, cells.MaxDataColumn + 1, opts); // DataTable table = cells.ExportDataTable(StartRow - 1, 0, 5, cells.MaxDataColumn + 1, opts); //TemplateCells.ImportDataTable(table, false, 0, 0, table.Rows.Count, table.Columns.Count, true, "yyyy/MM/dd"); TemplateCells.ImportDataTable(table, false, 0, 0, table.Rows.Count, table.Columns.Count, true, "mm/dd/yyyy", false); } } TemplateCells.DeleteBlankRows(); DataTable tableSource = TemplateCells.ExportDataTable(0, 0, TemplateCells.MaxDataRow + 1, TemplateCells.MaxDataColumn + 1, opts); tableSource = ReturnMergeData(tableSource); TemplateCells.Clear(); TemplateCells.ImportDataTable(tableSource, false, 0, 0, tableSource.Rows.Count, tableSource.Columns.Count, true, "mm/dd/yyyy", false); template.Save(txtResult.Text); workCheck.ReportProgress(0, "处理完成"); } catch (Exception ex) { workCheck.ReportProgress(0, ex.Message); } }
public void RefreshCells() { Cells.Clear(); List <Coordinates> aliveCells = _model.AliveCells; foreach (Coordinates coord in aliveCells) { Cells.Add(new CellField { CellState = (int)Cell.Alive, Row = coord.x * CellSizeY, Column = coord.y * CellSizeX }); } OnPropertyChanged("Generation"); OnPropertyChanged("Size"); OnPropertyChanged("Paused"); OnPropertyChanged("Playing"); }
/// <summary> /// Inicializa el tablero /// </summary> private void Reset() { if (ViewModel.SelectedGame != null) { PieceBaseModel.PieceColor color = PieceBaseModel.PieceColor.White; // Limpia el canvas Cells.Clear(); udtCanvas.Children.Clear(); // Añade las celdas for (int row = 0; row < 8; row++) { // Rellena por columnas for (int column = 0; column < 8; column++) { Cells.Add(CreateFigure(row, column, color, null)); color = GetNextColor(color); } // Cambia el color de inicio de la siguiente fila color = GetNextColor(color); } // Añade las etiquetas for (int row = 0; row < 8; row++) { Cells.Add(CreateLabel(row, -1, (char)('0' + 8 - row))); } for (int column = 0; column < 8; column++) { Cells.Add(CreateLabel(-1, column, (char)('A' + column))); } // Añade las piezas foreach (PieceBaseModel piece in ViewModel.MovementsList.GameBoard.Pieces) { Cells.Add(CreateFigure(piece.Cell.Row, piece.Cell.Column, piece.Color, piece.Type)); } // Muestra las imágenes ShowImages(); } }
public void Reset() { //if (!this.beachline) //{ // this.beachline = new this.RBTree(); //} //// Move leftover beachsections to the beachsection junkyard. //if (this.beachline.root) //{ // var beachsection = this.beachline.getFirst(this.beachline.root); // while (beachsection) // { // this.beachsectionJunkyard.push(beachsection); // mark for reuse // beachsection = beachsection.rbNext; // } //} //this.beachline.root = null; //if (!this.circleEvents) //{ // this.circleEvents = new this.RBTree(); //} //this.circleEvents.root = this.firstCircleEvent = null; //this.vertices = []; //this.edges = []; //this.cells = []; BeachLine = new RBTree(); CircleEvents = new RBTree(); BeachLine.Name = "BeachLine"; CircleEvents.Name = "CircleEvents"; firstCircleEvent = null; Vertices.Clear(); Edges.Clear(); Cells.Clear(); }
public void Load(string input) { // TODO Decompression string[] lines = input.Split('\n'); SizeX = int.Parse(lines[0]); SizeY = int.Parse(lines[1]); Cells.Clear(); Cells = new List <Cell>(SizeX * SizeY); int currentIndex = 0; for (int i = 2; i < lines.Length; i++) { string[] content = lines[i].Split(' '); if (content.Length == 2) { int n = int.Parse(content.First()); bool state = bool.Parse(content.Last()); while (n > 0) { int posX = currentIndex % SizeX; int posY = (currentIndex - posX) / SizeX; Cells.Add(new Cell(posX, posY) { IsCurrentlyAlive = state }); currentIndex++; n--; } } } SetupNeighborhood(); }
public void Open(Item[] items) { Cells.ForEach(cell => Destroy(cell.gameObject)); Cells.Clear(); var cellPrefab = Resources.Load <InventoryCell>("Prefabs/UI/InventoryCell"); foreach (var loopIndex in Enumerable.Range(0, items.Length)) { var cell = Instantiate(cellPrefab, layout.transform); cell.SetIndex(loopIndex); cell.SetData(items[loopIndex]); cell.SetOnClick(OnClickCell); Cells.Add(cell); } itemInfoPanel.ResetUI(); SetActive(true); OnOpen(); }
public void CalculateIndexes() { List <int> indexes = new List <int>(); Cells.Clear(); QuadtreeNode.ProcessFace(Tree, indexes, Cells); IndexCount = indexes.Count; if (indexes.Count != 0) { IndexBuffer.SetData <int>(indexes.ToArray()); } Vertices.Clear(); foreach (Cell c in Cells) { c.Polygonize(Vertices, Size); } VertexCount = Vertices.Count; if (VertexCount > 0) { VertexBuffer.SetData <VertexPositionColorNormal>(Vertices.ToArray()); } }