public void ShareText() { var text = TextComponentFormatter.PlainStringForTextComponents(ViewModel.TextRepresentation); var activityViewController = CreateActivityViewController(new NSString(text)); Context.PresentViewController(activityViewController, true, null); }
public void ShareCalendarEvent() { var store = new EventKit.EKEventStore(); store.RequestAccess(EventKit.EKEntityType.Event, (bool granted, NSError error) => { if (!granted) { return; } var theEvent = EventKit.EKEvent.FromStore(store); theEvent.Title = TextComponentFormatter.PlainStringForTextComponents(ViewModel.EventTitle); theEvent.Notes = TextComponentFormatter.PlainStringForTextComponents(ViewModel.EventText); theEvent.AllDay = true; theEvent.StartDate = ViewModel.Date.ToNSDate(); theEvent.EndDate = ViewModel.Date.ToNSDate(); theEvent.Calendar = store.DefaultCalendarForNewEvents; store.SaveEvent(theEvent, EventKit.EKSpan.ThisEvent, out NSError saveError); if (saveError != null) { System.Diagnostics.Debug.WriteLine("Failed to save calendar event: " + saveError.LocalizedDescription); } }); }
void UpdateView(ChangeViewModel model) { ChangeView.DisableShadows(); ChangeView.SchoolClassLabel.Text = model.ClassName; ChangeView.HoursLabel.Text = model.Day + ", " + model.Hours + " " + NSBundle.MainBundle.LocalizedString("change_suffix_hour", ""); ChangeView.ChangeLabel.Text = NSBundle.MainBundle.LocalizedString(model.Type, ""); ChangeView.SchoolGradientView.Gradient = model.FillColor; ChangeView.OriginalLessonLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(model.OldLesson, true); ChangeView.ChangeDescriptionLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(model.Description, false); // Calculate the dynamic content size with the width restricted to the view's width and a boundless height. // Set the priority for the width to required (so it doesn't get larger than the available space) the priority of the height to low PreferredContentSize = ChangeView.SystemLayoutSizeFittingSize(new CoreGraphics.CGSize(View.Bounds.Size.Width, nfloat.MaxValue), 1000, 100); }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { ChangeTableViewCell cell = (ChangeTableViewCell)tableView.DequeueReusableCell(ChangeTableViewCell.Key, indexPath); var change = Items[indexPath.Row]; cell.SchoolClassLabel.Text = change.ClassName; cell.HoursLabel.Text = change.Hours + " " + NSBundle.MainBundle.LocalizedString("change_suffix_hour", ""); cell.ChangeLabel.Text = NSBundle.MainBundle.LocalizedString(change.Type, ""); cell.SchoolGradientView.Gradient = change.FillColor; cell.OriginalLessonLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(change.OldLesson, true); cell.ChangeDescriptionLabel.AttributedText = TextComponentFormatter.AttributedStringForTextComponents(change.Description, false); if (Context.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available) { Context.RegisterForPreviewingWithDelegate(Context, cell.ContentView); } return(cell); }