From e68e052bbb3ed498da02f8239c345779e6ec57ed Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 00:21:34 +0100 Subject: [PATCH 01/29] Create push_master.yml --- .github/workflows/push_master.yml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/push_master.yml diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml new file mode 100644 index 0000000..e318061 --- /dev/null +++ b/.github/workflows/push_master.yml @@ -0,0 +1,51 @@ +name: Build and publish application on master push + + +on: + push: + branches: + - "master" + paths: + - "VDownload**" + + +jobs: + build: + name: Build + runs-on: windows-latest + steps: + - name: Setup GitVersion + uses: gittools/actions/gitversion/setup@v0.9.7 + with: + versionSpec: 5.x + - name: Determine Version + uses: gittools/actions/gitversion/execute@v0.9.7 + id: gitversion + with: + useConfigFile: true + configFilePath: ./.github/config/gitversion.yml + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set version in VDownload.csproj file + id: package_version + uses: KageKirin/set-csproj-version@v0 + with: + file: VDownload/VDownload.csproj + version: ${{steps.gitversion.outputs.SemVer}} + - name: Set version in Package.appxmanifest file + uses: Nambers/ReplaceStringInFile@v1.3 + with: + path: VDownload/Package.appxmanifest + oldString: "Version=\"0.0.0.0\"" + newString: "Version=\"${{steps.gitversion.outputs.major}}.${{steps.gitversion.outputs.minor}}.${{steps.gitversion.outputs.patch}}.0\"" + showFileContent: true + - name: Set version in app.manifest file + uses: Nambers/ReplaceStringInFile@v1.3 + with: + path: VDownload/app.manifest + oldString: "assemblyIdentity version=\"0.0.0.0\"" + newString: "assemblyIdentity version=\"${{steps.gitversion.outputs.major}}.${{steps.gitversion.outputs.minor}}.${{steps.gitversion.outputs.patch}}.0\"" + showFileContent: true + From 9c881ea5180365a483b4d632bffae24df712f60a Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 01:48:42 +0100 Subject: [PATCH 02/29] Update push_master.yml --- .github/workflows/push_master.yml | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index e318061..a3c8fd9 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -5,6 +5,7 @@ on: push: branches: - "master" + - "features/github_actions" paths: - "VDownload**" @@ -13,6 +14,10 @@ jobs: build: name: Build runs-on: windows-latest + strategy: + matrix: + configuration: [Release] + platform: [x64, x86] steps: - name: Setup GitVersion uses: gittools/actions/gitversion/setup@v0.9.7 @@ -48,4 +53,33 @@ jobs: oldString: "assemblyIdentity version=\"0.0.0.0\"" newString: "assemblyIdentity version=\"${{steps.gitversion.outputs.major}}.${{steps.gitversion.outputs.minor}}.${{steps.gitversion.outputs.patch}}.0\"" showFileContent: true - + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.0.2 + - name: Restore the application + run: msbuild VDownload /t:Restore /p:Configuration=$env:Configuration + env: + Configuration: ${{ matrix.configuration }} + - name: Decode certificate + run: | + $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.BASE64_ENCODED_PFX }}") + $certificatePath = "Certificate.pfx" + [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) + - name: Create the app package + run: msbuild VDownload /p:Configuration=$env:Configuration /p:Platform=$env:Platform /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=Certificate.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true + env: + Appx_Bundle: Never + Appx_Package_Build_Mode: SideloadOnly + Appx_Package_Dir: Packages\ + Configuration: ${{ matrix.configuration }} + Platform: ${{ matrix.platform }} + - name: Remove certificate + run: Remove-Item -path Certificate.pfx + - name: Upload package as artifact + uses: actions/upload-artifact@v2 + with: + name: MSIX Package + path: VDownload\\Packages From 0ca2791918e540e269ccd19400a9a9342bc3852c Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 01:49:13 +0100 Subject: [PATCH 03/29] Update app.manifest --- VDownload/app.manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VDownload/app.manifest b/VDownload/app.manifest index f61aa10..92e60ea 100644 --- a/VDownload/app.manifest +++ b/VDownload/app.manifest @@ -1,6 +1,6 @@ - + @@ -13,4 +13,4 @@ PerMonitorV2 - \ No newline at end of file + From 02e69d88e28bf0cb800c737f5a673a0d8ad9dae5 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 01:51:39 +0100 Subject: [PATCH 04/29] Update push_master.yml --- .github/workflows/push_master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index a3c8fd9..96387c7 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: configuration: [Release] - platform: [x64, x86] + platform: [x64, ARM64] steps: - name: Setup GitVersion uses: gittools/actions/gitversion/setup@v0.9.7 @@ -28,7 +28,7 @@ jobs: id: gitversion with: useConfigFile: true - configFilePath: ./.github/config/gitversion.yml + configFilePath: .github/config/gitversion.yml - name: Checkout uses: actions/checkout@v3 with: From 50c0c00ec98140c7e1a7ad20c5f6c976a3ad1121 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 01:52:37 +0100 Subject: [PATCH 05/29] Update push_master.yml --- .github/workflows/push_master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 96387c7..470b0bd 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -6,8 +6,8 @@ on: branches: - "master" - "features/github_actions" - paths: - - "VDownload**" + #paths: + #- "VDownload**" jobs: From 8560344a3c46dc804ed03bba767f8177568a16d1 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:00:05 +0100 Subject: [PATCH 06/29] Update gitversion.yml --- .github/config/gitversion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/config/gitversion.yml b/.github/config/gitversion.yml index f4a115a..e3c031a 100644 --- a/.github/config/gitversion.yml +++ b/.github/config/gitversion.yml @@ -1,4 +1,4 @@ -next-version: 2.0 +next-version: 2.0.0 assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch From ae61ee247bcca8f41bb2ee4234200c6b5420f6f1 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:03:24 +0100 Subject: [PATCH 07/29] Update gitversion.yml --- .github/config/gitversion.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/config/gitversion.yml b/.github/config/gitversion.yml index e3c031a..86fbdba 100644 --- a/.github/config/gitversion.yml +++ b/.github/config/gitversion.yml @@ -1,4 +1,4 @@ -next-version: 2.0.0 +next-version: 1.0.0 assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch @@ -9,3 +9,9 @@ branches: increment: Patch tag: '' is-release-branch: true + test: + regex: ^features + mode: ContinuousDelivery + increment: Patch + tag: '' + is-release-branch: true From 86d52b65028ffa0ddcedbfbbe4d6316387c3c688 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:05:06 +0100 Subject: [PATCH 08/29] Update push_master.yml --- .github/workflows/push_master.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 470b0bd..b26a1d3 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -19,6 +19,10 @@ jobs: configuration: [Release] platform: [x64, ARM64] steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup GitVersion uses: gittools/actions/gitversion/setup@v0.9.7 with: @@ -29,10 +33,6 @@ jobs: with: useConfigFile: true configFilePath: .github/config/gitversion.yml - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Set version in VDownload.csproj file id: package_version uses: KageKirin/set-csproj-version@v0 From f5978fa5ce0888cf9279749c1e194766146f50b5 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:09:59 +0100 Subject: [PATCH 09/29] Update gitversion.yml --- .github/config/gitversion.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/config/gitversion.yml b/.github/config/gitversion.yml index 86fbdba..b0eb3bf 100644 --- a/.github/config/gitversion.yml +++ b/.github/config/gitversion.yml @@ -15,3 +15,4 @@ branches: increment: Patch tag: '' is-release-branch: true + source-branches: [] From c46d9277fe3bbf1533178009d352445ddf66c0c4 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:32:00 +0100 Subject: [PATCH 10/29] Update push_master.yml --- .github/workflows/push_master.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index b26a1d3..f2ff7db 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -44,15 +44,17 @@ jobs: with: path: VDownload/Package.appxmanifest oldString: "Version=\"0.0.0.0\"" - newString: "Version=\"${{steps.gitversion.outputs.major}}.${{steps.gitversion.outputs.minor}}.${{steps.gitversion.outputs.patch}}.0\"" + newString: "Version=\"${{steps.gitversion.outputs.SemVer}}.0\"" showFileContent: true + escapeBackslash: true - name: Set version in app.manifest file uses: Nambers/ReplaceStringInFile@v1.3 with: path: VDownload/app.manifest oldString: "assemblyIdentity version=\"0.0.0.0\"" - newString: "assemblyIdentity version=\"${{steps.gitversion.outputs.major}}.${{steps.gitversion.outputs.minor}}.${{steps.gitversion.outputs.patch}}.0\"" + newString: "assemblyIdentity version=\"${{steps.gitversion.outputs.SemVer}}.0\"" showFileContent: true + escapeBackslash: true - name: Setup .NET uses: actions/setup-dotnet@v3 with: From dcc08010f763ead2565009702be68c21ed3652d6 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:36:28 +0100 Subject: [PATCH 11/29] Update push_master.yml --- .github/workflows/push_master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index f2ff7db..600a507 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -43,8 +43,8 @@ jobs: uses: Nambers/ReplaceStringInFile@v1.3 with: path: VDownload/Package.appxmanifest - oldString: "Version=\"0.0.0.0\"" - newString: "Version=\"${{steps.gitversion.outputs.SemVer}}.0\"" + oldString: 0.0.0.0 + newString: ${{steps.gitversion.outputs.SemVer}}.0 showFileContent: true escapeBackslash: true - name: Set version in app.manifest file From c063a710b8c8a9c91cd8fa6eedfbdd44e23ad7fb Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:39:30 +0100 Subject: [PATCH 12/29] Update push_master.yml --- .github/workflows/push_master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 600a507..90bc010 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -43,7 +43,7 @@ jobs: uses: Nambers/ReplaceStringInFile@v1.3 with: path: VDownload/Package.appxmanifest - oldString: 0.0.0.0 + oldString: 0\.0\.0\.0 newString: ${{steps.gitversion.outputs.SemVer}}.0 showFileContent: true escapeBackslash: true From 37f35c281bf0364a2530ac30b48c1106a238f143 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:43:13 +0100 Subject: [PATCH 13/29] Update push_master.yml --- .github/workflows/push_master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 90bc010..2b0c5d3 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -51,8 +51,8 @@ jobs: uses: Nambers/ReplaceStringInFile@v1.3 with: path: VDownload/app.manifest - oldString: "assemblyIdentity version=\"0.0.0.0\"" - newString: "assemblyIdentity version=\"${{steps.gitversion.outputs.SemVer}}.0\"" + oldString: 0\.0\.0\.0 + newString: ${{steps.gitversion.outputs.SemVer}}.0 showFileContent: true escapeBackslash: true - name: Setup .NET @@ -83,5 +83,5 @@ jobs: - name: Upload package as artifact uses: actions/upload-artifact@v2 with: - name: MSIX Package + name: MSIX ${{matrix.platform}} path: VDownload\\Packages From 268bfe798b0eb05bad29148119b5a4d243564c26 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 02:54:43 +0100 Subject: [PATCH 14/29] Update push_master.yml --- .github/workflows/push_master.yml | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 2b0c5d3..f53f27f 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -65,23 +65,13 @@ jobs: run: msbuild VDownload /t:Restore /p:Configuration=$env:Configuration env: Configuration: ${{ matrix.configuration }} - - name: Decode certificate - run: | - $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.BASE64_ENCODED_PFX }}") - $certificatePath = "Certificate.pfx" - [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte) - - name: Create the app package - run: msbuild VDownload /p:Configuration=$env:Configuration /p:Platform=$env:Platform /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=Certificate.pfx /p:AppxPackageDir="$env:Appx_Package_Dir" /p:GenerateAppxPackageOnBuild=true + - name: Create the app + run: msbuild $env:Solution_Name /t:Publish /p:Configuration=$env:Configuration /p:Platform=$env:Platform env: - Appx_Bundle: Never - Appx_Package_Build_Mode: SideloadOnly - Appx_Package_Dir: Packages\ Configuration: ${{ matrix.configuration }} Platform: ${{ matrix.platform }} - - name: Remove certificate - run: Remove-Item -path Certificate.pfx - - name: Upload package as artifact + - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: MSIX ${{matrix.platform}} - path: VDownload\\Packages + name: ${{matrix.platform}} + path: VDownload\\bin From b5a1d3c56040d05bc4add6a26396030c7f110a44 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 03:37:43 +0100 Subject: [PATCH 15/29] Update VDownload.csproj --- VDownload/VDownload.csproj | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index f25b174..58e0110 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -1,24 +1,24 @@  WinExe - net8.0-windows10.0.19041.0 - 10.0.17763.0 - VDownload - app.manifest - x86;x64;ARM64 - win10-x86;win10-x64;win10-arm64 - win10-$(Platform).pubxml - true - true - true - true - false - Assets\Logo\Logo.ico - LICENSE - True - 0.0.0 - false - true + net8.0-windows10.0.19041.0 + 10.0.17763.0 + VDownload + app.manifest + x64;ARM64 + win10-x64;win10-arm64 + win10-$(Platform).pubxml + true + true + true + false + Assets\Logo\Logo.ico + LICENSE + True + 0.0.0 + None + True + true From 43f92e524ddc1c82827ad6c0c2f267ab5b96335f Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 03:38:47 +0100 Subject: [PATCH 16/29] Update Package.appxmanifest --- VDownload/Package.appxmanifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VDownload/Package.appxmanifest b/VDownload/Package.appxmanifest index a07c131..0efd66c 100644 --- a/VDownload/Package.appxmanifest +++ b/VDownload/Package.appxmanifest @@ -11,7 +11,7 @@ From 7cf221b9bddf31c0d61847144bc3b7bad0c95438 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 17:56:03 +0100 Subject: [PATCH 17/29] Update push_master.yml --- .github/workflows/push_master.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index f53f27f..0cdaee6 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -14,10 +14,6 @@ jobs: build: name: Build runs-on: windows-latest - strategy: - matrix: - configuration: [Release] - platform: [x64, ARM64] steps: - name: Checkout uses: actions/checkout@v3 @@ -59,19 +55,10 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.0.2 - - name: Restore the application - run: msbuild VDownload /t:Restore /p:Configuration=$env:Configuration - env: - Configuration: ${{ matrix.configuration }} - name: Create the app - run: msbuild $env:Solution_Name /t:Publish /p:Configuration=$env:Configuration /p:Platform=$env:Platform - env: - Configuration: ${{ matrix.configuration }} - Platform: ${{ matrix.platform }} + run: dotnet build /p:Configuration=Release /p:Platform=x64 -o bin - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: ${{matrix.platform}} + name: build path: VDownload\\bin From 431c3d5118e752952870a2548177cc622e125315 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 18:03:50 +0100 Subject: [PATCH 18/29] Update push_master.yml --- .github/workflows/push_master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 0cdaee6..8274a7a 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -55,10 +55,10 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x - - name: Create the app + - name: Build application run: dotnet build /p:Configuration=Release /p:Platform=x64 -o bin - name: Upload artifact uses: actions/upload-artifact@v2 with: name: build - path: VDownload\\bin + path: bin From d91d56bc72e81bd29e5022147f1f23270b85eb58 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:02:34 +0100 Subject: [PATCH 19/29] Update push_master.yml --- .github/workflows/push_master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 8274a7a..21179f3 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -55,10 +55,10 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x - - name: Build application - run: dotnet build /p:Configuration=Release /p:Platform=x64 -o bin + - name: Deploy application + run: devenv VDownload.sln /Deploy Release - name: Upload artifact uses: actions/upload-artifact@v2 with: name: build - path: bin + path: VDownload\bin\x64\Release\net8.0-windows10.0.19041.0\win-x64 From 4fa78ccf803954c8e65a2bccfcdae4436c539ed2 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:04:43 +0100 Subject: [PATCH 20/29] Update push_master.yml --- .github/workflows/push_master.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 21179f3..ea90d41 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -55,6 +55,8 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x + - name: Setup msbuild + uses: microsoft/setup-msbuild@v2 - name: Deploy application run: devenv VDownload.sln /Deploy Release - name: Upload artifact From dfc9391c66ac8eea32ff7bc6c4d0efe7f7ec7a26 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:07:58 +0100 Subject: [PATCH 21/29] Update push_master.yml --- .github/workflows/push_master.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index ea90d41..f36d649 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -58,7 +58,9 @@ jobs: - name: Setup msbuild uses: microsoft/setup-msbuild@v2 - name: Deploy application - run: devenv VDownload.sln /Deploy Release + run: | + $devenv = & vswhere.exe '-property' productPath + Start-Process -FilePath $devenv -ArgumentList 'VDownload.sln /Deploy Release' -Wait - name: Upload artifact uses: actions/upload-artifact@v2 with: From c1aae72cfff5424104acb9af956b117d80485140 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:27:06 +0100 Subject: [PATCH 22/29] Update push_master.yml --- .github/workflows/push_master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index f36d649..df619a3 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -65,4 +65,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: build - path: VDownload\bin\x64\Release\net8.0-windows10.0.19041.0\win-x64 + path: bin From 3ad0d340aa91ac8f65ce653258f8c3832c5ab137 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:40:04 +0100 Subject: [PATCH 23/29] Update push_master.yml --- .github/workflows/push_master.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index df619a3..75cf719 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -58,9 +58,10 @@ jobs: - name: Setup msbuild uses: microsoft/setup-msbuild@v2 - name: Deploy application - run: | - $devenv = & vswhere.exe '-property' productPath - Start-Process -FilePath $devenv -ArgumentList 'VDownload.sln /Deploy Release' -Wait + shell: cmd + run: $MSBUILD_PATH VDownload.sln /Deploy Release + env: + MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.com - name: Upload artifact uses: actions/upload-artifact@v2 with: From e3c6e54bf82fb9a25255c95cfc5ce334e8b2b6e2 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:43:10 +0100 Subject: [PATCH 24/29] Update push_master.yml --- .github/workflows/push_master.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 75cf719..776eadf 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -14,6 +14,8 @@ jobs: build: name: Build runs-on: windows-latest + env: + MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.com steps: - name: Checkout uses: actions/checkout@v3 @@ -59,9 +61,8 @@ jobs: uses: microsoft/setup-msbuild@v2 - name: Deploy application shell: cmd - run: $MSBUILD_PATH VDownload.sln /Deploy Release - env: - MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.com + run: | + "$MSBUILD_PATH" VDownload.sln /Deploy Release - name: Upload artifact uses: actions/upload-artifact@v2 with: From 656d3854b62233ebd187bc45a68be5b7957f1d5f Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Mon, 11 Mar 2024 19:46:23 +0100 Subject: [PATCH 25/29] Update push_master.yml --- .github/workflows/push_master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 776eadf..4a4dfd5 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -62,7 +62,7 @@ jobs: - name: Deploy application shell: cmd run: | - "$MSBUILD_PATH" VDownload.sln /Deploy Release + "%MSBUILD_PATH%" VDownload.sln /Deploy Release - name: Upload artifact uses: actions/upload-artifact@v2 with: From fa71543773ffd6f241a463354ffed374c3fc0f7b Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Tue, 12 Mar 2024 00:16:21 +0100 Subject: [PATCH 26/29] build fix --- .github/workflows/push_master.yml | 10 +- .../DictionaryResourcesService.cs | 11 +- VDownload/App.xaml.cs | 139 ++++++++++-------- VDownload/VDownload.csproj | 1 + 4 files changed, 88 insertions(+), 73 deletions(-) diff --git a/.github/workflows/push_master.yml b/.github/workflows/push_master.yml index 4a4dfd5..accf086 100644 --- a/.github/workflows/push_master.yml +++ b/.github/workflows/push_master.yml @@ -57,14 +57,10 @@ jobs: uses: actions/setup-dotnet@v3 with: dotnet-version: 8.0.x - - name: Setup msbuild - uses: microsoft/setup-msbuild@v2 - - name: Deploy application - shell: cmd - run: | - "%MSBUILD_PATH%" VDownload.sln /Deploy Release + - name: Build application + run: dotnet build -o build - name: Upload artifact uses: actions/upload-artifact@v2 with: name: build - path: bin + path: build diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs index 5c97eef..fd8818e 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs @@ -9,6 +9,7 @@ namespace VDownload.Services.UI.DictionaryResources { public interface IDictionaryResourcesService { + ResourceDictionary Resources { get; set; } T Get(string key); } @@ -16,6 +17,14 @@ namespace VDownload.Services.UI.DictionaryResources public class DictionaryResourcesService : IDictionaryResourcesService { + #region PROPERTIES + + public ResourceDictionary Resources { get; set; } + + #endregion + + + #region CONSTRUCTORS public DictionaryResourcesService() { } @@ -28,7 +37,7 @@ namespace VDownload.Services.UI.DictionaryResources public T Get(string key) { - Application.Current.Resources.TryGetValue(key, out object value); + Resources.TryGetValue(key, out object value); if (value is not null && value is T cast) { return cast; diff --git a/VDownload/App.xaml.cs b/VDownload/App.xaml.cs index fc2d7c1..c390645 100644 --- a/VDownload/App.xaml.cs +++ b/VDownload/App.xaml.cs @@ -1,10 +1,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Microsoft.Toolkit.Uwp.Notifications; +using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.Windows.AppNotifications; using System; +using System.Net; using System.Net.Http; using System.Threading.Tasks; using VDownload.Core.Tasks; @@ -47,11 +50,21 @@ namespace VDownload { public partial class App : Application { - #region FIELDS + #region PROPERTIES - protected IServiceProvider _serviceProvider; + public static BaseWindow Window { get; protected set; } - protected BaseWindow _window; + public static T GetService() where T : class + { + if ((App.Current as App)!.Host.Services.GetService(typeof(T)) is not T service) + { + throw new ArgumentException($"{typeof(T)} needs to be registered in ConfigureServices within App.xaml.cs."); + } + + return service; + } + + public IHost Host { get; set; } #endregion @@ -63,22 +76,70 @@ namespace VDownload { this.InitializeComponent(); + Host = Microsoft.Extensions.Hosting.Host + .CreateDefaultBuilder() + .UseContentRoot(AppContext.BaseDirectory) + .ConfigureAppConfiguration((builder) => + { + builder.Sources.Add(new JsonConfigurationSource + { + Path = "configuration.json" + }); + }) + .ConfigureServices((context, services) => + { + BuildCore(services); - IServiceCollection services = new ServiceCollection(); + BuildDataServices(services); + BuildUIServices(services); + BuildUtilityServices(services); + BuildSourcesServices(services); - BuildCore(services); + BuildTasksManager(services); + BuildPresentation(services); + }) + .Build(); + } - BuildConfiguration(services); + #endregion - BuildDataServices(services); - BuildUIServices(services); - BuildUtilityServices(services); - BuildSourcesServices(services); - BuildTasksManager(services); - BuildPresentation(services); - _serviceProvider = services.BuildServiceProvider(); + #region EVENT HANDLERS + + private void WindowRootLoaded(object sender, EventArgs e) + { + GetService().DefaultRoot = Window.XamlRoot; + } + + protected override async void OnLaunched(LaunchActivatedEventArgs args) + { + base.OnLaunched(args); + + GetService().Resources = (App.Current as App).Resources; + + Window = GetService(); + Window.RootLoaded += WindowRootLoaded; + + IApplicationDataService applicationDataService = GetService(); + ISettingsService settingsService = GetService(); + IAuthenticationDataService authenticationDataService = GetService(); + ISubscriptionsDataService subscriptionsDataService = GetService(); + Task initViewModelToViewConverterTask = Task.Run(() => ViewModelToViewConverter.ServiceProvider = (App.Current as App)!.Host.Services); + Task initStoragePickerServiceTask = Task.Run(() => GetService().DefaultRoot = Window); + Task initNotificationsServiceTask = Task.Run(() => GetService().Initialize(() => WindowHelper.ShowWindow(Window))); + + await Task.WhenAll( + applicationDataService.Load(), + settingsService.Load(), + authenticationDataService.Load(), + subscriptionsDataService.Load(), + initStoragePickerServiceTask, + initViewModelToViewConverterTask, + initNotificationsServiceTask + ); + + Window.Activate(); } #endregion @@ -92,22 +153,6 @@ namespace VDownload services.AddSingleton(); } - protected void BuildConfiguration(IServiceCollection services) - { - IConfigurationBuilder configBuilder = new ConfigurationBuilder - { - Sources = - { - new JsonConfigurationSource - { - Path = "configuration.json" - } - } - }; - IConfiguration config = configBuilder.Build(); - services.AddSingleton(config); - } - protected void BuildDataServices(IServiceCollection services) { services.AddSingleton(); @@ -178,42 +223,6 @@ namespace VDownload services.AddTransient(); } - protected async Task InitializeServices() - { - IApplicationDataService applicationDataService = _serviceProvider.GetService(); - ISettingsService settingsService = _serviceProvider.GetService(); - IAuthenticationDataService authenticationDataService = _serviceProvider.GetService(); - ISubscriptionsDataService subscriptionsDataService = _serviceProvider.GetService(); - Task initViewModelToViewConverterTask = Task.Run(() => ViewModelToViewConverter.ServiceProvider = _serviceProvider); - Task initStoragePickerServiceTask = Task.Run(() => _serviceProvider.GetService().DefaultRoot = _window); - Task initNotificationsServiceTask = Task.Run(() => _serviceProvider.GetService().Initialize(() => WindowHelper.ShowWindow(_window))); - - await Task.WhenAll( - applicationDataService.Load(), - settingsService.Load(), - authenticationDataService.Load(), - subscriptionsDataService.Load(), - initStoragePickerServiceTask, - initViewModelToViewConverterTask, - initNotificationsServiceTask - ); - } - - protected override async void OnLaunched(LaunchActivatedEventArgs args) - { - _window = _serviceProvider.GetService(); - _window.RootLoaded += Window_RootLoaded; - _window.Activate(); - - await InitializeServices(); - } - - protected void Window_RootLoaded(object sender, EventArgs e) - { - IDialogsService dialogsService = _serviceProvider.GetService(); - dialogsService.DefaultRoot = _window.XamlRoot; - } - #endregion } } diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index 58e0110..63d4fc2 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -168,6 +168,7 @@ + From c9d81fe966531a64d8d54926008e6fcd1eff7436 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Thu, 14 Mar 2024 16:31:26 +0100 Subject: [PATCH 27/29] Activation service --- .../ViewModelToViewConverter.cs | 14 +- .../IInitializableService.cs | 26 ++++ .../VDownload.Services.Common.csproj | 9 ++ .../ApplicationDataService.cs | 5 +- ...VDownload.Services.Data.Application.csproj | 1 + .../AuthenticationDataService.cs | 5 +- ...wnload.Services.Data.Authentication.csproj | 1 + .../SettingsService.cs | 5 +- .../VDownload.Services.Data.Settings.csproj | 1 + .../SubscriptionsDataService.cs | 6 +- ...ownload.Services.Data.Subscriptions.csproj | 1 + .../DialogsService.cs | 27 +--- .../VDownload.Services.UI.Dialogs.csproj | 1 + .../DictionaryResourcesService.cs | 21 ++- ...oad.Services.UI.DictionaryResources.csproj | 1 + .../NotificationsService.cs | 32 ++++- ...VDownload.Services.UI.Notifications.csproj | 5 + .../StoragePickerService.cs | 23 +-- ...VDownload.Services.UI.StoragePicker.csproj | 4 + VDownload.sln | 21 ++- VDownload/Activation/ActivationHandler.cs | 38 +++++ VDownload/Activation/ActivationService.cs | 131 ++++++++++++++++++ .../Activation/DefaultActivationHandler.cs | 21 +++ VDownload/App.xaml.cs | 66 ++++----- VDownload/VDownload.csproj | 2 +- VDownload/WindowHelper.cs | 43 ------ 26 files changed, 356 insertions(+), 154 deletions(-) create mode 100644 VDownload.Services/VDownload.Services.Common/IInitializableService.cs create mode 100644 VDownload.Services/VDownload.Services.Common/VDownload.Services.Common.csproj create mode 100644 VDownload/Activation/ActivationHandler.cs create mode 100644 VDownload/Activation/ActivationService.cs create mode 100644 VDownload/Activation/DefaultActivationHandler.cs delete mode 100644 VDownload/WindowHelper.cs diff --git a/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs b/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs index bcf00dd..79b497a 100644 --- a/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs +++ b/VDownload.Core/VDownload.Core.Views/ViewModelToViewConverter.cs @@ -31,13 +31,7 @@ namespace VDownload.Core.Views { typeof(AuthenticationViewModel), typeof(AuthenticationView) } }; - #endregion - - - - #region PROPERTIES - - public static IServiceProvider ServiceProvider { protected get; set; } + protected static IServiceProvider _serviceProvider; #endregion @@ -45,6 +39,8 @@ namespace VDownload.Core.Views #region PUBLIC METHODS + public static void Initialize(IServiceProvider serviceProvider) => _serviceProvider = serviceProvider; + public object Convert(object value, Type targetType, object parameter, string language) { if (value is null) @@ -53,11 +49,11 @@ namespace VDownload.Core.Views } if (value is Type type && _viewModelViewBinding.ContainsKey(type)) { - return ServiceProvider.GetService(_viewModelViewBinding[type]); + return _serviceProvider.GetService(_viewModelViewBinding[type]); } if (_viewModelViewBinding.ContainsKey(value.GetType())) { - return ServiceProvider.GetService(_viewModelViewBinding[value.GetType()]); + return _serviceProvider.GetService(_viewModelViewBinding[value.GetType()]); } return null; } diff --git a/VDownload.Services/VDownload.Services.Common/IInitializableService.cs b/VDownload.Services/VDownload.Services.Common/IInitializableService.cs new file mode 100644 index 0000000..726f8e3 --- /dev/null +++ b/VDownload.Services/VDownload.Services.Common/IInitializableService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VDownload.Services.Common +{ + public interface IInitializableService + { + #region METHODS + + Task Initialize(); + + #endregion + } + + public interface IInitializableService + { + #region METHODS + + Task Initialize(T arg); + + #endregion + } +} diff --git a/VDownload.Services/VDownload.Services.Common/VDownload.Services.Common.csproj b/VDownload.Services/VDownload.Services.Common/VDownload.Services.Common.csproj new file mode 100644 index 0000000..fa71b7a --- /dev/null +++ b/VDownload.Services/VDownload.Services.Common/VDownload.Services.Common.csproj @@ -0,0 +1,9 @@ + + + + net8.0 + enable + enable + + + diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/ApplicationDataService.cs b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/ApplicationDataService.cs index 9684b3a..90f84c8 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/ApplicationDataService.cs +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/ApplicationDataService.cs @@ -4,11 +4,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; using VDownload.Services.Data.Configuration; namespace VDownload.Services.Data.Application { - public interface IApplicationDataService + public interface IApplicationDataService : IInitializableService { #region PROPERTIES @@ -73,6 +74,8 @@ namespace VDownload.Services.Data.Application #region PUBLIC METHODS + public async Task Initialize() => await Load(); + public async Task Load() { if (File.Exists(_filePath)) diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/VDownload.Services.Data.Application.csproj b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/VDownload.Services.Data.Application.csproj index 8b38c4b..62d33a0 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/VDownload.Services.Data.Application.csproj +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Application/VDownload.Services.Data.Application.csproj @@ -11,6 +11,7 @@ + diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/AuthenticationDataService.cs b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/AuthenticationDataService.cs index 80a0840..f97de09 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/AuthenticationDataService.cs +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/AuthenticationDataService.cs @@ -4,11 +4,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; using VDownload.Services.Data.Configuration; namespace VDownload.Services.Data.Authentication { - public interface IAuthenticationDataService + public interface IAuthenticationDataService : IInitializableService { #region PROPERTIES @@ -70,6 +71,8 @@ namespace VDownload.Services.Data.Authentication #region PUBLIC METHODS + public async Task Initialize() => await Load(); + public async Task Load() { Data = null; diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/VDownload.Services.Data.Authentication.csproj b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/VDownload.Services.Data.Authentication.csproj index 8b38c4b..62d33a0 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/VDownload.Services.Data.Authentication.csproj +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Authentication/VDownload.Services.Data.Authentication.csproj @@ -11,6 +11,7 @@ + diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/SettingsService.cs b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/SettingsService.cs index 2d83230..898eb44 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/SettingsService.cs +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/SettingsService.cs @@ -4,11 +4,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; using VDownload.Services.Data.Configuration; namespace VDownload.Services.Data.Settings { - public interface ISettingsService + public interface ISettingsService : IInitializableService { #region PROPERTIES @@ -73,6 +74,8 @@ namespace VDownload.Services.Data.Settings #region PUBLIC METHODS + public async Task Initialize() => await Load(); + public async Task Load() { if (File.Exists(_filePath)) diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/VDownload.Services.Data.Settings.csproj b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/VDownload.Services.Data.Settings.csproj index 12f9356..e689809 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/VDownload.Services.Data.Settings.csproj +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Settings/VDownload.Services.Data.Settings.csproj @@ -13,6 +13,7 @@ + diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/SubscriptionsDataService.cs b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/SubscriptionsDataService.cs index 4caee21..db08b2d 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/SubscriptionsDataService.cs +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/SubscriptionsDataService.cs @@ -2,13 +2,15 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; using VDownload.Services.Data.Configuration; namespace VDownload.Services.Data.Subscriptions { - public interface ISubscriptionsDataService + public interface ISubscriptionsDataService : IInitializableService { #region PROPERTIES @@ -72,6 +74,8 @@ namespace VDownload.Services.Data.Subscriptions #region PUBLIC METHODS + public async Task Initialize() => await Load(); + public async Task Load() { if (File.Exists(_filePath)) diff --git a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/VDownload.Services.Data.Subscriptions.csproj b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/VDownload.Services.Data.Subscriptions.csproj index d81009e..4c44878 100644 --- a/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/VDownload.Services.Data.Subscriptions.csproj +++ b/VDownload.Services/VDownload.Services.Data/VDownload.Services.Data.Subscriptions/VDownload.Services.Data.Subscriptions.csproj @@ -12,6 +12,7 @@ + diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs index 845663d..6a80b3b 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs @@ -6,22 +6,13 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; using VDownload.Services.UI.StringResources; namespace VDownload.Services.UI.Dialogs { - public interface IDialogsService + public interface IDialogsService : IInitializableService { - #region PROPERTIES - - XamlRoot DefaultRoot { get; set; } - - #endregion - - - - #region METHODS - Task ShowClose(string title, string message); Task ShowDouble(string title, string message, string primaryButtonText, string secondaryButtonText); Task ShowOk(string title, string message); @@ -30,8 +21,6 @@ namespace VDownload.Services.UI.Dialogs Task ShowTriple(string title, string message, string primaryButtonText, string secondaryButtonText, string cancelButtonText); Task ShowYesNo(string title, string message); Task ShowYesNoCancel(string title, string message); - - #endregion } @@ -54,13 +43,7 @@ namespace VDownload.Services.UI.Dialogs protected string _yesString; protected string _noString; - #endregion - - - - #region PROPERTIES - - public XamlRoot DefaultRoot { get; set; } + protected XamlRoot _root; #endregion @@ -84,6 +67,8 @@ namespace VDownload.Services.UI.Dialogs #region PUBLIC METHODS + public async Task Initialize(XamlRoot arg) => await Task.Run(() => _root = arg); + public async Task ShowOk(string title, string message) => await ShowSingle(title, message, _okString); public async Task ShowClose(string title, string message) => await ShowSingle(title, message, _closeString); public async Task ShowSingle(string title, string message, string buttonText) @@ -138,7 +123,7 @@ namespace VDownload.Services.UI.Dialogs { Title = title, Content = message, - XamlRoot = DefaultRoot + XamlRoot = _root }; } diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj index 8744244..fd60d13 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj @@ -15,6 +15,7 @@ + diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs index fd8818e..4c4ae40 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/DictionaryResourcesService.cs @@ -4,12 +4,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; +using Windows.Media.Core; namespace VDownload.Services.UI.DictionaryResources { - public interface IDictionaryResourcesService + public interface IDictionaryResourcesService : IInitializableService { - ResourceDictionary Resources { get; set; } T Get(string key); } @@ -17,17 +18,9 @@ namespace VDownload.Services.UI.DictionaryResources public class DictionaryResourcesService : IDictionaryResourcesService { - #region PROPERTIES + #region FIELDS - public ResourceDictionary Resources { get; set; } - - #endregion - - - - #region CONSTRUCTORS - - public DictionaryResourcesService() { } + protected ResourceDictionary _resources; #endregion @@ -35,9 +28,11 @@ namespace VDownload.Services.UI.DictionaryResources #region PUBLIC METHODS + public async Task Initialize(ResourceDictionary arg) => await Task.Run(() => _resources = arg); + public T Get(string key) { - Resources.TryGetValue(key, out object value); + _resources.TryGetValue(key, out object value); if (value is not null && value is T cast) { return cast; diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/VDownload.Services.UI.DictionaryResources.csproj b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/VDownload.Services.UI.DictionaryResources.csproj index 0404798..54b8411 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/VDownload.Services.UI.DictionaryResources.csproj +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.DictionaryResources/VDownload.Services.UI.DictionaryResources.csproj @@ -15,6 +15,7 @@ + diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/NotificationsService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/NotificationsService.cs index 653760b..527dbd2 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/NotificationsService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/NotificationsService.cs @@ -1,17 +1,19 @@ using Microsoft.Toolkit.Uwp.Notifications; +using Microsoft.UI.Xaml; using Microsoft.Windows.AppNotifications; using Microsoft.Windows.AppNotifications.Builder; +using SimpleToolkit.UI.WinUI.Helpers; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Services.Common; namespace VDownload.Services.UI.Notifications { - public interface INotificationsService + public interface INotificationsService : IInitializableService { - void Initialize(Action notificationInvoked); void SendNotification(string title, IEnumerable message); } @@ -19,7 +21,15 @@ namespace VDownload.Services.UI.Notifications public class NotificationsService : INotificationsService { - #region CONSTRCUTORS + #region FIELDS + + protected Window _window; + + #endregion + + + + #region CONSTRUCTORS ~NotificationsService() { @@ -32,12 +42,14 @@ namespace VDownload.Services.UI.Notifications #region PUBLIC METHODS - public void Initialize(Action notificationInvoked) + public async Task Initialize(Window window) => await Task.Run(() => { - AppNotificationManager.Default.NotificationInvoked += (obj, args) => notificationInvoked.Invoke(); + _window = window; + + AppNotificationManager.Default.NotificationInvoked += NotificationInvoked; AppNotificationManager.Default.Register(); - } + }); public void SendNotification(string title, IEnumerable message) { @@ -54,5 +66,13 @@ namespace VDownload.Services.UI.Notifications } #endregion + + + + #region PRIVATE METHODS + + private void NotificationInvoked(AppNotificationManager sender, AppNotificationActivatedEventArgs args) => WindowHelper.ShowWindow(_window); + + #endregion } } diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/VDownload.Services.UI.Notifications.csproj b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/VDownload.Services.UI.Notifications.csproj index 8d89a91..e6fa01d 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/VDownload.Services.UI.Notifications.csproj +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Notifications/VDownload.Services.UI.Notifications.csproj @@ -13,5 +13,10 @@ + + + + + diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/StoragePickerService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/StoragePickerService.cs index 5981f8c..effbd19 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/StoragePickerService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/StoragePickerService.cs @@ -3,24 +3,15 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using VDownload.Services.Common; using Windows.Storage; using Windows.Storage.Pickers; using WinRT.Interop; namespace VDownload.Services.UI.StoragePicker { - public interface IStoragePickerService + public interface IStoragePickerService : IInitializableService { - #region PROPERTIES - - Window DefaultRoot { get; set; } - - #endregion - - - - #region METHODS - Task OpenDirectory(); Task OpenDirectory(StoragePickerStartLocation startLocation); Task> OpenMultipleFiles(); @@ -33,17 +24,15 @@ namespace VDownload.Services.UI.StoragePicker Task OpenSingleFile(string[] fileTypes, StoragePickerStartLocation startLocation); Task SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType); Task SaveFile(FileSavePickerFileTypeChoice[] fileTypes, string defaultFileType, StoragePickerStartLocation startLocation); - - #endregion } public class StoragePickerService : IStoragePickerService { - #region PROPERTIES + #region FIELDS - public Window DefaultRoot { get; set; } + protected Window _root; #endregion @@ -51,6 +40,8 @@ namespace VDownload.Services.UI.StoragePicker #region PUBLIC METHODS + public async Task Initialize(Window arg) => await Task.Run(() => _root = arg); + public async Task OpenDirectory() => await OpenDirectory(StoragePickerStartLocation.Unspecified); public async Task OpenDirectory(StoragePickerStartLocation startLocation) { @@ -111,7 +102,7 @@ namespace VDownload.Services.UI.StoragePicker protected void InitializePicker(object picker) { - var hwnd = WindowNative.GetWindowHandle(DefaultRoot); + var hwnd = WindowNative.GetWindowHandle(_root); InitializeWithWindow.Initialize(picker, hwnd); } diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/VDownload.Services.UI.StoragePicker.csproj b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/VDownload.Services.UI.StoragePicker.csproj index 6ea7798..8407c20 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/VDownload.Services.UI.StoragePicker.csproj +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StoragePicker/VDownload.Services.UI.StoragePicker.csproj @@ -13,4 +13,8 @@ + + + + diff --git a/VDownload.sln b/VDownload.sln index 117e850..9e75b74 100644 --- a/VDownload.sln +++ b/VDownload.sln @@ -73,7 +73,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Utility. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Data.Application", "VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Application\VDownload.Services.Data.Application.csproj", "{4983E15B-3730-4646-A2BD-16B9ECC9E4FF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Data.Subscriptions", "VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Subscriptions\VDownload.Services.Data.Subscriptions.csproj", "{3193DABC-87F8-4256-9449-3CF42FEF7098}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Data.Subscriptions", "VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Subscriptions\VDownload.Services.Data.Subscriptions.csproj", "{3193DABC-87F8-4256-9449-3CF42FEF7098}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Common", "VDownload.Services\VDownload.Services.Common\VDownload.Services.Common.csproj", "{267F5A31-1257-4820-9FE5-C11D26CC3C55}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -557,6 +559,22 @@ Global {3193DABC-87F8-4256-9449-3CF42FEF7098}.Release|x64.Build.0 = Release|Any CPU {3193DABC-87F8-4256-9449-3CF42FEF7098}.Release|x86.ActiveCfg = Release|Any CPU {3193DABC-87F8-4256-9449-3CF42FEF7098}.Release|x86.Build.0 = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|Any CPU.Build.0 = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|ARM64.Build.0 = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|x64.ActiveCfg = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|x64.Build.0 = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|x86.ActiveCfg = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Debug|x86.Build.0 = Debug|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|Any CPU.ActiveCfg = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|Any CPU.Build.0 = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|ARM64.ActiveCfg = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|ARM64.Build.0 = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|x64.ActiveCfg = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|x64.Build.0 = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|x86.ActiveCfg = Release|Any CPU + {267F5A31-1257-4820-9FE5-C11D26CC3C55}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -593,6 +611,7 @@ Global {4647EFB5-A206-4F47-976D-BAED11B52579} = {1020167A-4101-496E-82CF-41B65769DD28} {4983E15B-3730-4646-A2BD-16B9ECC9E4FF} = {05A45688-7EEF-4656-818A-2477625C3707} {3193DABC-87F8-4256-9449-3CF42FEF7098} = {05A45688-7EEF-4656-818A-2477625C3707} + {267F5A31-1257-4820-9FE5-C11D26CC3C55} = {8D351DB0-74E6-4C1E-A123-34D6BBBD5585} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9FD7B842-C3E2-4FD0-AD8A-C8E619280AB7} diff --git a/VDownload/Activation/ActivationHandler.cs b/VDownload/Activation/ActivationHandler.cs new file mode 100644 index 0000000..1d6ef5f --- /dev/null +++ b/VDownload/Activation/ActivationHandler.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VDownload.Activation +{ + public interface IActivationHandler + { + bool CanHandle(object args); + Task HandleAsync(object args); + } + + + + public abstract class ActivationHandler : IActivationHandler + where T : class + { + #region PUBLIC METHODS + + public bool CanHandle(object args) => args is T && CanHandleInternal((args as T)!); + + public async Task HandleAsync(object args) => await HandleInternalAsync((args as T)!); + + #endregion + + + + #region PRIVATE METHODS + + protected virtual bool CanHandleInternal(T args) => true; + + protected abstract Task HandleInternalAsync(T args); + + #endregion + } +} diff --git a/VDownload/Activation/ActivationService.cs b/VDownload/Activation/ActivationService.cs new file mode 100644 index 0000000..6cbd3af --- /dev/null +++ b/VDownload/Activation/ActivationService.cs @@ -0,0 +1,131 @@ +using Microsoft.UI.Xaml; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using VDownload.Core.Views; +using VDownload.Services.Common; +using VDownload.Services.Data.Application; +using VDownload.Services.Data.Authentication; +using VDownload.Services.Data.Settings; +using VDownload.Services.Data.Subscriptions; +using VDownload.Services.UI.Dialogs; +using VDownload.Services.UI.DictionaryResources; +using VDownload.Services.UI.Notifications; +using VDownload.Services.UI.StoragePicker; + +namespace VDownload.Activation +{ + public interface IActivationService + { + Task ActivateAsync(object activationArgs); + } + + + + public class ActivationService : IActivationService + { + #region SERVICES + protected readonly ActivationHandler _defaultHandler; + protected readonly IEnumerable _activationHandlers; + + #endregion + + + + #region FIELDS + + protected readonly ICollection> _beforeActivationInitializations = new List>(); + protected readonly ICollection> _afterActivationInitializations = new List>(); + protected readonly ICollection> _afterWindowRootLoadedInitializations = new List>(); + + protected BaseWindow _window; + + #endregion + + + + #region CONSTRUCTORS + + public ActivationService(ActivationHandler defaultHandler, IEnumerable activationHandlers, ISettingsService settingsService, IApplicationDataService applicationDataService, IAuthenticationDataService authenticationDataService, ISubscriptionsDataService subscriptionsDataService, IStoragePickerService storagePickerService, INotificationsService notificationsService, IDictionaryResourcesService dictionaryResourcesService, IDialogsService dialogsService) + { + _defaultHandler = defaultHandler; + _activationHandlers = activationHandlers; + + _beforeActivationInitializations.Add(() => dictionaryResourcesService.Initialize((App.Current as App).Resources)); + + _afterActivationInitializations.Add(settingsService.Initialize); + _afterActivationInitializations.Add(applicationDataService.Initialize); + _afterActivationInitializations.Add(authenticationDataService.Initialize); + _afterActivationInitializations.Add(subscriptionsDataService.Initialize); + _afterActivationInitializations.Add(() => storagePickerService.Initialize(_window)); + _afterActivationInitializations.Add(() => notificationsService.Initialize(_window)); + + _afterWindowRootLoadedInitializations.Add(() => dialogsService.Initialize(_window.XamlRoot)); + } + + #endregion + + + + #region PUBLIC METHODS + + public async Task ActivateAsync(object activationArgs) + { + await InitializeAsync(); + ViewModelToViewConverter.Initialize((App.Current as App)!.Host.Services); + + await HandleActivationAsync(activationArgs); + + _window = App.GetService(); + _window.RootLoaded += Window_RootLoaded; + _window.Activate(); + + await StartupAsync(); + } + + #endregion + + + + #region PRIVATE METHODS + + #region EVENT HANDLERS + + protected async void Window_RootLoaded(object sender, EventArgs e) => await AfterWindowRootLoaded(); + + #endregion + + protected async Task InitializeAsync() + { + List tasks = new List(); + foreach (Func init in _beforeActivationInitializations) + { + tasks.Add(init.Invoke()); + } + await Task.WhenAll(tasks); + } + + protected async Task StartupAsync() => await Task.WhenAll(_afterActivationInitializations.Select(x => x.Invoke())); + + protected async Task AfterWindowRootLoaded() => await Task.WhenAll(_afterWindowRootLoadedInitializations.Select(x => x.Invoke())); + + protected async Task HandleActivationAsync(object activationArgs) + { + var activationHandler = _activationHandlers.FirstOrDefault(h => h.CanHandle(activationArgs)); + + if (activationHandler != null) + { + await activationHandler.HandleAsync(activationArgs); + } + + if (_defaultHandler.CanHandle(activationArgs)) + { + await _defaultHandler.HandleAsync(activationArgs); + } + } + + #endregion + } +} diff --git a/VDownload/Activation/DefaultActivationHandler.cs b/VDownload/Activation/DefaultActivationHandler.cs new file mode 100644 index 0000000..402ec4c --- /dev/null +++ b/VDownload/Activation/DefaultActivationHandler.cs @@ -0,0 +1,21 @@ +using Microsoft.UI.Xaml; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VDownload.Activation +{ + public class DefaultActivationHandler : ActivationHandler + { + #region PRIVATE METHODS + + protected override async Task HandleInternalAsync(LaunchActivatedEventArgs args) + { + await Task.CompletedTask; + } + + #endregion + } +} diff --git a/VDownload/App.xaml.cs b/VDownload/App.xaml.cs index c390645..5bed22b 100644 --- a/VDownload/App.xaml.cs +++ b/VDownload/App.xaml.cs @@ -10,6 +10,7 @@ using System; using System.Net; using System.Net.Http; using System.Threading.Tasks; +using VDownload.Activation; using VDownload.Core.Tasks; using VDownload.Core.ViewModels; using VDownload.Core.ViewModels.About; @@ -97,49 +98,11 @@ namespace VDownload BuildTasksManager(services); BuildPresentation(services); + BuildActivation(services); }) .Build(); - } - #endregion - - - - #region EVENT HANDLERS - - private void WindowRootLoaded(object sender, EventArgs e) - { - GetService().DefaultRoot = Window.XamlRoot; - } - - protected override async void OnLaunched(LaunchActivatedEventArgs args) - { - base.OnLaunched(args); - - GetService().Resources = (App.Current as App).Resources; - - Window = GetService(); - Window.RootLoaded += WindowRootLoaded; - - IApplicationDataService applicationDataService = GetService(); - ISettingsService settingsService = GetService(); - IAuthenticationDataService authenticationDataService = GetService(); - ISubscriptionsDataService subscriptionsDataService = GetService(); - Task initViewModelToViewConverterTask = Task.Run(() => ViewModelToViewConverter.ServiceProvider = (App.Current as App)!.Host.Services); - Task initStoragePickerServiceTask = Task.Run(() => GetService().DefaultRoot = Window); - Task initNotificationsServiceTask = Task.Run(() => GetService().Initialize(() => WindowHelper.ShowWindow(Window))); - - await Task.WhenAll( - applicationDataService.Load(), - settingsService.Load(), - authenticationDataService.Load(), - subscriptionsDataService.Load(), - initStoragePickerServiceTask, - initViewModelToViewConverterTask, - initNotificationsServiceTask - ); - - Window.Activate(); + UnhandledException += UnhandledExceptionCatched; } #endregion @@ -148,6 +111,22 @@ namespace VDownload #region PRIVATE METHODS + #region EVENT HANDLERS + + protected override async void OnLaunched(LaunchActivatedEventArgs args) + { + base.OnLaunched(args); + + await GetService().ActivateAsync(args); + } + + protected void UnhandledExceptionCatched(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) + { + throw new NotImplementedException(); + } + + #endregion + protected void BuildCore(IServiceCollection services) { services.AddSingleton(); @@ -223,6 +202,13 @@ namespace VDownload services.AddTransient(); } + protected void BuildActivation(IServiceCollection services) + { + services.AddTransient, DefaultActivationHandler>(); + + services.AddSingleton(); + } + #endregion } } diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index 63d4fc2..df49035 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -16,8 +16,8 @@ LICENSE True 0.0.0 + false None - True true diff --git a/VDownload/WindowHelper.cs b/VDownload/WindowHelper.cs deleted file mode 100644 index e63b411..0000000 --- a/VDownload/WindowHelper.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Microsoft.UI.Xaml; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace VDownload -{ - public static partial class WindowHelper - { - #region PUBLIC METHODS - - public static void ShowWindow(Window window) - { - // Bring the window to the foreground... first get the window handle... - var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window); - - // Restore window if minimized... requires DLL import above - ShowWindow(hwnd, 0x00000009); - - // And call SetForegroundWindow... requires DLL import above - SetForegroundWindow(hwnd); - } - - #endregion - - - - #region PRIVATE METHODS - - [LibraryImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - private static partial bool ShowWindow(IntPtr hWnd, int nCmdShow); - - [LibraryImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - private static partial bool SetForegroundWindow(IntPtr hWnd); - - #endregion - } -} From 8ff6071c1d59b6a45eeb04487d0e751917d3a99d Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Thu, 14 Mar 2024 18:58:05 +0100 Subject: [PATCH 28/29] debugging --- .../VDownload.Core.Strings/StringResource.cs | 37 ++++++++++++++++ .../StringResourcesManager.cs | 44 +++++++++++++++++++ .../StringResourcesService.cs | 6 ++- VDownload/Activation/ActivationService.cs | 6 +++ VDownload/App.xaml.cs | 9 ++++ VDownload/VDownload.csproj | 8 ++++ 6 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 VDownload.Core/VDownload.Core.Strings/StringResource.cs create mode 100644 VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs diff --git a/VDownload.Core/VDownload.Core.Strings/StringResource.cs b/VDownload.Core/VDownload.Core.Strings/StringResource.cs new file mode 100644 index 0000000..86dec6d --- /dev/null +++ b/VDownload.Core/VDownload.Core.Strings/StringResource.cs @@ -0,0 +1,37 @@ +using Microsoft.Windows.ApplicationModel.Resources; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VDownload.Core.Strings +{ + public class StringResource + { + #region FIELDS + + protected ResourceLoader _resourceLoader; + + #endregion + + + + #region CONSTRUCTORS + + internal StringResource(ResourceLoader resourceLoader) + { + _resourceLoader = resourceLoader; + } + + #endregion + + + + #region PUBLIC METHODS + + public string Get(string key) => _resourceLoader.GetString(key); + + #endregion + } +} diff --git a/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs b/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs new file mode 100644 index 0000000..f5913b3 --- /dev/null +++ b/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs @@ -0,0 +1,44 @@ +using Microsoft.UI.Xaml; +using Microsoft.Windows.ApplicationModel.Resources; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace VDownload.Core.Strings +{ + public static class StringResourcesManager + { + #region PROPERTIES + + public static StringResource BaseView { get; } = BuildResource("BaseViewResources"); + public static StringResource HomeView { get; } = BuildResource("HomeViewResources"); + public static StringResource HomeVideoView { get; } = BuildResource("HomeVideoViewResources"); + public static StringResource HomeVideoCollectionView { get; } = BuildResource("HomeVideoCollectionViewResources"); + public static StringResource HomeDownloadsView { get; } = BuildResource("HomeDownloadsViewResources"); + public static StringResource AuthenticationView { get; } = BuildResource("AuthenticationViewResources"); + public static StringResource Notifications { get; } = BuildResource("NotificationsResources"); + public static StringResource Search { get; } = BuildResource("SearchResources"); + public static StringResource Common { get; } = BuildResource("CommonResources"); + public static StringResource DialogButtons { get; } = BuildResource("DialogButtonsResources"); + public static StringResource SettingsView { get; } = BuildResource("SettingsViewResources"); + public static StringResource FilenameTemplate { get; } = BuildResource("FilenameTemplateResources"); + public static StringResource AboutView { get; } = BuildResource("AboutViewResources"); + public static StringResource SubscriptionsView { get; } = BuildResource("SubscriptionsViewResources"); + + #endregion + + + + #region PRIVATE METHODS + + private static StringResource BuildResource(string resourceName) + { + ResourceLoader loader = new ResourceLoader(resourceName); + return new StringResource(loader); + } + + #endregion + } +} diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StringResources/StringResourcesService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StringResources/StringResourcesService.cs index e7bf3e0..97f9e2c 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StringResources/StringResourcesService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.StringResources/StringResourcesService.cs @@ -82,7 +82,11 @@ namespace VDownload.Services.UI.StringResources #region PRIVATE METHODS - protected StringResources BuildResource(string resourceName) => new StringResources(ResourceLoader.GetForViewIndependentUse($"{_configurationService.Common.StringResourcesAssembly}/{resourceName}")); + protected StringResources BuildResource(string resourceName) + { + ResourceLoader loader = new ResourceLoader($"{_configurationService.Common.StringResourcesAssembly}/{resourceName}"); + return new StringResources(loader); + } #endregion } diff --git a/VDownload/Activation/ActivationService.cs b/VDownload/Activation/ActivationService.cs index 6cbd3af..1cb9125 100644 --- a/VDownload/Activation/ActivationService.cs +++ b/VDownload/Activation/ActivationService.cs @@ -1,6 +1,7 @@ using Microsoft.UI.Xaml; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -73,14 +74,19 @@ namespace VDownload.Activation public async Task ActivateAsync(object activationArgs) { + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "testactivate\n"); await InitializeAsync(); ViewModelToViewConverter.Initialize((App.Current as App)!.Host.Services); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "test1\n"); await HandleActivationAsync(activationArgs); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "test2\n"); _window = App.GetService(); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "test3\n"); _window.RootLoaded += Window_RootLoaded; _window.Activate(); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "test4\n"); await StartupAsync(); } diff --git a/VDownload/App.xaml.cs b/VDownload/App.xaml.cs index 5bed22b..a766bef 100644 --- a/VDownload/App.xaml.cs +++ b/VDownload/App.xaml.cs @@ -2,11 +2,13 @@ using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.UI; using Microsoft.UI.Xaml; using Microsoft.Windows.AppNotifications; using System; +using System.IO; using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -87,6 +89,10 @@ namespace VDownload Path = "configuration.json" }); }) + .ConfigureLogging((builder) => + { + builder.AddConsole(); + }) .ConfigureServices((context, services) => { BuildCore(services); @@ -117,11 +123,14 @@ namespace VDownload { base.OnLaunched(args); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", "testlaunched\n"); + await GetService().ActivateAsync(args); } protected void UnhandledExceptionCatched(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"test {e.Message}\n"); throw new NotImplementedException(); } diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index df49035..efaa3fc 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -189,8 +189,12 @@ + + + + @@ -206,8 +210,12 @@ + + + + From c4710b5a539260d07fc0928d4579021d2bc69605 Mon Sep 17 00:00:00 2001 From: Mateusz Skoczek Date: Fri, 15 Mar 2024 12:54:21 +0100 Subject: [PATCH 29/29] test --- .../VDownload.Core.Strings/StringResource.cs | 8 +++- .../StringResourcesManager.cs | 17 +++++++- .../VDownload.Core.Strings.csproj | 40 +++++++++++++++++++ .../VDownload.Core.Tasks/DownloadTask.cs | 22 +++++----- .../DownloadTaskFactoryService.cs | 7 +--- .../VDownload.Core.Tasks.csproj | 2 +- .../About/AboutViewModel.cs | 8 ++-- .../Authentication/AuthenticationViewModel.cs | 22 +++++----- .../BaseViewModel.cs | 14 +++---- .../Home/HomeDownloadsViewModel.cs | 14 +++---- .../Home/HomeVideoCollectionViewModel.cs | 10 ++--- .../Home/HomeVideoViewModel.cs | 10 ++--- .../Home/HomeViewModel.cs | 26 ++++++------ .../Settings/SettingsViewModel.cs | 8 ++-- .../Subscriptions/SubscriptionsViewModel.cs | 14 +++---- .../VDownload.Core.ViewModels.csproj | 1 - .../DialogsService.cs | 36 +++-------------- .../VDownload.Services.UI.Dialogs.csproj | 2 +- VDownload.sln | 21 +--------- VDownload/App.xaml.cs | 6 +-- VDownload/VDownload.csproj | 1 - 21 files changed, 138 insertions(+), 151 deletions(-) diff --git a/VDownload.Core/VDownload.Core.Strings/StringResource.cs b/VDownload.Core/VDownload.Core.Strings/StringResource.cs index 86dec6d..5b2fc9f 100644 --- a/VDownload.Core/VDownload.Core.Strings/StringResource.cs +++ b/VDownload.Core/VDownload.Core.Strings/StringResource.cs @@ -1,9 +1,10 @@ -using Microsoft.Windows.ApplicationModel.Resources; +using Windows.ApplicationModel.Resources; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.IO; namespace VDownload.Core.Strings { @@ -30,7 +31,10 @@ namespace VDownload.Core.Strings #region PUBLIC METHODS - public string Get(string key) => _resourceLoader.GetString(key); + public string Get(string key) + { + return _resourceLoader.GetString(key); + } #endregion } diff --git a/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs b/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs index f5913b3..3bcdad2 100644 --- a/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs +++ b/VDownload.Core/VDownload.Core.Strings/StringResourcesManager.cs @@ -1,10 +1,11 @@ using Microsoft.UI.Xaml; -using Microsoft.Windows.ApplicationModel.Resources; +using Windows.ApplicationModel.Resources; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.IO; namespace VDownload.Core.Strings { @@ -35,7 +36,19 @@ namespace VDownload.Core.Strings private static StringResource BuildResource(string resourceName) { - ResourceLoader loader = new ResourceLoader(resourceName); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"teststring {resourceName}\n"); + ResourceLoader loader; + try + { + loader = new ResourceLoader($"VDownload.Core.Strings/{resourceName}"); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"afterteststring {resourceName}\n"); + } + catch (Exception e) + { + + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"teststringerror {e.Message}\n"); + throw; + } return new StringResource(loader); } diff --git a/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj b/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj index 7a200cb..146088e 100644 --- a/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj +++ b/VDownload.Core/VDownload.Core.Strings/VDownload.Core.Strings.csproj @@ -15,8 +15,48 @@ + + Always + + + Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always diff --git a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs index da21750..f855683 100644 --- a/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs +++ b/VDownload.Core/VDownload.Core.Tasks/DownloadTask.cs @@ -11,11 +11,11 @@ using System.Linq; using Windows.Storage; using System.IO; using VDownload.Services.UI.Notifications; -using VDownload.Services.UI.StringResources; using System.Collections.Generic; using System.Net.Http; using Instances.Exceptions; using FFMpegCore.Exceptions; +using VDownload.Core.Strings; namespace VDownload.Core.Tasks { @@ -39,7 +39,6 @@ namespace VDownload.Core.Tasks protected readonly IConfigurationService _configurationService; protected readonly ISettingsService _settingsService; protected readonly IFFmpegService _ffmpegService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly INotificationsService _notificationsService; #endregion @@ -87,12 +86,11 @@ namespace VDownload.Core.Tasks #region CONSTRUCTORS - internal DownloadTask(Video video, VideoDownloadOptions downloadOptions, IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, IStringResourcesService stringResourcesService, INotificationsService notificationsService) + internal DownloadTask(Video video, VideoDownloadOptions downloadOptions, IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, INotificationsService notificationsService) { _configurationService = configurationService; _settingsService = settingsService; _ffmpegService = ffmpegService; - _stringResourcesService = stringResourcesService; _notificationsService = notificationsService; _video = video; @@ -165,8 +163,8 @@ namespace VDownload.Core.Tasks List content = new List() { - $"{_stringResourcesService.NotificationsResources.Get("Title")}: {Video.Title}", - $"{_stringResourcesService.NotificationsResources.Get("Author")}: {Video.Author}" + $"{StringResourcesManager.Notifications.Get("Title")}: {Video.Title}", + $"{StringResourcesManager.Notifications.Get("Author")}: {Video.Author}" }; string errorMessage = null; @@ -222,15 +220,15 @@ namespace VDownload.Core.Tasks if (ex is TaskCanceledException || ex is HttpRequestException) { - message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorDownloadingTimeout"); + message = StringResourcesManager.HomeDownloadsView.Get("ErrorDownloadingTimeout"); } else if (ex is InstanceFileNotFoundException) { - message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorFFmpegPath"); + message = StringResourcesManager.HomeDownloadsView.Get("ErrorFFmpegPath"); } else if (ex is FFMpegException) { - message = _stringResourcesService.HomeDownloadsViewResources.Get("ErrorFFmpeg"); + message = StringResourcesManager.HomeDownloadsView.Get("ErrorFFmpeg"); } else { @@ -249,15 +247,15 @@ namespace VDownload.Core.Tasks case TaskResult.Error: if (_settingsService.Data.Common.Notifications.OnUnsuccessful) { - string title = _stringResourcesService.NotificationsResources.Get("OnUnsuccessfulTitle"); - content.Add($"{_stringResourcesService.NotificationsResources.Get("Message")}: {errorMessage}"); + string title = StringResourcesManager.Notifications.Get("OnUnsuccessfulTitle"); + content.Add($"{StringResourcesManager.Notifications.Get("Message")}: {errorMessage}"); _notificationsService.SendNotification(title, content); } break; case TaskResult.Success: if (_settingsService.Data.Common.Notifications.OnSuccessful) { - string title = _stringResourcesService.NotificationsResources.Get("OnSuccessfulTitle"); + string title = StringResourcesManager.Notifications.Get("OnSuccessfulTitle"); _notificationsService.SendNotification(title, content); } break; diff --git a/VDownload.Core/VDownload.Core.Tasks/DownloadTaskFactoryService.cs b/VDownload.Core/VDownload.Core.Tasks/DownloadTaskFactoryService.cs index ff2b3f2..1e25a64 100644 --- a/VDownload.Core/VDownload.Core.Tasks/DownloadTaskFactoryService.cs +++ b/VDownload.Core/VDownload.Core.Tasks/DownloadTaskFactoryService.cs @@ -7,7 +7,6 @@ using VDownload.Models; using VDownload.Services.Data.Configuration; using VDownload.Services.Data.Settings; using VDownload.Services.UI.Notifications; -using VDownload.Services.UI.StringResources; using VDownload.Services.Utility.FFmpeg; namespace VDownload.Core.Tasks @@ -26,7 +25,6 @@ namespace VDownload.Core.Tasks protected readonly IConfigurationService _configurationService; protected readonly ISettingsService _settingsService; protected readonly IFFmpegService _ffmpegService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly INotificationsService _notificationsService; #endregion @@ -35,12 +33,11 @@ namespace VDownload.Core.Tasks #region CONSTRUCTORS - public DownloadTaskFactoryService(IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, IStringResourcesService stringResourcesService, INotificationsService notificationsService) + public DownloadTaskFactoryService(IConfigurationService configurationService, ISettingsService settingsService, IFFmpegService ffmpegService, INotificationsService notificationsService) { _configurationService = configurationService; _settingsService = settingsService; _ffmpegService = ffmpegService; - _stringResourcesService = stringResourcesService; _notificationsService = notificationsService; } @@ -52,7 +49,7 @@ namespace VDownload.Core.Tasks public DownloadTask Create(Video video, VideoDownloadOptions downloadOptions) { - return new DownloadTask(video, downloadOptions, _configurationService, _settingsService, _ffmpegService, _stringResourcesService, _notificationsService); + return new DownloadTask(video, downloadOptions, _configurationService, _settingsService, _ffmpegService, _notificationsService); } #endregion diff --git a/VDownload.Core/VDownload.Core.Tasks/VDownload.Core.Tasks.csproj b/VDownload.Core/VDownload.Core.Tasks/VDownload.Core.Tasks.csproj index 29a2a02..ae5c5fc 100644 --- a/VDownload.Core/VDownload.Core.Tasks/VDownload.Core.Tasks.csproj +++ b/VDownload.Core/VDownload.Core.Tasks/VDownload.Core.Tasks.csproj @@ -19,8 +19,8 @@ - + diff --git a/VDownload.Core/VDownload.Core.ViewModels/About/AboutViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/About/AboutViewModel.cs index 938ad57..6d824a3 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/About/AboutViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/About/AboutViewModel.cs @@ -9,10 +9,10 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Core.ViewModels.About.Helpers; using VDownload.Services.Data.Configuration; using VDownload.Services.Data.Configuration.Models; -using VDownload.Services.UI.StringResources; using Windows.System.UserProfile; namespace VDownload.Core.ViewModels.About @@ -21,7 +21,6 @@ namespace VDownload.Core.ViewModels.About { #region SERVICES - protected readonly IStringResourcesService _stringResourcesService; protected readonly IConfigurationService _configurationService; #endregion @@ -51,15 +50,14 @@ namespace VDownload.Core.ViewModels.About #region CONSTRUCTORS - public AboutViewModel(IStringResourcesService stringResourcesService, IConfigurationService configurationService) + public AboutViewModel(IConfigurationService configurationService) { - _stringResourcesService = stringResourcesService; _configurationService = configurationService; string version = Assembly.GetEntryAssembly().GetCustomAttribute()?.InformationalVersion; if (version == "0.0.0") { - version = _stringResourcesService.AboutViewResources.Get("SelfbuiltVersion"); + version = StringResourcesManager.AboutView.Get("SelfbuiltVersion"); } _version = version; diff --git a/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs index 4356c02..1c210df 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Authentication/AuthenticationViewModel.cs @@ -8,9 +8,9 @@ using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Services.Data.Configuration; using VDownload.Services.UI.Dialogs; -using VDownload.Services.UI.StringResources; using VDownload.Services.UI.WebView; using VDownload.Sources.Twitch.Authentication; @@ -36,7 +36,6 @@ namespace VDownload.Core.ViewModels.Authentication protected readonly IDialogsService _dialogsService; protected readonly IWebViewService _webViewService; protected readonly IConfigurationService _configurationService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly ITwitchAuthenticationService _twitchAuthenticationService; #endregion @@ -60,12 +59,11 @@ namespace VDownload.Core.ViewModels.Authentication #region CONSTRUCTORS - public AuthenticationViewModel(IDialogsService dialogsService, IWebViewService webViewService, IConfigurationService configurationService, IStringResourcesService stringResourcesService, ITwitchAuthenticationService twitchAuthenticationService) + public AuthenticationViewModel(IDialogsService dialogsService, IWebViewService webViewService, IConfigurationService configurationService, ITwitchAuthenticationService twitchAuthenticationService) { _dialogsService = dialogsService; _webViewService = webViewService; _configurationService = configurationService; - _stringResourcesService = stringResourcesService; _twitchAuthenticationService = twitchAuthenticationService; } @@ -100,7 +98,7 @@ namespace VDownload.Core.ViewModels.Authentication Sources.Twitch.Configuration.Models.Authentication auth = _configurationService.Twitch.Authentication; string authUrl = string.Format(auth.Url, auth.ClientId, auth.RedirectUrl, auth.ResponseType, string.Join(' ', auth.Scopes)); - string url = await _webViewService.Show(new Uri(authUrl), (url) => url.StartsWith(auth.RedirectUrl), _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationWindowTitle")); + string url = await _webViewService.Show(new Uri(authUrl), (url) => url.StartsWith(auth.RedirectUrl), StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationWindowTitle")); Regex regex = new Regex(auth.RedirectUrlRegex); Match match = regex.Match(url); @@ -112,8 +110,8 @@ namespace VDownload.Core.ViewModels.Authentication } else { - string title = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDialogTitle"); - string message = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDialogMessage"); + string title = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDialogTitle"); + string message = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDialogMessage"); await _dialogsService.ShowOk(title, message); } } @@ -138,11 +136,11 @@ namespace VDownload.Core.ViewModels.Authentication if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { TwitchButtonEnable = false; - TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionNotAuthenticatedNoInternetConnection"); + TwitchDescription = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDescriptionNotAuthenticatedNoInternetConnection"); } else { - TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionNotAuthenticated"); + TwitchDescription = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDescriptionNotAuthenticated"); } TwitchButtonState = AuthenticationButton.SignIn; } @@ -155,7 +153,7 @@ namespace VDownload.Core.ViewModels.Authentication } catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException) { - TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionCannotValidate"); + TwitchDescription = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDescriptionCannotValidate"); TwitchButtonState = AuthenticationButton.SignIn; TwitchButtonEnable = false; return; @@ -163,13 +161,13 @@ namespace VDownload.Core.ViewModels.Authentication if (validationResult.Success) { - TwitchDescription = string.Format(_stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionAuthenticated"), validationResult.TokenData.Login, validationResult.TokenData.ExpirationDate); + TwitchDescription = string.Format(StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDescriptionAuthenticated"), validationResult.TokenData.Login, validationResult.TokenData.ExpirationDate); TwitchButtonState = AuthenticationButton.SignOut; } else { await _twitchAuthenticationService.DeleteToken(); - TwitchDescription = _stringResourcesService.AuthenticationViewResources.Get("TwitchAuthenticationDescriptionAuthenticationInvalid"); + TwitchDescription = StringResourcesManager.AuthenticationView.Get("TwitchAuthenticationDescriptionAuthenticationInvalid"); TwitchButtonState = AuthenticationButton.SignIn; } } diff --git a/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs index cd7ff21..4c36354 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/BaseViewModel.cs @@ -10,10 +10,10 @@ using VDownload.Core.ViewModels.Authentication; using VDownload.Core.ViewModels.Home; using VDownload.Core.ViewModels.Settings; using VDownload.Services.UI.DictionaryResources; -using VDownload.Services.UI.StringResources; using SimpleToolkit.UI.Models; using VDownload.Core.ViewModels.About; using VDownload.Core.ViewModels.Subscriptions; +using VDownload.Core.Strings; namespace VDownload.Core.ViewModels { @@ -21,7 +21,6 @@ namespace VDownload.Core.ViewModels { #region SERVICES - protected readonly IStringResourcesService _stringResourcesService; protected readonly IDictionaryResourcesService _dictionaryResourcesService; #endregion @@ -53,9 +52,8 @@ namespace VDownload.Core.ViewModels #region CONSTRUCTORS - public BaseViewModel(IStringResourcesService stringResourcesService, IDictionaryResourcesService dictionaryResourcesService) + public BaseViewModel(IDictionaryResourcesService dictionaryResourcesService) { - _stringResourcesService = stringResourcesService; _dictionaryResourcesService = dictionaryResourcesService; Items = new ReadOnlyObservableCollection @@ -64,13 +62,13 @@ namespace VDownload.Core.ViewModels { new NavigationViewItem() { - Name = _stringResourcesService.BaseViewResources.Get("HomeNavigationViewItem"), + Name = StringResourcesManager.BaseView.Get("HomeNavigationViewItem"), IconSource = _dictionaryResourcesService.Get("ImageBaseViewHome"), ViewModel = typeof(HomeViewModel), }, new NavigationViewItem() { - Name = _stringResourcesService.BaseViewResources.Get("SubscriptionsNavigationViewItem"), + Name = StringResourcesManager.BaseView.Get("SubscriptionsNavigationViewItem"), IconSource = _dictionaryResourcesService.Get("ImageBaseViewSubscriptions"), ViewModel = typeof(SubscriptionsViewModel), }, @@ -82,13 +80,13 @@ namespace VDownload.Core.ViewModels { new NavigationViewItem() { - Name = _stringResourcesService.BaseViewResources.Get("AboutNavigationViewItem"), + Name = StringResourcesManager.BaseView.Get("AboutNavigationViewItem"), IconSource = _dictionaryResourcesService.Get("ImageBaseViewAbout"), ViewModel = typeof(AboutViewModel), }, new NavigationViewItem() { - Name = _stringResourcesService.BaseViewResources.Get("AuthenticationNavigationViewItem"), + Name = StringResourcesManager.BaseView.Get("AuthenticationNavigationViewItem"), IconSource = _dictionaryResourcesService.Get("ImageBaseViewAuthentication"), ViewModel = typeof(AuthenticationViewModel), } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs index 47e53a5..e32dbc4 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeDownloadsViewModel.cs @@ -7,10 +7,10 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Core.Tasks; using VDownload.Services.Data.Settings; using VDownload.Services.UI.Dialogs; -using VDownload.Services.UI.StringResources; namespace VDownload.Core.ViewModels.Home { @@ -21,7 +21,6 @@ namespace VDownload.Core.ViewModels.Home protected readonly IDownloadTaskManager _tasksManager; protected readonly IDialogsService _dialogsService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly ISettingsService _settingsService; #endregion @@ -41,13 +40,12 @@ namespace VDownload.Core.ViewModels.Home #region CONSTRUCTORS - public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, IStringResourcesService stringResourcesService, ISettingsService settingsService) + public HomeDownloadsViewModel(IDownloadTaskManager tasksManager, IDialogsService dialogsService, ISettingsService settingsService) { _tasksManager = tasksManager; _tasksManager.TaskCollectionChanged += Tasks_CollectionChanged; _dialogsService = dialogsService; - _stringResourcesService = stringResourcesService; _settingsService = settingsService; _taskListIsEmpty = _tasksManager.Tasks.Count == 0; @@ -73,8 +71,8 @@ namespace VDownload.Core.ViewModels.Home { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { - string title = _stringResourcesService.HomeDownloadsViewResources.Get("DialogErrorTitle"); - string message = _stringResourcesService.HomeDownloadsViewResources.Get("DialogErrorMessageNoInternetConnection"); + string title = StringResourcesManager.HomeDownloadsView.Get("DialogErrorTitle"); + string message = StringResourcesManager.HomeDownloadsView.Get("DialogErrorMessageNoInternetConnection"); await _dialogsService.ShowOk(title, message); return; } @@ -87,8 +85,8 @@ namespace VDownload.Core.ViewModels.Home NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection ) { - string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); - string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); + string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle"); + string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage"); DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); continueEnqueue = result == DialogResultYesNo.Yes; } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs index ca3fe15..430cb2b 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoCollectionViewModel.cs @@ -18,9 +18,9 @@ using SimpleToolkit.MVVM; using System.Text.RegularExpressions; using VDownload.Services.Utility.Filename; using VDownload.Services.UI.Dialogs; -using VDownload.Services.UI.StringResources; using CommunityToolkit.WinUI.Helpers; using VDownload.Services.Data.Application; +using VDownload.Core.Strings; namespace VDownload.Core.ViewModels.Home { @@ -34,7 +34,6 @@ namespace VDownload.Core.ViewModels.Home protected readonly IStoragePickerService _storagePickerService; protected readonly IFilenameService _filenameService; protected readonly IDialogsService _dialogsService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly IApplicationDataService _applicationDataService; #endregion @@ -181,14 +180,13 @@ namespace VDownload.Core.ViewModels.Home #region CONSTRUCTORS - public HomeVideoCollectionViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService, IApplicationDataService applicationDataService) + public HomeVideoCollectionViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IApplicationDataService applicationDataService) { _tasksManager = tasksManager; _settingsService = settingsService; _storagePickerService = storagePickerService; _filenameService = filenameService; _dialogsService = dialogsService; - _stringResourcesService = stringResourcesService; _applicationDataService = applicationDataService; _removedVideos = new List(); @@ -306,8 +304,8 @@ namespace VDownload.Core.ViewModels.Home NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection ) { - string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); - string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); + string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle"); + string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage"); DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); download = result == DialogResultYesNo.Yes; } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs index 4c4e483..8ebb554 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeVideoViewModel.cs @@ -8,13 +8,13 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Core.Tasks; using VDownload.Models; using VDownload.Services.Data.Application; using VDownload.Services.Data.Settings; using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.StoragePicker; -using VDownload.Services.UI.StringResources; using VDownload.Services.Utility.Filename; namespace VDownload.Core.ViewModels.Home @@ -29,7 +29,6 @@ namespace VDownload.Core.ViewModels.Home protected readonly IStoragePickerService _storagePickerService; protected readonly IFilenameService _filenameService; protected readonly IDialogsService _dialogsService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly IApplicationDataService _applicationDataService; #endregion @@ -98,14 +97,13 @@ namespace VDownload.Core.ViewModels.Home #region CONSTRUCTORS - public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IStringResourcesService stringResourcesService, IApplicationDataService applicationDataService) + public HomeVideoViewModel(IDownloadTaskManager tasksManager, ISettingsService settingsService, IStoragePickerService storagePickerService, IFilenameService filenameService, IDialogsService dialogsService, IApplicationDataService applicationDataService) { _tasksManager = tasksManager; _settingsService = settingsService; _storagePickerService = storagePickerService; _filenameService = filenameService; _dialogsService = dialogsService; - _stringResourcesService = stringResourcesService; _applicationDataService = applicationDataService; } @@ -184,8 +182,8 @@ namespace VDownload.Core.ViewModels.Home NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection ) { - string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); - string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); + string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle"); + string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage"); DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); download = result == DialogResultYesNo.Yes; } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs index 9319f71..050750e 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Home/HomeViewModel.cs @@ -7,13 +7,13 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Core.Tasks; using VDownload.Models; using VDownload.Services.Data.Configuration; using VDownload.Services.Data.Settings; using VDownload.Services.Data.Subscriptions; using VDownload.Services.UI.Dialogs; -using VDownload.Services.UI.StringResources; using VDownload.Sources; using VDownload.Sources.Common; using VDownload.Sources.Twitch.Configuration.Models; @@ -45,7 +45,6 @@ namespace VDownload.Core.ViewModels.Home protected readonly IConfigurationService _configurationService; protected readonly ISettingsService _settingsService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly ISearchService _searchService; protected readonly ISubscriptionsDataService _subscriptionsDataService; protected readonly IDialogsService _dialogsService; @@ -116,11 +115,10 @@ namespace VDownload.Core.ViewModels.Home #region CONSTRUCTORS - public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, ISubscriptionsDataService subscriptionsDataService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel) + public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, ISearchService searchService, ISubscriptionsDataService subscriptionsDataService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel) { _configurationService = configurationService; _settingsService = settingsService; - _stringResourcesService = stringResourcesService; _searchService = searchService; _subscriptionsDataService = subscriptionsDataService; _dialogsService = dialogsService; @@ -181,7 +179,7 @@ namespace VDownload.Core.ViewModels.Home StartSearch(); - SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") }; + SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = StringResourcesManager.Common.Get("SubscriptionVideoListName") }; List tasks = new List(); try { @@ -218,14 +216,14 @@ namespace VDownload.Core.ViewModels.Home if (subList.Count > 0) { - OptionBarMessage = $"{_stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosFound")} {subList.Count}"; + OptionBarMessage = $"{StringResourcesManager.HomeView.Get("OptionBarMessageVideosFound")} {subList.Count}"; _videoCollectionViewModel.LoadCollection(subList); MainContent = _videoCollectionView; } else { - OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosNotFound"); + OptionBarMessage = StringResourcesManager.HomeView.Get("OptionBarMessageVideosNotFound"); } OptionBarSearchNotPending = true; @@ -285,7 +283,7 @@ namespace VDownload.Core.ViewModels.Home } catch (MediaSearchException ex) { - ShowError(_stringResourcesService.SearchResources.Get(ex.StringCode)); + ShowError(StringResourcesManager.Search.Get(ex.StringCode)); return; } catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException) @@ -321,7 +319,7 @@ namespace VDownload.Core.ViewModels.Home } catch (MediaSearchException ex) { - ShowError(_stringResourcesService.SearchResources.Get(ex.StringCode)); + ShowError(StringResourcesManager.Search.Get(ex.StringCode)); return; } catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException) @@ -357,8 +355,8 @@ namespace VDownload.Core.ViewModels.Home NetworkHelper.Instance.ConnectionInformation.IsInternetOnMeteredConnection ) { - string title = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogTitle"); - string message = _stringResourcesService.CommonResources.Get("StartAtMeteredConnectionDialogMessage"); + string title = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogTitle"); + string message = StringResourcesManager.Common.Get("StartAtMeteredConnectionDialogMessage"); DialogResultYesNo result = await _dialogsService.ShowYesNo(title, message); if (result == DialogResultYesNo.No) { @@ -417,14 +415,14 @@ namespace VDownload.Core.ViewModels.Home { OptionBarSearchNotPending = false; OptionBarLoading = true; - OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading"); + OptionBarMessage = StringResourcesManager.HomeView.Get("OptionBarMessageLoading"); } protected async void BackToDownload_EventHandler(object sender, EventArgs e) => await Navigation(); - protected string ErrorNoInternetConnection() => _stringResourcesService.HomeViewResources.Get("ErrorInfoBarNoInternetConnection"); + protected string ErrorNoInternetConnection() => StringResourcesManager.HomeView.Get("ErrorInfoBarNoInternetConnection"); - protected string ErrorSearchTimeout() => _stringResourcesService.SearchResources.Get("SearchTimeout"); + protected string ErrorSearchTimeout() => StringResourcesManager.Search.Get("SearchTimeout"); #endregion } diff --git a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs index cfa9784..1330ecc 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Settings/SettingsViewModel.cs @@ -6,11 +6,11 @@ using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Models; using VDownload.Services.Data.Configuration; using VDownload.Services.Data.Settings; using VDownload.Services.UI.StoragePicker; -using VDownload.Services.UI.StringResources; namespace VDownload.Core.ViewModels.Settings { @@ -20,7 +20,6 @@ namespace VDownload.Core.ViewModels.Settings protected readonly ISettingsService _settingsService; protected readonly IConfigurationService _configurationService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly IStoragePickerService _storagePickerService; #endregion @@ -176,16 +175,15 @@ namespace VDownload.Core.ViewModels.Settings #region CONSTRUCTORS - public SettingsViewModel(ISettingsService settingsService, IConfigurationService configurationService, IStringResourcesService stringResourcesService, IStoragePickerService storagePickerService) + public SettingsViewModel(ISettingsService settingsService, IConfigurationService configurationService, IStoragePickerService storagePickerService) { _settingsService = settingsService; _configurationService = configurationService; - _stringResourcesService = stringResourcesService; _storagePickerService = storagePickerService; base.PropertyChanged += PropertyChangedEventHandler; - _tasksFilenameTemplateTooltip = string.Join('\n', _configurationService.Common.FilenameTemplates.Select(x => _stringResourcesService.FilenameTemplateResources.Get(x.Name))); + _tasksFilenameTemplateTooltip = string.Join('\n', _configurationService.Common.FilenameTemplates.Select(x => StringResourcesManager.FilenameTemplate.Get(x.Name))); } #endregion diff --git a/VDownload.Core/VDownload.Core.ViewModels/Subscriptions/SubscriptionsViewModel.cs b/VDownload.Core/VDownload.Core.ViewModels/Subscriptions/SubscriptionsViewModel.cs index 31d8712..63bfefb 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/Subscriptions/SubscriptionsViewModel.cs +++ b/VDownload.Core/VDownload.Core.ViewModels/Subscriptions/SubscriptionsViewModel.cs @@ -9,10 +9,10 @@ using System.Linq; using System.Net.Http; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Core.ViewModels.Subscriptions.Helpers; using VDownload.Models; using VDownload.Services.Data.Subscriptions; -using VDownload.Services.UI.StringResources; using VDownload.Sources; using VDownload.Sources.Common; @@ -23,7 +23,6 @@ namespace VDownload.Core.ViewModels.Subscriptions #region SERVICES protected readonly ISearchService _searchService; - protected readonly IStringResourcesService _stringResourcesService; protected readonly ISubscriptionsDataService _subscriptionsDataService; #endregion @@ -53,10 +52,9 @@ namespace VDownload.Core.ViewModels.Subscriptions #region CONSTRUCTORS - public SubscriptionsViewModel(ISearchService searchService, IStringResourcesService stringResourcesService, ISubscriptionsDataService subscriptionsDataService) + public SubscriptionsViewModel(ISearchService searchService, ISubscriptionsDataService subscriptionsDataService) { _searchService = searchService; - _stringResourcesService = stringResourcesService; _subscriptionsDataService = subscriptionsDataService; _playlists = new ObservableCollection(); @@ -96,7 +94,7 @@ namespace VDownload.Core.ViewModels.Subscriptions { if (!NetworkHelper.Instance.ConnectionInformation.IsInternetAvailable) { - ShowError(_stringResourcesService.SubscriptionsViewResources.Get("NoInternetConnectionError")); + ShowError(StringResourcesManager.SubscriptionsView.Get("NoInternetConnectionError")); return; } @@ -109,18 +107,18 @@ namespace VDownload.Core.ViewModels.Subscriptions } catch (MediaSearchException ex) { - ShowError(_stringResourcesService.SearchResources.Get(ex.StringCode)); + ShowError(StringResourcesManager.Search.Get(ex.StringCode)); return; } catch (Exception ex) when (ex is TaskCanceledException || ex is HttpRequestException) { - ShowError(_stringResourcesService.SearchResources.Get("SearchTimeout")); + ShowError(StringResourcesManager.Search.Get("SearchTimeout")); return; } if (_subscriptionsDataService.Data.Any(x => x.Source == playlist.Source && x.Name == playlist.Name)) { - ShowError(_stringResourcesService.SubscriptionsViewResources.Get("DuplicateError")); + ShowError(StringResourcesManager.SubscriptionsView.Get("DuplicateError")); return; } diff --git a/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj b/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj index e493bd7..bf03ae7 100644 --- a/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj +++ b/VDownload.Core/VDownload.Core.ViewModels/VDownload.Core.ViewModels.csproj @@ -24,7 +24,6 @@ - diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs index 6a80b3b..2e91dea 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/DialogsService.cs @@ -6,8 +6,8 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using VDownload.Core.Strings; using VDownload.Services.Common; -using VDownload.Services.UI.StringResources; namespace VDownload.Services.UI.Dialogs { @@ -27,21 +27,13 @@ namespace VDownload.Services.UI.Dialogs public class DialogsService : IDialogsService { - #region SERVICES - - protected readonly IStringResourcesService _stringResourcesService; - - #endregion - - - #region FIELDS - protected string _okString; - protected string _closeString; - protected string _cancelString; - protected string _yesString; - protected string _noString; + protected string _okString = StringResourcesManager.DialogButtons.Get("OK"); + protected string _closeString = StringResourcesManager.DialogButtons.Get("Close"); + protected string _cancelString = StringResourcesManager.DialogButtons.Get("Cancel"); + protected string _yesString = StringResourcesManager.DialogButtons.Get("Yes"); + protected string _noString = StringResourcesManager.DialogButtons.Get("No"); protected XamlRoot _root; @@ -49,22 +41,6 @@ namespace VDownload.Services.UI.Dialogs - #region CONSTRUCTORS - - public DialogsService(IStringResourcesService stringResourcesService) - { - _stringResourcesService = stringResourcesService; - _okString = _stringResourcesService.DialogButtonsResources.Get("OK"); - _closeString = _stringResourcesService.DialogButtonsResources.Get("Close"); - _cancelString = _stringResourcesService.DialogButtonsResources.Get("Cancel"); - _yesString = _stringResourcesService.DialogButtonsResources.Get("Yes"); - _noString = _stringResourcesService.DialogButtonsResources.Get("No"); - } - - #endregion - - - #region PUBLIC METHODS public async Task Initialize(XamlRoot arg) => await Task.Run(() => _root = arg); diff --git a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj index fd60d13..6167d47 100644 --- a/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj +++ b/VDownload.Services/VDownload.Services.UI/VDownload.Services.UI.Dialogs/VDownload.Services.UI.Dialogs.csproj @@ -15,7 +15,7 @@ + - diff --git a/VDownload.sln b/VDownload.sln index 9e75b74..0261eef 100644 --- a/VDownload.sln +++ b/VDownload.sln @@ -53,8 +53,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VDownload.Core", "VDownload EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Models", "VDownload.Models\VDownload.Models.csproj", "{16B56EA9-C218-4A8E-B3DE-29F200EF2EE2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.UI.StringResources", "VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.StringResources\VDownload.Services.UI.StringResources.csproj", "{6F6CA153-1AC6-454A-ACDC-2C706E2A437E}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.UI.DictionaryResources", "VDownload.Services\VDownload.Services.UI\VDownload.Services.UI.DictionaryResources\VDownload.Services.UI.DictionaryResources.csproj", "{8DC55331-B9F3-4811-8474-348662963260}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Sources.Twitch.Settings", "VDownload.Sources\VDownload.Sources.Twitch\VDownload.Sources.Twitch.Settings\VDownload.Sources.Twitch.Settings.csproj", "{A726FD43-B111-423B-BAF6-D65B4C0E37B5}" @@ -75,7 +73,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Data.App EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Data.Subscriptions", "VDownload.Services\VDownload.Services.Data\VDownload.Services.Data.Subscriptions\VDownload.Services.Data.Subscriptions.csproj", "{3193DABC-87F8-4256-9449-3CF42FEF7098}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VDownload.Services.Common", "VDownload.Services\VDownload.Services.Common\VDownload.Services.Common.csproj", "{267F5A31-1257-4820-9FE5-C11D26CC3C55}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VDownload.Services.Common", "VDownload.Services\VDownload.Services.Common\VDownload.Services.Common.csproj", "{267F5A31-1257-4820-9FE5-C11D26CC3C55}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -383,22 +381,6 @@ Global {16B56EA9-C218-4A8E-B3DE-29F200EF2EE2}.Release|x64.Build.0 = Release|Any CPU {16B56EA9-C218-4A8E-B3DE-29F200EF2EE2}.Release|x86.ActiveCfg = Release|Any CPU {16B56EA9-C218-4A8E-B3DE-29F200EF2EE2}.Release|x86.Build.0 = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|ARM64.Build.0 = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|x64.ActiveCfg = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|x64.Build.0 = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|x86.ActiveCfg = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Debug|x86.Build.0 = Debug|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|Any CPU.Build.0 = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|ARM64.ActiveCfg = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|ARM64.Build.0 = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|x64.ActiveCfg = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|x64.Build.0 = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|x86.ActiveCfg = Release|Any CPU - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E}.Release|x86.Build.0 = Release|Any CPU {8DC55331-B9F3-4811-8474-348662963260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8DC55331-B9F3-4811-8474-348662963260}.Debug|Any CPU.Build.0 = Debug|Any CPU {8DC55331-B9F3-4811-8474-348662963260}.Debug|ARM64.ActiveCfg = Debug|Any CPU @@ -600,7 +582,6 @@ Global {711FA7BE-27DA-425D-9777-967F6E519CFF} = {8D94F264-4EE9-4C24-AB77-2CCA36858309} {8E850249-E79D-40E7-B02D-393632DF8B8E} = {9A8EB967-1EAB-439E-8FDB-B9ACAC6499EC} {64A217AE-4E95-468E-85C3-67C27D689FF4} = {9A8EB967-1EAB-439E-8FDB-B9ACAC6499EC} - {6F6CA153-1AC6-454A-ACDC-2C706E2A437E} = {4CC2DC7D-27D2-4F52-89DF-7D45B41BB40F} {8DC55331-B9F3-4811-8474-348662963260} = {4CC2DC7D-27D2-4F52-89DF-7D45B41BB40F} {A726FD43-B111-423B-BAF6-D65B4C0E37B5} = {8D94F264-4EE9-4C24-AB77-2CCA36858309} {E1D4352C-51AC-4572-8515-0B4E89A2442F} = {8539067C-9968-4AEB-928C-FEDC43989A79} diff --git a/VDownload/App.xaml.cs b/VDownload/App.xaml.cs index a766bef..22ce65d 100644 --- a/VDownload/App.xaml.cs +++ b/VDownload/App.xaml.cs @@ -36,7 +36,6 @@ using VDownload.Services.UI.Dialogs; using VDownload.Services.UI.DictionaryResources; using VDownload.Services.UI.Notifications; using VDownload.Services.UI.StoragePicker; -using VDownload.Services.UI.StringResources; using VDownload.Services.UI.WebView; using VDownload.Services.Utility.Encryption; using VDownload.Services.Utility.FFmpeg; @@ -130,8 +129,8 @@ namespace VDownload protected void UnhandledExceptionCatched(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) { - File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"test {e.Message}\n"); - throw new NotImplementedException(); + File.AppendAllText("C:\\Users\\mateusz\\Desktop\\test.txt", $"test {e.Message} {e.Exception.StackTrace}\n"); + Environment.Exit(0); } #endregion @@ -152,7 +151,6 @@ namespace VDownload protected void BuildUIServices(IServiceCollection services) { - services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/VDownload/VDownload.csproj b/VDownload/VDownload.csproj index efaa3fc..eefb73b 100644 --- a/VDownload/VDownload.csproj +++ b/VDownload/VDownload.csproj @@ -204,7 +204,6 @@ -