first commit

This commit is contained in:
2024-09-15 22:35:54 +02:00
commit df3b8a3135
22 changed files with 1363 additions and 0 deletions

552
.gitignore vendored Normal file
View File

@@ -0,0 +1,552 @@
# Created by https://www.toptal.com/developers/gitignore/api/csharp,rider,jetbrains+all,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=csharp,rider,jetbrains+all,visualstudiocode
### Csharp ###
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.tlog
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
*.vbp
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
*.dsw
*.dsp
# Visual Studio 6 technical files
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# Visual Studio History (VSHistory) files
.vshistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd
# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
# Windows Installer files from build outputs
*.cab
*.msi
*.msix
*.msm
*.msp
# JetBrains Rider
*.sln.iml
### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### JetBrains+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.
.idea/*
!.idea/codeStyles
!.idea/runConfigurations
### Rider ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
# AWS User-specific
# Generated files
# Sensitive or high-churn files
# Gradle
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
# Mongo Explorer plugin
# File-based project format
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# SonarLint plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
# Editor-based Rest Client
# Android studio 3.1+ serialized cache file
### VisualStudioCode ###
!.vscode/*.code-snippets
# Local History for Visual Studio Code
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# End of https://www.toptal.com/developers/gitignore/api/csharp,rider,jetbrains+all,visualstudiocode

1
GtkSharp Submodule

Submodule GtkSharp added at b730361612

70
KioskApp.sln Normal file
View File

@@ -0,0 +1,70 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KioskApp", "KioskApp\KioskApp.csproj", "{C128382B-DBDF-4017-8880-23840B73AAB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AtkSharp", "GtkSharp\Source\Libs\AtkSharp\AtkSharp.csproj", "{476FBBC9-C99D-4537-8B56-2CE642AA503E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CairoSharp", "GtkSharp\Source\Libs\CairoSharp\CairoSharp.csproj", "{9A48E886-1822-4236-A755-CC9DD6950101}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GdkSharp", "GtkSharp\Source\Libs\GdkSharp\GdkSharp.csproj", "{FB688484-D9B1-4CFB-9D9B-B010B481C0F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GioSharp", "GtkSharp\Source\Libs\GioSharp\GioSharp.csproj", "{3FC90735-CAB1-408F-A7BB-A3F7C3828537}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GLibSharp", "GtkSharp\Source\Libs\GLibSharp\GLibSharp.csproj", "{F0197969-1997-47D9-8E2D-5E5D72604E6F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkSharp", "GtkSharp\Source\Libs\GtkSharp\GtkSharp.csproj", "{6FC9ABA1-04FE-4CF9-A28E-A6FDFBC88BDF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GtkSourceSharp", "GtkSharp\Source\Libs\GtkSourceSharp\GtkSourceSharp.csproj", "{865BAF09-CDF5-4EB1-847F-85D45B1E3594}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PangoSharp", "GtkSharp\Source\Libs\PangoSharp\PangoSharp.csproj", "{5D8BA324-01BC-4FF2-A51A-00B2AB0997FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebkitGtkSharp", "GtkSharp\Source\Libs\WebkitGtkSharp\WebkitGtkSharp.csproj", "{C5088BEC-C4C9-44F4-9C93-48F0BCD5B5CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C128382B-DBDF-4017-8880-23840B73AAB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C128382B-DBDF-4017-8880-23840B73AAB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C128382B-DBDF-4017-8880-23840B73AAB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C128382B-DBDF-4017-8880-23840B73AAB3}.Release|Any CPU.Build.0 = Release|Any CPU
{476FBBC9-C99D-4537-8B56-2CE642AA503E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{476FBBC9-C99D-4537-8B56-2CE642AA503E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{476FBBC9-C99D-4537-8B56-2CE642AA503E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{476FBBC9-C99D-4537-8B56-2CE642AA503E}.Release|Any CPU.Build.0 = Release|Any CPU
{9A48E886-1822-4236-A755-CC9DD6950101}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A48E886-1822-4236-A755-CC9DD6950101}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A48E886-1822-4236-A755-CC9DD6950101}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A48E886-1822-4236-A755-CC9DD6950101}.Release|Any CPU.Build.0 = Release|Any CPU
{FB688484-D9B1-4CFB-9D9B-B010B481C0F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB688484-D9B1-4CFB-9D9B-B010B481C0F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB688484-D9B1-4CFB-9D9B-B010B481C0F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB688484-D9B1-4CFB-9D9B-B010B481C0F4}.Release|Any CPU.Build.0 = Release|Any CPU
{3FC90735-CAB1-408F-A7BB-A3F7C3828537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FC90735-CAB1-408F-A7BB-A3F7C3828537}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FC90735-CAB1-408F-A7BB-A3F7C3828537}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FC90735-CAB1-408F-A7BB-A3F7C3828537}.Release|Any CPU.Build.0 = Release|Any CPU
{F0197969-1997-47D9-8E2D-5E5D72604E6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0197969-1997-47D9-8E2D-5E5D72604E6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0197969-1997-47D9-8E2D-5E5D72604E6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0197969-1997-47D9-8E2D-5E5D72604E6F}.Release|Any CPU.Build.0 = Release|Any CPU
{6FC9ABA1-04FE-4CF9-A28E-A6FDFBC88BDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6FC9ABA1-04FE-4CF9-A28E-A6FDFBC88BDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6FC9ABA1-04FE-4CF9-A28E-A6FDFBC88BDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6FC9ABA1-04FE-4CF9-A28E-A6FDFBC88BDF}.Release|Any CPU.Build.0 = Release|Any CPU
{865BAF09-CDF5-4EB1-847F-85D45B1E3594}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{865BAF09-CDF5-4EB1-847F-85D45B1E3594}.Debug|Any CPU.Build.0 = Debug|Any CPU
{865BAF09-CDF5-4EB1-847F-85D45B1E3594}.Release|Any CPU.ActiveCfg = Release|Any CPU
{865BAF09-CDF5-4EB1-847F-85D45B1E3594}.Release|Any CPU.Build.0 = Release|Any CPU
{5D8BA324-01BC-4FF2-A51A-00B2AB0997FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D8BA324-01BC-4FF2-A51A-00B2AB0997FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D8BA324-01BC-4FF2-A51A-00B2AB0997FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D8BA324-01BC-4FF2-A51A-00B2AB0997FD}.Release|Any CPU.Build.0 = Release|Any CPU
{C5088BEC-C4C9-44F4-9C93-48F0BCD5B5CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5088BEC-C4C9-44F4-9C93-48F0BCD5B5CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5088BEC-C4C9-44F4-9C93-48F0BCD5B5CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5088BEC-C4C9-44F4-9C93-48F0BCD5B5CC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

25
KioskApp/.dockerignore Normal file
View File

@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

View File

@@ -0,0 +1,18 @@
<Project>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/obj/**/*</DefaultItemExcludes>
<DefaultItemExcludes>$(DefaultItemExcludes);$(MSBuildProjectDirectory)/bin/**/*</DefaultItemExcludes>
</PropertyGroup>
<PropertyGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' == 'true'">
<BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/container/</BaseIntermediateOutputPath>
<BaseOutputPath>$(MSBuildProjectDirectory)/bin/container/</BaseOutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(DOTNET_RUNNING_IN_CONTAINER)' != 'true'">
<BaseIntermediateOutputPath>$(MSBuildProjectDirectory)/obj/local/</BaseIntermediateOutputPath>
<BaseOutputPath>$(MSBuildProjectDirectory)/bin/local/</BaseOutputPath>
</PropertyGroup>
</Project>

