Skip to content

Commit

Permalink
Merge pull request #5 from davidtimovski/dev
Browse files Browse the repository at this point in the history
Upgrade to Avalonia UI v11
  • Loading branch information
davidtimovski authored Nov 9, 2024
2 parents 3ce9a49 + f0f8b5a commit 7dd25f9
Show file tree
Hide file tree
Showing 82 changed files with 561 additions and 593 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ msbuild.wrn
# Custom
publishing/*/*.lnk
publishing/*/installers/
publishing/linux/output/
publishing/linux/output/
!publishing/linux/template_*/usr/bin
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ Create a room and connect with friends or join a random room and connect with a
### Download

You can download it from my website [here](https://www.davidtimovski.com/team-sketch#download).

## License

This project is licensed under the GNU GPLv3 License - see the [LICENSE](LICENSE) file for details.
7 changes: 7 additions & 0 deletions TeamSketch.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamSketch.Benchmarks", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamSketch.Common", "src\TeamSketch.Common\TeamSketch.Common.csproj", "{0AF8DCE2-00D4-45A9-864D-44DBDF0AAFA0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8079599B-405F-4D9C-B2D2-3571FF9CD75A}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
kestrel-team-sketch.service = kestrel-team-sketch.service
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
440 changes: 249 additions & 191 deletions design/icon.ai

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions publishing/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Publishing for Linux

1. Update the version and potentially target framework in the files
2. Publish the app for x64 and ARM with the following commands:
```
dotnet publish "./TeamSketch.csproj" --verbosity quiet --nologo --configuration Release --self-contained true --runtime linux-x64 --output "./bin/Release/net8.0/linux-x64"
dotnet publish "./TeamSketch.csproj" --verbosity quiet --nologo --configuration Release --self-contained true --runtime linux-arm --output "./bin/Release/net8.0/linux-arm"
```
3. Create the deployment files by running the PowerShell scripts
4. Move the produced files from the `output` folder to WSL and run the Debian packaging commands:

```
dpkg-deb --root-owner-group --build team-sketch_*_amd64
dpkg-deb --root-owner-group --build team-sketch_*_armhf
```

Follow the [official Avalonia UI guidance](https://docs.avaloniaui.net/docs/deployment/debian-ubuntu) for more details.
2 changes: 0 additions & 2 deletions publishing/linux/packaging commands.txt

This file was deleted.

13 changes: 7 additions & 6 deletions publishing/linux/publish_64.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
$Version = "0.8.2"
$Version = "0.9.0"
$RepoDir = "R:\repos\team-sketch"
$TargetFramework = "net8.0"

cd "C:\Users\david\source\repos\team-sketch\publishing\linux"
cd "${RepoDir}\publishing\linux"

New-Item -Path . -Name "output\team-sketch_${Version}_amd64" -ItemType "directory"
Copy-Item -Path "C:\Users\david\source\repos\team-sketch\publishing\linux\template_64\*" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_amd64\" -Recurse
Copy-Item -Path "${RepoDir}\publishing\linux\template_64\*" -Destination "${RepoDir}\publishing\linux\output\team-sketch_${Version}_amd64\" -Recurse

Copy-Item "C:\Users\david\source\repos\team-sketch\publishing\linux\template_64\DEBIAN\control" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_amd64\DEBIAN\control"

Copy-Item "C:\Users\david\source\repos\team-sketch\src\TeamSketch\bin\Release\net6.0\publish\linux-x64\TeamSketch" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_amd64\usr\bin\team-sketch"
New-Item -Path . -Name "output\team-sketch_${Version}_amd64\usr\lib\team-sketch" -ItemType "directory"
Copy-Item "${RepoDir}\src\TeamSketch\bin\Release\${TargetFramework}\linux-x64\*" -Destination "${RepoDir}\publishing\linux\output\team-sketch_${Version}_amd64\usr\lib\team-sketch\"
13 changes: 7 additions & 6 deletions publishing/linux/publish_arm.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
$Version = "0.8.2"
$Version = "0.9.0"
$RepoDir = "R:\repos\team-sketch"
$TargetFramework = "net8.0"

cd "C:\Users\david\source\repos\team-sketch\publishing\linux"
cd "${RepoDir}\publishing\linux"

New-Item -Path . -Name "output\team-sketch_${Version}_armhf" -ItemType "directory"
Copy-Item -Path "C:\Users\david\source\repos\team-sketch\publishing\linux\template_arm\*" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_armhf\" -Recurse
Copy-Item -Path "${RepoDir}\publishing\linux\template_arm\*" -Destination "${RepoDir}\publishing\linux\output\team-sketch_${Version}_armhf\" -Recurse

Copy-Item "C:\Users\david\source\repos\team-sketch\publishing\linux\template_arm\DEBIAN\control" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_armhf\DEBIAN\control"

Copy-Item "C:\Users\david\source\repos\team-sketch\src\TeamSketch\bin\Release\net6.0\publish\linux-arm\TeamSketch" -Destination "C:\Users\david\source\repos\team-sketch\publishing\linux\output\team-sketch_${Version}_armhf\usr\bin\team-sketch"
New-Item -Path . -Name "output\team-sketch_${Version}_armhf\usr\lib\team-sketch" -ItemType "directory"
Copy-Item "${RepoDir}\src\TeamSketch\bin\Release\${TargetFramework}\linux-arm\*" -Destination "${RepoDir}\publishing\linux\output\team-sketch_${Version}_armhf\usr\lib\team-sketch\"
17 changes: 7 additions & 10 deletions publishing/linux/template_64/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
Package: team-sketch
Architecture: amd64
Section: base
Standards-Version: 4.0.0
Version: 0.9.0
Section: devel
Priority: optional
Name: Team Sketch
Description: Sketch with your friends.
Author: David Timovski <david.timovski@gmail.com>
Maintainer: David Timovski <david.timovski@gmail.com>
Version: 0.8.2
Essential: no
Icon: /usr/share/icons/hicolor/scalable/apps/team-sketch.svg
Architecture: amd64
Depends: libc6, libc6, libgcc-s1, libicu74, libssl3, libstdc++6, zlib1g
Maintainer: David Timovski
Homepage: https://www.davidtimovski.com/team-sketch
Description: Sketch with your friends.
Copyright: 2021-2024 David Timovski
4 changes: 4 additions & 0 deletions publishing/linux/template_64/usr/bin/team-sketch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# use exec to not have the wrapper script staying as a separate process
# "$@" to pass command line arguments to the app
exec /usr/lib/team-sketch/TeamSketch "$@"
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[Desktop Entry]
Name=Team Sketch
Comment=Sketch with your friends
GenericName=Text Editor
Icon=team-sketch
Exec=team-sketch
Icon=/usr/share/icons/hicolor/scalable/apps/team-sketch.svg
StartupWMClass=team-sketch
Terminal=false
Type=Application
Categories=Art;
Keywords=team;sketch;
GenericName=Team Sketch
Keywords=team; sketch;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 7 additions & 10 deletions publishing/linux/template_arm/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
Package: team-sketch
Architecture: armhf
Section: base
Standards-Version: 4.0.0
Version: 0.9.0
Section: devel
Priority: optional
Name: Team Sketch
Description: Sketch with your friends.
Author: David Timovski <david.timovski@gmail.com>
Maintainer: David Timovski <david.timovski@gmail.com>
Version: 0.8.2
Essential: no
Icon: /usr/share/icons/hicolor/scalable/apps/team-sketch.svg
Architecture: armhf
Depends: libc6, libc6, libgcc-s1, libicu74, libssl3, libstdc++6, zlib1g
Maintainer: David Timovski
Homepage: https://www.davidtimovski.com/team-sketch
Description: Sketch with your friends.
Copyright: 2021-2024 David Timovski
4 changes: 4 additions & 0 deletions publishing/linux/template_arm/usr/bin/team-sketch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# use exec to not have the wrapper script staying as a separate process
# "$@" to pass command line arguments to the app
exec /usr/lib/team-sketch/TeamSketch "$@"
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[Desktop Entry]
Name=Team Sketch
Comment=Sketch with your friends
GenericName=Text Editor
Icon=team-sketch
Exec=team-sketch
Icon=/usr/share/icons/hicolor/scalable/apps/team-sketch.svg
StartupWMClass=team-sketch
Terminal=false
Type=Application
Categories=Art;
Keywords=team;sketch;
GenericName=Team Sketch
Keywords=team; sketch;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions publishing/windows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Publishing for Windows

1. Adjust the `Properties\PublishProfiles\Win64.pubxml` file if needed
2. Publish for Win64 using Visual Studio
3. Open the `win64.iss` file with Inno Setup Compiler
4. Adjust the version or target framework values
5. Compile it
8 changes: 4 additions & 4 deletions publishing/windows/win64.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Team Sketch"
#define MyAppVersion "0.8.2"
#define MyAppVersion "0.9.0"
#define MyAppPublisher "David Timovski"
#define MyAppURL "https://www.davidtimovski.com/team-sketch"
#define MyAppExeName "TeamSketch.exe"
Expand All @@ -22,9 +22,9 @@ DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\david\source\repos\team-sketch\publishing\windows\installers
OutputDir=R:\repos\team-sketch\publishing\windows\installers
OutputBaseFilename="team-sketch_{#MyAppVersion}_win64_setup"
SetupIconFile=C:\Users\david\source\repos\team-sketch\src\TeamSketch\Assets\logo.ico
SetupIconFile=R:\repos\team-sketch\src\TeamSketch\Assets\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern
Expand All @@ -36,7 +36,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\david\source\repos\team-sketch\src\TeamSketch\bin\Release\net6.0\publish\win-x64\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "R:\repos\team-sketch\src\TeamSketch\bin\Release\net8.0\publish\win-x64\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Expand Down
61 changes: 30 additions & 31 deletions src/TeamSketch.Benchmarks/Benchmarks/PayloadConverterBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,43 @@
using TeamSketch.Models;
using TeamSketch.Utils;

namespace TeamSketch.Benchmarks
namespace TeamSketch.Benchmarks;

[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class PayloadConverterPointBenchmarks
{
[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class PayloadConverterPointBenchmarks
private readonly Random _random = new();
private readonly int x1;
private readonly int y1;

public PayloadConverterPointBenchmarks()
{
private readonly Random _random = new();
private readonly int x1;
private readonly int y1;
x1 = _random.Next(0, Globals.CanvasWidth);
y1 = _random.Next(0, Globals.CanvasHeight);
}

public PayloadConverterPointBenchmarks()
{
x1 = _random.Next(0, Globals.CanvasWidth);
y1 = _random.Next(0, Globals.CanvasHeight);
}
[Benchmark]
public void PointToBytes() => PayloadConverter.ToBytes(x1, y1, ThicknessEnum.SemiThin, ColorsEnum.Blue);
}

[Benchmark]
public void PointToBytes() => PayloadConverter.ToBytes(x1, y1, ThicknessEnum.SemiThin, ColorsEnum.Blue);
}
[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class PayloadConverterLineBenchmarks
{
private readonly Random _random = new();
private readonly List<Point> _linePoints = new(40);

[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class PayloadConverterLineBenchmarks
public PayloadConverterLineBenchmarks()
{
private readonly Random _random = new();
private readonly List<Point> _linePoints = new(40);

public PayloadConverterLineBenchmarks()
for (int i = 0; i < _linePoints.Count; i++)
{
for (int i = 0; i < _linePoints.Count; i++)
{
var x = _random.Next(0, Globals.CanvasWidth);
var y = _random.Next(0, Globals.CanvasHeight);
_linePoints[i] = new Point(x, y);
}
var x = _random.Next(0, Globals.CanvasWidth);
var y = _random.Next(0, Globals.CanvasHeight);
_linePoints[i] = new Point(x, y);
}

[Benchmark]
public void LineToBytes() => PayloadConverter.ToBytes(_linePoints, ThicknessEnum.SemiThin, ColorsEnum.Blue);
}

[Benchmark]
public void LineToBytes() => PayloadConverter.ToBytes(_linePoints, ThicknessEnum.SemiThin, ColorsEnum.Blue);
}
51 changes: 25 additions & 26 deletions src/TeamSketch.Benchmarks/Benchmarks/RendererBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,35 @@
using TeamSketch.Models;
using TeamSketch.Services;

namespace TeamSketch.Benchmarks
namespace TeamSketch.Benchmarks;

[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class RendererBenchmarks
{
[SimpleJob(launchCount: 5, warmupCount: 5)]
[MemoryDiagnoser]
public class RendererBenchmarks
{
private readonly Random _random = new();
private readonly IRenderer _renderer;
private const int LineSegmentsCount = 20;
private readonly Random _random = new();
private readonly IRenderer _renderer;
private const int LineSegmentsCount = 20;

public RendererBenchmarks()
public RendererBenchmarks()
{
var canvas = new Canvas
{
var canvas = new Canvas
{
Width = Globals.CanvasWidth,
Height = Globals.CanvasHeight
};
_renderer = new Renderer(new BrushSettings(""), canvas);
Width = Globals.CanvasWidth,
Height = Globals.CanvasHeight
};
_renderer = new Renderer(new BrushSettings(""), canvas);

for (int i = 0; i < LineSegmentsCount; i++)
{
var x1 = _random.Next(0, Globals.CanvasWidth);
var y1 = _random.Next(0, Globals.CanvasHeight);
var x2 = _random.Next(0, Globals.CanvasWidth);
var y2 = _random.Next(0, Globals.CanvasHeight);
_renderer.EnqueueLineSegment(new Point(x1, y1), new Point(x2, y2));
}
for (int i = 0; i < LineSegmentsCount; i++)
{
var x1 = _random.Next(0, Globals.CanvasWidth);
var y1 = _random.Next(0, Globals.CanvasHeight);
var x2 = _random.Next(0, Globals.CanvasWidth);
var y2 = _random.Next(0, Globals.CanvasHeight);
_renderer.EnqueueLineSegment(new Point(x1, y1), new Point(x2, y2));
}

[Benchmark]
public void RenderLine() => _renderer.RenderLine();
}

[Benchmark]
public void RenderLine() => _renderer.RenderLine();
}
2 changes: 1 addition & 1 deletion src/TeamSketch.Benchmarks/TeamSketch.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" />
</ItemGroup>
Expand Down
7 changes: 5 additions & 2 deletions src/TeamSketch.Common/Validations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TeamSketch.Common;

public static class Validations
public static partial class Validations
{
public static string? ValidateNickname(string nickname)
{
Expand Down Expand Up @@ -43,6 +43,9 @@ private static bool IsAlphanumeric(string text)

text = text.Trim();

return Regex.IsMatch(text, @"^[a-zA-Z0-9\s]*$");
return AlphanumericRegex().IsMatch(text);
}

[GeneratedRegex(@"^[a-zA-Z0-9\s]*$")]
private static partial Regex AlphanumericRegex();
}
2 changes: 1 addition & 1 deletion src/TeamSketch.Web/Config/DatabaseSettings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TeamSketch.Web.Config;

public class DatabaseSettings
public sealed class DatabaseSettings
{
public required string ConnectionString { get; init; }
}
2 changes: 1 addition & 1 deletion src/TeamSketch.Web/Controllers/LiveViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace TeamSketch.Web.Controllers;

[Route("api/[controller]")]
[ApiController]
public class LiveViewController : ControllerBase
public sealed class LiveViewController : ControllerBase
{
private readonly ILiveViewService _liveLiveService;

Expand Down
Loading

0 comments on commit 7dd25f9

Please sign in to comment.