Reviewing Values for iOS UIViewContentMode with Xamarin and F#

Who can remember the scaling behavior of UIView.ContentMode? Not me!

So I wrote this quick little F# program to review them:

    namespace Simple
     
    open System
    open MonoTouch.UIKit
    open MonoTouch.Foundation
    open System.Drawing
     
    type ContentView ( color : UIColor ) as self = 
        inherit UIView ()
        do
            self.BackgroundColor < - color

    type ContentModeModel  () = 
         inherit UIPickerViewModel ()

         let T = typedefof<UIViewContentMode>

         let selectionChanged = Event<_>()

         member this.SelectionChanged = selectionChanged.Publish 

         override this.GetRowsInComponent(_, _) = Enum.GetNames(T).Length
           
         override this.GetTitle(_, row : int, _) = Enum.GetName(T, row)

         override this.GetComponentCount(_) = 1

         override this.Selected(_, row : int, _) = selectionChanged.Trigger(enum<UIViewContentMode>(row))
       
     
    type SimpleController ( ) =
        inherit UIViewController ()
     
        override this.ViewDidLoad () = 
            this.View < - new ContentView(UIColor.Blue)

            let imgView = new UIImageView(new RectangleF(20.0F, 80.0F, UIScreen.MainScreen.Bounds.Width - 40.0F, 100.0F))
            imgView.Image <- UIImage.FromFile("flower.png")
            imgView.ClipsToBounds <- true
            this.View.AddSubview(imgView)

            let picker = new UIPickerView(new RectangleF(20.0F, UIScreen.MainScreen.Bounds.Height - 180.0F, 250.0F, 140.0F))
            let model = new ContentModeModel()
            picker.Model <- model 

            model.SelectionChanged.Add <| fun newMode -> imgView.ContentMode < - newMode

            this.View.AddSubview(picker)
     
    [<Register ("AppDelegate")>]
    type AppDelegate () =
        inherit UIApplicationDelegate ()
     
        let window = new UIWindow (UIScreen.MainScreen.Bounds)
     
        // This method is invoked when the application is ready to run.
        override this.FinishedLaunching (app, options) =
            let viewController = new SimpleController()
            window.RootViewController < - viewController
            window.MakeKeyAndVisible ()
            true
     
    module Main =
        [<EntryPoint>]
        let main args =
            UIApplication.Main (args, null, "AppDelegate")
            0

No real interesting techniques, but another nice quick iOS app in Xamarin using F#.

contentview

div>