Esempio n. 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);
        }
        public override void ViewWillAppear()
        {
            base.ViewWillAppear();

            // Tell the app delegate that we're alive.
            App.FilmInfoController = this;

            // Inactivate screenings view actions.
            App.Controller.RunningPopupsCount++;

            // Get the selected film.
            _film = ((IScreeningProvider)Presentor).CurrentFilm;

            // Get the downloaded film info if present.
            _filmInfo = ViewController.GetFilmInfo(_film.FilmId);

            // Set basis dimensions.
            var dialogFrame = View.Frame;

            _yCurr        = (float)dialogFrame.Height;
            _contentWidth = (float)dialogFrame.Width - 2 * _xMargin;

            // Create the controls that were not defined in Xcode.
            PopulatieDialogView();

            // Disable resizing.
            Presentor.DisableResizing(this, _sampleView);
        }
Esempio n. 3
0
        public Film(string filmText)
        {
            // Assign the fields of the input string.
            string[] fields         = filmText.Split(';');
            string   sequenceNumber = fields[0];
            string   filmId         = fields[1];

            SortedTitle   = fields[2];
            Title         = fields[3];
            TitleLanguage = fields[4];
            string subsectionIdStr = fields[5];
            string duration        = fields[6];
            string category        = fields[7];

            Url = fields[8];

            // Assign properties that need calculating.
            SequenceNumber = int.Parse(sequenceNumber);
            FilmId         = int.Parse(filmId);
            int?subsectionId = int.TryParse(subsectionIdStr, out int outcome) ? (int?)outcome : null;

            _subsection = ViewController.GetSubsection(subsectionId);
            int minutes = int.Parse(duration.TrimEnd('′'));

            Duration = new TimeSpan(0, minutes, 0);
            Category = (WebUtility.MediumCategory)Enum.Parse(typeof(WebUtility.MediumCategory), category);

            // Get Film Info.
            if (FilmInfo == null)
            {
                ScreeningsPlan.FilmInfos.Add(new FilmInfo(FilmId, FilmInfoStatus.Absent, "", ""));
                _filmInfo = null;
            }
        }
 void IFilmOutlinable.SetInfo(NSTextField view)
 {
     view.AttributedStringValue = FilmInfo.InfoString(Film);
     view.LineBreakMode         = NSLineBreakMode.ByWordWrapping;
     view.BackgroundColor       = NSColor.Clear;
     view.TextColor             = NSColor.Text;
 }
        public void SetInfo(NSTextField view)
        {
            ColorView.SetScreeningColor(Screening, view);
            switch (OutlineLevel)
            {
            case Level.OverlappingScreening:
                var attributedInfo = new NSMutableAttributedString(Screening.ScreeningStringForLabel() + " ");
                attributedInfo.Append(FilmInfo.InfoString(Screening.Film));
                view.AttributedStringValue = attributedInfo;
                break;

            case Level.FilmScreening:
                view.StringValue = Screening.ScreeningStringForLabel(true);
                break;
            }
            view.LineBreakMode = NSLineBreakMode.TruncatingTail;
        }
 private void SetSummaryFieldText(string text, bool alternativeFormat = false)
 {
     if (alternativeFormat && _summaryFieldFormatIsOriginal)
     {
         _summaryField.Selectable      = false;
         _summaryField.Font            = NSFont.LabelFontOfSize(24);
         _summaryField.TextColor       = NSColor.LightGray;
         _summaryFieldFormatIsOriginal = false;
     }
     else if (!alternativeFormat && !_summaryFieldFormatIsOriginal)
     {
         _summaryField.Selectable      = true;
         _summaryField.Font            = _originalSummaryFieldFont;
         _summaryField.TextColor       = _originalSummaryFieldColor;
         _summaryFieldFormatIsOriginal = true;
     }
     _summaryField.AttributedStringValue = FilmInfo.HtmlToAttributed(text);
     ;
 }
Esempio n. 7
0
        public static List <FilmInfo> LoadFilmInfoFromXml(string path)
        {
            var filmInfos = new List <FilmInfo> {
            };
            XElement root;

            try
            {
                root = XElement.Load(path);
            }
            catch (FileNotFoundException)
            {
                return(filmInfos);
            }
            catch (System.Exception)
            {
                return(filmInfos);
            }
            var filmInfoElements =
                from el in root.Elements("FilmInfo")
                select
                (
                    (int)el.Attribute("FilmId"),
                    (string)el.Attribute("InfoStatus"),
                    (string)el.Attribute("FilmDescription"),
                    (string)el.Attribute("FilmArticle"),
                    from c in el.Element("CombinationPrograms").Elements("CombinationProgram")
                    select
                    (
                        (int)c.Attribute("CombinationProgramId")
                    ),
                    from s in el.Element("ScreenedFilms").Elements("ScreenedFilm")
                    select
                    (
                        (string)s.Attribute("ScreenedFilmId"),
                        (string)s.Attribute("Title"),
                        (string)s.Attribute("Description"),
                        (string)s.Attribute("ScreenedFilmType")
                    )
                );

            foreach (var filmInfoElement in filmInfoElements)
            {
                var filmInfo = new FilmInfo
                               (
                    filmInfoElement.Item1,
                    StringToFilmInfoStatus(filmInfoElement.Item2),
                    filmInfoElement.Item3,
                    filmInfoElement.Item4
                               );
                foreach (var compilationProgramAttribute in filmInfoElement.Item5)
                {
                    filmInfo.CombinationProgramIds.Add(compilationProgramAttribute);
                }
                foreach (var screenedFilmAttribute in filmInfoElement.Item6)
                {
                    int filmid           = int.Parse(screenedFilmAttribute.Item1);
                    var title            = screenedFilmAttribute.Item2;
                    var description      = screenedFilmAttribute.Item3;
                    var type             = screenedFilmAttribute.Item4;
                    var screenedFilmType = _screenedFilmTypeByString[type];
                    filmInfo.AddScreenedFilm(filmid, title, description, screenedFilmType);
                }
                filmInfos.Add(filmInfo);
            }
            return(filmInfos);
        }