Пример #1
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            // Get the cell view
            NSTextField view = (NSTextField)tableView.MakeView(_cellIdentifier, this);

            // Get the data for the row
            Film film = _dataSource.Films[(int)row];

            // Setup view based on the column selected
            switch (tableColumn.Title)
            {
            case "Film":
                NSTextField filmLabel = (NSTextField)view;
                PopulateFilm(ref filmLabel);
                filmLabel.StringValue = film.Title;
                tableColumn.Width     = _titleWidth;
                return(filmLabel);

            case "Description":
                NSTextField descriptionLabel = (NSTextField)view;
                PopulateDescription(ref descriptionLabel);
                descriptionLabel.AttributedStringValue = FilmInfo.InfoString(film);
                return(descriptionLabel);

            case "Duration":
                NSTextField durationLabel = (NSTextField)view;
                PopulateDuration(ref durationLabel);
                durationLabel.StringValue = film.DurationString;
                durationLabel.TextColor   = DurationTextColor(film.Duration);
                return(durationLabel);

            case "#Screenings":
                NSTextField screeningCountLabel = (NSTextField)view;
                PopulateScreeningCount(ref screeningCountLabel);
                int screeningCount = film.FilmScreenings.Count;
                screeningCountLabel.StringValue = screeningCount.ToString();
                screeningCountLabel.TextColor   = ScreeningCountTextColor(screeningCount);
                return(screeningCountLabel);

            case "Subsection":
                NSTextField subsectionLabel = (NSTextField)view;
                PupulateSubsection(ref subsectionLabel);
                subsectionLabel.StringValue = film.SubsectionName;
                subsectionLabel.TextColor   = SubsectionTextColor(film);
                subsectionLabel.ToolTip     = film.SubsectionDescription;
                return(subsectionLabel);

            default:
                if (ScreeningInfo.FilmFans.Contains(tableColumn.Title))
                {
                    RatingField friendRatingField = (RatingField)view;
                    PopulateFilmFanFilmRating(ref friendRatingField, film, tableColumn.Title, row);
                    friendRatingField.StringValue = ViewController.GetFilmFanFilmRating(film, tableColumn.Title).ToString();
                    friendRatingField.Tag         = row;
                    return(friendRatingField);
                }
                break;
            }
            return(view);
        }
Пример #2
0
        private void PopulateFilmFanFilmRating(ref RatingField box, Film film, string filmFan, nint row)
        {
            if (box == null)
            {
                box = new RatingField(_dialogController)
                {
                    Identifier      = _cellIdentifier,
                    BackgroundColor = NSColor.Clear,
                    Bordered        = false,
                    Selectable      = false,
                    Editable        = true,
                    Alignment       = NSTextAlignment.Right,
                };
            }
            var ratingField = box;

            box.EditingEnded += (s, e) => HandleFilmFanRatingEditingEnded(ratingField, filmFan);
        }