/// <summary> /// Gets the grid from TreeView item asynchronous. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public async Task <Grid> GetGridFromTreeViewItemAsync(TreeViewItem <Photo> item) { if (!item.ItemsLoaded) { await AddFilesToTreeViewItemAsync(item); } var grid = new Grid { Caption = _localizer["List of photos in the current directory."] }; var headerRow = new Grid.GridRow(); headerRow.Cells.Add(new Grid.GridHeaderCell { Text = _localizer["Label"], CellIndex = headerRow.Cells.Count, Row = headerRow, Grid = grid }); headerRow.Cells.Add(new Grid.GridHeaderCell { Text = _localizer["Filename"], CellIndex = headerRow.Cells.Count, Row = headerRow, Grid = grid }); headerRow.Cells.Add(new Grid.GridHeaderCell { Text = _localizer["Creation date"], CellIndex = headerRow.Cells.Count, Row = headerRow, Grid = grid }); headerRow.Grid = grid; grid.Header = new Grid.GridHeader { Row = headerRow }; grid.Body = new Grid.GridBody(); foreach (var photo in item.Items) { var row = new Grid.GridRow(); var labelCell = new Grid.GridCell { Text = photo.Label ?? _localizer["Unlabeled"], CellIndex = row.Cells.Count, Row = row, Grid = grid }; row.Cells.Add(labelCell); var nameCell = new Grid.GridCell { Text = Path.GetFileName(photo.Path), CellIndex = row.Cells.Count, Row = row, Grid = grid }; row.Cells.Add(nameCell); var dateTakenCell = new Grid.GridCell { Text = (photo.TakenDate.HasValue ? photo.TakenDate.Value.ToString("F") : _localizer["unknown"]), CellIndex = row.Cells.Count, Row = row, Grid = grid }; row.Cells.Add(dateTakenCell); row.RowIndex = grid.Body.Rows.Count; row.Grid = grid; grid.Body.Rows.Add(row); } if (grid.Body.Rows.Any()) { grid.Body.Rows[0].Cells[0].Selected = true; } return(grid); }
/// <summary> /// Remove the link of the cell from the grid. /// For internal use only. /// </summary> public virtual void UnBindToGrid() { mGrid = null; mColumn = null; mRow = null; }
/// <summary> /// Link the cell at the specified grid. /// For internal use only. /// </summary> /// <param name="p_grid"></param> /// <param name="p_Position"></param> public virtual void BindToGrid(Grid p_grid, Position p_Position) { mGrid = p_grid; mRow = Grid.Rows[p_Position.Row]; mColumn = Grid.Columns[p_Position.Column]; }