public void SetGo(NSView view) { FilmScreeningControl infoButton; ScreeningsView.DisposeSubViews(view); infoButton = new FilmScreeningControl(view.Frame, Screening); infoButton.ReDraw(); infoButton.ScreeningInfoAsked += (sender, e) => GoToScreening(Screening); infoButton.Selected = ScreeningIsSelected(Screening); view.AddSubview(infoButton); }
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; } }