void ReleaseDesignerOutlets() { if (FlowerImage != null) { FlowerImage.Dispose(); FlowerImage = null; } if (NameText != null) { NameText.Dispose(); NameText = null; } if (Scroll != null) { Scroll.Dispose(); Scroll = null; } if (SeeCommentsButton != null) { SeeCommentsButton.Dispose(); SeeCommentsButton = null; } }
public override void ViewDidLoad() { if (NavigationParameter == null) { throw new InvalidOperationException("No parameter found after navigation"); } Vm = (FlowerViewModel)NavigationParameter; DescriptionText = new UILabel(new CGRect(0, 0, 300, 235)) { LineBreakMode = UILineBreakMode.WordWrap, Lines = 0, }; Scroll.Add(DescriptionText); FlowerImage.SetImage( new NSUrl(Vm.ImageUri.AbsoluteUri), UIImage.FromBundle("flower_256_magenta.png")); this.SetBinding( () => Vm.Model.Name) .WhenSourceChanges( () => { // iOS is quite primitive and requires layout recalculation when the content // of UI elements changes. This is a good place to do that. NameText.Text = Vm.Model.Name; NameText.SizeToFit(); NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height); }); this.SetBinding( () => Vm.Model.Description) .WhenSourceChanges( () => { DescriptionText.Text = Vm.Model.Description; DescriptionText.SizeToFit(); DescriptionText.Frame = new CGRect( 0, 0, Scroll.Bounds.Width - 20, DescriptionText.Bounds.Height); Scroll.ContentSize = new CGSize(Scroll.Bounds.Width - 20, DescriptionText.Bounds.Height + 20); Scroll.SetNeedsLayout(); }); SeeCommentsButton.TouchUpInside += (s, e) => { var nav = ServiceLocator.Current.GetInstance <INavigationService>(); nav.NavigateTo(AppDelegate.SeeCommentsPageKey, Vm); }; base.ViewDidLoad(); }
public override void ViewDidLoad() { View = new UniversalView(); base.ViewDidLoad(); InitializeComponent(); Title = "Details"; FlowerImage.SetImage( new NSUrl(Vm.ImageUri.AbsoluteUri), UIImage.FromBundle("flower_256_magenta.png")); this.SetBinding( () => Vm.Model.Name) .WhenSourceChanges( () => { // iOS is quite primitive and requires layout recalculation when the content // of UI elements changes. This is a good place to do that. NameText.Text = Vm.Model.Name; NameText.SizeToFit(); NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height); }); this.SetBinding( () => Vm.Model.Description) .WhenSourceChanges( () => { DescriptionText.Text = Vm.Model.Description; DescriptionText.SizeToFit(); DescriptionText.Frame = new CGRect(0, 0, 300, DescriptionText.Bounds.Height); Scroll.ContentSize = new CGSize(300, DescriptionText.Bounds.Height); Scroll.SetNeedsLayout(); }); SeeCommentButton.Clicked += (s, e) => { // iOS is the only framework where we decided to split the comments // on a different page. This is a good example that you can easily // have different UI experience even though the ViewModel and Model are the same var controller = Vm.Model.Comments.GetController( CreateCommentCell, BindCommentCell); controller.Title = "Comments"; var addCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null); addCommentButton.SetCommand("Clicked", Vm.AddCommentCommand); controller.NavigationItem.SetRightBarButtonItem(addCommentButton, false); AppDelegate.MainNavigationController.PushViewController(controller, true); }; }
public ActionResult DeleteConfirmed(int id) { FlowerImage productImage = imageService.DetailImage(id); if (productImage == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } imageService.DeleteImage(productImage); return(RedirectToAction("Index")); }
public void DeleteImage(FlowerImage flowerImage) { DbContext.FlowerImages.Remove(flowerImage); DbContext.SaveChanges(); }