-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7955269
Showing
31 changed files
with
1,609 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#Ignore thumbnails created by Windows | ||
Thumbs.db | ||
#Ignore files built by Visual Studio | ||
*.obj | ||
*.exe | ||
*.pdb | ||
*.user | ||
*.aps | ||
*.pch | ||
*.vspscc | ||
*_i.c | ||
*_p.c | ||
*.ncb | ||
*.suo | ||
*.tlb | ||
*.tlh | ||
*.bak | ||
*.cache | ||
*.ilk | ||
*.log | ||
[Bb]in | ||
[Dd]ebug*/ | ||
*.lib | ||
*.sbr | ||
obj/ | ||
[Rr]elease*/ | ||
_ReSharper*/ | ||
[Tt]est[Rr]esult* | ||
.vs/ | ||
#Nuget packages folder | ||
packages/ | ||
*.ncrunchsolution | ||
.ionide/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2004 Sam Hocevar <[email protected]> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# README | ||
Timeboxing is a AvaloniaUI based Desktop Application, written in F# by Martin Kramer (https://lostindetails.com) | ||
|
||
|
||
|
||
|
||
## COPYRIGHT | ||
Copyright © 2021 Martin Kramer (https://lostindetails.com) | ||
This work is free. You can redistribute it and/or modify it under the | ||
terms of the Do What The Fuck You Want To Public License, Version 2, | ||
as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
in/ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:: build the application | ||
dotnet publish ..\src\TimeBoxing\TimeBoxing.fsproj -f netcoreapp5.0 -c Release -r win-x64 -p:PublishSingleFile=true --self-contained true /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=true -o ../setup/in/ | ||
|
||
:: build the setup.exe | ||
call "%PROGRAMFILES(x86)%\NSIS\makensis.exe" setup.nsi | ||
|
||
:: zip the installer | ||
cd out | ||
call 7z a TimeboxingSetup.zip TimeboxingSetup.exe | ||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
; Get rid of warn "7998: ANSI targets are deprecated" | ||
Unicode True | ||
|
||
; Name of the installer | ||
Name "Timeboxing" | ||
|
||
; Name of the setup file | ||
OutFile "out\TimeboxingSetup.exe" | ||
|
||
; Installation directory | ||
InstallDir $PROGRAMFILES\Timeboxing | ||
|
||
InstallDirRegKey HKLM "Software\Timeboxing" "Install_Dir" | ||
|
||
; Pages | ||
Page components | ||
Page directory | ||
Page instfiles | ||
|
||
; Pages for uninstallation | ||
UninstPage uninstConfirm | ||
UninstPage instfiles | ||
|
||
; Main Application | ||
Section "!Timeboxing" | ||
|
||
SectionIn RO | ||
|
||
SetOutPath $INSTDIR | ||
|
||
File ".\in\Timeboxing.exe" | ||
|
||
; Write shortcut link | ||
CreateShortCut "$SMPROGRAMS\Timeboxing.lnk" "$INSTDIR\Timeboxing.exe" "" "$INSTDIR\Timeboxing.exe" 0 | ||
|
||
; Write the installation path into the registry | ||
WriteRegStr HKLM SOFTWARE\Timeboxing "Install_Dir" "$INSTDIR" | ||
|
||
; Write the uninstall keys for windows | ||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Timeboxing" "DisplayName" "Timeboxing" | ||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Timeboxing" "UninstallString" '"$INSTDIR\uninstall.exe"' | ||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Timeboxing" "NoModify" 1 | ||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Timeboxing" "NoRepair" 1 | ||
|
||
; Write Uninstaller | ||
WriteUninstaller "uninstall.exe" | ||
|
||
SectionEnd | ||
|
||
|
||
; Uninstaller | ||
Section "Uninstall" | ||
|
||
; Remove the registry key that stores the installation directory | ||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Timeboxing" | ||
DeleteRegKey HKLM SOFTWARE\Timeboxing | ||
|
||
; Delete Shortcut link | ||
Delete "$SMPROGRAMS\Timeboxing.lnk" | ||
|
||
; Delete Application Files | ||
Delete $INSTDIR\Timeboxing.exe | ||
|
||
Delete $INSTDIR\uninstall.exe | ||
RMDir "$INSTDIR" | ||
|
||
SectionEnd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Timeboxing.Test.ColorPalettesTest | ||
|
||
open Xunit | ||
open Timeboxing | ||
|
||
[<Fact>] | ||
let trueGrayTest () = | ||
let colorPalette = ColorPalettes.trueGray | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
module Timeboxing.Test.Preview | ||
|
||
open System.IO | ||
open Avalonia | ||
open Avalonia.Controls | ||
open Avalonia.Layout | ||
open Timeboxing.Test.Render | ||
|
||
type ControlFactory = unit -> IControl | ||
|
||
let renderToStream appBuilder (settings : RenderSettings) (stream : Stream) (controlFactory : ControlFactory) = | ||
|
||
let initApp (appBuilder : AppBuilder) = | ||
appBuilder | ||
.SetupWithoutStarting() | ||
|
||
let ensureAppInitialized appBuilder = | ||
if Application.Current = null then | ||
initApp appBuilder |> ignore | ||
true | ||
else | ||
false | ||
|
||
// initialize the app | ||
ensureAppInitialized appBuilder |> ignore | ||
|
||
let control = controlFactory () | ||
|
||
// create a window | ||
let window = Window () | ||
|
||
let wrapper = | ||
ContentControl ( | ||
Content = (control), | ||
(* some styles, like the fluent styles, depend on the window background style *) | ||
Background = window.Background | ||
) | ||
|
||
// associate the layoutable with the window, which in turn makes the application styles available | ||
window.Content <- wrapper | ||
|
||
// render the layoutable | ||
render settings stream (wrapper :> ILayoutable) | ||
() | ||
|
||
let renderToFile appBuilder (settings : RenderSettings) (filePath : string) (controlFactory : ControlFactory) = | ||
use fs = File.Create filePath | ||
renderToStream appBuilder settings fs controlFactory | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Timeboxing.Test.Render | ||
|
||
open System.IO | ||
open Avalonia | ||
open Avalonia.Layout | ||
open Avalonia.Media.Imaging | ||
open Avalonia.Skia | ||
|
||
type SizeType = | ||
| Desired | ||
| Exact | ||
|
||
type RenderSettings = { | ||
Width : int | ||
Height : int | ||
Dpi : float | ||
SizeType : SizeType | ||
} | ||
|
||
module RenderSettings = | ||
let def = { Width = 800; Height = 800; Dpi = 96.; SizeType = SizeType.Desired } | ||
|
||
let render (settings : RenderSettings) (stream : Stream) (control : ILayoutable) = | ||
SkiaPlatform.Initialize () | ||
|
||
let dpiVector = Vector (settings.Dpi, settings.Dpi) | ||
let size = Size (float settings.Width, float settings.Height) | ||
|
||
control.Measure(size) | ||
|
||
let rect = | ||
match settings.SizeType with | ||
| Exact -> Rect size | ||
| Desired -> Rect control.DesiredSize | ||
|
||
control.Arrange(rect) | ||
|
||
let pixelSize = | ||
match settings.SizeType with | ||
| Exact -> PixelSize (settings.Width, settings.Height) | ||
| Desired -> PixelSize (int rect.Width, int rect.Height) | ||
|
||
use bitmap = new RenderTargetBitmap (pixelSize, dpiVector) | ||
|
||
bitmap.Render(control) | ||
bitmap.Save(stream) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp5.0</TargetFramework> | ||
<!--<TargetFrameworks>net48;netcoreapp5.0</TargetFrameworks>--> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Render.fs" /> | ||
<Compile Include="Preview.fs" /> | ||
<Compile Include="ColorPalettesTest.fs" /> | ||
<Compile Include="ViewsTest.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0" /> | ||
<PackageReference Include="FSharp.Control.Reactive" Version="4.5.0" /> | ||
<PackageReference Include="FsUnit.xUnit" Version="4.0.4" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<AvaloniaResource Include="assets\*" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Timeboxing\Timeboxing.fsproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ProjectConfiguration> | ||
<Settings> | ||
<AdditionalFilesToIncludeForProject> | ||
<Value>assets\**.*</Value> | ||
</AdditionalFilesToIncludeForProject> | ||
</Settings> | ||
</ProjectConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module Timeboxing.Test.ViewsTest | ||
|
||
open System.IO | ||
open System | ||
open System.Reflection | ||
|
||
open Xunit | ||
|
||
open Avalonia.Controls | ||
open Timeboxing | ||
open Timeboxing.Test.Preview | ||
open Timeboxing.Test.Render | ||
open Timeboxing.Program | ||
open Timeboxing.Views | ||
|
||
let render settings name (controlFactory : unit -> IControl) = | ||
let appBuilder = createApp () | ||
let filePath = | ||
Path.Combine [| | ||
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) | ||
"screenshots" | ||
Assembly.GetExecutingAssembly().GetName().Name | ||
$"{name}.png" | ||
|] | ||
|
||
renderToFile appBuilder settings filePath controlFactory | ||
|
||
let renderSizeAuto name controlFactory = | ||
render RenderSettings.def name controlFactory | ||
|
||
let renderSizeExact (width, height) name controlFactory = | ||
render | ||
{ RenderSettings.def with Width = width; Height = height; SizeType = SizeType.Exact; } | ||
name | ||
controlFactory | ||
|
||
[<Fact>] | ||
let titleViewTest () = | ||
renderSizeExact (400, 20) "titleView" (State.init >> titleView) | ||
|
||
[<Fact>] | ||
let titleViewFullTest () = | ||
let state = | ||
let state = State.init () | ||
state.CompletedTimeboxes.OnNext(8) | ||
state | ||
|
||
renderSizeAuto "titleView-full" (fun () -> titleView state) | ||
|
||
[<Fact>] | ||
let buttonViewTest () = | ||
renderSizeAuto "buttonsView" (State.init >> buttonsView) | ||
|
||
[<Fact>] | ||
let timerViewTest() = | ||
renderSizeAuto "timerView" (State.init >> timerView) | ||
|
||
[<Fact>] | ||
let mainViewTest () = | ||
renderSizeAuto "mainView" (State.init >> mainView) | ||
|
||
[<Fact>] | ||
let settingsViewTest () = | ||
renderSizeAuto "settingsView" (State.init >> settingsView) |
Oops, something went wrong.