42
KioskApp/Dockerfile Normal file
View File

@@ -0,0 +1,42 @@
# Define a separate build stage for installing libraries
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS lib-install
USER root
# Install libgtk-3-0 and X11 libraries
RUN apt-get update && apt-get install -y \
libgtk-3-0 \
libx11-6 \
libxext6 \
libxrender1 \
libxtst6 \
libxi6 \
libwebkit2gtk-4.0-dev
# Continue with your existing Dockerfile
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
USER $APP_UID
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /app
COPY ["KioskApp.csproj", "."]
RUN dotnet restore "KioskApp.csproj"
COPY . .
RUN dotnet build "KioskApp.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "KioskApp.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Copy installed libraries from lib-install stage
COPY --from=lib-install /usr/lib /usr/lib
COPY --from=lib-install /usr/include /usr/include
USER $APP_UID
ENTRYPOINT ["dotnet", "KioskApp.dll"]

27
KioskApp/KioskApp.csproj Normal file
View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2783-prerelease" />
<PackageReference Include="NWindows" Version="0.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GtkSharp\Source\Libs\AtkSharp\AtkSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\CairoSharp\CairoSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\GdkSharp\GdkSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\GioSharp\GioSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\GLibSharp\GLibSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\GtkSharp\GtkSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\GtkSourceSharp\GtkSourceSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\PangoSharp\PangoSharp.csproj" />
<ProjectReference Include="..\GtkSharp\Source\Libs\WebkitGtkSharp\WebkitGtkSharp.csproj" />
</ItemGroup>
</Project>

