Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: paulcbetts/BigNerdIOS-MonoDevelop
base: bc043affe8
...
head fork: paulcbetts/BigNerdIOS-MonoDevelop
compare: 8262dbbbd0
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
View
1  Hypnosister/Hypnosister/AppDelegate.cs
@@ -30,6 +30,7 @@ public override bool FinishedLaunching (UIApplication app, NSDictionary options)
var view = new HypnosisView() { Frame = window.Bounds };
window.AddSubview(view);
+ view.BecomeFirstResponder();
window.BackgroundColor = UIColor.White;
View
39 Hypnosister/Hypnosister/HypnosisView.cs
@@ -1,5 +1,6 @@
using System;
using System.Drawing;
+using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace Hypnosister
@@ -9,6 +10,16 @@ public class HypnosisView : UIView
public HypnosisView ()
{
BackgroundColor = UIColor.Clear;
+ CircleColor = UIColor.LightGray;
+ }
+
+ UIColor _CircleColor;
+ public UIColor CircleColor {
+ get { return _CircleColor; }
+ set {
+ _CircleColor = value;
+ SetNeedsDisplay();
+ }
}
public override void Draw (RectangleF rect)
@@ -21,12 +32,23 @@ public override void Draw (RectangleF rect)
var maxRadius = distance(Bounds.Width, Bounds.Height) / 2.0f;
ctx.SetLineWidth(10);
- ctx.SetRGBStrokeColor(0.6f, 0.6f, 0.6f, 1.0f);
+ CircleColor.SetStroke();
for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20.0f) {
ctx.AddArc(center.X, center.Y, currentRadius, 0.0f, (float)Math.PI * 2.0f, true);
ctx.StrokePath();
}
+
+ var text = new NSString("You are getting sleepy.");
+ var font = UIFont.BoldSystemFontOfSize(28.0f);
+ var textSize = text.StringSize(font);
+
+ UIColor.Black.SetFill();
+
+ var offset = new SizeF(4.0f, 3.0f);
+ ctx.SetShadowWithColor(offset, 2.0f, UIColor.DarkGray.CGColor);
+
+ text.DrawString(new PointF(center.X - textSize.Width / 2.0f, center.Y - textSize.Height / 2.0f), font);
}
// In the book they call the C function hypot()
@@ -34,6 +56,21 @@ float distance(float x, float y)
{
return (float)Math.Sqrt(x*x + y*y);
}
+
+ public override bool CanBecomeFirstResponder {
+ get { return true; }
+ }
+
+ public override void MotionBegan (UIEventSubtype motion, UIEvent evt)
+ {
+ base.MotionBegan (motion, evt);
+ if (motion != UIEventSubtype.MotionShake) {
+ return;
+ }
+
+ Console.WriteLine("Device started shaking!");
+ CircleColor = UIColor.Red;
+ }
}
}

No commit comments for this range

Something went wrong with that request. Please try again.