From 10fdfe64e20d7b462988e24551b56eb252b3bd17 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 16 Jun 2018 00:18:27 +0100 Subject: [PATCH 01/29] Created the console program. --- Smouldering Beach Ball.sln | 25 ++++++ Smouldering Beach Ball/App.config | 6 ++ Smouldering Beach Ball/AssemblyInfo.fs | 41 +++++++++ Smouldering Beach Ball/Program.fs | 7 ++ .../Smouldering Beach Ball.fsproj | 84 +++++++++++++++++++ Smouldering Beach Ball/packages.config | 4 + 6 files changed, 167 insertions(+) create mode 100644 Smouldering Beach Ball.sln create mode 100644 Smouldering Beach Ball/App.config create mode 100644 Smouldering Beach Ball/AssemblyInfo.fs create mode 100644 Smouldering Beach Ball/Program.fs create mode 100644 Smouldering Beach Ball/Smouldering Beach Ball.fsproj create mode 100644 Smouldering Beach Ball/packages.config diff --git a/Smouldering Beach Ball.sln b/Smouldering Beach Ball.sln new file mode 100644 index 0000000..4eadf32 --- /dev/null +++ b/Smouldering Beach Ball.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27703.2026 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldering Beach Ball", "Smouldering Beach Ball\Smouldering Beach Ball.fsproj", "{F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B081B383-0027-4016-B9DA-B77383FA2E92} + EndGlobalSection +EndGlobal diff --git a/Smouldering Beach Ball/App.config b/Smouldering Beach Ball/App.config new file mode 100644 index 0000000..787dcbe --- /dev/null +++ b/Smouldering Beach Ball/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Smouldering Beach Ball/AssemblyInfo.fs b/Smouldering Beach Ball/AssemblyInfo.fs new file mode 100644 index 0000000..f07f9a9 --- /dev/null +++ b/Smouldering Beach Ball/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Smouldering_Beach_Ball.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/Smouldering Beach Ball/Program.fs b/Smouldering Beach Ball/Program.fs new file mode 100644 index 0000000..2bcf7f9 --- /dev/null +++ b/Smouldering Beach Ball/Program.fs @@ -0,0 +1,7 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +[] +let main argv = + printfn "%A" argv + 0 // return an integer exit code diff --git a/Smouldering Beach Ball/Smouldering Beach Ball.fsproj b/Smouldering Beach Ball/Smouldering Beach Ball.fsproj new file mode 100644 index 0000000..630a828 --- /dev/null +++ b/Smouldering Beach Ball/Smouldering Beach Ball.fsproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + 2.0 + f7e9c02a-2abf-49ea-a582-07ea7fa17efe + Exe + Smouldering_Beach_Ball + Smouldering_Beach_Ball + v4.7.1 + true + true + 4.4.3.0 + Smouldering Beach Ball + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + True + + + + \ No newline at end of file diff --git a/Smouldering Beach Ball/packages.config b/Smouldering Beach Ball/packages.config new file mode 100644 index 0000000..b4aca10 --- /dev/null +++ b/Smouldering Beach Ball/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 6596481558b6e852f160444cb6f27c959c0d2de9 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 16 Jun 2018 00:33:14 +0100 Subject: [PATCH 02/29] Created the library. Removed console project for naming reasons. Easier to delete and start again. --- ...each Ball.sln => Smouldeing Beach Ball.sln | 12 +++++----- .../AssemblyInfo.fs | 8 +++---- Smouldeing Beach Ball/Library1.fs | 4 ++++ .../Script.fsx | 9 ++++---- .../Smouldeing Beach Ball.fsproj | 22 ++++++++----------- .../packages.config | 0 Smouldering Beach Ball/App.config | 6 ----- 7 files changed, 28 insertions(+), 33 deletions(-) rename Smouldering Beach Ball.sln => Smouldeing Beach Ball.sln (57%) rename {Smouldering Beach Ball => Smouldeing Beach Ball}/AssemblyInfo.fs (85%) create mode 100644 Smouldeing Beach Ball/Library1.fs rename Smouldering Beach Ball/Program.fs => Smouldeing Beach Ball/Script.fsx (51%) rename Smouldering Beach Ball/Smouldering Beach Ball.fsproj => Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj (88%) rename {Smouldering Beach Ball => Smouldeing Beach Ball}/packages.config (100%) delete mode 100644 Smouldering Beach Ball/App.config diff --git a/Smouldering Beach Ball.sln b/Smouldeing Beach Ball.sln similarity index 57% rename from Smouldering Beach Ball.sln rename to Smouldeing Beach Ball.sln index 4eadf32..49386e5 100644 --- a/Smouldering Beach Ball.sln +++ b/Smouldeing Beach Ball.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27703.2026 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldering Beach Ball", "Smouldering Beach Ball\Smouldering Beach Ball.fsproj", "{F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}" +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldeing Beach Ball", "Smouldeing Beach Ball\Smouldeing Beach Ball.fsproj", "{7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F7E9C02A-2ABF-49EA-A582-07EA7FA17EFE}.Release|Any CPU.Build.0 = Release|Any CPU + {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B081B383-0027-4016-B9DA-B77383FA2E92} + SolutionGuid = {35E66E82-0589-48AE-B937-66D3E84E1B3A} EndGlobalSection EndGlobal diff --git a/Smouldering Beach Ball/AssemblyInfo.fs b/Smouldeing Beach Ball/AssemblyInfo.fs similarity index 85% rename from Smouldering Beach Ball/AssemblyInfo.fs rename to Smouldeing Beach Ball/AssemblyInfo.fs index f07f9a9..ceeb402 100644 --- a/Smouldering Beach Ball/AssemblyInfo.fs +++ b/Smouldeing Beach Ball/AssemblyInfo.fs @@ -1,4 +1,4 @@ -namespace Smouldering_Beach_Ball.AssemblyInfo +namespace Smouldeing_Beach_Ball.AssemblyInfo open System.Reflection open System.Runtime.CompilerServices @@ -7,11 +7,11 @@ open System.Runtime.InteropServices // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[] +[] [] [] [] -[] +[] [] [] [] @@ -22,7 +22,7 @@ open System.Runtime.InteropServices [] // The following GUID is for the ID of the typelib if this project is exposed to COM -[] +[] // Version information for an assembly consists of the following four values: // diff --git a/Smouldeing Beach Ball/Library1.fs b/Smouldeing Beach Ball/Library1.fs new file mode 100644 index 0000000..09156f5 --- /dev/null +++ b/Smouldeing Beach Ball/Library1.fs @@ -0,0 +1,4 @@ +namespace Smouldeing_Beach_Ball + +type Class1() = + member this.X = "F#" diff --git a/Smouldering Beach Ball/Program.fs b/Smouldeing Beach Ball/Script.fsx similarity index 51% rename from Smouldering Beach Ball/Program.fs rename to Smouldeing Beach Ball/Script.fsx index 2bcf7f9..a16cb11 100644 --- a/Smouldering Beach Ball/Program.fs +++ b/Smouldeing Beach Ball/Script.fsx @@ -1,7 +1,8 @@ // Learn more about F# at http://fsharp.org // See the 'F# Tutorial' project for more help. -[] -let main argv = - printfn "%A" argv - 0 // return an integer exit code +#load "Library1.fs" +open Smouldeing_Beach_Ball + +// Define your library scripting code here + diff --git a/Smouldering Beach Ball/Smouldering Beach Ball.fsproj b/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj similarity index 88% rename from Smouldering Beach Ball/Smouldering Beach Ball.fsproj rename to Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj index 630a828..86000b2 100644 --- a/Smouldering Beach Ball/Smouldering Beach Ball.fsproj +++ b/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj @@ -5,15 +5,15 @@ Debug AnyCPU 2.0 - f7e9c02a-2abf-49ea-a582-07ea7fa17efe - Exe - Smouldering_Beach_Ball - Smouldering_Beach_Ball - v4.7.1 - true + 7c2b506a-a7db-4b97-8443-befdf57e95ae + Library + Smouldeing_Beach_Ball + Smouldeing_Beach_Ball true + v4.7.1 4.4.3.0 - Smouldering Beach Ball + true + Smouldeing Beach Ball true @@ -23,9 +23,7 @@ bin\$(Configuration)\ DEBUG;TRACE 3 - AnyCPU bin\$(Configuration)\$(AssemblyName).XML - true pdbonly @@ -34,9 +32,7 @@ bin\$(Configuration)\ TRACE 3 - AnyCPU bin\$(Configuration)\$(AssemblyName).XML - true 11 @@ -56,8 +52,8 @@ - - + + diff --git a/Smouldering Beach Ball/packages.config b/Smouldeing Beach Ball/packages.config similarity index 100% rename from Smouldering Beach Ball/packages.config rename to Smouldeing Beach Ball/packages.config diff --git a/Smouldering Beach Ball/App.config b/Smouldering Beach Ball/App.config deleted file mode 100644 index 787dcbe..0000000 --- a/Smouldering Beach Ball/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 0eae26e6b5abd9a223221422ed032ac8f8f21081 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 16 Jun 2018 00:35:23 +0100 Subject: [PATCH 03/29] Remade console program. Name is different from original one. --- Smouldeing Beach Ball.sln | 6 ++ Smouldering Beach Ball CLI/App.config | 6 ++ Smouldering Beach Ball CLI/AssemblyInfo.fs | 41 +++++++++ Smouldering Beach Ball CLI/Program.fs | 7 ++ .../Smouldering Beach Ball CLI.fsproj | 84 +++++++++++++++++++ Smouldering Beach Ball CLI/packages.config | 4 + 6 files changed, 148 insertions(+) create mode 100644 Smouldering Beach Ball CLI/App.config create mode 100644 Smouldering Beach Ball CLI/AssemblyInfo.fs create mode 100644 Smouldering Beach Ball CLI/Program.fs create mode 100644 Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj create mode 100644 Smouldering Beach Ball CLI/packages.config diff --git a/Smouldeing Beach Ball.sln b/Smouldeing Beach Ball.sln index 49386e5..7da3d03 100644 --- a/Smouldeing Beach Ball.sln +++ b/Smouldeing Beach Ball.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.27703.2026 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldeing Beach Ball", "Smouldeing Beach Ball\Smouldeing Beach Ball.fsproj", "{7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldering Beach Ball CLI", "Smouldering Beach Ball CLI\Smouldering Beach Ball CLI.fsproj", "{18B85D45-9A87-4174-B0DC-C5F7B77921F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.Build.0 = Release|Any CPU + {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Smouldering Beach Ball CLI/App.config b/Smouldering Beach Ball CLI/App.config new file mode 100644 index 0000000..787dcbe --- /dev/null +++ b/Smouldering Beach Ball CLI/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/AssemblyInfo.fs b/Smouldering Beach Ball CLI/AssemblyInfo.fs new file mode 100644 index 0000000..13b4e5b --- /dev/null +++ b/Smouldering Beach Ball CLI/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Smouldering_Beach_Ball_CLI.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/Program.fs b/Smouldering Beach Ball CLI/Program.fs new file mode 100644 index 0000000..2bcf7f9 --- /dev/null +++ b/Smouldering Beach Ball CLI/Program.fs @@ -0,0 +1,7 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +[] +let main argv = + printfn "%A" argv + 0 // return an integer exit code diff --git a/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj b/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj new file mode 100644 index 0000000..c07e1fd --- /dev/null +++ b/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + 2.0 + 18b85d45-9a87-4174-b0dc-c5f7b77921f3 + Exe + Smouldering_Beach_Ball_CLI + Smouldering_Beach_Ball_CLI + v4.7.1 + true + true + 4.4.3.0 + Smouldering Beach Ball CLI + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + True + + + + \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/packages.config b/Smouldering Beach Ball CLI/packages.config new file mode 100644 index 0000000..b4aca10 --- /dev/null +++ b/Smouldering Beach Ball CLI/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From b73a1d3a01ade96996a143b5f66ac52853313494 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 16 Jun 2018 00:37:17 +0100 Subject: [PATCH 04/29] Created the test centre. --- Smouldeing Beach Ball.sln | 6 +++ Test Centre/AssemblyInfo.fs | 41 +++++++++++++++++ Test Centre/Library1.fs | 4 ++ Test Centre/Script.fsx | 8 ++++ Test Centre/Test Centre.fsproj | 80 ++++++++++++++++++++++++++++++++++ Test Centre/packages.config | 4 ++ 6 files changed, 143 insertions(+) create mode 100644 Test Centre/AssemblyInfo.fs create mode 100644 Test Centre/Library1.fs create mode 100644 Test Centre/Script.fsx create mode 100644 Test Centre/Test Centre.fsproj create mode 100644 Test Centre/packages.config diff --git a/Smouldeing Beach Ball.sln b/Smouldeing Beach Ball.sln index 7da3d03..d173c3a 100644 --- a/Smouldeing Beach Ball.sln +++ b/Smouldeing Beach Ball.sln @@ -7,6 +7,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldeing Beach Ball", "Sm EndProject Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldering Beach Ball CLI", "Smouldering Beach Ball CLI\Smouldering Beach Ball CLI.fsproj", "{18B85D45-9A87-4174-B0DC-C5F7B77921F3}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Test Centre", "Test Centre\Test Centre.fsproj", "{0571746B-5FDC-4D98-84DC-5B98D1801964}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Debug|Any CPU.Build.0 = Debug|Any CPU {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.Build.0 = Release|Any CPU + {0571746B-5FDC-4D98-84DC-5B98D1801964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0571746B-5FDC-4D98-84DC-5B98D1801964}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0571746B-5FDC-4D98-84DC-5B98D1801964}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0571746B-5FDC-4D98-84DC-5B98D1801964}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Test Centre/AssemblyInfo.fs b/Test Centre/AssemblyInfo.fs new file mode 100644 index 0000000..8347fd3 --- /dev/null +++ b/Test Centre/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace Test_Centre.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/Test Centre/Library1.fs b/Test Centre/Library1.fs new file mode 100644 index 0000000..ad02a4d --- /dev/null +++ b/Test Centre/Library1.fs @@ -0,0 +1,4 @@ +namespace Test_Centre + +type Class1() = + member this.X = "F#" diff --git a/Test Centre/Script.fsx b/Test Centre/Script.fsx new file mode 100644 index 0000000..7f57a26 --- /dev/null +++ b/Test Centre/Script.fsx @@ -0,0 +1,8 @@ +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +#load "Library1.fs" +open Test_Centre + +// Define your library scripting code here + diff --git a/Test Centre/Test Centre.fsproj b/Test Centre/Test Centre.fsproj new file mode 100644 index 0000000..69079fb --- /dev/null +++ b/Test Centre/Test Centre.fsproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + 2.0 + 0571746b-5fdc-4d98-84dc-5b98d1801964 + Library + Test_Centre + Test_Centre + true + v4.7.1 + 4.4.3.0 + true + Test Centre + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + bin\$(Configuration)\$(AssemblyName).XML + + + 11 + + + + + $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets + + + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + + + + FSharp.Core + FSharp.Core.dll + $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll + + + + + + True + + + + \ No newline at end of file diff --git a/Test Centre/packages.config b/Test Centre/packages.config new file mode 100644 index 0000000..b4aca10 --- /dev/null +++ b/Test Centre/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 6d6d0918d81b15bb604c8611e199c03438c0391b Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 28 Aug 2018 23:40:51 +0100 Subject: [PATCH 05/29] Stub out initial functions in NuGet. Update assembly info. in CLI and NuGet --- Smouldeing Beach Ball/AssemblyInfo.fs | 4 ++-- Smouldeing Beach Ball/BeachBall.fs | 12 ++++++++++++ Smouldeing Beach Ball/Library1.fs | 4 ---- Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj | 2 +- Smouldering Beach Ball CLI/AssemblyInfo.fs | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 Smouldeing Beach Ball/BeachBall.fs delete mode 100644 Smouldeing Beach Ball/Library1.fs diff --git a/Smouldeing Beach Ball/AssemblyInfo.fs b/Smouldeing Beach Ball/AssemblyInfo.fs index ceeb402..f26afea 100644 --- a/Smouldeing Beach Ball/AssemblyInfo.fs +++ b/Smouldeing Beach Ball/AssemblyInfo.fs @@ -34,8 +34,8 @@ open System.Runtime.InteropServices // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [] -[] -[] +[] +[] do () \ No newline at end of file diff --git a/Smouldeing Beach Ball/BeachBall.fs b/Smouldeing Beach Ball/BeachBall.fs new file mode 100644 index 0000000..230a1e6 --- /dev/null +++ b/Smouldeing Beach Ball/BeachBall.fs @@ -0,0 +1,12 @@ +namespace Smouldeing_Beach_Ball + +module BeachBall = + + let buildImage width height colour = + null + + let addOverlay image colour = + null + + let saveImage image = + null \ No newline at end of file diff --git a/Smouldeing Beach Ball/Library1.fs b/Smouldeing Beach Ball/Library1.fs deleted file mode 100644 index 09156f5..0000000 --- a/Smouldeing Beach Ball/Library1.fs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Smouldeing_Beach_Ball - -type Class1() = - member this.X = "F#" diff --git a/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj b/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj index 86000b2..f7bd3a6 100644 --- a/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj +++ b/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj @@ -52,7 +52,7 @@ - + diff --git a/Smouldering Beach Ball CLI/AssemblyInfo.fs b/Smouldering Beach Ball CLI/AssemblyInfo.fs index 13b4e5b..b5358bf 100644 --- a/Smouldering Beach Ball CLI/AssemblyInfo.fs +++ b/Smouldering Beach Ball CLI/AssemblyInfo.fs @@ -34,8 +34,8 @@ open System.Runtime.InteropServices // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [] -[] -[] +[] +[] do () \ No newline at end of file From b0d5c6d76ee3f1362cb94e90933982cb379a5b7f Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 28 Aug 2018 23:51:12 +0100 Subject: [PATCH 06/29] Remove all projects. Add .net standard project. --- Smouldeing Beach Ball.sln | 37 -------- Smouldeing Beach Ball/AssemblyInfo.fs | 41 --------- Smouldeing Beach Ball/BeachBall.fs | 12 --- Smouldeing Beach Ball/Script.fsx | 8 -- .../Smouldeing Beach Ball.fsproj | 80 ------------------ Smouldeing Beach Ball/packages.config | 4 - Smouldering Beach Ball CLI/App.config | 6 -- Smouldering Beach Ball CLI/AssemblyInfo.fs | 41 --------- Smouldering Beach Ball CLI/Program.fs | 7 -- .../Smouldering Beach Ball CLI.fsproj | 84 ------------------- Smouldering Beach Ball CLI/packages.config | 4 - SmoulderingBeachBall/SmoulderingBeachBall.sln | 25 ++++++ .../SmoulderingBeachBall/ImageMaker.fs | 5 ++ .../SmoulderingBeachBall.fsproj | 11 +++ Test Centre/AssemblyInfo.fs | 41 --------- Test Centre/Library1.fs | 4 - Test Centre/Script.fsx | 8 -- Test Centre/Test Centre.fsproj | 80 ------------------ Test Centre/packages.config | 4 - 19 files changed, 41 insertions(+), 461 deletions(-) delete mode 100644 Smouldeing Beach Ball.sln delete mode 100644 Smouldeing Beach Ball/AssemblyInfo.fs delete mode 100644 Smouldeing Beach Ball/BeachBall.fs delete mode 100644 Smouldeing Beach Ball/Script.fsx delete mode 100644 Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj delete mode 100644 Smouldeing Beach Ball/packages.config delete mode 100644 Smouldering Beach Ball CLI/App.config delete mode 100644 Smouldering Beach Ball CLI/AssemblyInfo.fs delete mode 100644 Smouldering Beach Ball CLI/Program.fs delete mode 100644 Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj delete mode 100644 Smouldering Beach Ball CLI/packages.config create mode 100644 SmoulderingBeachBall/SmoulderingBeachBall.sln create mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs create mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj delete mode 100644 Test Centre/AssemblyInfo.fs delete mode 100644 Test Centre/Library1.fs delete mode 100644 Test Centre/Script.fsx delete mode 100644 Test Centre/Test Centre.fsproj delete mode 100644 Test Centre/packages.config diff --git a/Smouldeing Beach Ball.sln b/Smouldeing Beach Ball.sln deleted file mode 100644 index d173c3a..0000000 --- a/Smouldeing Beach Ball.sln +++ /dev/null @@ -1,37 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2026 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldeing Beach Ball", "Smouldeing Beach Ball\Smouldeing Beach Ball.fsproj", "{7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Smouldering Beach Ball CLI", "Smouldering Beach Ball CLI\Smouldering Beach Ball CLI.fsproj", "{18B85D45-9A87-4174-B0DC-C5F7B77921F3}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Test Centre", "Test Centre\Test Centre.fsproj", "{0571746B-5FDC-4D98-84DC-5B98D1801964}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7C2B506A-A7DB-4B97-8443-BEFDF57E95AE}.Release|Any CPU.Build.0 = Release|Any CPU - {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18B85D45-9A87-4174-B0DC-C5F7B77921F3}.Release|Any CPU.Build.0 = Release|Any CPU - {0571746B-5FDC-4D98-84DC-5B98D1801964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0571746B-5FDC-4D98-84DC-5B98D1801964}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0571746B-5FDC-4D98-84DC-5B98D1801964}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0571746B-5FDC-4D98-84DC-5B98D1801964}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {35E66E82-0589-48AE-B937-66D3E84E1B3A} - EndGlobalSection -EndGlobal diff --git a/Smouldeing Beach Ball/AssemblyInfo.fs b/Smouldeing Beach Ball/AssemblyInfo.fs deleted file mode 100644 index f26afea..0000000 --- a/Smouldeing Beach Ball/AssemblyInfo.fs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Smouldeing_Beach_Ball.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[] -[] -[] -[] -[] -[] -[] -[] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [] -[] -[] - -do - () \ No newline at end of file diff --git a/Smouldeing Beach Ball/BeachBall.fs b/Smouldeing Beach Ball/BeachBall.fs deleted file mode 100644 index 230a1e6..0000000 --- a/Smouldeing Beach Ball/BeachBall.fs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Smouldeing_Beach_Ball - -module BeachBall = - - let buildImage width height colour = - null - - let addOverlay image colour = - null - - let saveImage image = - null \ No newline at end of file diff --git a/Smouldeing Beach Ball/Script.fsx b/Smouldeing Beach Ball/Script.fsx deleted file mode 100644 index a16cb11..0000000 --- a/Smouldeing Beach Ball/Script.fsx +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org -// See the 'F# Tutorial' project for more help. - -#load "Library1.fs" -open Smouldeing_Beach_Ball - -// Define your library scripting code here - diff --git a/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj b/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj deleted file mode 100644 index f7bd3a6..0000000 --- a/Smouldeing Beach Ball/Smouldeing Beach Ball.fsproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - 7c2b506a-a7db-4b97-8443-befdf57e95ae - Library - Smouldeing_Beach_Ball - Smouldeing_Beach_Ball - true - v4.7.1 - 4.4.3.0 - true - Smouldeing Beach Ball - - - true - full - false - false - bin\$(Configuration)\ - DEBUG;TRACE - 3 - bin\$(Configuration)\$(AssemblyName).XML - - - pdbonly - true - true - bin\$(Configuration)\ - TRACE - 3 - bin\$(Configuration)\$(AssemblyName).XML - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - - - - - FSharp.Core - FSharp.Core.dll - $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll - - - - - - True - - - - \ No newline at end of file diff --git a/Smouldeing Beach Ball/packages.config b/Smouldeing Beach Ball/packages.config deleted file mode 100644 index b4aca10..0000000 --- a/Smouldeing Beach Ball/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/App.config b/Smouldering Beach Ball CLI/App.config deleted file mode 100644 index 787dcbe..0000000 --- a/Smouldering Beach Ball CLI/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/AssemblyInfo.fs b/Smouldering Beach Ball CLI/AssemblyInfo.fs deleted file mode 100644 index b5358bf..0000000 --- a/Smouldering Beach Ball CLI/AssemblyInfo.fs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Smouldering_Beach_Ball_CLI.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[] -[] -[] -[] -[] -[] -[] -[] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [] -[] -[] - -do - () \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/Program.fs b/Smouldering Beach Ball CLI/Program.fs deleted file mode 100644 index 2bcf7f9..0000000 --- a/Smouldering Beach Ball CLI/Program.fs +++ /dev/null @@ -1,7 +0,0 @@ -// Learn more about F# at http://fsharp.org -// See the 'F# Tutorial' project for more help. - -[] -let main argv = - printfn "%A" argv - 0 // return an integer exit code diff --git a/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj b/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj deleted file mode 100644 index c07e1fd..0000000 --- a/Smouldering Beach Ball CLI/Smouldering Beach Ball CLI.fsproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - 18b85d45-9a87-4174-b0dc-c5f7b77921f3 - Exe - Smouldering_Beach_Ball_CLI - Smouldering_Beach_Ball_CLI - v4.7.1 - true - true - 4.4.3.0 - Smouldering Beach Ball CLI - - - true - full - false - false - bin\$(Configuration)\ - DEBUG;TRACE - 3 - AnyCPU - bin\$(Configuration)\$(AssemblyName).XML - true - - - pdbonly - true - true - bin\$(Configuration)\ - TRACE - 3 - AnyCPU - bin\$(Configuration)\$(AssemblyName).XML - true - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - - - - - FSharp.Core - FSharp.Core.dll - $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll - - - - - - True - - - - \ No newline at end of file diff --git a/Smouldering Beach Ball CLI/packages.config b/Smouldering Beach Ball CLI/packages.config deleted file mode 100644 index b4aca10..0000000 --- a/Smouldering Beach Ball CLI/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.sln b/SmoulderingBeachBall/SmoulderingBeachBall.sln new file mode 100644 index 0000000..bbb4752 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBall.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBall", "SmoulderingBeachBall\SmoulderingBeachBall.fsproj", "{279C546F-588A-4343-9E11-8EB21188DA70}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {279C546F-588A-4343-9E11-8EB21188DA70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {279C546F-588A-4343-9E11-8EB21188DA70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B5BDCF9E-3DC2-4A57-91F3-62EFADB6BEF0} + EndGlobalSection +EndGlobal diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs new file mode 100644 index 0000000..72918ca --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs @@ -0,0 +1,5 @@ +namespace SmoulderingBeachBall + +module ImageMaker = + let hello name = + printfn "Hello %s" name diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj new file mode 100644 index 0000000..a3905c1 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/Test Centre/AssemblyInfo.fs b/Test Centre/AssemblyInfo.fs deleted file mode 100644 index 8347fd3..0000000 --- a/Test Centre/AssemblyInfo.fs +++ /dev/null @@ -1,41 +0,0 @@ -namespace Test_Centre.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[] -[] -[] -[] -[] -[] -[] -[] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [] -[] -[] - -do - () \ No newline at end of file diff --git a/Test Centre/Library1.fs b/Test Centre/Library1.fs deleted file mode 100644 index ad02a4d..0000000 --- a/Test Centre/Library1.fs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Test_Centre - -type Class1() = - member this.X = "F#" diff --git a/Test Centre/Script.fsx b/Test Centre/Script.fsx deleted file mode 100644 index 7f57a26..0000000 --- a/Test Centre/Script.fsx +++ /dev/null @@ -1,8 +0,0 @@ -// Learn more about F# at http://fsharp.org -// See the 'F# Tutorial' project for more help. - -#load "Library1.fs" -open Test_Centre - -// Define your library scripting code here - diff --git a/Test Centre/Test Centre.fsproj b/Test Centre/Test Centre.fsproj deleted file mode 100644 index 69079fb..0000000 --- a/Test Centre/Test Centre.fsproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - 0571746b-5fdc-4d98-84dc-5b98d1801964 - Library - Test_Centre - Test_Centre - true - v4.7.1 - 4.4.3.0 - true - Test Centre - - - true - full - false - false - bin\$(Configuration)\ - DEBUG;TRACE - 3 - bin\$(Configuration)\$(AssemblyName).XML - - - pdbonly - true - true - bin\$(Configuration)\ - TRACE - 3 - bin\$(Configuration)\$(AssemblyName).XML - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - - - - - FSharp.Core - FSharp.Core.dll - $(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\$(TargetFSharpCoreVersion)\FSharp.Core.dll - - - - - - True - - - - \ No newline at end of file diff --git a/Test Centre/packages.config b/Test Centre/packages.config deleted file mode 100644 index b4aca10..0000000 --- a/Test Centre/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file From 9f982e3d1935618407a5d0019f66aad93e082584 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 28 Aug 2018 23:56:23 +0100 Subject: [PATCH 07/29] stub out inital public facing functions. --- .../SmoulderingBeachBall/ImageMaker.fs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs index 72918ca..2fcba82 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs @@ -1,5 +1,12 @@ namespace SmoulderingBeachBall module ImageMaker = - let hello name = - printfn "Hello %s" name + + let makeImage width height colour = + null + + let addOverlay colour image = + null + + let saveImage filePath = + null From 8da13c695e2fe10f31b6eab2d158af22e6162007 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Tue, 28 Aug 2018 23:57:41 +0100 Subject: [PATCH 08/29] add scratchpad script. --- SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx | 1 + .../SmoulderingBeachBall/SmoulderingBeachBall.fsproj | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx @@ -0,0 +1 @@ + diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index a3905c1..3791c98 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -6,6 +6,9 @@ + + + From 47071e7b8a62b597c8121a2d8a4a1cd1a171acf1 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Wed, 29 Aug 2018 01:11:42 +0100 Subject: [PATCH 09/29] add initial sketching out of image creation in scratch pad. --- .../SmoulderingBeachBall/ScratchPad.fsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx index e02abfc..f15e156 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx @@ -1 +1,15 @@ - +#load "ImageMaker.fs" + +open System.Drawing +open System.Drawing.Imaging + +let width = 500 +let height = 500 +let colour = Brushes.BurlyWood +let draw () = + use bmp = new Bitmap(width, height) + use gr = Graphics.FromImage(bmp) + gr.FillRectangle(colour, new Rectangle(0, 0, bmp.Width, bmp.Height)) + gr.DrawImage(bmp, 0, 0) + bmp.Save("C:/users/craig/desktop/test.png", ImageFormat.Png) +let result = draw () From 0fb5dfa31f96d8852223282687a94f94326008b9 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Wed, 29 Aug 2018 01:51:12 +0100 Subject: [PATCH 10/29] move script code to ImageMaker. Add Windows Compatibility Pack. --- .../SmoulderingBeachBall/ImageMaker.fs | 12 ++++++++++-- .../SmoulderingBeachBall.fsproj | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs index 2fcba82..d9afa56 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs @@ -2,11 +2,19 @@ namespace SmoulderingBeachBall module ImageMaker = - let makeImage width height colour = - null + open System.Drawing + //open System.Drawing.Imaging let addOverlay colour image = null let saveImage filePath = null + + let makeImage (width: int) (height: int) (colour: Brush) = + async { + use bitmap = new Bitmap(width, height) + use graphics = Graphics.FromImage(bitmap) + graphics.FillRectangle(Brushes.Coral, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) + return "we" + } \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index 3791c98..baad55f 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -6,9 +6,23 @@ + + 215d64d2-031c-33c7-96e3-61794cd1ee61 + 2 + 4 + tlbimp + + + d37e2a3e-8545-3a39-9f4f-31827c9124ab + 2 + 4 + tlbimp + - + + + From 351b7c76a9aea39bebbda8f7941c66832c601a19 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Wed, 29 Aug 2018 03:22:50 +0100 Subject: [PATCH 11/29] add input validation to makeImage. Add async and try-catch blocks to makeImage. Refactor the scratch pad. script --- .../SmoulderingBeachBall/ImageMaker.fs | 34 +++++++++++++------ .../SmoulderingBeachBall/ScratchPad.fsx | 17 ++++++++-- .../SmoulderingBeachBall.fsproj | 12 ------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs index d9afa56..6c5ff54 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs @@ -2,19 +2,33 @@ namespace SmoulderingBeachBall module ImageMaker = + open System open System.Drawing - //open System.Drawing.Imaging + open System.IO - let addOverlay colour image = - null + let private validateDimension dimension = + match dimension with + | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." + | _ -> () - let saveImage filePath = - null + let private validateDirectory filePath = + let path = Path.GetDirectoryName filePath + match (Directory.Exists path) with + | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." + | true -> () - let makeImage (width: int) (height: int) (colour: Brush) = + let makeImage width height colour filepath = async { - use bitmap = new Bitmap(width, height) - use graphics = Graphics.FromImage(bitmap) - graphics.FillRectangle(Brushes.Coral, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) - return "we" + try + validateDimension width + validateDimension height + validateDirectory filepath + use bitmap = new Bitmap(width, height) + use graphics = Graphics.FromImage(bitmap) + graphics.FillRectangle(colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) + bitmap.Save(filepath) + return "Image saved." + with + | :? ArgumentException as ex -> return ex.Message + | _ as ex -> return ex.Message } \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx index f15e156..caef410 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx @@ -2,14 +2,27 @@ open System.Drawing open System.Drawing.Imaging +open SmoulderingBeachBall + +// INITIAL IDEA ======================================================================================================= let width = 500 let height = 500 let colour = Brushes.BurlyWood +let testPath = "C:/users/craig/desktop/test.png" let draw () = use bmp = new Bitmap(width, height) use gr = Graphics.FromImage(bmp) gr.FillRectangle(colour, new Rectangle(0, 0, bmp.Width, bmp.Height)) gr.DrawImage(bmp, 0, 0) - bmp.Save("C:/users/craig/desktop/test.png", ImageFormat.Png) -let result = draw () + bmp.Save(testPath, ImageFormat.Png) + +// IMAGE MAKER ======================================================================================================== + +let im_width = 500 +let im_height = 500 +let im_colour = Brushes.BurlyWood +let im_testPath = "C:/users/craig/desktop/test.png" + +ImageMaker.makeImage im_width im_height im_colour im_testPath + |> Async.RunSynchronously \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index baad55f..4395824 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -6,18 +6,6 @@ - - 215d64d2-031c-33c7-96e3-61794cd1ee61 - 2 - 4 - tlbimp - - - d37e2a3e-8545-3a39-9f4f-31827c9124ab - 2 - 4 - tlbimp - From 7748ab33ffab07c52f43d695af6b4b2c6150231b Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Wed, 29 Aug 2018 03:47:45 +0100 Subject: [PATCH 12/29] create a console project. Add references/NuGets to console project. Include basic logic to create image in console. --- SmoulderingBeachBall/SmoulderingBeachBall.sln | 6 ++ .../SmoulderingBeachBallCLI/App.config | 6 ++ .../SmoulderingBeachBallCLI/AssemblyInfo.fs | 41 +++++++++ .../SmoulderingBeachBallCLI/Program.fs | 15 ++++ .../SmoulderingBeachBallCLI.fsproj | 83 +++++++++++++++++++ .../SmoulderingBeachBallCLI/packages.config | 6 ++ .../SmoulderingBeachBallCLICore/Program.fs | 13 +++ .../SmoulderingBeachBallCLICore.fsproj | 20 +++++ 8 files changed, 190 insertions(+) create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs create mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.sln b/SmoulderingBeachBall/SmoulderingBeachBall.sln index bbb4752..7806d8b 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.sln +++ b/SmoulderingBeachBall/SmoulderingBeachBall.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 15.0.28010.2016 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBall", "SmoulderingBeachBall\SmoulderingBeachBall.fsproj", "{279C546F-588A-4343-9E11-8EB21188DA70}" EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBallCLI", "SmoulderingBeachBallCLI\SmoulderingBeachBallCLI.fsproj", "{F3027063-706C-442F-8C88-11A33E8EA222}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {279C546F-588A-4343-9E11-8EB21188DA70}.Debug|Any CPU.Build.0 = Debug|Any CPU {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.ActiveCfg = Release|Any CPU {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.Build.0 = Release|Any CPU + {F3027063-706C-442F-8C88-11A33E8EA222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F3027063-706C-442F-8C88-11A33E8EA222}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F3027063-706C-442F-8C88-11A33E8EA222}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F3027063-706C-442F-8C88-11A33E8EA222}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config b/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config new file mode 100644 index 0000000..787dcbe --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs new file mode 100644 index 0000000..b13b321 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs @@ -0,0 +1,41 @@ +namespace SmoulderingBeachBallCLI.AssemblyInfo + +open System.Reflection +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[] +[] +[] +[] +[] +[] +[] +[] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [] +[] +[] + +do + () \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs new file mode 100644 index 0000000..894ff75 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs @@ -0,0 +1,15 @@ +open SmoulderingBeachBall.ImageMaker +open System.Drawing +open System + +// Learn more about F# at http://fsharp.org +// See the 'F# Tutorial' project for more help. + +[] +let main argv = + printfn "%A" argv + let result = + makeImage 500 500 Brushes.PaleVioletRed "C:/users/craig/desktop/test.png" + |> Async.RunSynchronously + //Console.ReadLine |> ignore + 0 // return an integer exit code diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj b/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj new file mode 100644 index 0000000..818f2b6 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + 2.0 + f3027063-706c-442f-8c88-11a33e8ea222 + Exe + SmoulderingBeachBallCLI + SmoulderingBeachBallCLI + v4.7.1 + true + true + SmoulderingBeachBallCLI + + + true + full + false + false + bin\$(Configuration)\ + DEBUG;TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + pdbonly + true + true + bin\$(Configuration)\ + TRACE + 3 + AnyCPU + bin\$(Configuration)\$(AssemblyName).XML + true + + + 11 + + + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets + + + + + + + + + + + ..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll + + + + + + + ..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll + + + + True + + + + + SmoulderingBeachBall + {279c546f-588a-4343-9e11-8eb21188da70} + True + + + + \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config b/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config new file mode 100644 index 0000000..82d5083 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs new file mode 100644 index 0000000..d1744b9 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs @@ -0,0 +1,13 @@ +// Learn more about F# at http://fsharp.org + +open System +open SmoulderingBeachBall.ImageMaker +open System.Drawing + +[] +let main argv = + printfn "Hello World from F#!" + let result = + makeImage 500 500 Brushes.PaleVioletRed "C:/users/craig/desktop/test.png" + |> Async.RunSynchronously + 0 // return an integer exit code diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj new file mode 100644 index 0000000..7984f9b --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj @@ -0,0 +1,20 @@ + + + + Exe + netcoreapp2.1 + + + + + + + + + + + + + + + From 90bf28cc007ec3cd2d0e84a8f51049f16cfc42d8 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Aug 2018 20:20:22 +0100 Subject: [PATCH 13/29] remove old projects, in prep. for repo. restructuring. --- SmoulderingBeachBall.sln | 25 ++++++ SmoulderingBeachBall/Library.fs | 5 ++ .../SmoulderingBeachBall.fsproj | 11 +++ SmoulderingBeachBall/SmoulderingBeachBall.sln | 31 ------- .../SmoulderingBeachBall/ImageMaker.fs | 34 -------- .../SmoulderingBeachBall/ScratchPad.fsx | 28 ------- .../SmoulderingBeachBall.fsproj | 16 ---- .../SmoulderingBeachBallCLI/App.config | 6 -- .../SmoulderingBeachBallCLI/AssemblyInfo.fs | 41 --------- .../SmoulderingBeachBallCLI/Program.fs | 15 ---- .../SmoulderingBeachBallCLI.fsproj | 83 ------------------- .../SmoulderingBeachBallCLI/packages.config | 6 -- .../SmoulderingBeachBallCLICore/Program.fs | 13 --- .../SmoulderingBeachBallCLICore.fsproj | 20 ----- 14 files changed, 41 insertions(+), 293 deletions(-) create mode 100644 SmoulderingBeachBall.sln create mode 100644 SmoulderingBeachBall/Library.fs create mode 100644 SmoulderingBeachBall/SmoulderingBeachBall.fsproj delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBall.sln delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs delete mode 100644 SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj diff --git a/SmoulderingBeachBall.sln b/SmoulderingBeachBall.sln new file mode 100644 index 0000000..d7de6b3 --- /dev/null +++ b/SmoulderingBeachBall.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBall", "SmoulderingBeachBall\SmoulderingBeachBall.fsproj", "{DFC3CBCA-3DA7-4CF4-A8BC-BCCB740FA6CD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DFC3CBCA-3DA7-4CF4-A8BC-BCCB740FA6CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFC3CBCA-3DA7-4CF4-A8BC-BCCB740FA6CD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFC3CBCA-3DA7-4CF4-A8BC-BCCB740FA6CD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFC3CBCA-3DA7-4CF4-A8BC-BCCB740FA6CD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {78F0A77D-F78C-476F-A7C5-64E5579E9EB4} + EndGlobalSection +EndGlobal diff --git a/SmoulderingBeachBall/Library.fs b/SmoulderingBeachBall/Library.fs new file mode 100644 index 0000000..b448dc3 --- /dev/null +++ b/SmoulderingBeachBall/Library.fs @@ -0,0 +1,5 @@ +namespace SmoulderingBeachBall + +module Say = + let hello name = + printfn "Hello %s" name diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj new file mode 100644 index 0000000..df45432 --- /dev/null +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -0,0 +1,11 @@ + + + + netstandard2.0 + + + + + + + diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.sln b/SmoulderingBeachBall/SmoulderingBeachBall.sln deleted file mode 100644 index 7806d8b..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBall.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2016 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBall", "SmoulderingBeachBall\SmoulderingBeachBall.fsproj", "{279C546F-588A-4343-9E11-8EB21188DA70}" -EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SmoulderingBeachBallCLI", "SmoulderingBeachBallCLI\SmoulderingBeachBallCLI.fsproj", "{F3027063-706C-442F-8C88-11A33E8EA222}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {279C546F-588A-4343-9E11-8EB21188DA70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {279C546F-588A-4343-9E11-8EB21188DA70}.Debug|Any CPU.Build.0 = Debug|Any CPU - {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.ActiveCfg = Release|Any CPU - {279C546F-588A-4343-9E11-8EB21188DA70}.Release|Any CPU.Build.0 = Release|Any CPU - {F3027063-706C-442F-8C88-11A33E8EA222}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F3027063-706C-442F-8C88-11A33E8EA222}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F3027063-706C-442F-8C88-11A33E8EA222}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F3027063-706C-442F-8C88-11A33E8EA222}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B5BDCF9E-3DC2-4A57-91F3-62EFADB6BEF0} - EndGlobalSection -EndGlobal diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs deleted file mode 100644 index 6c5ff54..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ImageMaker.fs +++ /dev/null @@ -1,34 +0,0 @@ -namespace SmoulderingBeachBall - -module ImageMaker = - - open System - open System.Drawing - open System.IO - - let private validateDimension dimension = - match dimension with - | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." - | _ -> () - - let private validateDirectory filePath = - let path = Path.GetDirectoryName filePath - match (Directory.Exists path) with - | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." - | true -> () - - let makeImage width height colour filepath = - async { - try - validateDimension width - validateDimension height - validateDirectory filepath - use bitmap = new Bitmap(width, height) - use graphics = Graphics.FromImage(bitmap) - graphics.FillRectangle(colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) - bitmap.Save(filepath) - return "Image saved." - with - | :? ArgumentException as ex -> return ex.Message - | _ as ex -> return ex.Message - } \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx deleted file mode 100644 index caef410..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBall/ScratchPad.fsx +++ /dev/null @@ -1,28 +0,0 @@ -#load "ImageMaker.fs" - -open System.Drawing -open System.Drawing.Imaging -open SmoulderingBeachBall - -// INITIAL IDEA ======================================================================================================= - -let width = 500 -let height = 500 -let colour = Brushes.BurlyWood -let testPath = "C:/users/craig/desktop/test.png" -let draw () = - use bmp = new Bitmap(width, height) - use gr = Graphics.FromImage(bmp) - gr.FillRectangle(colour, new Rectangle(0, 0, bmp.Width, bmp.Height)) - gr.DrawImage(bmp, 0, 0) - bmp.Save(testPath, ImageFormat.Png) - -// IMAGE MAKER ======================================================================================================== - -let im_width = 500 -let im_height = 500 -let im_colour = Brushes.BurlyWood -let im_testPath = "C:/users/craig/desktop/test.png" - -ImageMaker.makeImage im_width im_height im_colour im_testPath - |> Async.RunSynchronously \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj deleted file mode 100644 index 4395824..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - netstandard2.0 - - - - - - - - - - - - diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config b/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config deleted file mode 100644 index 787dcbe..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLI/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs deleted file mode 100644 index b13b321..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLI/AssemblyInfo.fs +++ /dev/null @@ -1,41 +0,0 @@ -namespace SmoulderingBeachBallCLI.AssemblyInfo - -open System.Reflection -open System.Runtime.CompilerServices -open System.Runtime.InteropServices - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[] -[] -[] -[] -[] -[] -[] -[] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [] -[] -[] - -do - () \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs deleted file mode 100644 index 894ff75..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLI/Program.fs +++ /dev/null @@ -1,15 +0,0 @@ -open SmoulderingBeachBall.ImageMaker -open System.Drawing -open System - -// Learn more about F# at http://fsharp.org -// See the 'F# Tutorial' project for more help. - -[] -let main argv = - printfn "%A" argv - let result = - makeImage 500 500 Brushes.PaleVioletRed "C:/users/craig/desktop/test.png" - |> Async.RunSynchronously - //Console.ReadLine |> ignore - 0 // return an integer exit code diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj b/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj deleted file mode 100644 index 818f2b6..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLI/SmoulderingBeachBallCLI.fsproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - f3027063-706c-442f-8c88-11a33e8ea222 - Exe - SmoulderingBeachBallCLI - SmoulderingBeachBallCLI - v4.7.1 - true - true - SmoulderingBeachBallCLI - - - true - full - false - false - bin\$(Configuration)\ - DEBUG;TRACE - 3 - AnyCPU - bin\$(Configuration)\$(AssemblyName).XML - true - - - pdbonly - true - true - bin\$(Configuration)\ - TRACE - 3 - AnyCPU - bin\$(Configuration)\$(AssemblyName).XML - true - - - 11 - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - - - - - - - - ..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll - - - - - - - ..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll - - - - True - - - - - SmoulderingBeachBall - {279c546f-588a-4343-9e11-8eb21188da70} - True - - - - \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config b/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config deleted file mode 100644 index 82d5083..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLI/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs deleted file mode 100644 index d1744b9..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/Program.fs +++ /dev/null @@ -1,13 +0,0 @@ -// Learn more about F# at http://fsharp.org - -open System -open SmoulderingBeachBall.ImageMaker -open System.Drawing - -[] -let main argv = - printfn "Hello World from F#!" - let result = - makeImage 500 500 Brushes.PaleVioletRed "C:/users/craig/desktop/test.png" - |> Async.RunSynchronously - 0 // return an integer exit code diff --git a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj b/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj deleted file mode 100644 index 7984f9b..0000000 --- a/SmoulderingBeachBall/SmoulderingBeachBallCLICore/SmoulderingBeachBallCLICore.fsproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - Exe - netcoreapp2.1 - - - - - - - - - - - - - - - From ff999edffbf7d2166febe2c3e18f66dad6097e47 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Aug 2018 20:22:34 +0100 Subject: [PATCH 14/29] rename Library.fs to ImageMaker.fs. Port code from previous commits into new NuGet project. --- SmoulderingBeachBall/ImageMaker.fs | 34 +++++++++++++++++++ SmoulderingBeachBall/Library.fs | 5 --- .../SmoulderingBeachBall.fsproj | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 SmoulderingBeachBall/ImageMaker.fs delete mode 100644 SmoulderingBeachBall/Library.fs diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs new file mode 100644 index 0000000..9f3e8df --- /dev/null +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -0,0 +1,34 @@ +namespace SmoulderingBeachBall + +module ImageMaker = + + open System + open System.Drawing + open System.IO + + let private validateDimension dimension = + match dimension with + | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." + | _ -> () + + let private validateDirectory filePath = + let path = Path.GetDirectoryName filePath + match (Directory.Exists path) with + | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." + | true -> () + + let makeImage width height colour filepath = + async { + try + validateDimension width + validateDimension height + validateDirectory filepath + use bitmap = new Bitmap(width, height) + use graphics = Graphics.FromImage(bitmap) + graphics.FillRectangle(colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) + bitmap.Save(filepath) + return "Image saved." + with + | :? ArgumentException as ex -> return ex.Message + | _ as ex -> return ex.Message + } diff --git a/SmoulderingBeachBall/Library.fs b/SmoulderingBeachBall/Library.fs deleted file mode 100644 index b448dc3..0000000 --- a/SmoulderingBeachBall/Library.fs +++ /dev/null @@ -1,5 +0,0 @@ -namespace SmoulderingBeachBall - -module Say = - let hello name = - printfn "Hello %s" name diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index df45432..a3905c1 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -5,7 +5,7 @@ - + From f885b0fff4e6686d574a1bdfb7f6af3e7c08aba1 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Aug 2018 20:23:50 +0100 Subject: [PATCH 15/29] add Scrathpad.fsx from removed NuGet project. --- SmoulderingBeachBall/ScratchPad.fsx | 28 +++++++++++++++++++ .../SmoulderingBeachBall.fsproj | 3 ++ 2 files changed, 31 insertions(+) create mode 100644 SmoulderingBeachBall/ScratchPad.fsx diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx new file mode 100644 index 0000000..caef410 --- /dev/null +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -0,0 +1,28 @@ +#load "ImageMaker.fs" + +open System.Drawing +open System.Drawing.Imaging +open SmoulderingBeachBall + +// INITIAL IDEA ======================================================================================================= + +let width = 500 +let height = 500 +let colour = Brushes.BurlyWood +let testPath = "C:/users/craig/desktop/test.png" +let draw () = + use bmp = new Bitmap(width, height) + use gr = Graphics.FromImage(bmp) + gr.FillRectangle(colour, new Rectangle(0, 0, bmp.Width, bmp.Height)) + gr.DrawImage(bmp, 0, 0) + bmp.Save(testPath, ImageFormat.Png) + +// IMAGE MAKER ======================================================================================================== + +let im_width = 500 +let im_height = 500 +let im_colour = Brushes.BurlyWood +let im_testPath = "C:/users/craig/desktop/test.png" + +ImageMaker.makeImage im_width im_height im_colour im_testPath + |> Async.RunSynchronously \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index a3905c1..3791c98 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -6,6 +6,9 @@ + + + From e132daedbf40c0ae51bd4ace366dada11bb25d42 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Aug 2018 20:27:59 +0100 Subject: [PATCH 16/29] add Microsoft.Windows.Compatibility NuGet. --- SmoulderingBeachBall/SmoulderingBeachBall.fsproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index 3791c98..4395824 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -9,6 +9,8 @@ - + + + From cecb8682c8ddd2a181de8f7f81428f748aa8a70a Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 30 Aug 2018 20:34:18 +0100 Subject: [PATCH 17/29] begin adding record types for image specs. --- SmoulderingBeachBall/ImageMaker.fs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 9f3e8df..7483178 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -5,6 +5,11 @@ module ImageMaker = open System open System.Drawing open System.IO + open System + + type OverlaySpec = { colour: Brush} + + type ImageSpec = { width: int; height: int; colour: Brush; filePath: string; overlay: Overlay } let private validateDimension dimension = match dimension with From b27fe400cec928321227548260b6bdf5e972156a Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Fri, 31 Aug 2018 23:18:35 +0100 Subject: [PATCH 18/29] finish adding initial design of types. --- SmoulderingBeachBall/ImageMaker.fs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 7483178..e7948ed 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -3,13 +3,25 @@ namespace SmoulderingBeachBall module ImageMaker = open System - open System.Drawing open System.IO - open System + open System.Drawing - type OverlaySpec = { colour: Brush} + type OverlayType = + | Border + | Complete - type ImageSpec = { width: int; height: int; colour: Brush; filePath: string; overlay: Overlay } + type OverlaySpec = { + colour: Brush; + overlayType: OverlayType + } + + type ImageSpec = { + width: int; + height: int; + colour: Brush; + filePath: string; + overlay: OverlaySpec + } let private validateDimension dimension = match dimension with From b413819584ee8bca2713da58d6b8f6e0c8ef32be Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Fri, 31 Aug 2018 23:51:17 +0100 Subject: [PATCH 19/29] add code to create basic image using record types. --- SmoulderingBeachBall/ImageMaker.fs | 42 ++++++++++++++++++++--------- SmoulderingBeachBall/ScratchPad.fsx | 21 ++++++++++++++- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index e7948ed..7393cfa 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -8,20 +8,18 @@ module ImageMaker = type OverlayType = | Border - | Complete + | Full - type OverlaySpec = { - colour: Brush; - overlayType: OverlayType - } + type OverlaySpec = + { colour: Brush; + overlayType: OverlayType } - type ImageSpec = { - width: int; - height: int; - colour: Brush; - filePath: string; - overlay: OverlaySpec - } + type ImageSpec = + { width: int; + height: int; + colour: Brush; + filePath: string; + overlay: OverlaySpec } let private validateDimension dimension = match dimension with @@ -49,3 +47,23 @@ module ImageMaker = | :? ArgumentException as ex -> return ex.Message | _ as ex -> return ex.Message } + + let drawMainImage spec = + use bitmap = new Bitmap(spec.width, spec.height) + use graphics = Graphics.FromImage(bitmap) + graphics.FillRectangle(spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) + bitmap.Save(spec.filePath) + + let makeImage2 spec = + async { + try + validateDimension spec.width + validateDimension spec.height + validateDirectory spec.filePath + // add option code for overlay here + drawMainImage spec + return "Image saved." + with + | :? ArgumentException as ex -> return ex.Message + | _ as ex -> return ex.Message + } diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index caef410..ae86926 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -3,6 +3,7 @@ open System.Drawing open System.Drawing.Imaging open SmoulderingBeachBall +open SmoulderingBeachBall.ImageMaker // INITIAL IDEA ======================================================================================================= @@ -25,4 +26,22 @@ let im_colour = Brushes.BurlyWood let im_testPath = "C:/users/craig/desktop/test.png" ImageMaker.makeImage im_width im_height im_colour im_testPath - |> Async.RunSynchronously \ No newline at end of file + |> Async.RunSynchronously + + +let borderOverlay = + { colour = Brushes.BlueViolet; + overlayType = Border } + +let fullOverlay = + { colour = Brushes.Fuchsia; + overlayType = Full } + +let imageSpec = + { width = 500; + height = 500; + colour = Brushes.Yellow; + filePath = im_testPath; + overlay = borderOverlay } // Change this to quickly change between a border overlay and a full overlay. + +makeImage2 imageSpec |> Async.RunSynchronously From 9dfa4b4a859e4b7da0350a3abdfa839aa6378682 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 00:26:42 +0100 Subject: [PATCH 20/29] add option features to makeImage2. Make some functions private. Update ScratchPad.fs to use the new option-based code. --- SmoulderingBeachBall/ImageMaker.fs | 16 +++++++++++----- SmoulderingBeachBall/ScratchPad.fsx | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 7393cfa..6658d0f 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -19,7 +19,7 @@ module ImageMaker = height: int; colour: Brush; filePath: string; - overlay: OverlaySpec } + overlay: OverlaySpec option } let private validateDimension dimension = match dimension with @@ -32,6 +32,7 @@ module ImageMaker = | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." | true -> () + // This function is to be deleted. let makeImage width height colour filepath = async { try @@ -48,21 +49,26 @@ module ImageMaker = | _ as ex -> return ex.Message } - let drawMainImage spec = + let private drawMainImage spec = use bitmap = new Bitmap(spec.width, spec.height) use graphics = Graphics.FromImage(bitmap) graphics.FillRectangle(spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) bitmap.Save(spec.filePath) + printfn "[SUCCESS] Image saved." + + let private drawImageWithOverlay spec = printfn "Overlay section is not complete." let makeImage2 spec = async { try + printfn "[INFO.] Attempting to make image..." validateDimension spec.width validateDimension spec.height validateDirectory spec.filePath - // add option code for overlay here - drawMainImage spec - return "Image saved." + match Option.isSome spec.overlay with + | true -> drawImageWithOverlay spec + | false -> drawMainImage spec + return "[SUCCESS.] Image creation attempt complete." with | :? ArgumentException as ex -> return ex.Message | _ as ex -> return ex.Message diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index ae86926..3b2383f 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -42,6 +42,6 @@ let imageSpec = height = 500; colour = Brushes.Yellow; filePath = im_testPath; - overlay = borderOverlay } // Change this to quickly change between a border overlay and a full overlay. + overlay = None } // Change this to quickly change between border/full overlay or None. makeImage2 imageSpec |> Async.RunSynchronously From ee4d5ec8e27575a569900735e00329c84fd89617 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 01:27:03 +0100 Subject: [PATCH 21/29] add note outling the plan to include reduce logic branches. --- SmoulderingBeachBall/ImageMaker.fs | 46 +++++++++++++++++++++++++---- SmoulderingBeachBall/ScratchPad.fsx | 2 +- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 6658d0f..4d6cb96 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -50,13 +50,47 @@ module ImageMaker = } let private drawMainImage spec = - use bitmap = new Bitmap(spec.width, spec.height) - use graphics = Graphics.FromImage(bitmap) - graphics.FillRectangle(spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) - bitmap.Save(spec.filePath) + use bitmap = new Bitmap (spec.width, spec.height) + use graphics = Graphics.FromImage (bitmap) + graphics.FillRectangle (spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) + bitmap.Save (spec.filePath) printfn "[SUCCESS] Image saved." - let private drawImageWithOverlay spec = printfn "Overlay section is not complete." + (* + Need to call dispose manually because of how the image is/can be built-up. + need to reduce the amount of branching code... it's getting unwieldy. + create bitmap + create graphics + draw base + check overlay + add border + add full overlay + write image to disk + dispose resources + write output message*) + + let private createBorderPositions spec = + [|Point (0, 0); + Point (spec.width, 0); + Point (spec.width, spec.height); + Point (spec.height, 0); + Point (0, 0)|] + + let private drawImageWithBorder spec = + let overlay = spec.overlay.Value + use bitmap = new Bitmap (spec.width, spec.height) + use graphics = Graphics.FromImage (bitmap) + use pen = new Pen (overlay.colour) + let border = createBorderPositions spec + graphics.DrawLines (pen, border) + printfn "Overlay image function not finished." + + let private drawImageWithFullOverlay spec = () + + let private drawImageWithOverlay spec = + match spec.overlay.Value.overlayType with + | Border -> drawImageWithBorder spec + | Full -> drawImageWithFullOverlay spec let makeImage2 spec = async { @@ -68,7 +102,7 @@ module ImageMaker = match Option.isSome spec.overlay with | true -> drawImageWithOverlay spec | false -> drawMainImage spec - return "[SUCCESS.] Image creation attempt complete." + return "[SUCCESS] Image creation attempt complete." with | :? ArgumentException as ex -> return ex.Message | _ as ex -> return ex.Message diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 3b2383f..8cd3d28 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -41,7 +41,7 @@ let imageSpec = { width = 500; height = 500; colour = Brushes.Yellow; - filePath = im_testPath; + filePath = "C:/users/craig/desktop/test.png"; overlay = None } // Change this to quickly change between border/full overlay or None. makeImage2 imageSpec |> Async.RunSynchronously From 970b13899c5bdb429cab926a77f65d87133d07af Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 16:05:43 +0100 Subject: [PATCH 22/29] remove MakeImage2 code. Reduce the amount of possible duplicate code in logic branches. And, update Scratchpad to reflect the changes. Draw border logic will, also, be added but it will be incomplete and produce incorrect results. --- SmoulderingBeachBall/ImageMaker.fs | 84 +++++++++++++---------------- SmoulderingBeachBall/ScratchPad.fsx | 6 +-- 2 files changed, 41 insertions(+), 49 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 4d6cb96..f100f02 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -33,7 +33,7 @@ module ImageMaker = | true -> () // This function is to be deleted. - let makeImage width height colour filepath = + let makeImageBase width height colour filepath = async { try validateDimension width @@ -49,61 +49,53 @@ module ImageMaker = | _ as ex -> return ex.Message } - let private drawMainImage spec = - use bitmap = new Bitmap (spec.width, spec.height) - use graphics = Graphics.FromImage (bitmap) - graphics.FillRectangle (spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) - bitmap.Save (spec.filePath) - printfn "[SUCCESS] Image saved." + let private createBorderPath spec = + [|Point (10, 10); + Point (spec.width, 10); + Point (spec.width, spec.height); + Point (spec.height, 10); + Point (10, 10)|] - (* - Need to call dispose manually because of how the image is/can be built-up. - need to reduce the amount of branching code... it's getting unwieldy. - create bitmap - create graphics - draw base - check overlay - add border - add full overlay - write image to disk - dispose resources - write output message*) + let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = + printfn "[INFO.] Adding border to image..." + let penPath = createBorderPath spec + graphics.DrawLines (pen, penPath) - let private createBorderPositions spec = - [|Point (0, 0); - Point (spec.width, 0); - Point (spec.width, spec.height); - Point (spec.height, 0); - Point (0, 0)|] - let private drawImageWithBorder spec = - let overlay = spec.overlay.Value - use bitmap = new Bitmap (spec.width, spec.height) - use graphics = Graphics.FromImage (bitmap) - use pen = new Pen (overlay.colour) - let border = createBorderPositions spec - graphics.DrawLines (pen, border) - printfn "Overlay image function not finished." + let private drawImageWithFullOverlay graphics pen spec = + printfn "[INFO.] Adding full overlay to image..." + () - let private drawImageWithFullOverlay spec = () + let private addOverlayToImage graphics spec = + let overlay = spec.overlay.Value + let pen = new Pen (overlay.colour, Width = 10.0f) + match overlay.overlayType with + | Border -> drawImageWithBorder graphics pen spec + | Full -> drawImageWithFullOverlay graphics pen spec - let private drawImageWithOverlay spec = - match spec.overlay.Value.overlayType with - | Border -> drawImageWithBorder spec - | Full -> drawImageWithFullOverlay spec + let private drawImage spec = + let bitmap = new Bitmap (spec.width, spec.height) + let graphics = Graphics.FromImage (bitmap) + let rectangle = Rectangle (0, 0, spec.width, spec.height) + graphics.FillRectangle (spec.colour, rectangle) + match spec.overlay.IsSome with + | true -> addOverlayToImage graphics spec + | false -> printfn "[INFO.] No overlay specified. Creating image without one." + bitmap.Save (spec.filePath) + bitmap.Dispose() + graphics.Dispose() - let makeImage2 spec = + let makeImage spec = async { try printfn "[INFO.] Attempting to make image..." validateDimension spec.width validateDimension spec.height validateDirectory spec.filePath - match Option.isSome spec.overlay with - | true -> drawImageWithOverlay spec - | false -> drawMainImage spec - return "[SUCCESS] Image creation attempt complete." + drawImage spec + printfn "[SUCCESS] Image creation attempt complete." + return () with - | :? ArgumentException as ex -> return ex.Message - | _ as ex -> return ex.Message - } + | :? ArgumentException as ex -> printfn "%s" ex.Message + | _ as ex -> printfn "%s" ex.Message + } \ No newline at end of file diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 8cd3d28..1da7979 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -25,7 +25,7 @@ let im_height = 500 let im_colour = Brushes.BurlyWood let im_testPath = "C:/users/craig/desktop/test.png" -ImageMaker.makeImage im_width im_height im_colour im_testPath +ImageMaker.makeImageBase im_width im_height im_colour im_testPath |> Async.RunSynchronously @@ -42,6 +42,6 @@ let imageSpec = height = 500; colour = Brushes.Yellow; filePath = "C:/users/craig/desktop/test.png"; - overlay = None } // Change this to quickly change between border/full overlay or None. + overlay = Some borderOverlay } // Change this to quickly change between border/full overlay or None. -makeImage2 imageSpec |> Async.RunSynchronously +ImageMaker.makeImage imageSpec |> Async.RunSynchronously \ No newline at end of file From acb442ed156cefa4791e247b84a048969ddcb637 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 16:20:40 +0100 Subject: [PATCH 23/29] create a working "pen path" array for adding a border to the image. --- SmoulderingBeachBall/ImageMaker.fs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index f100f02..4558a66 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -50,11 +50,11 @@ module ImageMaker = } let private createBorderPath spec = - [|Point (10, 10); - Point (spec.width, 10); - Point (spec.width, spec.height); - Point (spec.height, 10); - Point (10, 10)|] + [|Point (5, 5); + Point ((spec.width - 5), 5); + Point ((spec.width - 5), (spec.height - 5)); + Point (5, (spec.height - 5)); + Point (5, 0)|] let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = printfn "[INFO.] Adding border to image..." From 68e65552c11fe8d5cbd2c0f5a6a2a069aebd7d6d Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 16:42:56 +0100 Subject: [PATCH 24/29] remove hard coding of pen offset in border path array. --- SmoulderingBeachBall/ImageMaker.fs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index 4558a66..f36b951 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -49,16 +49,17 @@ module ImageMaker = | _ as ex -> return ex.Message } - let private createBorderPath spec = - [|Point (5, 5); - Point ((spec.width - 5), 5); - Point ((spec.width - 5), (spec.height - 5)); - Point (5, (spec.height - 5)); - Point (5, 0)|] + let private createBorderPath penWidth spec = + let penOffset = int (penWidth / (float32 2)) + [|Point (0, penOffset); // Essentially (0, 0) + Point ((spec.width - penOffset), penOffset); + Point ((spec.width - penOffset), (spec.height - penOffset)); + Point (penOffset, (spec.height - penOffset)); + Point (penOffset, 0)|] let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = printfn "[INFO.] Adding border to image..." - let penPath = createBorderPath spec + let penPath = createBorderPath pen.Width spec graphics.DrawLines (pen, penPath) From 214878807dc8bb4a5eff03ce1626d82237c78303 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 17:17:48 +0100 Subject: [PATCH 25/29] add working code for drawing a full overlay. Update the scratch pad to reflect changes. --- SmoulderingBeachBall/ImageMaker.fs | 31 ++++++++++++++++++----------- SmoulderingBeachBall/ScratchPad.fsx | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index f36b951..ba465f3 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -49,30 +49,37 @@ module ImageMaker = | _ as ex -> return ex.Message } + let private penOffset penWidth = int (penWidth / (float32 2)) + let private createBorderPath penWidth spec = - let penOffset = int (penWidth / (float32 2)) - [|Point (0, penOffset); // Essentially (0, 0) - Point ((spec.width - penOffset), penOffset); - Point ((spec.width - penOffset), (spec.height - penOffset)); - Point (penOffset, (spec.height - penOffset)); - Point (penOffset, 0)|] - - let private drawImageWithBorder (graphics: Graphics) (pen: Pen) spec = + let offset = penOffset penWidth + [|Point (0, offset); // Essentially (0, 0) + Point ((spec.width - offset), offset); + Point ((spec.width - offset), (spec.height - offset)); + Point (offset, (spec.height - offset)); + Point (offset, 0)|] + + let private drawBorder (graphics: Graphics) (pen: Pen) spec = printfn "[INFO.] Adding border to image..." let penPath = createBorderPath pen.Width spec graphics.DrawLines (pen, penPath) - let private drawImageWithFullOverlay graphics pen spec = + let private drawFullOverlay (graphics: Graphics) (pen: Pen) spec = + drawBorder graphics pen spec printfn "[INFO.] Adding full overlay to image..." - () + let offset = penOffset pen.Width + // Draws line from top-left to bottom-right of square. + graphics.DrawLine (pen, offset, offset, (spec.width - offset), (spec.height - offset)) + // Draws line from top-right to bottom-left of square. + graphics.DrawLine (pen, (spec.width - offset), offset, offset, (spec.height - offset)) let private addOverlayToImage graphics spec = let overlay = spec.overlay.Value let pen = new Pen (overlay.colour, Width = 10.0f) match overlay.overlayType with - | Border -> drawImageWithBorder graphics pen spec - | Full -> drawImageWithFullOverlay graphics pen spec + | Border -> drawBorder graphics pen spec + | Full -> drawFullOverlay graphics pen spec let private drawImage spec = let bitmap = new Bitmap (spec.width, spec.height) diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 1da7979..ef833ec 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -42,6 +42,6 @@ let imageSpec = height = 500; colour = Brushes.Yellow; filePath = "C:/users/craig/desktop/test.png"; - overlay = Some borderOverlay } // Change this to quickly change between border/full overlay or None. + overlay = Some fullOverlay } // Change this to quickly change between border/full overlay or None. ImageMaker.makeImage imageSpec |> Async.RunSynchronously \ No newline at end of file From 74c30f216d98103924889ff0bcef25c9ca1bfb9c Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 17:20:34 +0100 Subject: [PATCH 26/29] remove excess code. --- SmoulderingBeachBall/ImageMaker.fs | 17 ----------------- SmoulderingBeachBall/ScratchPad.fsx | 9 --------- 2 files changed, 26 deletions(-) diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs index ba465f3..d58d8cf 100644 --- a/SmoulderingBeachBall/ImageMaker.fs +++ b/SmoulderingBeachBall/ImageMaker.fs @@ -32,23 +32,6 @@ module ImageMaker = | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." | true -> () - // This function is to be deleted. - let makeImageBase width height colour filepath = - async { - try - validateDimension width - validateDimension height - validateDirectory filepath - use bitmap = new Bitmap(width, height) - use graphics = Graphics.FromImage(bitmap) - graphics.FillRectangle(colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) - bitmap.Save(filepath) - return "Image saved." - with - | :? ArgumentException as ex -> return ex.Message - | _ as ex -> return ex.Message - } - let private penOffset penWidth = int (penWidth / (float32 2)) let private createBorderPath penWidth spec = diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index ef833ec..06c22ad 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -20,15 +20,6 @@ let draw () = // IMAGE MAKER ======================================================================================================== -let im_width = 500 -let im_height = 500 -let im_colour = Brushes.BurlyWood -let im_testPath = "C:/users/craig/desktop/test.png" - -ImageMaker.makeImageBase im_width im_height im_colour im_testPath - |> Async.RunSynchronously - - let borderOverlay = { colour = Brushes.BlueViolet; overlayType = Border } From 9fc1d6c46af37f57191f06def1afea1394c52004 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 17:56:36 +0100 Subject: [PATCH 27/29] seperate into public and private modules and namespaces. --- SmoulderingBeachBall/DomainTypes.fs | 21 +++++ SmoulderingBeachBall/ImageMaker.fs | 92 ------------------- SmoulderingBeachBall/InternalServices.fs | 64 +++++++++++++ SmoulderingBeachBall/PublicServices.fs | 22 +++++ SmoulderingBeachBall/ScratchPad.fsx | 8 +- .../SmoulderingBeachBall.fsproj | 4 +- 6 files changed, 115 insertions(+), 96 deletions(-) create mode 100644 SmoulderingBeachBall/DomainTypes.fs delete mode 100644 SmoulderingBeachBall/ImageMaker.fs create mode 100644 SmoulderingBeachBall/InternalServices.fs create mode 100644 SmoulderingBeachBall/PublicServices.fs diff --git a/SmoulderingBeachBall/DomainTypes.fs b/SmoulderingBeachBall/DomainTypes.fs new file mode 100644 index 0000000..408a107 --- /dev/null +++ b/SmoulderingBeachBall/DomainTypes.fs @@ -0,0 +1,21 @@ +namespace SmoulderingBeachBall + + [] + module DomainTypes = + + open System.Drawing + + type OverlayType = + | Border + | Full + + type OverlaySpec = + { colour: Brush; + overlayType: OverlayType } + + type ImageSpec = + { width: int; + height: int; + colour: Brush; + filePath: string; + overlay: OverlaySpec option } \ No newline at end of file diff --git a/SmoulderingBeachBall/ImageMaker.fs b/SmoulderingBeachBall/ImageMaker.fs deleted file mode 100644 index d58d8cf..0000000 --- a/SmoulderingBeachBall/ImageMaker.fs +++ /dev/null @@ -1,92 +0,0 @@ -namespace SmoulderingBeachBall - -module ImageMaker = - - open System - open System.IO - open System.Drawing - - type OverlayType = - | Border - | Full - - type OverlaySpec = - { colour: Brush; - overlayType: OverlayType } - - type ImageSpec = - { width: int; - height: int; - colour: Brush; - filePath: string; - overlay: OverlaySpec option } - - let private validateDimension dimension = - match dimension with - | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." - | _ -> () - - let private validateDirectory filePath = - let path = Path.GetDirectoryName filePath - match (Directory.Exists path) with - | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." - | true -> () - - let private penOffset penWidth = int (penWidth / (float32 2)) - - let private createBorderPath penWidth spec = - let offset = penOffset penWidth - [|Point (0, offset); // Essentially (0, 0) - Point ((spec.width - offset), offset); - Point ((spec.width - offset), (spec.height - offset)); - Point (offset, (spec.height - offset)); - Point (offset, 0)|] - - let private drawBorder (graphics: Graphics) (pen: Pen) spec = - printfn "[INFO.] Adding border to image..." - let penPath = createBorderPath pen.Width spec - graphics.DrawLines (pen, penPath) - - - let private drawFullOverlay (graphics: Graphics) (pen: Pen) spec = - drawBorder graphics pen spec - printfn "[INFO.] Adding full overlay to image..." - let offset = penOffset pen.Width - // Draws line from top-left to bottom-right of square. - graphics.DrawLine (pen, offset, offset, (spec.width - offset), (spec.height - offset)) - // Draws line from top-right to bottom-left of square. - graphics.DrawLine (pen, (spec.width - offset), offset, offset, (spec.height - offset)) - - let private addOverlayToImage graphics spec = - let overlay = spec.overlay.Value - let pen = new Pen (overlay.colour, Width = 10.0f) - match overlay.overlayType with - | Border -> drawBorder graphics pen spec - | Full -> drawFullOverlay graphics pen spec - - let private drawImage spec = - let bitmap = new Bitmap (spec.width, spec.height) - let graphics = Graphics.FromImage (bitmap) - let rectangle = Rectangle (0, 0, spec.width, spec.height) - graphics.FillRectangle (spec.colour, rectangle) - match spec.overlay.IsSome with - | true -> addOverlayToImage graphics spec - | false -> printfn "[INFO.] No overlay specified. Creating image without one." - bitmap.Save (spec.filePath) - bitmap.Dispose() - graphics.Dispose() - - let makeImage spec = - async { - try - printfn "[INFO.] Attempting to make image..." - validateDimension spec.width - validateDimension spec.height - validateDirectory spec.filePath - drawImage spec - printfn "[SUCCESS] Image creation attempt complete." - return () - with - | :? ArgumentException as ex -> printfn "%s" ex.Message - | _ as ex -> printfn "%s" ex.Message - } \ No newline at end of file diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs new file mode 100644 index 0000000..a121eaf --- /dev/null +++ b/SmoulderingBeachBall/InternalServices.fs @@ -0,0 +1,64 @@ +module internal InternalServices + + open System.IO + open System.Drawing + open SmoulderingBeachBall + + module Validation = + + let validateDimension dimension = + match dimension with + | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." + | _ -> () + + let validateDirectory filePath = + let path = Path.GetDirectoryName filePath + match (Directory.Exists path) with + | false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." + | true -> () + + module Drawing = + + let penOffset penWidth = int (penWidth / (float32 2)) + + let createBorderPath penWidth spec = + let offset = penOffset penWidth + [|Point (0, offset); // Essentially (0, 0) + Point ((spec.width - offset), offset); + Point ((spec.width - offset), (spec.height - offset)); + Point (offset, (spec.height - offset)); + Point (offset, 0)|] + + let drawBorder (graphics: Graphics) (pen: Pen) spec = + printfn "[INFO.] Adding border to image..." + let penPath = createBorderPath pen.Width spec + graphics.DrawLines (pen, penPath) + + + let drawFullOverlay (graphics: Graphics) (pen: Pen) spec = + drawBorder graphics pen spec + printfn "[INFO.] Adding full overlay to image..." + let offset = penOffset pen.Width + // Draws line from top-left to bottom-right of square. + graphics.DrawLine (pen, offset, offset, (spec.width - offset), (spec.height - offset)) + // Draws line from top-right to bottom-left of square. + graphics.DrawLine (pen, (spec.width - offset), offset, offset, (spec.height - offset)) + + let addOverlayToImage graphics spec = + let overlay = spec.overlay.Value + let pen = new Pen (overlay.colour, Width = 10.0f) + match overlay.overlayType with + | Border -> drawBorder graphics pen spec + | Full -> drawFullOverlay graphics pen spec + + let drawImage spec = + let bitmap = new Bitmap (spec.width, spec.height) + let graphics = Graphics.FromImage (bitmap) + let rectangle = Rectangle (0, 0, spec.width, spec.height) + graphics.FillRectangle (spec.colour, rectangle) + match spec.overlay.IsSome with + | true -> addOverlayToImage graphics spec + | false -> printfn "[INFO.] No overlay specified. Creating image without one." + bitmap.Save (spec.filePath) + bitmap.Dispose() + graphics.Dispose() \ No newline at end of file diff --git a/SmoulderingBeachBall/PublicServices.fs b/SmoulderingBeachBall/PublicServices.fs new file mode 100644 index 0000000..f038f93 --- /dev/null +++ b/SmoulderingBeachBall/PublicServices.fs @@ -0,0 +1,22 @@ +namespace SmoulderingBeachBall + +module ImageMaker = + + open System + open InternalServices.Validation + open InternalServices.Drawing + + let makeImage (spec: ImageSpec) = + async { + try + printfn "[INFO.] Attempting to make image..." + validateDimension spec.width + validateDimension spec.height + validateDirectory spec.filePath + drawImage spec + printfn "[SUCCESS] Image creation attempt complete." + return () + with + | :? ArgumentException as ex -> printfn "%s" ex.Message + | _ as ex -> printfn "%s" ex.Message + } \ No newline at end of file diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 06c22ad..6b6657c 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -1,9 +1,11 @@ -#load "ImageMaker.fs" +#load "DomainTypes.fs" +#load "InternalServices.fs" +#load "PublicServices.fs" open System.Drawing open System.Drawing.Imaging -open SmoulderingBeachBall open SmoulderingBeachBall.ImageMaker +open Domain // INITIAL IDEA ======================================================================================================= @@ -35,4 +37,4 @@ let imageSpec = filePath = "C:/users/craig/desktop/test.png"; overlay = Some fullOverlay } // Change this to quickly change between border/full overlay or None. -ImageMaker.makeImage imageSpec |> Async.RunSynchronously \ No newline at end of file +makeImage imageSpec |> Async.RunSynchronously \ No newline at end of file diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index 4395824..22aff2f 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -5,7 +5,9 @@ - + + + From ffc261ea8789e22cc219e625f61c148d876b5c96 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 18:00:50 +0100 Subject: [PATCH 28/29] rename domain namespace. --- SmoulderingBeachBall/DomainTypes.fs | 2 +- SmoulderingBeachBall/InternalServices.fs | 2 +- SmoulderingBeachBall/PublicServices.fs | 1 + SmoulderingBeachBall/ScratchPad.fsx | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SmoulderingBeachBall/DomainTypes.fs b/SmoulderingBeachBall/DomainTypes.fs index 408a107..286c5d8 100644 --- a/SmoulderingBeachBall/DomainTypes.fs +++ b/SmoulderingBeachBall/DomainTypes.fs @@ -1,4 +1,4 @@ -namespace SmoulderingBeachBall +namespace SmoulderingBeachBall.Domain [] module DomainTypes = diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs index a121eaf..0002ad4 100644 --- a/SmoulderingBeachBall/InternalServices.fs +++ b/SmoulderingBeachBall/InternalServices.fs @@ -2,7 +2,7 @@ open System.IO open System.Drawing - open SmoulderingBeachBall + open SmoulderingBeachBall.Domain module Validation = diff --git a/SmoulderingBeachBall/PublicServices.fs b/SmoulderingBeachBall/PublicServices.fs index f038f93..1794a75 100644 --- a/SmoulderingBeachBall/PublicServices.fs +++ b/SmoulderingBeachBall/PublicServices.fs @@ -3,6 +3,7 @@ namespace SmoulderingBeachBall module ImageMaker = open System + open SmoulderingBeachBall.Domain open InternalServices.Validation open InternalServices.Drawing diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 6b6657c..3a32ec1 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -4,8 +4,8 @@ open System.Drawing open System.Drawing.Imaging +open SmoulderingBeachBall.Domain open SmoulderingBeachBall.ImageMaker -open Domain // INITIAL IDEA ======================================================================================================= From c8529873ede56fc1128357fb103cf6df81e0a1b6 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 1 Sep 2018 18:25:16 +0100 Subject: [PATCH 29/29] rename files, namespaces and modules. --- .../{DomainTypes.fs => Domain.fs} | 0 SmoulderingBeachBall/InternalServices.fs | 3 ++- SmoulderingBeachBall/ScratchPad.fsx | 15 ++++++++------- .../{PublicServices.fs => Services.fs} | 4 ++-- SmoulderingBeachBall/SmoulderingBeachBall.fsproj | 4 ++-- 5 files changed, 14 insertions(+), 12 deletions(-) rename SmoulderingBeachBall/{DomainTypes.fs => Domain.fs} (100%) rename SmoulderingBeachBall/{PublicServices.fs => Services.fs} (89%) diff --git a/SmoulderingBeachBall/DomainTypes.fs b/SmoulderingBeachBall/Domain.fs similarity index 100% rename from SmoulderingBeachBall/DomainTypes.fs rename to SmoulderingBeachBall/Domain.fs diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs index 0002ad4..ac0df8f 100644 --- a/SmoulderingBeachBall/InternalServices.fs +++ b/SmoulderingBeachBall/InternalServices.fs @@ -8,7 +8,8 @@ let validateDimension dimension = match dimension with - | dimension when dimension <= 0 -> invalidArg "dimension" "The width and height must be greater than 0." + | dimension when dimension <= 0 -> + invalidArg "dimension" "The width and height must be greater than 0." | _ -> () let validateDirectory filePath = diff --git a/SmoulderingBeachBall/ScratchPad.fsx b/SmoulderingBeachBall/ScratchPad.fsx index 3a32ec1..544dcb6 100644 --- a/SmoulderingBeachBall/ScratchPad.fsx +++ b/SmoulderingBeachBall/ScratchPad.fsx @@ -1,13 +1,13 @@ -#load "DomainTypes.fs" +#load "Domain.fs" #load "InternalServices.fs" -#load "PublicServices.fs" +#load "Services.fs" open System.Drawing open System.Drawing.Imaging -open SmoulderingBeachBall.Domain -open SmoulderingBeachBall.ImageMaker +open SmoulderingBeachBall.Domain.DomainTypes +open SmoulderingBeachBall.Services -// INITIAL IDEA ======================================================================================================= +// INITIAL IDEA =============================================================== let width = 500 let height = 500 @@ -20,7 +20,7 @@ let draw () = gr.DrawImage(bmp, 0, 0) bmp.Save(testPath, ImageFormat.Png) -// IMAGE MAKER ======================================================================================================== +// Smouldering Beach Ball Library Code ======================================== let borderOverlay = { colour = Brushes.BlueViolet; @@ -35,6 +35,7 @@ let imageSpec = height = 500; colour = Brushes.Yellow; filePath = "C:/users/craig/desktop/test.png"; - overlay = Some fullOverlay } // Change this to quickly change between border/full overlay or None. + // Change this to flip between border/full overlay or None. + overlay = Some fullOverlay } makeImage imageSpec |> Async.RunSynchronously \ No newline at end of file diff --git a/SmoulderingBeachBall/PublicServices.fs b/SmoulderingBeachBall/Services.fs similarity index 89% rename from SmoulderingBeachBall/PublicServices.fs rename to SmoulderingBeachBall/Services.fs index 1794a75..f394b55 100644 --- a/SmoulderingBeachBall/PublicServices.fs +++ b/SmoulderingBeachBall/Services.fs @@ -1,9 +1,9 @@ namespace SmoulderingBeachBall -module ImageMaker = +module Services = open System - open SmoulderingBeachBall.Domain + open SmoulderingBeachBall.Domain.DomainTypes open InternalServices.Validation open InternalServices.Drawing diff --git a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj index 22aff2f..e6eb3b4 100644 --- a/SmoulderingBeachBall/SmoulderingBeachBall.fsproj +++ b/SmoulderingBeachBall/SmoulderingBeachBall.fsproj @@ -5,9 +5,9 @@ - + - +