21
KioskApp/compose.yml Normal file
View File

@@ -0,0 +1,21 @@
services:
kioskapp:
build:
context: .
dockerfile: Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Production
- DISPLAY=:0 # Set DISPLAY environment variable for X11
networks:
- kiosknet
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix # Mount X11 socket
develop:
watch:
- action: sync+restart
path: .
target: /app
networks:
kiosknet:
driver: bridge

View File

@@ -0,0 +1,32 @@
using System.Reflection;
using KioskApp.Portal.Platforms.Attributes;
namespace KioskApp.Portal.Helper;
public static class OsReflectionHelper
{
public static Type? GetSupportedClassForCurrentOs(Type baseType)
{
var currentOs = GetCurrentOs();
var assembly = Assembly.GetExecutingAssembly();
return assembly.GetTypes()
.Where(t => baseType.IsAssignableFrom(t) && !t.IsAbstract)
.FirstOrDefault(t =>
{
var attr = t.GetCustomAttribute<SupportedOSAttribute>();
return attr != null && (attr.SupportedOperatingSystems & currentOs) == currentOs;
});
}
private static SupportedOS GetCurrentOs()
{
if (OperatingSystem.IsWindows())
return SupportedOS.Windows;
if (OperatingSystem.IsLinux())
return SupportedOS.Linux;
if (OperatingSystem.IsMacOS())
return SupportedOS.MacOS;
return SupportedOS.None;
}
}

View File

@@ -0,0 +1,12 @@
namespace KioskApp.Portal.Platforms.Attributes;
[Flags]
public enum SupportedOS
{
None = 0,
Windows = 1,
Linux = 2,
MacOS = 4,
All = Windows | Linux | MacOS
}

View File

@@ -0,0 +1,12 @@
namespace KioskApp.Portal.Platforms.Attributes;
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class SupportedOSAttribute : Attribute
{
public SupportedOS SupportedOperatingSystems { get; }
public SupportedOSAttribute(SupportedOS supportedOS)
{
SupportedOperatingSystems = supportedOS;
}
}

View File

@@ -0,0 +1,7 @@
namespace KioskApp.Portal.Platforms.Events;
public class WindowClosingEventArgs : EventArgs
{
public bool Cancel { get; set; }
}

View File

