1. Animating the stroke color of a CAShapeLayer with Xamarin

    I wanted to indicate the most recent move in an AI-on-AI game of TicTacToe, so I wanted to have the most recent move be highlighted. The Xs and Os are CAShapeLayer objects.

    Here's the code to do it, ~~featuring a very ugly hack to cast an IntPtr to an NSObject …

    read more
  2. GameplayKit path-finding in iOS 9 with Xamarin.iOS

    Easy-peasy, lemon-squeazy:

    [code lang="csharp"]
    var a = GKGraphNode2D.FromPoint (new Vector2 (0, 5));
    var b = GKGraphNode2D.FromPoint (new Vector2 (3, 0));
    var c = GKGraphNode2D.FromPoint (new Vector2 (2, 6));
    var d = GKGraphNode2D.FromPoint (new Vector2 (4, 6));
    var e = GKGraphNode2D.FromPoint (new Vector2 (6, 5));
    var f = GKGraphNode2D.FromPoint (new …

    read more
  3. FizzBuzz with iOS 9 GameplayKit Expert System in C# with Xam.iOS

    OK, so this is silly, but:

    [code lang="csharp"]
    var clearRule = GKRule.FromPredicate ((rules) => reset, rules => {
    output = "";
    reset = false;
    });
    clearRule.Salience = 1;

    var fizzRule = GKRule.FromPredicate (mod (3), rules => {
    output += "fizz";
    });
    fizzRule.Salience = 2;
    var buzzRule = GKRule.FromPredicate (mod (5), rules => {
    output += "buzz";
    });
    buzzRule.Salience = 2;

    var outputRule = GKRule.FromPredicate …

    read more
  4. How to: Handoff to a Xamarin iPhone app from Apple Watch

    # How to: Handoff to a Xamarin iPhone app from Apple Watch

    There are two ways to activate the parent (aka container) app from an Apple Watch app. You can either directly activate the container app using WKInterfaceController.OpenParentApplication or you can use Handoff.

    Using Handoff is a little more complex …

    read more
  5. The Protocol Pattern

    In C# (and F#), one can define extension methods on interfaces. These extension methods can have implementations, which can be used as default implementations for implementors of the extension. I haven't heard a name for this technique.

    Example:

    [code lang="csharp"]
    interface IFoo
    {

    }

    static class IFoo_Extensions
    {
    public static void …

    read more
  6. Using Xamarin.Forms.Maps: You have to Init() first!

    The first time I wrote a Xamarin.Forms.Maps program, I couldn't figure out why my map wasn't appearing. And then I put a call to Xamarin.FormsMaps.Init() into the AppDelegate (iOS) and MainActivity (Android):

    Shared:

    [code lang="csharp"]
    public class App
    {
    public static Page GetMainPage ()
    {
    return new ContentPage …

    read more
  7. Natively Recognize Barcodes/QR Codes in iOS 7 with Xamarin.iOS

    There have been great barcode-reading libraries available for Xamarin for some time, but iOS 7 has built-in barcode-recognition support.

    There's only one tricky bit: you have to tell the AVCaptureMetadataOutput what types of barcodes you're interested in after you've added it to the AVCaptureSession. (I suppose what happens behind the …

    read more
  8. My Favorite iOS 7 APIs Part 3 : CoreMotion (iPhone 5S only)

    The new M7 coprocessor in the iPhone 5S makes pedometer apps trivial:

    [code lang="csharp"]
    if(CMStepCounter.IsStepCountingAvailable)
    {
    var counter = new CMStepCounter();
    //Last 8 hours
    counter.QueryStepCount(NSDate.FromTimeIntervalSinceNow(-8 * 60 * 60), NSDate.Now, NSOperationQueue.CurrentQueue, StepQueryHandler);
    }

    void StepQueryHandler(int nssteps, NSError error)
    {
    Console.WriteLine(nssteps);
    }
    [/code]

    read more

Page 1 / 2 »

blogroll

social