public void RemoveItemsFromCell(int x, int y, Guid guid) { int index = y * _gridWidth + x; GridItems items = _gridItems[index]; int itemCount = items.itemGuids.Length + 1; int indexToRemove = -1; for (int i = 0; i < itemCount; i++) { if (items.itemGuids[i] == guid) { indexToRemove = i; break; } if (indexToRemove != -1) { var itemGuids = new Guid[itemCount]; for (int i2 = 0; i2 < itemCount; i2++) { if (i2 != indexToRemove) { itemGuids[i2] = items.itemGuids[i]; } } _gridItems[index] = new GridItems { }; } } }
public void Init(GridItems i_GridItems) { m_GridItems = i_GridItems; m_GridItems.Strategy = new GridItems.RetrivalStrategy(startingIndex, GridColumns + GridRows); if (i_GridItems != null) { reset(); m_GridPictureBoxs = new PictureBox[GridRows, GridColumns]; int i = 0, j = 0; int counter = 0; foreach (IGridItem gridItem in m_GridItems) { m_GridPictureBoxs[i, j] = new PictureBox(); m_GridPictureBoxs[i, j].Text = counter.ToString(); ++counter; m_GridPictureBoxs[i, j].Click += gridItem_Click; m_GridPictureBoxs[i, j].BackgroundImageLayout = ImageLayout.Center; m_GridPictureBoxs[i, j].BackgroundImage = gridItem.ImageThumb; m_GridPictureBoxs[i, j].Size = new Size(GridItemWidth, GridItemHeight); m_GridPictureBoxs[i, j].Left = pictureBoxTitle.Left + (j * (k_Margin + GridItemWidth)); m_GridPictureBoxs[i, j].Top = pictureBoxTitle.Top + pictureBoxTitle.Height + (i * (k_Margin + GridItemHeight)) + k_Margin; Controls.Add(m_GridPictureBoxs[i, j]); ++j; if (j == GridColumns) { j = 0; ++i; } } } }
public void cargarGrid() { DataTable dt2 = new DataTable(); dt2.Columns.AddRange(new DataColumn[6] { new DataColumn("Posi", typeof(string)), new DataColumn("Sku", typeof(string)), new DataColumn("Desc", typeof(string)), new DataColumn("Cant", typeof(string)), new DataColumn("Uni", typeof(string)), new DataColumn("Esp", typeof(string)), }); foreach (var item in ped.Items) { string Posi = item.Posicion; string Sku = item.SKU; string Desc = item.Descripcion; string Cant = item.Cantidad; string Uni = item.UNIDAD; string Esp = item.Especial1; dt2.Rows.Add(Posi, Sku, Desc, Cant, Uni, Esp); } GridItems.DataSource = dt2; GridItems.DataBind(); }
public async Task <FileDownload> ProcessUrl(string url) { if (!PauseAllEnabled) { return(null); } var item = new TaskDataGridItem { Url = url, DownloadStatus = Enum.GetName(typeof(DownloadStatus), DownloadStatus.Downloading), Progress = 0 }; var tokenSource = new CancellationTokenSource(); FileDownload fileDownload = new FileDownload(url, ChunkSize, tokenSource); fileDownload.DownloadProgressChanged += FileDownload_DownloadProgressChanged; fileDownload.DownloadCompleted += FileDownload_DownloadCompleted; fileDownload.DownloadError += FileDownload_DownloadError; Application.Current.Dispatcher.Invoke(() => GridItems.Add(item)); this._downloads.Add(fileDownload); Interlocked.Increment(ref _currentRunningThreads); OnPropertyChanged(nameof(CurrentThreadsToShow)); await fileDownload.Start(); return(fileDownload); }
private void OnDeleteRowClick(object sender, RoutedEventArgs e) { int nIndex = dataGrid.SelectedIndex; System.Diagnostics.Debug.WriteLine($"Deleting row at index \"{nIndex}\""); if (dataGrid.SelectedItem is DataGridCardItem) { //MetroWindow window = Window.GetWindow(this) as MetroWindow; //MessageDialogResult result = await window.ShowMessageAsync(string.Empty, "Are you sure you want to remove the selected card?", MessageDialogStyle.AffirmativeAndNegative); //if (result == MessageDialogResult.Affirmative) //{ DataGridCardItem item = dataGrid.SelectedItem as DataGridCardItem; GridItems.RemoveAt(nIndex); if (RowDeleted != null) { RowDeleted(this, new DataGridCardItemEventArgs(item, nIndex)); } else { } //} //else { } } else { } }
MatchInfo GetMatchInfo(GridItems item) { MatchInfo h = new MatchInfo(); h.match = null; List <GridItems> hmatch = SearchHorizontally(item); List <GridItems> vmatch = SearchVertically(item); if (hmatch.Count > minItemForMatch && hmatch.Count > vmatch.Count) { h.matchStartingX = GetMinimumX(hmatch); h.matchEndX = GetMaximumX(hmatch); h.matchStartingY = h.matchEndY = hmatch[0].y; h.match = hmatch; } else if (vmatch.Count >= minItemForMatch) { h.matchStartingY = GetMinimumY(vmatch); h.matchEndY = GetMaximumY(vmatch); h.matchStartingX = h.matchEndX = vmatch[0].x; h.match = vmatch; } return(h); }
IEnumerator TryMatch(GridItems a, GridItems b) { yield return(StartCoroutine(Swap(a, b))); Debug.Log("Swap Candies"); MatchInfo matchA = GetMatchInfo(a); MatchInfo matchB = GetMatchInfo(b); if (!matchA.validMatch() && !matchB.validMatch()) { yield return(StartCoroutine(Swap(a, b))); yield break; } if (matchA.validMatch()) { Debug.Log("Matche"); yield return(StartCoroutine(MyDestroy(matchA.match))); yield return(new WaitForSeconds(DelayBetweenMathes)); yield return(StartCoroutine(UpdateGridAfterMAtch(matchA))); } else if (matchB.validMatch()) { Debug.Log("No Matches"); yield return(StartCoroutine(MyDestroy(matchB.match))); yield return(new WaitForSeconds(DelayBetweenMathes)); yield return(StartCoroutine(UpdateGridAfterMAtch(matchB))); } }
public Guid[] GetItemsAtCell(int x, int y) { int index = y * _gridWidth + x; GridItems items = _gridItems[index]; return(items.itemGuids); }
public void ReOrderItems() { foreach (var item in GridItems) { item.GridRow = GridItems.IndexOf(item); } }
private void OnMouseOverItem(GridItems item) { if (SelectedItems == null) { Debug.Log("Start Point"); SelectedItems = item; } else { Debug.Log("End Point"); float xDiff = Mathf.Abs(item.x - SelectedItems.x); float yDiff = Mathf.Abs(item.y - SelectedItems.y); if (xDiff + yDiff == 1) { Debug.Log("Try Match Function"); StartCoroutine(TryMatch(SelectedItems, item)); } else { Debug.Log("ZEPSUTE ACHTUNG!"); } SelectedItems = null; } }
public void Dispose() { GridItems.Clear(); _mutex.Dispose(); _downloads.Clear(); base.Dispose(); }
/* * public class TransparentPB : PictureBox { * public void New() * { * this.SetStyle(ControlStyles.Opaque, true); * this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false); * } * new public CreateParams CreateParams * { * get * { * CreateParams cp = new CreateParams(); * cp.ExStyle &= 0x00000020; * return cp; * } * } * } */ private bool AlreadyUsed(int index) { bool booRetVal = false; IEnumerable <GridItem> items = GridItems.Where(GridItems => GridItems.Index == index); booRetVal = (items.Count() > 0); return(booRetVal); }
public void CreateGridItems() { while (xamlitems.Count >= 2) { var res = new GridItem(xamlitems); GridItems.Add(res); } }
GridItems InstantiateCandy(int x, int y) { GameObject randomCandy = Candies[Random.Range(0, Candies.Length)]; GridItems newCandy = ((GameObject)Instantiate(randomCandy, new Vector2(x * CandiesWidth, y), Quaternion.identity)).GetComponent <GridItems>(); newCandy.OnItemPositionChanged(x, y); return(newCandy); }
protected void GridItems_PageIndexChanging(object sender, GridViewPageEventArgs e) { DataTable data = (DataTable)Cache["data"]; GridItems.DataSource = data; MediaGalleryItems.RecourdNumber = data.Rows.Count; GridItems.PageIndex = e.NewPageIndex; GridItems.DataBind(); }
private void fillComments() { DataTable dtTbl = new DataTable(); dtTbl = (new BL()).searchComments(); GridItems.PageSize = Convert.ToInt32(10); GridItems.DataSource = dtTbl; GridItems.DataBind(); }
public void AddGridItem() { GridItem item = new GridItem(); item.ID = GridItems.Count; item.OnGridItemInvalidate += new GridItem.GridItemInvalidateHandle(this.OnGridItemInvalidateHandle); item.OnContentReset += new GridItem.ResetControlHandle(this.OnResetControlHandle); GridItems.Add(item); }
//New candies after destrpy old IEnumerator UpdateGridAfterMAtch(MatchInfo match) { //match Horizontally if (match.matchStartingY == match.matchEndX) { for (int x = match.matchStartingX; x <= match.matchEndX; x++) { for (int y = match.matchStartingY; y < Ysize - 1; y++) { GridItems upperIndex = items[x, y + 1]; GridItems current = items[x, y]; items[x, y] = upperIndex; items[x, y + 1] = current; items[x, y].OnItemPositionChanged(items[x, y].x, items[x, y].y - 1); } } } //match Vertically else if (match.matchEndX == match.matchStartingX) { int matchHeigh = 1 + (match.matchEndY - match.matchStartingY); for (int y = match.matchStartingY + matchHeigh; y < Ysize - 1; y++) { GridItems lowerIndex = items[match.matchStartingX, y - matchHeigh]; GridItems current = items[match.matchStartingX, y]; items[match.matchStartingX, y - matchHeigh] = current; items[match.matchStartingX, y + 1] = lowerIndex; } for (int y = 0; y < Ysize - matchHeigh; y++) { items[match.matchStartingX, y].OnItemPositionChanged(match.matchStartingX, y); } for (int i = 0; i < match.match.Count; i++) { items[match.matchStartingX, (Ysize - 1) - i] = InstantiateCandy(match.matchStartingX, (Ysize - 1) - i); } } for (int x = 0; x < Xsize; x++) { for (int y = 0; y < Ysize; y++) { MatchInfo matchinfo = GetMatchInfo(items[x, y]); if (matchinfo.validMatch()) { yield return(new WaitForSeconds(DelayBetweenMathes)); yield return(StartCoroutine(MyDestroy(matchinfo.match))); yield return(new WaitForSeconds(DelayBetweenMathes)); yield return(StartCoroutine(UpdateGridAfterMAtch(matchinfo))); yield return(new WaitForSeconds(DelayBetweenMathes)); } } } }
GridItems instantiate_items(int x, int y) { GameObject random_items = itemPrefabs[Random.Range(0, 5)]; GridItems newItem = ((GameObject)Instantiate(random_items, new Vector2(x * items_width, y), Quaternion.identity)).GetComponent <GridItems>(); newItem.OnItemPostionChanged(x, y); return(newItem); }
private void FillRegions() { Regions = GridItems .Select(i => new IdNameItem() { Id = i.RegionId, Name = i.Region }) .Distinct() .ToList(); }
public void OnCountryChanged() { Cities = GridItems .Where(i => i.CountryId == Selected.CountryId) .Select(i => new IdNameItem() { Id = i.CityId, Name = i.City }) .Distinct() .ToList(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dtTbl = new DataTable(); dtTbl = (new BL()).searchComments(); GridItems.PageSize = Convert.ToInt32(10); GridItems.DataSource = dtTbl; GridItems.DataBind(); } }
public void OnRegionChanged() { Countries = GridItems .Where(i => i.RegionId == Selected.RegionId) .Select(i => new IdNameItem() { Id = i.CountryId, Name = i.Country }) .Distinct() .ToList(); }
void swapIndices(GridItems gridA, GridItems gridB) { GridItems tempA = gridItems[gridA.x, gridA.y]; gridItems[gridA.x, gridA.y] = gridB; gridItems[gridB.x, gridB.y] = tempA; int boldx = gridB.x; int boldy = gridB.y; gridB.OnItemPostionChanged(gridA.x, gridA.y); gridA.OnItemPostionChanged(boldx, boldy); }
void SwapIndeces(GridItems a, GridItems b) { GridItems tempA = items[a.x, a.y]; items[a.x, a.y] = items[b.x, b.y]; items[b.x, b.y] = tempA; int bOldX = b.x; int bOldY = b.y; b.OnItemPositionChanged(a.x, a.y); a.OnItemPositionChanged(bOldX, bOldY); }
protected void GridItems_RowDeleting(object sender, GridViewDeleteEventArgs e) { DataTable data = (DataTable)Cache["data"]; Item item = Helper.GetDatabase().GetItem(data.Rows[e.RowIndex]["ID"].ToString()); item.Delete(); data.Rows.RemoveAt(e.RowIndex); Cache["data"] = data; MediaGalleryItems.RecourdNumber = data.Rows.Count; GridItems.DataSource = data; GridItems.DataBind(); }
IEnumerator Swap(GridItems a, GridItems b) { ChangeRigidBodyStatus(false); Vector3 apos = a.transform.position; Vector3 bpos = b.transform.position; StartCoroutine(a.transform.Move(bpos, MoveDuration)); StartCoroutine(b.transform.Move(apos, MoveDuration)); yield return(new WaitForSeconds(MoveDuration)); SwapIndeces(a, b); ChangeRigidBodyStatus(true); }
IEnumerator Swap(GridItems a, GridItems b) { changerGridBodyStatus(false); float moveduration = 0.1f; Vector3 apos = a.transform.position; Vector3 bpos = b.transform.position; StartCoroutine(a.transform.Move(bpos, moveduration)); StartCoroutine(b.transform.Move(apos, moveduration)); yield return(new WaitForSeconds(moveduration)); swapIndices(a, b); changerGridBodyStatus(true); }
private void SpawnNewItems() { //int -> number of position to move down, List<GridItem> -> list of items to move down about this(key) positions. Dictionary <int, List <GridItem> > itemsToMove = new Dictionary <int, List <GridItem> >(); int lenghtY = GridItems.GetLength(1); foreach (int x in positionsForNewItems.Keys) { int numberOfDestroyedItems = 0; for (int y = 0; y < lenghtY; y++) { if (GridItems[x, y] == null) { numberOfDestroyedItems++; } else if (numberOfDestroyedItems > 0) { if (!itemsToMove.ContainsKey(numberOfDestroyedItems)) { itemsToMove.Add(numberOfDestroyedItems, new List <GridItem>()); } int newY = y - numberOfDestroyedItems; GridItems[x, newY] = GridItems[x, y]; GridItems[x, newY].Position = new IntVector2(x, newY); itemsToMove[numberOfDestroyedItems].Add(GridItems[x, newY]); #if UNITY_EDITOR GridItems[x, newY].UpdateGameObjectName(); #endif } } if (!itemsToMove.ContainsKey(numberOfDestroyedItems)) { itemsToMove.Add(numberOfDestroyedItems, new List <GridItem>()); } //Spawn new items for (int i = lenghtY - numberOfDestroyedItems; i < lenghtY; i++) { ItemsGenerator.GenerateNewItem(x, i, numberOfDestroyedItems, true); itemsToMove[numberOfDestroyedItems].Add(GridItems[x, i]); } } MoveItems(itemsToMove, false, AnimManager.FallDownItems); }
public GridItems<Rockmelon.Domain.Game> ToList(IEnumerable<Rockmelon.Domain.Game> games) { var grid = new GridItems<Rockmelon.Domain.Game>(); grid.PrimaryKey = new Func<Rockmelon.Domain.Game, int>(g => g.GameId); grid.Columns = new List<Func<Rockmelon.Domain.Game, object>>() { new Func<Rockmelon.Domain.Game, object>(g => g.Title), new Func<Rockmelon.Domain.Game, object>(g => g.Description), new Func<Rockmelon.Domain.Game, object>(g => g.TotalRating()) }; foreach (var game in games) { grid.Items.Add(game); } return grid; }
/// <summary>Verify that the coordinates are within the boundary of the board</summary> private bool InsideBorders(params IntVector2[] coordinates) { int gridItemsXLenght = GridItems.GetLength(0); int gridItemsYLenght = GridItems.GetLength(1); //Use "for" loop instead of foreach for GB oprimization :) int lenght = coordinates.Length; for (int i = 0; i < lenght; i++) { if (coordinates[i].x >= gridItemsXLenght || coordinates[i].y >= gridItemsYLenght || coordinates[i].x < 0 || coordinates[i].y < 0) { return(false); } } return(true); }
public GameModel() { Games = new GridItems<Rockmelon.Domain.Game>(); }