@@ -0,0 +1,106 @@
using System.Drawing;
using Gdk;
using Gtk;
using KioskApp.Portal.Platforms.Events;
using KioskApp.Portal.Platforms.Windows;
using Widget = KioskApp.Portal.Widgets.Widget;
namespace KioskApp.Portal.Platforms.Linux;
public class LinuxWindow : Window
{
public override event EventHandler<WindowClosingEventArgs> Closing;
private Gtk.Window _nativeWindow;
public LinuxWindow(WindowOptions options) : base(options)
{
InternalCreate();
}
protected sealed override void InternalCreate()
{
Application.Init();
_nativeWindow = new Gtk.Window(Title);
_nativeWindow.SetDefaultSize(Width, Height);
_nativeWindow.DeleteEvent += NativeWindowOnDeleteEvent;
_nativeWindow.SizeAllocated += (_, _) => InternalResize(_nativeWindow.Allocation.Width, _nativeWindow.Allocation.Height);
}
private void NativeWindowOnDeleteEvent(object o, DeleteEventArgs args)
{
args.RetVal = !Close();
}
protected override void InternalResize(int width, int height)
{
Width = width;
Height = height;
var clientSize = GetClientSize();
var widgets = GetWidgets();
foreach (var widget in widgets)
{
widget.Resize((int)clientSize.Width, (int)clientSize.Height);
}
}
protected override bool Close()
{
return false;
var args = new WindowClosingEventArgs();
Closing?.Invoke(this, args);
if (args.Cancel) return false;
// Dispose all widgets
var widgets = GetWidgets();
foreach (var widget in widgets)
{
widget.Dispose();
}
// TODO: We only need to call it when the last window is closed
Application.Quit();
return true;
}
public override void Show()
{
_nativeWindow.ShowAll();
Application.Run();
}
public override T GetNativeWindow<T>()
{
return (_nativeWindow as T)!;
}
public override IntPtr GetNativeHandle()
{
return _nativeWindow.Handle;
}
public override SizeF GetClientSize()
{
// Get the allocation of the window
var allocation = _nativeWindow.Allocation;
// If you have a Container as the direct child of the window (e.g., VBox, HBox),
// you might want to use its allocation instead for more accurate client area
if (_nativeWindow.Child is Container container)
{
allocation = container.Allocation;
}
return new SizeF(allocation.Width, allocation.Height);
}
public override void Fullscreen()
{
_nativeWindow.KeepAbove = true;
_nativeWindow.Fullscreen();
}
}

View File

@@ -0,0 +1,44 @@
using GLib;
using KioskApp.Portal.Platforms.Attributes;
using KioskApp.Portal.Widgets;
using WebKit;
namespace KioskApp.Portal.Platforms.Linux.Widgets;
[SupportedOS(SupportedOS.Linux)]
public class WebView : BaseWebView
{
private WebKit.WebView _webView;
public override void Resize(int width, int height)
{
}
public override void Navigate(string url)
{
_webView.LoadUri(url);
}
public override void Dispose()
{
_webView.Destroy();
}
public override void OnInitialized()
{
_webView = new WebKit.WebView();
var window = GetParentWindow();
var gtkWindow = window.GetNativeWindow<Gtk.Window>();
gtkWindow.Add(_webView);
// (Delegate) value, typeof (CreateArgs)
_webView.Create += WebViewOnCreate;
}
private void WebViewOnCreate(object o, CreateArgs args)
{
var req = args.NavigationAction.Request;
var x = 0;
}
}

View File

@@ -0,0 +1,55 @@
using KioskApp.Portal.Platforms.Attributes;
using KioskApp.Portal.Widgets;
using Microsoft.Web.WebView2.Core;
namespace KioskApp.Portal.Platforms.Windows.Widgets;
[SupportedOS(SupportedOS.Windows)]
public class WebView : BaseWebView
{
private string _lastUrl = string.Empty;
private CoreWebView2Controller? _controller;
protected override void InternalCreate()
{
InternalCreateAsync();
return;
async void InternalCreateAsync()
{
var window = GetParentWindow();
var env = await CoreWebView2Environment.CreateAsync();
_controller = await env.CreateCoreWebView2ControllerAsync(window.GetNativeHandle());
var clientSize = GetParentWindow().GetClientSize();
_controller.Bounds = new(0, 0, (int)clientSize.Width, (int)clientSize.Height);
if (!string.IsNullOrEmpty(_lastUrl))
{
_controller.CoreWebView2.Navigate(_lastUrl);
_lastUrl = string.Empty;
}
}
}
public override void Resize(int width, int height)
{
_controller.Bounds = new(0, 0, width, height);
}
public override void Navigate(string url)
{
if (_controller == null)
{
_lastUrl = url;
return;
}
_controller.CoreWebView2.Navigate(url);
}
public override void Dispose()
{
_controller.Close();
}
}

View File

