// user tapped "blur" or "sepia" buttons (lower right) public override void PrepareForSegue(UIStoryboardSegue segue, NSObject sender) { base.PrepareForSegue(segue, sender); string key = null; string segueIdentifier = segue.Identifier; if (segueIdentifier == "showBlurInfo") { key = BlurFilter.Key; } else if (segueIdentifier == "showModifyInfo") { key = ModifyFilter.Key; } if (key == null) { return; } ImageFilter filter = CreateImageFilter(key); var filterViewController = (FilterViewController)segue.DestinationViewController; filterViewController.Filter = filter; }
void PresentFilter(NSObject sender) { var button = (UIBarButtonItem)sender; string key = null, identifier = null; if (button.Tag == BlurButtonTag) { key = BlurFilter.Key; identifier = "blurController"; } else if (button.Tag == SepiaButtonTag) { key = ModifyFilter.Key; identifier = "modsController"; } if (key == null) { return; } currentlyPresentedFilterTitle = button.Title; ImageFilter filter = CreateImageFilter(key); // check for activity view controller is open, dismiss it TryDismiss(activityViewController, () => { activityViewController = null; TryDismiss(currentFilterViewController, () => CreateAndPresentFilterVC(button, filter, identifier)); }); }
void CreateAndPresentFilterVC(UIBarButtonItem sender, ImageFilter filter, string identifier) { currentFilterViewController = (FilterViewController)Storyboard.InstantiateViewController(identifier); currentFilterViewController.Filter = filter; currentFilterViewController.ModalPresentationStyle = UIModalPresentationStyle.Popover; currentFilterViewController.PopoverPresentationController.BarButtonItem = sender; currentFilterViewController.UserActivity = UserActivity; // so "WasDismissed" can be called currentFilterViewController.MasterViewController = this; // so "popoverPresentationControllerDidDismissPopover" can be called currentFilterViewController.PopoverPresentationController.WeakDelegate = this; PresentViewController(currentFilterViewController, true, () => UpdateImage(false, false)); }
static ImageFilter CreateFilter(string key, bool setDefaults) { ImageFilter filter = null; if (key == BlurFilter.Key) { filter = new BlurFilter(setDefaults); } else if (key == ModifyFilter.Key) { filter = new ModifyFilter(setDefaults); } else { throw new NotImplementedException(); } UIApplication.RegisterObjectForStateRestoration(filter, key); filter.Dirty = false; filter.RestorationType = typeof(DetailViewController); return(filter); }
void Subscribe(ImageFilter subject) { subject.DirtyChanged += OnDirtyChanged; }
void CreateAndPresentFilterVC(UIBarButtonItem sender, ImageFilter filter, string identifier) { currentFilterViewController = (FilterViewController)Storyboard.InstantiateViewController (identifier); currentFilterViewController.Filter = filter; currentFilterViewController.ModalPresentationStyle = UIModalPresentationStyle.Popover; currentFilterViewController.PopoverPresentationController.BarButtonItem = sender; currentFilterViewController.UserActivity = UserActivity; // so "WasDismissed" can be called currentFilterViewController.MasterViewController = this; // so "popoverPresentationControllerDidDismissPopover" can be called currentFilterViewController.PopoverPresentationController.WeakDelegate = this; PresentViewController (currentFilterViewController, true, () => UpdateImage (false, false)); }