Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…-book-samples into jamessdixon-master
  • Loading branch information
lobrien committed Jun 5, 2019
2 parents 93795f5 + 196c614 commit 6d78ade
Show file tree
Hide file tree
Showing 38 changed files with 978 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added Chapter08/.DS_Store
Binary file not shown.
Binary file added Chapter09/.DS_Store
Binary file not shown.
Binary file added Chapter09/DisplayPlatformInfo/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file added Chapter09/FS/.DS_Store
Binary file not shown.
41 changes: 41 additions & 0 deletions Chapter09/FS/DisplayPlatformInfo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Autosave files
*~

# build
[Oo]bj/
[Bb]in/
packages/
TestResults/

# globs
Makefile.in
*.DS_Store
*.sln.cache
*.suo
*.cache
*.pidb
*.userprefs
*.usertasks
config.log
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.user
*.tar.gz
tarballs/
test-results/
Thumbs.db
.vs/

# Mac bundle stuff
*.dmg
*.app

# resharper
*_Resharper.*
*.Resharper

# dotCover
*.dotCover
45 changes: 45 additions & 0 deletions Chapter09/FS/DisplayPlatformInfo/DisplayPlatformInfo.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "DisplayPlatformInfo", "DisplayPlatformInfo\DisplayPlatformInfo.shproj", "{F9A4A10A-9582-4579-9B0F-451F8D57C850}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "DisplayPlatformInfo.iOS", "iOS\DisplayPlatformInfo.iOS.fsproj", "{B79B9A0C-926D-4848-B3B1-62A54E0931DA}"
EndProject
Project("{f2a71f9b-5d33-465a-a702-920d77279786}") = "DisplayPlatformInfo.Droid", "Droid\DisplayPlatformInfo.Droid.fsproj", "{C0486668-642D-467E-9879-84C32B1D2933}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|iPhone.ActiveCfg = Release|iPhone
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|iPhone.Build.0 = Release|iPhone
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|iPhone.ActiveCfg = Debug|iPhone
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|iPhone.Build.0 = Debug|iPhone
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|Any CPU.ActiveCfg = Release|iPhone
{B79B9A0C-926D-4848-B3B1-62A54E0931DA}.Release|Any CPU.Build.0 = Release|iPhone
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|iPhone.ActiveCfg = Release|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|iPhone.Build.0 = Release|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|iPhone.Build.0 = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0486668-642D-467E-9879-84C32B1D2933}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions Chapter09/FS/DisplayPlatformInfo/DisplayPlatformInfo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="DisplayPlatformInfo.App">
<Application.Resources>
<!-- Application resource dictionary -->
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace DisplayPlatformInfo

open Xamarin.Forms

type App() =
inherit Application(MainPage = MainPage())
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>{F9A4A10A-9582-4579-9B0F-451F8D57C850}</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>DisplayPlatformInfo</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)MainPage.xaml" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)App.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)IPlatformInfo.fs" />
<Compile Include="$(MSBuildThisFileDirectory)MainPage.xaml.fs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)App.xaml.fs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{F9A4A10A-9582-4579-9B0F-451F8D57C850}</ProjectGuid>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<Import Project="DisplayPlatformInfo.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.FSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace DisplayPlatformInfo

type public IPlatformInfo =
abstract member GetModel : unit -> string
abstract member GetVersion : unit -> string
24 changes: 24 additions & 0 deletions Chapter09/FS/DisplayPlatformInfo/DisplayPlatformInfo/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DisplayPlatformInfo.MainPage">
<StackLayout Padding="20">
<StackLayout VerticalOptions="CenterAndExpand">
<Label Text="Device Model:" />
<ContentView Padding="50, 0, 0, 0">
<Label x:Name="modelLabel"
FontSize="Large"
FontAttributes="Bold" />
</ContentView>
</StackLayout>

<StackLayout VerticalOptions="CenterAndExpand">
<Label Text="Operating System Version:" />
<ContentView Padding="50, 0, 0, 0">
<Label x:Name="versionLabel"
FontSize="Large"
FontAttributes="Bold" />
</ContentView>
</StackLayout>
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace DisplayPlatformInfo

open Xamarin.Forms
open Xamarin.Forms.Xaml

type MainPage() =
inherit ContentPage()
let _ = base.LoadFromXaml(typeof<MainPage>)
let platformInfo = DependencyService.Get<IPlatformInfo>()
let baseStack = base.Content :?> StackLayout
let stack0 = baseStack.Children.[0] :?> StackLayout
let stack1 = baseStack.Children.[1] :?> StackLayout
let contentView0 = stack0.Children.[1] :?> ContentView
let contentView1 = stack1.Children.[1] :?> ContentView
let label0 = contentView0.Children.[0] :?> Label
let label1 = contentView1.Children.[0] :?> Label

do
label0.Text <- platformInfo.GetModel()
label1.Text <- platformInfo.GetVersion();





19 changes: 19 additions & 0 deletions Chapter09/FS/DisplayPlatformInfo/Droid/Assets/AboutAssets.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories) and given a Build Action of "AndroidAsset".

These files will be deployed with your package and will be accessible using Android's
AssetManager, like this:

public class ReadAsset : Activity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);

InputStream input = Assets.Open ("my_asset.txt");
}
}

Additionally, some Android functions will automatically load asset files:

Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
Loading

0 comments on commit 6d78ade

Please sign in to comment.