@@ -0,0 +1,180 @@
using System.Drawing;
using KioskApp.Portal.Platforms.Events;
using NWindows.Events;
using NWindows.Threading;
namespace KioskApp.Portal.Platforms.Windows;
public class WindowsWindow : Window
{
public override event EventHandler<WindowClosingEventArgs> Closing;
private NWindows.Window _nativeWindow;
public WindowsWindow(WindowOptions options) : base(options)
{
InternalCreate();
}
protected override bool Close()
{
var args = new WindowClosingEventArgs();
Closing?.Invoke(this, args);
if (args.Cancel) return false;
_nativeWindow.Events.Frame -= EventsOnFrame;
_nativeWindow.Events.Close -= EventsOnClose;
// Dispose all widgets
var widgets = GetWidgets();
foreach (var widget in widgets)
{
widget.Dispose();
}
// TODO: We only need to call it when the last window is closed
Dispatcher.Current.Shutdown();
return true;
}
public override void Show()
{
_nativeWindow.Visible = true;
_nativeWindow.Events.Frame += EventsOnFrame;
_nativeWindow.Events.Close += EventsOnClose;
Dispatcher.Current.Run();
}
public override T GetNativeWindow<T>()
{
return (_nativeWindow as T)!;
}
private void EventsOnClose(NWindows.Window window, CloseEvent evt)
{
evt.Cancel = !Close();
}
private void EventsOnFrame(NWindows.Window window, FrameEvent evt)
{
switch (evt.ChangeKind)
{
case FrameChangeKind.Resized:
case FrameChangeKind.Maximized:
case FrameChangeKind.Restored:
InternalResize((int)_nativeWindow.Size.Width, (int)_nativeWindow.Size.Height);
break;
case FrameChangeKind.None:
break;
case FrameChangeKind.Created:
break;
case FrameChangeKind.Destroyed:
break;
case FrameChangeKind.PositionAndSizeChanged:
break;
case FrameChangeKind.Shown:
break;
case FrameChangeKind.Hidden:
break;
case FrameChangeKind.Moved:
break;
case FrameChangeKind.Minimized:
break;
case FrameChangeKind.FullScreen:
break;
case FrameChangeKind.FocusGained:
break;
case FrameChangeKind.FocusLost:
break;
case FrameChangeKind.MinimumSizeChanged:
break;
case FrameChangeKind.MaximumSizeChanged:
break;
case FrameChangeKind.ResizeableChanged:
break;
case FrameChangeKind.StateChanged:
break;
case FrameChangeKind.OpacityChanged:
break;
case FrameChangeKind.TopMostChanged:
break;
case FrameChangeKind.ModalChanged:
break;
case FrameChangeKind.Enabled:
break;
case FrameChangeKind.Disabled:
break;
case FrameChangeKind.TitleChanged:
break;
case FrameChangeKind.MaximizeableChanged:
break;
case FrameChangeKind.MinimizeableChanged:
break;
case FrameChangeKind.BackgroundColorChanged:
break;
case FrameChangeKind.ShowInTaskBarChanged:
break;
case FrameChangeKind.DpiChanged:
break;
case FrameChangeKind.DpiModeChanged:
break;
case FrameChangeKind.DragDropChanged:
break;
case FrameChangeKind.ClipboardChanged:
break;
case FrameChangeKind.DecorationsChanged:
break;
case FrameChangeKind.ThemeChanged:
break;
case FrameChangeKind.ThemeSyncModeChanged:
break;
default:
throw new ArgumentOutOfRangeException();
}
}
public override IntPtr GetNativeHandle()
{
return _nativeWindow.Handle;
}
protected sealed override void InternalCreate()
{
_nativeWindow = NWindows.Window.Create(new()
{
Title = Title,
});
_nativeWindow.Size = new(Width, Height);
}
public sealed override SizeF GetClientSize()
{
Dispatcher.Current.VerifyAccess();
return _nativeWindow.ClientSize;
}
public override void Fullscreen()
{
var screen = _nativeWindow.GetScreen();
if(screen == null) return;
_nativeWindow.Position = new(0, 0);
_nativeWindow.Decorations = false;
_nativeWindow.TopMost = true;
_nativeWindow.Size = screen.Size;
}
protected override void InternalResize(int width, int height)
{
Width = width;
Height = height;
var clientSize = GetClientSize();
var widgets = GetWidgets();
foreach (var widget in widgets)
{
widget.Resize((int)clientSize.Width, (int)clientSize.Height);
}
}
}

