Added F# version of TableParts

Included conversions for 64bit type
Included numerical constants too.
This commit is contained in:
7sharp9 2014-08-05 20:13:44 +01:00
Родитель 85e8546616
Коммит 093a63fd9a
9 изменённых файлов: 324 добавлений и 1 удалений

Просмотреть файл

@ -3,14 +3,22 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableParts", "TableParts\TableParts.csproj", "{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "TablePartsFS", "TablePartsFS\TablePartsFS.fsproj", "{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
Ad-Hoc|iPhone = Ad-Hoc|iPhone
AppStore|iPhone = AppStore|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Ad-Hoc|iPhone.ActiveCfg = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Ad-Hoc|iPhone.Build.0 = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.AppStore|iPhone.ActiveCfg = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.AppStore|iPhone.Build.0 = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Debug|iPhone.ActiveCfg = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Debug|iPhone.Build.0 = Debug|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
@ -19,8 +27,20 @@ Global
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Release|iPhone.Build.0 = Release|iPhone
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{30CC7D7B-7DD0-4A6E-B483-D83ADB46A2B7}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.AppStore|iPhone.Build.0 = AppStore|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Debug|iPhone.ActiveCfg = Debug|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Debug|iPhone.Build.0 = Debug|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Release|iPhone.ActiveCfg = Release|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Release|iPhone.Build.0 = Release|iPhone
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = TableParts\TableParts.csproj
StartupItem = TablePartsFS\TablePartsFS.fsproj
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,32 @@
namespace TablePartsFS
open System
open UIKit
open Foundation
open Conversion
[<Register("AppDelegate")>]
type AppDelegate () =
inherit UIApplicationDelegate()
let mutable window = null
override x.FinishedLaunching (app, options) =
// create our window
window <- new UIWindow (UIScreen.MainScreen.Bounds)
window.MakeKeyAndVisible ()
// create the home screen and modify it's frame
let iPhoneHome = new HomeScreen()
iPhoneHome.View.Frame <- CoreGraphics.CGRect (nfloat 0,
UIApplication.SharedApplication.StatusBarFrame.Height,
UIScreen.MainScreen.ApplicationFrame.Width,
UIScreen.MainScreen.ApplicationFrame.Height)
window.RootViewController <- iPhoneHome
true
module Main =
[<EntryPoint>]
let main args =
UIApplication.Main(args, null, "AppDelegate")
0

Просмотреть файл

@ -0,0 +1,34 @@
namespace TablePartsFS
open System
////Q, R, Z, I, N, or G
module NumericLiteralZ =
let FromZero() = nfloat.op_Implicit(0)
let FromOne() = nfloat.op_Implicit(1)
let FromInt16 (n:int16) = nfloat.op_Implicit(n)
let FromInt32 (n:int) = nfloat.op_Implicit(n)
let FromInt64 (n:int64) = nfloat.op_Implicit(n)
let FromString (n:string) = nfloat.Parse(n)
module NumericLiteralI =
let FromZero() = nint.op_Implicit(0)
let FromOne() = nint.op_Implicit(1)
let FromInt16 (n:int16) = nint.op_Implicit(n)
let FromInt32 (n:int) = nint.op_Implicit(n)
let FromString (n:string) = nint.Parse(n)
module NumericLiteralN =
let FromZero() = nuint.op_Implicit(0u)
let FromOne() = nuint.op_Implicit(1u)
let FromUInt16 (n:UInt16) = nuint.op_Implicit(n)
let FromUInt32 (n:UInt32) = nuint.op_Implicit(n)
let FromString (n:string) = nuint.Parse(n)
module Conversion =
let inline implicit< ^a,^b when ^a : (static member op_Implicit : ^b -> ^a)> arg =
(^a : (static member op_Implicit : ^b -> ^a) arg)
let inline nint (x:^a) : ^b = ((^a or ^b) : (static member op_Implicit : ^a -> nint) x)
let inline nfloat (x:^a) : ^b = ((^a or ^b) : (static member op_Implicit : ^a -> nfloat) x)
let inline nuint (x:^a) : ^b = ((^a or ^b) : (static member op_Implicit : ^a -> nuint) x)

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,23 @@
namespace TablePartsFS
open System
open UIKit
open Foundation
open System.Collections.Generic
[<AllowNullLiteral>]
type HomeScreen =
inherit UITableViewController
new () = {inherit UITableViewController (UITableViewStyle.Grouped)}
new (handle:IntPtr) = {inherit UITableViewController (handle)}
[<Export ("initWithCoder:")>]
new (coder:NSCoder) = {inherit UITableViewController (coder)}
// Creates a set of table items.
member x.CreateTableItems () =
new TableSource [|{Name = "Section 0 Header"; Footer = "Section 0 Footer"; Items = ["Row 0";"Row 1";"Row 2"]}
{Name = "Section 1 Header"; Footer = "Section 1 Footer"; Items = ["Row 0";"Row 1";"Row 2"]}
{Name = "Section 2 Header"; Footer = "Section 2 Footer"; Items = ["Row 0";"Row 1";"Row 2"]}|]
override x.ViewDidLoad () =
base.ViewDidLoad ()
x.TableView.Source <- x.CreateTableItems ()

Просмотреть файл

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>MinimumOSVersion</key>
<string>3.2</string>
</dict>
</plist>

Двоичные данные
TableParts/TablePartsFS/Resources/Default-568h@2x.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.2 KiB

Просмотреть файл

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{F2A71F9B-5D33-465A-A702-920D77279786}</ProjectTypeGuids>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{ABF7D8BA-BF6F-4D0E-B330-15405C1E55A0}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>TablePartsFS</RootNamespace>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
<AssemblyName>TablePartsFS</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;XAMCORE_2_0;ARCH_64</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<Tailcalls>false</Tailcalls>
<ConsolePause>false</ConsolePause>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<PlatformTarget>
</PlatformTarget>
<MtouchDebug>true</MtouchDebug>
<MtouchLink>None</MtouchLink>
<MtouchExtraArgs>--registrar:static --nofastsim --override-abi x86_64</MtouchExtraArgs>
<MtouchI18n>
</MtouchI18n>
<MtouchArch>i386</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget>
</PlatformTarget>
<MtouchLink>None</MtouchLink>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<ConsolePause>false</ConsolePause>
<Tailcalls>true</Tailcalls>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<Tailcalls>false</Tailcalls>
<ConsolePause>false</ConsolePause>
<MtouchDebug>true</MtouchDebug>
<PlatformTarget>
</PlatformTarget>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget>
</PlatformTarget>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>iPhone Developer</CodesignKey>
<ConsolePause>false</ConsolePause>
<Tailcalls>true</Tailcalls>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget>
</PlatformTarget>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<BuildIpa>true</BuildIpa>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
<ConsolePause>false</ConsolePause>
<Tailcalls>true</Tailcalls>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\AppStore</OutputPath>
<ErrorReport>prompt</ErrorReport>
<PlatformTarget>
</PlatformTarget>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<CodesignKey>iPhone Distribution</CodesignKey>
<CodesignProvision>Automatic:AppStore</CodesignProvision>
<ConsolePause>false</ConsolePause>
<Tailcalls>true</Tailcalls>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core" />
<Reference Include="Xamarin.iOS">
<HintPath>\Developer\MonoTouch\usr\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Default-568h%402x.png" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
</ItemGroup>
<ItemGroup>
<Compile Include="Conversion.fs" />
<Compile Include="TableSource.fs" />
<Compile Include="Home.fs" />
<Compile Include="AppDelegate.fs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.1\Framework\v4.0\Microsoft.FSharp.Targets" />
</Project>

Просмотреть файл

@ -0,0 +1,54 @@
namespace TablePartsFS
open System
open System.Linq
open UIKit
open System.Collections.Generic
open Foundation
open Conversion
type TableItemGroup = {Name : string; Footer : string; Items : string list}
type TableSource(tableItems: TableItemGroup array) =
inherit UITableViewSource()
let cellIdentifier = "TableCell"
/// Called by the TableView to determine how many sections(groups) there are.
override x.NumberOfSections (tableView) =
implicit tableItems.Length
/// Called by the TableView to determine how many cells to create for that particular section.
override x.RowsInSection (tableview, section) =
nint (tableItems.[int section].Items.Count())
/// Called by the TableView to retrieve the header text for the particular section(group)
override x.TitleForHeader (tableView, section) =
let title = tableItems.[int section].Name
title
/// Called by the TableView to retrieve the footer text for the particular section(group)
override x.TitleForFooter (tableView, section) =
tableItems.[int section].Footer
override x.RowSelected (tableView, indexPath) =
(new UIAlertView ("Row Selected", tableItems.[int indexPath.Section].Items.[int indexPath.Row], null, "OK", null)).Show ()
override x.RowDeselected (tableView, indexPath) =
printfn "Row %s deselected" <| indexPath.Row.ToString()
/// Called by the TableView to get the actual UITableViewCell to render for the particular section and row
override x.GetCell (tableView, indexPath) =
printfn "Calling Get Cell, isEditing:%b" tableView.Editing
// declare vars
let cell =
match tableView.DequeueReusableCell (cellIdentifier) with
// if there are no cells to reuse, create a new one
| null -> new UITableViewCell (UITableViewCellStyle.Default, cellIdentifier)
| a -> a
// set the item text
cell.TextLabel.Text <- tableItems.[int indexPath.Section].Items.[int indexPath.Row]
cell