Skip to content

Instantly share code, notes, and snippets.

View Clancey's full-sized avatar

James Clancey Clancey

View GitHub Profile
@Clancey
Clancey / myIphoneDataSource
Created April 28, 2010 04:52
myIphoneDataSource
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
public class MyDatasource : UITableViewDataSource
{
object[] dataArray;
public class PolygonOverlay : MKPolygonView{
private MKPolygon _polygon;
public PolygonOverlay(MKPolygon polygon)
{
_polygon = polygon;
}
public CGPath polyPath(MKPolygon polygon)
{
[Register("RotatingViewController")]
public partial class RotatingViewController : UIViewController
{
public UIViewController LandscapeLeftViewController {get;set;}
public UIViewController LandscapeRightViewController {get;set;}
public UIViewController PortraitViewController {get;set;}
private NSObject notificationObserver;
public RotatingViewController (IntPtr handle) : base(handle)
public partial class AppDelegate : UIApplicationDelegate
{
CLLocationManager _iPhoneLocationManager = null;
LocationDelegate _locationDelegate = null;
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
@Clancey
Clancey / ScrollBarWithHeaderView
Created July 13, 2010 23:56
ScrollViewWithHeader
public class ScrollViewWithHeader : UIView
{
private UIView _content;
private UIScrollView _header;
private UIView _headerContent;
private MyScrollViewDelegate _headerDelegate;
private RectangleF _headerFrame;
private UIScrollView _mainContent;
private MyScrollViewDelegate _mainContentDelegate;
@Clancey
Clancey / Adjust an Image
Created July 16, 2010 21:35
Allows on the fly change the properties of an image
public static UIImage AdjustImage(RectangleF rect,UIImage template, CGBlendMode mode,float red,float green,float blue,float alpha )
{
using (var cs = CGColorSpace.CreateDeviceRGB ()){
using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height*4, cs, CGImageAlphaInfo.PremultipliedLast)){
context.TranslateCTM(0.0f,0f);
//context.ScaleCTM(1.0f,-1.0f);
context.DrawImage(rect,template.CGImage);
context.SetBlendMode(mode);
context.ClipToMask(rect,template.CGImage);
/*
// example
MyMoviePlayer movieView = new MyMoviePlayer(window.Bounds) { MovieUrl = new NSUrl("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8")};
movieView.Play();
movieView.Done += delegate{
movieView.RemoveFromSuperview();
}
window.AddSubview (movieView);
*/
/// this is the first pass/untested translation of the code used in the store kit from this tutorial http://troybrant.net/blog/2010/01/in-app-purchases-a-full-walkthrough/
using System;
using MonoTouch.StoreKit;
using MonoTouch.Foundation;
using System.Globalization;
using System.Threading;
namespace StoreKitExample
{
@Clancey
Clancey / resume
Created October 5, 2010 07:36
Downloader with background completion/resume and progress message
using System;
using System.Collections.Generic;
using System.Threading;
using MonoTouch.Foundation;
using System.IO;
using MonoTouch.UIKit;
/// <summary>
/// Static downloader class.
/// This class will download files one at a time.
using System;
using System.Drawing;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;
namespace BundlerCrash
{
public partial class AppDelegate : NSApplicationDelegate
{