View File

@@ -0,0 +1,7 @@
namespace KioskApp.Portal.Widgets;
public abstract class BaseWebView: Widget, IWebView
{
public abstract override void Resize(int width, int height);
public abstract void Navigate(string url);
}

View File

@@ -0,0 +1,6 @@
namespace KioskApp.Portal.Widgets;
public interface IWebView
{
void Navigate(string url);
}

View File

@@ -0,0 +1,27 @@
using KioskApp.Portal;
namespace KioskApp.Portal.Widgets;
public abstract class Widget
{
private Window _parentWindow = null!;
public void Initialize(Window parentWindow)
{
_parentWindow = parentWindow;
InternalCreate();
OnInitialized();
}
public Window GetParentWindow()
{
return _parentWindow;
}
protected virtual void InternalCreate() {}
public abstract void Resize(int width, int height);
public virtual void Dispose() {}
public virtual void OnInitialized() {}
}

View File

@@ -0,0 +1,72 @@
using System.Drawing;
using KioskApp.Portal.Helper;
using KioskApp.Portal.Platforms.Events;
using KioskApp.Portal.Platforms.Linux;
using KioskApp.Portal.Platforms.Windows;
using KioskApp.Portal.Widgets;
namespace KioskApp.Portal;
// NOTE: The Window class is a facade for the platform-specific window implementations.
// It provides a common interface for creating, resizing, and closing windows.
// The Window class uses the OsReflectionHelper class to determine the appropriate platform-specific implementation.
// TODO: Redesign the Window class because right now its just random stuff that i need
public abstract class Window
{
public abstract event EventHandler<WindowClosingEventArgs> Closing;
private List<Widget> _widgets;
protected Window(WindowOptions options)
{
Title = options.Title;
Width = options.Width;
Height = options.Height;
_widgets = [];
}
public string Title { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public T AddWidget<T>() where T : Widget
{
var baseWidget = OsReflectionHelper.GetSupportedClassForCurrentOs(typeof(T));
var widget = (T)Activator.CreateInstance(baseWidget);
_widgets.Add(widget);
widget.Initialize(this);
return widget;
}
public static Window Create(WindowOptions options)
{
if (OperatingSystem.IsWindows()) return new WindowsWindow(options);
if (OperatingSystem.IsLinux()) return new LinuxWindow(options);
// if (OperatingSystem.IsMacOS()) return new MacWindow(options);
throw new PlatformNotSupportedException("Platform not supported.");
}
protected abstract void InternalCreate();
protected abstract void InternalResize(int width, int height);
protected abstract bool Close();
public abstract void Show();
public abstract T GetNativeWindow<T>() where T : class;
public abstract IntPtr GetNativeHandle();
public abstract SizeF GetClientSize();
public abstract void Fullscreen();
protected List<Widget> GetWidgets()
{
return _widgets;
}
}

View File

@@ -0,0 +1,8 @@
namespace KioskApp.Portal;
public class WindowOptions
{
public string Title { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}

39
KioskApp/src/Program.cs Normal file
View File

@@ -0,0 +1,39 @@
using KioskApp.Portal;
using KioskApp.Portal.Platforms.Events;
using KioskApp.Portal.Widgets;
using Window = KioskApp.Portal.Window;
namespace KioskApp;
class Program
{
[STAThread]
static void Main(string[] args)
{
var window = Window.Create(new WindowOptions
{
Title = "Kiosk App",
Width = 800,
Height = 600
});
window.Closing += WindowOnClosing;
// TODO: Links should open in the same view (Kinda broken in GTK Linux)
// TODO: Support for Window.CenterOnScreen()
// TODO: JavaScript to C# communication
// TODO: Add Razor Templating Engine
// TODO: Add Mac Support
var webview = window.AddWidget<BaseWebView>();
webview.Navigate("https://cocreate.novartis.com/");
// window.Fullscreen();
window.Show();
}
private static void WindowOnClosing(object? sender, WindowClosingEventArgs e)
{
}
}