RecipesAndPrinting sample ported to 64-bits

This commit is contained in:
Paola Villarreal 2014-07-24 14:26:07 -05:00
Родитель b449b1deb3
Коммит 64ac381476
14 изменённых файлов: 95 добавлений и 92 удалений

Просмотреть файл

@ -27,8 +27,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -26,8 +26,8 @@
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
namespace RecipesAndPrinting
{
@ -12,9 +12,9 @@ namespace RecipesAndPrinting
partial class InstructionsViewController
{
[Outlet]
MonoTouch.UIKit.UITextView instructionsText { get; set; }
UIKit.UITextView instructionsText { get; set; }
[Outlet]
MonoTouch.UIKit.UILabel nameLabel { get; set; }
UIKit.UILabel nameLabel { get; set; }
}
}

Просмотреть файл

@ -27,8 +27,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -29,8 +29,8 @@ using System.Text;
using System.Collections;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -25,11 +25,11 @@
//
using System;
using System.Drawing;
using CoreGraphics;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{
@ -71,12 +71,12 @@ namespace RecipesAndPrinting
get { return controller.Recipe; }
}
public override int NumberOfSections (UITableView tableView)
public override nint NumberOfSections (UITableView tableView)
{
return (int) RecipeSection.TotalSections;
}
public override string TitleForHeader (UITableView tableView, int section)
public override string TitleForHeader (UITableView tableView, nint section)
{
if (section == (int) RecipeSection.Instructions)
return "Instructions";
@ -84,25 +84,25 @@ namespace RecipesAndPrinting
return null;
}
public override int RowsInSection (UITableView tableView, int section)
public override nint RowsInSection (UITableView tableView, nint section)
{
switch ((RecipeSection) section) {
switch ((RecipeSection) (int)section) {
case RecipeSection.Instructions: return 1;
case RecipeSection.Ingredients: return Recipe.Ingredients.Length;
default: return 0;
}
}
UITableViewCell GetIngredientsCellAtIndex (UITableView tableView, int index)
UITableViewCell GetIngredientsCellAtIndex (UITableView tableView, nint index)
{
UITableViewCell cell = tableView.DequeueReusableCell (IngredientsCellId);
RectangleF computedFrame;
CGRect computedFrame;
UILabel amountLabel;
if (cell == null) {
cell = new UITableViewCell (UITableViewCellStyle.Default, IngredientsCellId);
amountLabel = new UILabel (RectangleF.Empty);
amountLabel = new UILabel (CGRect.Empty);
amountLabel.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
amountLabel.TextColor = UIColor.FromRGBA (50.0f / 255.0f, 79.0f / 255.0f, 133.0f / 255.0f, 1.0f);
amountLabel.TextAlignment = UITextAlignment.Right;
@ -118,11 +118,11 @@ namespace RecipesAndPrinting
cell.TextLabel.Text = Recipe.Ingredients[index].Name;
amountLabel.Text = Recipe.Ingredients[index].Amount;
SizeF desiredSize = amountLabel.SizeThatFits (new SizeF (160.0f, 32.0f));
float midY = (cell.ContentView.Bounds.Y + cell.ContentView.Bounds.Height) / 2.0f;
float maxX = cell.ContentView.Bounds.Right;
CGSize desiredSize = amountLabel.SizeThatFits (new CGSize (160.0f, 32.0f));
nfloat midY = (cell.ContentView.Bounds.Y + cell.ContentView.Bounds.Height) / 2.0f;
nfloat maxX = cell.ContentView.Bounds.Right;
computedFrame = new RectangleF (new PointF (maxX - desiredSize.Width - 10.0f, midY - desiredSize.Height / 2.0f), desiredSize);
computedFrame = new CGRect (new CGPoint (maxX - desiredSize.Width - 10.0f, midY - desiredSize.Height / 2.0f), desiredSize);
amountLabel.Frame = computedFrame;
return cell;
@ -130,7 +130,7 @@ namespace RecipesAndPrinting
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
RecipeSection section = (RecipeSection) indexPath.Section;
RecipeSection section = (RecipeSection)(int) indexPath.Section;
if (section == (int) RecipeSection.Ingredients)
return GetIngredientsCellAtIndex (tableView, indexPath.Row);
@ -154,7 +154,7 @@ namespace RecipesAndPrinting
public override NSIndexPath WillSelectRow (UITableView tableView, NSIndexPath indexPath)
{
RecipeSection section = (RecipeSection) indexPath.Section;
RecipeSection section = (RecipeSection)(int) indexPath.Section;
// Don't allow ingredients to be selected
if (section == RecipeSection.Ingredients) {

Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
namespace RecipesAndPrinting
{
@ -12,15 +12,15 @@ namespace RecipesAndPrinting
partial class RecipeDetailViewController
{
[Outlet]
MonoTouch.UIKit.UIView tableHeaderView { get; set; }
UIKit.UIView tableHeaderView { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton photoButton { get; set; }
UIKit.UIButton photoButton { get; set; }
[Outlet]
MonoTouch.UIKit.UILabel nameLabel { get; set; }
UIKit.UILabel nameLabel { get; set; }
[Action ("ShowPhoto:")]
partial void ShowPhoto (MonoTouch.Foundation.NSObject sender);
partial void ShowPhoto (Foundation.NSObject sender);
}
}

Просмотреть файл

@ -27,8 +27,8 @@
using System;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{
@ -104,12 +104,12 @@ namespace RecipesAndPrinting
get { return controller.recipes.Recipes; }
}
public override int NumberOfSections (UITableView tableView)
public override nint NumberOfSections (UITableView tableView)
{
return 1;
}
public override int RowsInSection (UITableView tableView, int section)
public override nint RowsInSection (UITableView tableView, nint section)
{
return Recipes.Length;
}

Просмотреть файл

@ -4,7 +4,7 @@
// actions made in the Xcode designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using MonoTouch.Foundation;
using Foundation;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -26,8 +26,8 @@
using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{

Просмотреть файл

@ -25,12 +25,12 @@
//
using System;
using System.Drawing;
using CoreGraphics;
using System.Collections;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{
@ -55,9 +55,9 @@ namespace RecipesAndPrinting
// Calculate the content area based on the printableRect, that is, the area in which
// the printer can print content. a.k.a the imageable area of the paper.
RectangleF ContentArea {
CGRect ContentArea {
get {
RectangleF r = PrintableRect;
CGRect r = PrintableRect;
r.Height -= HeaderHeight + FooterHeight;
r.Y += HeaderHeight;
return r;
@ -77,7 +77,7 @@ namespace RecipesAndPrinting
// provided by those formatters.
//
// Therefore, setup the formatters, and ask super to count the pages.
public override int NumberOfPages {
public override nint NumberOfPages {
get {
PrintFormatters = new UIPrintFormatter [0];
SetupPrintFormatters ();
@ -89,9 +89,9 @@ namespace RecipesAndPrinting
// a UIMarkupTextPrintFormatter and add that formatter to the printing job.
void SetupPrintFormatters ()
{
RectangleF contentArea = ContentArea;
float previousFormatterMaxY = contentArea.Top;
int page = 0;
CGRect contentArea = ContentArea;
nfloat previousFormatterMaxY = contentArea.Top;
nint page = 0;
foreach (Recipe recipe in recipes) {
string html = recipe.HtmlRepresentation;
@ -115,14 +115,14 @@ namespace RecipesAndPrinting
AddPrintFormatter (formatter, page);
page = formatter.StartPage + formatter.PageCount - 1;
previousFormatterMaxY = formatter.RectangleForPage (page).Bottom;
}
}
// Custom UIPrintPageRenderer's may override this class to draw a custom print page header.
// To illustrate that, this class sets the date in the header.
public override void DrawHeaderForPage (int index, RectangleF headerRect)
public override void DrawHeaderForPage (nint index, CGRect headerRect)
{
NSDateFormatter dateFormatter = new NSDateFormatter ();
dateFormatter.DateFormat = "MMMM d, yyyy 'at' h:mm a";
@ -134,7 +134,7 @@ namespace RecipesAndPrinting
dateString.Dispose ();
}
public override void DrawFooterForPage (int index, RectangleF footerRect)
public override void DrawFooterForPage (nint index, CGRect footerRect)
{
NSString footer = new NSString (string.Format ("Page {0} of {1}", index - pageRange.Location + 1, pageRange.Length));
footer.DrawString (footerRect, SystemFont, UILineBreakMode.Clip, UITextAlignment.Center);
@ -147,13 +147,13 @@ namespace RecipesAndPrinting
// We do this to intermix/overlay our custom drawing onto the recipe presentation.
// We draw the upper portion of the recipe presentation by hand (image, title, desc),
// and the bottom portion is drawn via the UIMarkupTextPrintFormatter.
public override void DrawPrintFormatterForPage (UIPrintFormatter printFormatter, int page)
public override void DrawPrintFormatterForPage (UIPrintFormatter printFormatter, nint page)
{
base.DrawPrintFormatterForPage (printFormatter, page);
// To keep our custom drawing in sync with the printFormatter, base our drawing
// on the formatters rect.
RectangleF rect = printFormatter.RectangleForPage (page);
CGRect rect = printFormatter.RectangleForPage (page);
// Use a bezier path to draw the borders.
// We may potentially choose not to draw either the top or bottom line
@ -169,7 +169,7 @@ namespace RecipesAndPrinting
rect.Y -= RecipeInfoHeight;
border.MoveTo (rect.Location);
border.AddLineTo (new PointF (rect.Right, rect.Top));
border.AddLineTo (new CGPoint (rect.Right, rect.Top));
Recipe recipe = recipeFormatterMap[printFormatter];
@ -179,14 +179,14 @@ namespace RecipesAndPrinting
// Draw the left border
border.MoveTo (rect.Location);
border.AddLineTo (new PointF (rect.Left, rect.Bottom));
border.AddLineTo (new CGPoint (rect.Left, rect.Bottom));
// Draw the right border
border.MoveTo (new PointF (rect.Right, rect.Top));
border.AddLineTo (new PointF (rect.Right, rect.Bottom));
border.MoveTo (new CGPoint (rect.Right, rect.Top));
border.AddLineTo (new CGPoint (rect.Right, rect.Bottom));
if (page == printFormatter.StartPage + printFormatter.PageCount - 1)
border.AddLineTo (new PointF (rect.Left, rect.Bottom));
border.AddLineTo (new CGPoint (rect.Left, rect.Bottom));
// Set the UIColor to be used by the current graphics context, and then stroke
// stroke the current path that is defined by the border bezier path.
@ -196,36 +196,36 @@ namespace RecipesAndPrinting
// Custom code to draw upper portion of the recipe presentation (image, title, desc).
// The argument rect is the full size of the recipe presentation.
void DrawRecipe (Recipe recipe, RectangleF rect)
void DrawRecipe (Recipe recipe, CGRect rect)
{
DrawRecipeImage (recipe.Image, rect);
DrawRecipeName (recipe.Name, rect);
DrawRecipeInfo (recipe.AggregatedInfo, rect);
}
void DrawRecipeImage (UIImage image, RectangleF rect)
void DrawRecipeImage (UIImage image, CGRect rect)
{
// Create a new rect based on the size of the header area
RectangleF imageRect = RectangleF.Empty;
CGRect imageRect = CGRect.Empty;
// Scale the image to fit in the infoRect
float maxImageDimension = RecipeInfoHeight - Padding * 2;
float largestImageDimension = Math.Max (image.Size.Width, image.Size.Height);
float scale = maxImageDimension / largestImageDimension;
nfloat maxImageDimension = RecipeInfoHeight - Padding * 2;
nfloat largestImageDimension = (nfloat)Math.Max (image.Size.Width, image.Size.Height);
nfloat scale = maxImageDimension / largestImageDimension;
imageRect.Size = new SizeF (image.Size.Width * scale, image.Size.Height * scale);
imageRect.Size = new CGSize (image.Size.Width * scale, image.Size.Height * scale);
// Place the image rect at the x,y defined by the argument rect
imageRect.Location = new PointF (rect.Left + Padding, rect.Top + Padding);
imageRect.Location = new CGPoint (rect.Left + Padding, rect.Top + Padding);
// Ask the image to draw in the image rect
image.Draw (imageRect);
}
// Custom drawing code to put the recipe name in the title section of the recipe presentation's header.
void DrawRecipeName (string name, RectangleF rect)
void DrawRecipeName (string name, CGRect rect)
{
RectangleF nameRect = RectangleF.Empty;
CGRect nameRect = CGRect.Empty;
nameRect.X = rect.Left + RecipeInfoHeight;
nameRect.Y = rect.Top + Padding;
nameRect.Width = rect.Width - RecipeInfoHeight;
@ -240,9 +240,9 @@ namespace RecipesAndPrinting
// Custom drawing code to put the recipe recipe description, and prep time
// in the title section of the recipe presentation's header.
void DrawRecipeInfo (string info, RectangleF rect)
void DrawRecipeInfo (string info, CGRect rect)
{
RectangleF infoRect = RectangleF.Empty;
CGRect infoRect = CGRect.Empty;
infoRect.X = rect.Left + RecipeInfoHeight;
infoRect.Y = rect.Top + TitleSize * 2;
infoRect.Width = rect.Width - RecipeInfoHeight;

Просмотреть файл

@ -25,10 +25,10 @@
//
using System;
using System.Drawing;
using CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{
@ -48,23 +48,23 @@ namespace RecipesAndPrinting
public RecipeTableViewCell (UITableViewCellStyle style, NSString identifier) : base (style, identifier)
{
imageView = new UIImageView (RectangleF.Empty);
imageView = new UIImageView (CGRect.Empty);
ContentView.AddSubview (imageView);
descriptionLabel = new UILabel (RectangleF.Empty);
descriptionLabel = new UILabel (CGRect.Empty);
descriptionLabel.Font = UIFont.SystemFontOfSize (12.0f);
descriptionLabel.TextColor = UIColor.DarkGray;
descriptionLabel.HighlightedTextColor = UIColor.White;
ContentView.AddSubview (descriptionLabel);
prepTimeLabel = new UILabel (RectangleF.Empty);
prepTimeLabel = new UILabel (CGRect.Empty);
prepTimeLabel.TextAlignment = UITextAlignment.Right;
prepTimeLabel.Font = UIFont.SystemFontOfSize (12.0f);
prepTimeLabel.TextColor = UIColor.Black;
prepTimeLabel.HighlightedTextColor = UIColor.White;
ContentView.AddSubview (prepTimeLabel);
nameLabel = new UILabel (RectangleF.Empty);
nameLabel = new UILabel (CGRect.Empty);
nameLabel.Font = UIFont.BoldSystemFontOfSize (14.0f);
nameLabel.TextColor = UIColor.Black;
nameLabel.HighlightedTextColor = UIColor.White;
@ -85,39 +85,39 @@ namespace RecipesAndPrinting
}
}
RectangleF ImageViewFrame {
CGRect ImageViewFrame {
get {
if (Editing) {
return new RectangleF (EditingInset, 0.0f, ImageSize, ImageSize);
return new CGRect (EditingInset, 0.0f, ImageSize, ImageSize);
} else {
return new RectangleF (0.0f, 0.0f, ImageSize, ImageSize);
return new CGRect (0.0f, 0.0f, ImageSize, ImageSize);
}
}
}
RectangleF NameLabelFrame {
CGRect NameLabelFrame {
get {
if (Editing) {
return new RectangleF (ImageSize + EditingInset + TextLeftMargin, 4.0f, ContentView.Bounds.Width - ImageSize - EditingInset - TextLeftMargin, 16.0f);
return new CGRect (ImageSize + EditingInset + TextLeftMargin, 4.0f, ContentView.Bounds.Width - ImageSize - EditingInset - TextLeftMargin, 16.0f);
} else {
return new RectangleF (ImageSize + TextLeftMargin, 4.0f, ContentView.Bounds.Width - ImageSize - TextLeftMargin - PrepTimeWidth, 16.0f);
return new CGRect (ImageSize + TextLeftMargin, 4.0f, ContentView.Bounds.Width - ImageSize - TextLeftMargin - PrepTimeWidth, 16.0f);
}
}
}
RectangleF DescriptionLabelFrame {
CGRect DescriptionLabelFrame {
get {
if (Editing) {
return new RectangleF (ImageSize + EditingInset + TextLeftMargin, 22.0f, ContentView.Bounds.Width - ImageSize - EditingInset - TextLeftMargin, 16.0f);
return new CGRect (ImageSize + EditingInset + TextLeftMargin, 22.0f, ContentView.Bounds.Width - ImageSize - EditingInset - TextLeftMargin, 16.0f);
} else {
return new RectangleF (ImageSize + TextLeftMargin, 22.0f, ContentView.Bounds.Width - ImageSize - TextLeftMargin, 16.0f);
return new CGRect (ImageSize + TextLeftMargin, 22.0f, ContentView.Bounds.Width - ImageSize - TextLeftMargin, 16.0f);
}
}
}
RectangleF PrepTimeLabelFrame {
CGRect PrepTimeLabelFrame {
get {
return new RectangleF (ContentView.Bounds.Width - PrepTimeWidth - TextRightMargin, 4.0f, PrepTimeWidth, 16.0f);
return new CGRect (ContentView.Bounds.Width - PrepTimeWidth - TextRightMargin, 4.0f, PrepTimeWidth, 16.0f);
}
}

Просмотреть файл

@ -23,6 +23,7 @@
<MtouchLink>None</MtouchLink>
<MtouchDebug>True</MtouchDebug>
<MtouchI18n />
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
@ -59,7 +60,9 @@
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
<Reference Include="Xamarin.iOS">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
@ -121,4 +124,4 @@
<ItemGroup>
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -30,8 +30,8 @@ using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Foundation;
using UIKit;
namespace RecipesAndPrinting
{