Exemple #1
0
 public static void UpdateScreeningControls()
 {
     foreach (var screening in _labelByfilmScreening.Keys)
     {
         ColorView.SetScreeningColor(screening, _labelByfilmScreening[screening]);
         _labelByfilmScreening[screening].StringValue = screening.ToFilmScreeningLabelString();
     }
 }
 public ScreeningLabel(CGRect frame, Screening screening, bool withDay = false) : base(frame)
 {
     Initialize();
     _screening    = screening;
     Font          = NSFont.BoldSystemFontOfSize(ScreeningControl.FontSize);
     Editable      = false;
     Bordered      = false;
     StringValue   = _screening.ToScreeningLabelString(withDay);
     LineBreakMode = NSLineBreakMode.TruncatingMiddle;
     ColorView.SetScreeningColor(_screening, this);
     NeedsDisplay = true;
 }
Exemple #3
0
        public static void DisplayScreeningControls(
            List <Screening> screenings,
            NSView screeningsView,
            GoToScreeningDelegate goToScreening,
            ref FilmScreeningControl currentScreeningControl)
        {
            // Initialize the dictionary to find labels by screening.
            _labelByfilmScreening = new Dictionary <Screening, NSTextField> {
            };

            // Initialize dimensions.
            var xLabel       = _buttonWidth + _xBetweenLabels;
            var yScreening   = screeningsView.Frame.Height;
            var contentWidth = screeningsView.Frame.Width;
            var buttonRect   = new CGRect(0, yScreening, _buttonWidth, _labelHeight);
            var labelRect    = new CGRect(xLabel, yScreening, contentWidth - xLabel, _labelHeight);

            foreach (var screening in screenings)
            {
                // Update the vertical position.
                yScreening -= _labelHeight;

                // Create the screening info button.
                buttonRect.Y = yScreening;
                var infoButton = new FilmScreeningControl(buttonRect, screening);
                infoButton.ReDraw();
                infoButton.ScreeningInfoAsked += (sender, e) => goToScreening(screening);
                if (screening == _app.Controller.CurrentScreening)
                {
                    currentScreeningControl          = infoButton;
                    currentScreeningControl.Selected = true;
                }
                screeningsView.AddSubview(infoButton);

                // Create the screening label.
                labelRect.Y = yScreening;
                var screeningLabel = ControlsFactory.NewStandardLabel(labelRect);
                screeningLabel.StringValue = screening.ToFilmScreeningLabelString();
                ColorView.SetScreeningColor(screening, screeningLabel);
                screeningsView.AddSubview(screeningLabel);

                // Link the label to the screening.
                _labelByfilmScreening.Add(screening, screeningLabel);

                yScreening -= _yBetweenLabels;
            }
        }
        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;
        }
Exemple #5
0
        public override void DrawRect(CGRect dirtyRect)
        {
            base.DrawRect(dirtyRect);

            // Use Core Graphic routines to draw our UI
            using (CGContext context = NSGraphicsContext.CurrentContext.GraphicsPort)
            {
                // Fill the screening color.
                CGPath path  = new CGPath();
                CGRect frame = new CGRect(0, 0, base.Frame.Width, base.Frame.Height);
                path.AddRect(frame);
                ColorView.SetScreeningColor(_screening, context);
                context.AddPath(path);
                context.DrawPath(CGPathDrawingMode.Fill);

                // Draw screening information.
                context.TranslateCTM(2, ScreeningsView.VerticalTextOffset);
                context.SetTextDrawingMode(CGTextDrawingMode.Fill);
                ColorView.SetScreeningColor(_screening, context, true);
                CTStringAttributes attrs = new CTStringAttributes();
                attrs.ForegroundColorFromContext = true;
                attrs.Font = ScreeningControl.StandardFont;
                var      textPosition = new CGPoint(0, _lineHeight);
                string[] lines        = _screening.ToScreeningLabelString().Split('\n');
                foreach (var line in lines)
                {
                    context.TextPosition = textPosition;
                    var attributedString = new NSAttributedString(line, attrs);
                    using (var textLine = new CTLine(attributedString))
                    {
                        textLine.Draw(context);
                    }
                    textPosition.Y -= _lineHeight;
                }
            }
            NeedsDisplay = true;
        }