зеркало из https://github.com/xamarin/ios-samples.git
Quotes sample ported to 64-bits
This commit is contained in:
Родитель
64ac381476
Коммит
f891b5b531
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
@ -8,8 +8,8 @@ using System.Xml.Linq;
|
|||
using System.Xml.XPath;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.Foundation;
|
||||
using UIKit;
|
||||
using Foundation;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ namespace Quotes
|
|||
{
|
||||
var layout = new UICollectionViewFlowLayout ();
|
||||
layout.MinimumInteritemSpacing = 20;
|
||||
layout.ItemSize = new SizeF (200.0f, 290.0f);
|
||||
layout.ItemSize = new CGSize (200.0f, 290.0f);
|
||||
|
||||
var collectionView = new UICollectionView (UIScreen.MainScreen.ApplicationFrame, layout);
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace Quotes
|
|||
CollectionView = collectionView;
|
||||
}
|
||||
|
||||
public override int GetItemsCount (UICollectionView collectionView, int section)
|
||||
public override nint GetItemsCount (UICollectionView collectionView, nint section)
|
||||
{
|
||||
return pages.Count;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ namespace Quotes
|
|||
{
|
||||
var cell = (PagePreview)collectionView.DequeueReusableCell (cellName, indexPath);
|
||||
|
||||
cell.Page = pages.ElementAt (indexPath.Row);
|
||||
cell.Page = pages.ElementAt ((int)indexPath.Row);
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace Quotes
|
|||
{
|
||||
var pvc = new PageViewController ();
|
||||
|
||||
pvc.controllerPage = pages.ElementAt (indexPath.Row);
|
||||
pvc.controllerPage = pages.ElementAt ((int)indexPath.Row);
|
||||
|
||||
NavigationController.PushViewController (pvc, true);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ using System.Text.RegularExpressions;
|
|||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.CoreText;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using CoreText;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
@ -17,8 +17,8 @@ namespace Quotes
|
|||
public List<XElement> Paragraphs { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
public int SelectedParagraph { get; set; }
|
||||
public float LineHeight { get; set; }
|
||||
public nint SelectedParagraph { get; set; }
|
||||
public nfloat LineHeight { get; set; }
|
||||
|
||||
public Page (string title, List<XElement> paragraphs)
|
||||
{
|
||||
|
@ -71,7 +71,7 @@ namespace Quotes
|
|||
ligatures: NSLigatureType.None,
|
||||
kerning: 10,
|
||||
underlineStyle: NSUnderlineStyle.Single,
|
||||
shadow: new NSShadow () { ShadowColor = UIColor.Red, ShadowOffset = new System.Drawing.SizeF (5, 5) },
|
||||
shadow: new NSShadow () { ShadowColor = UIColor.Red, ShadowOffset = new CoreGraphics.CGSize (5, 5) },
|
||||
strokeWidth: 5
|
||||
#endif
|
||||
);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
|
||||
using UIKit;
|
||||
using CoreFoundation;
|
||||
using Foundation;
|
||||
using CoreText;
|
||||
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.CoreFoundation;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.CoreText;
|
||||
using MonoTouch.CoreGraphics;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ namespace Quotes
|
|||
cellPage = value;
|
||||
|
||||
var textShadow = new NSShadow () {
|
||||
ShadowOffset = new SizeF (3, 3),
|
||||
ShadowOffset = new CGSize (3, 3),
|
||||
ShadowBlurRadius = 2
|
||||
};
|
||||
|
||||
|
|
|
@ -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 Quotes
|
||||
{
|
||||
|
@ -12,10 +12,10 @@ namespace Quotes
|
|||
partial class PagePreview
|
||||
{
|
||||
[Outlet]
|
||||
MonoTouch.UIKit.UIImageView pageImageView { get; set; }
|
||||
UIKit.UIImageView pageImageView { get; set; }
|
||||
|
||||
[Outlet]
|
||||
MonoTouch.UIKit.UILabel textLabel { get; set; }
|
||||
UIKit.UILabel textLabel { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
using System.Linq;
|
||||
using MonoTouch.UIKit;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.CoreGraphics;
|
||||
using MonoTouch.CoreText;
|
||||
using UIKit;
|
||||
using Foundation;
|
||||
|
||||
using CoreText;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
@ -14,13 +14,13 @@ namespace Quotes
|
|||
{
|
||||
Page page;
|
||||
public bool UnstyledDrawing;
|
||||
RectangleF[] paragraphBounds;
|
||||
CGRect[] paragraphBounds;
|
||||
|
||||
public PageView (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
|
||||
public PageView (RectangleF rect) : base (rect)
|
||||
public PageView (CGRect rect) : base (rect)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace Quotes
|
|||
}
|
||||
}
|
||||
|
||||
public float GetLineHeight ()
|
||||
public nfloat GetLineHeight ()
|
||||
{
|
||||
return page.LineHeight;
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ namespace Quotes
|
|||
* full screen; for full screen rendering, we map the whole view, whereas the preview maps
|
||||
* the whole preview image to a quarter of the page.
|
||||
* */
|
||||
public RectangleF [] RenderPage (Page page, SizeF size, bool unstyledDrawing)
|
||||
public CGRect [] RenderPage (Page page, CGSize size, bool unstyledDrawing)
|
||||
{
|
||||
var pageRect = new RectangleF (0, 0, size.Width, size.Height);
|
||||
var paragraphBounds = new RectangleF [page.Paragraphs.Count];
|
||||
var pageRect = new CGRect (0, 0, size.Width, size.Height);
|
||||
var paragraphBounds = new CGRect [page.Paragraphs.Count];
|
||||
|
||||
using (var ctxt = UIGraphics.GetCurrentContext ()) {
|
||||
// fill background
|
||||
|
@ -84,7 +84,7 @@ namespace Quotes
|
|||
|
||||
int i = 0;
|
||||
foreach (var p in page.Paragraphs) {
|
||||
var bounds = new RectangleF (pageRect.X, pageRect.Y, 0, 0);
|
||||
var bounds = new CGRect (pageRect.X, pageRect.Y, 0, 0);
|
||||
|
||||
if (UnstyledDrawing) {
|
||||
|
||||
|
@ -117,10 +117,10 @@ namespace Quotes
|
|||
}
|
||||
}
|
||||
|
||||
public void SelectParagraphAtPosition (PointF position, bool shouldShowMenu)
|
||||
public void SelectParagraphAtPosition (CGPoint position, bool shouldShowMenu)
|
||||
{
|
||||
page.SelectedParagraph = NSRange.NotFound;
|
||||
var bounds = RectangleF.Empty;
|
||||
var bounds = CGRect.Empty;
|
||||
|
||||
for (int i = 0; i < paragraphBounds.Length; i++) {
|
||||
bounds = paragraphBounds [i];
|
||||
|
@ -143,14 +143,14 @@ namespace Quotes
|
|||
UpdatePage ();
|
||||
}
|
||||
|
||||
public UIImage RenderPagePreview (Page page, SizeF size)
|
||||
public UIImage RenderPagePreview (Page page, CGSize size)
|
||||
{
|
||||
UIGraphics.BeginImageContextWithOptions (size, true, 0.0f);
|
||||
|
||||
var scale = CGAffineTransform.MakeScale (0.5f, 0.5f);
|
||||
UIGraphics.GetCurrentContext ().ConcatCTM (scale);
|
||||
|
||||
RenderPage (page, new SizeF (1024, 768), false);
|
||||
RenderPage (page, new CGSize (1024, 768), false);
|
||||
|
||||
var ret = UIGraphics.GetImageFromCurrentImageContext ();
|
||||
|
||||
|
@ -159,7 +159,7 @@ namespace Quotes
|
|||
return ret;
|
||||
}
|
||||
|
||||
public UIImage RenderPageWithSize (SizeF size)
|
||||
public UIImage RenderPageWithSize (CGSize size)
|
||||
{
|
||||
UIGraphics.BeginImageContextWithOptions (size, true, 0.0f);
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using CoreGraphics;
|
||||
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Quotes
|
||||
{
|
||||
|
@ -38,24 +38,24 @@ namespace Quotes
|
|||
}
|
||||
}
|
||||
|
||||
partial void ParagraphSelected (MonoTouch.UIKit.UILongPressGestureRecognizer sender)
|
||||
partial void ParagraphSelected (UIKit.UILongPressGestureRecognizer sender)
|
||||
{
|
||||
pageView.SelectParagraphAtPosition (sender.LocationInView (pageView),
|
||||
sender.State == MonoTouch.UIKit.UIGestureRecognizerState.Ended);
|
||||
sender.State == UIKit.UIGestureRecognizerState.Ended);
|
||||
}
|
||||
|
||||
partial void DrawingModeToggled (MonoTouch.UIKit.UISwipeGestureRecognizer sender)
|
||||
partial void DrawingModeToggled (UIKit.UISwipeGestureRecognizer sender)
|
||||
{
|
||||
pageView.UnstyledDrawing = !pageView.UnstyledDrawing;
|
||||
pageView.UpdatePage ();
|
||||
}
|
||||
|
||||
partial void MenuDismissed (MonoTouch.UIKit.UITapGestureRecognizer sender)
|
||||
partial void MenuDismissed (UIKit.UITapGestureRecognizer sender)
|
||||
{
|
||||
pageView.SelectParagraphAtPosition (new System.Drawing.PointF (-100.0f, -100.0f), false);
|
||||
pageView.SelectParagraphAtPosition (new CoreGraphics.CGPoint (-100.0f, -100.0f), false);
|
||||
}
|
||||
|
||||
partial void LineHeightChanged (MonoTouch.UIKit.UISlider sender)
|
||||
partial void LineHeightChanged (UIKit.UISlider sender)
|
||||
{
|
||||
pageView.SetLineHeight (sender.Value);
|
||||
}
|
||||
|
|
|
@ -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 Quotes
|
||||
{
|
||||
|
@ -15,16 +15,16 @@ namespace Quotes
|
|||
Quotes.PageView pageView { get; set; }
|
||||
|
||||
[Action ("ParagraphSelected:")]
|
||||
partial void ParagraphSelected (MonoTouch.UIKit.UILongPressGestureRecognizer sender);
|
||||
partial void ParagraphSelected (UIKit.UILongPressGestureRecognizer sender);
|
||||
|
||||
[Action ("DrawingModeToggled:")]
|
||||
partial void DrawingModeToggled (MonoTouch.UIKit.UISwipeGestureRecognizer sender);
|
||||
partial void DrawingModeToggled (UIKit.UISwipeGestureRecognizer sender);
|
||||
|
||||
[Action ("MenuDismissed:")]
|
||||
partial void MenuDismissed (MonoTouch.UIKit.UITapGestureRecognizer sender);
|
||||
partial void MenuDismissed (UIKit.UITapGestureRecognizer sender);
|
||||
|
||||
[Action ("LineHeightChanged:")]
|
||||
partial void LineHeightChanged (MonoTouch.UIKit.UISlider sender);
|
||||
partial void LineHeightChanged (UIKit.UISlider sender);
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<AssemblyName>Quotes</AssemblyName>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
|
@ -103,7 +104,9 @@
|
|||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<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" />
|
||||
|
@ -164,4 +167,4 @@
|
|||
<ItemGroup>
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Загрузка…
Ссылка в новой задаче