2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// Recipe.cs
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// Author: Jeffrey Stedfast <jeff@xamarin.com>
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// Copyright (c) 2011 Xamarin Inc.
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
// THE SOFTWARE.
|
2015-01-19 18:09:40 +03:00
|
|
|
//
|
2011-10-01 01:09:49 +04:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Text;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2015-01-19 18:09:40 +03:00
|
|
|
using Foundation;
|
|
|
|
using UIKit;
|
2011-10-01 01:09:49 +04:00
|
|
|
|
|
|
|
namespace RecipesAndPrinting
|
|
|
|
{
|
|
|
|
public class Ingredient {
|
|
|
|
public string Name;
|
|
|
|
public string Amount;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public class Recipe : IDisposable
|
|
|
|
{
|
|
|
|
public Recipe ()
|
|
|
|
{
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string Name {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string Description {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string PrepTime {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string Instructions {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public UIImage Image {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public UIImage ThumbnailImage {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public Ingredient[] Ingredients {
|
|
|
|
get; set;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string HtmlRepresentation {
|
|
|
|
get {
|
|
|
|
StringBuilder body = new StringBuilder ("<!DOCTYPE html><html><body>");
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
if (Ingredients != null && Ingredients.Length > 0) {
|
|
|
|
body.Append ("<h2>Ingredients</h2>");
|
|
|
|
body.Append ("<ul>");
|
|
|
|
foreach (var ingredient in Ingredients)
|
|
|
|
body.AppendFormat ("<li>{0} {1}</li>", ingredient.Amount, ingredient.Name);
|
|
|
|
body.Append ("</ul>");
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
if (Instructions != null && Instructions.Length > 0) {
|
|
|
|
body.Append ("<h2>Instructions</h2>");
|
|
|
|
body.AppendFormat ("<p>{0}</p>", Instructions);
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
body.Append ("</body></html>");
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
return body.ToString ();
|
|
|
|
}
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public string AggregatedInfo {
|
|
|
|
get {
|
|
|
|
StringBuilder info = new StringBuilder ();
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
if (Description != null && Description.Length > 0)
|
|
|
|
info.Append (Description);
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
if (PrepTime != null && PrepTime.Length > 0) {
|
|
|
|
if (info.Length > 0)
|
|
|
|
info.Append ('\n');
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
info.AppendFormat ("Preparation Time: {0}", PrepTime);
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
return info.ToString ();
|
|
|
|
}
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
public void Dispose ()
|
|
|
|
{
|
|
|
|
if (ThumbnailImage != null) {
|
|
|
|
ThumbnailImage.Dispose ();
|
|
|
|
ThumbnailImage = null;
|
|
|
|
}
|
2015-01-19 18:09:40 +03:00
|
|
|
|
2011-10-01 01:09:49 +04:00
|
|
|
if (Image != null) {
|
|
|
|
Image.Dispose ();
|
|
|
|
Image = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|