示例#1
0
        ZMJCell ISpreadsheetViewDataSource.CellForItemAt(SpreadsheetView spreadsheetView, NSIndexPath indexPath)
        {
            if (indexPath.Row == 0)
            {
                HeaderCell headeCell = (HeaderCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(HeaderCell), indexPath);
                headeCell.Label.Text = _header[indexPath.GetColumn()];

                if (indexPath.GetColumn() == _sortedColumn.Column)
                {
                    headeCell.SortArrow.Text = GetSymbol(_sortedColumn.Sorting);
                    return(headeCell);
                }

                headeCell.SortArrow.Text = "";
                return(headeCell);
            }


            TextCell cell = (TextCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(TextCell), indexPath);

            cell.Label.Text = _data[indexPath.Row - 1][indexPath.GetColumn()];
            return(cell);
        }
示例#2
0
        public void DidSelectItemAt(SpreadsheetView spreadsheetView, NSIndexPath indexPath)
        {
            if (indexPath.Row != 0)
            {
                return;
            }

            if (_sortedColumn.Column == indexPath.GetColumn())
            {
                SortedColumn sc = _sortedColumn;
                sc.Sorting = _sortedColumn.Sorting == ZMJSorting.ZMJAscending
                    ? ZMJSorting.ZMJDsescending
                    : ZMJSorting.ZMJAscending;

                _sortedColumn = sc;
            }
            else
            {
                _sortedColumn = new SortedColumn((int)indexPath.GetColumn(), ZMJSorting.ZMJAscending);
            }

            if (_sortedColumn.Sorting == ZMJSorting.ZMJAscending)
            {
                _data = _data
                        .OrderBy(r => r[_sortedColumn.Column])
                        .ToList();
            }
            else
            {
                _data = _data
                        .OrderByDescending(r => r[_sortedColumn.Column])
                        .ToList();
            }

            spreadsheetView.ReloadData();
        }
示例#3
0
        ZMJCell ISpreadsheetViewDataSource.CellForItemAt(SpreadsheetView spreadsheetView, NSIndexPath indexPath)
        {
            nint column = indexPath.GetColumn();

            if (column >= 1 &&
                indexPath.Row <= _dates.Length + 1 &&
                indexPath.Row == 0)
            {
                DateCell cell = (DateCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(DateCell), indexPath);
                cell.Label.Text = _dates[column - 1];
                return(cell);
            }

            if (column >= 1 &&
                column <= _days.Length + 1 &&
                indexPath.Row == 1)
            {
                DayTitleCell cell = (DayTitleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(DayTitleCell), indexPath);
                cell.Label.Text      = _days[column - 1];
                cell.Label.TextColor = _dayColors[column - 1];
                return(cell);
            }

            if (column == 0 &&
                indexPath.Row == 1)
            {
                TimeTitleCell cell = (TimeTitleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(TimeTitleCell), indexPath);
                cell.Label.Text = "TIME";
                return(cell);
            }

            if (column == 0 &&
                indexPath.Row >= 2 &&
                indexPath.Row <= _hours.Length + 2)
            {
                TimeCell cell = (TimeCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(TimeCell), indexPath);

                cell.Label.Text      = _hours[indexPath.Row - 2];
                cell.BackgroundColor = indexPath.Row % 2 == 0
                    ? _evenRowColor
                    : _oddRowColor;
                return(cell);
            }

            if (column >= 1 &&
                column <= _days.Length + 1 &&
                indexPath.Row >= 2 &&
                indexPath.Row <= _hours.Length + 2)
            {
                ScheduleCell cell = (ScheduleCell)spreadsheetView.DequeueReusableCellWithReuseIdentifier(nameof(ScheduleCell), indexPath);

                String text = _data[column - 1][indexPath.Row - 2];
                if (!String.IsNullOrWhiteSpace(text))
                {
                    cell.Label.Text = text;
                    UIColor color = _dayColors[column - 1];
                    cell.Label.TextColor = color;
                    cell.Color           = color.ColorWithAlpha(0.2f);
                    cell.Borders.Top     = new BorderStyle(BorderStyleType.Solid, 2f, color);
                    cell.Borders.Bottom  = new BorderStyle(BorderStyleType.Solid, 2f, color);
                }
                else
                {
                    cell.Label.Text = null;
                    cell.Color      = indexPath.Row % 2 == 0
                        ? _evenRowColor
                        : _oddRowColor;
                    cell.Borders.Top    = BorderStyle.BorderStyleNone;
                    cell.Borders.Bottom = BorderStyle.BorderStyleNone;
                }
                return(cell);
            }

            return(null);
        }
示例#4
0
 public void DidSelectItemAt(SpreadsheetView spreadsheetView, NSIndexPath indexPath)
 {
     Console.WriteLine($"Row: {indexPath.Row}, Column: {indexPath.GetColumn()}");
 }