_libraryList = [];
[ObservableProperty] private bool _environmentFoundVisible;
- [ObservableProperty] private bool _listVisible;
[RelayCommand]
private void NavigateToAddEnvironment()
diff --git a/src/PipManager/ViewModels/Pages/Search/SearchDetailViewModel.cs b/src/PipManager/ViewModels/Pages/Search/SearchDetailViewModel.cs
index a49b5e9..eb5a9e1 100644
--- a/src/PipManager/ViewModels/Pages/Search/SearchDetailViewModel.cs
+++ b/src/PipManager/ViewModels/Pages/Search/SearchDetailViewModel.cs
@@ -11,6 +11,7 @@
using System.Drawing;
using System.Net.Http;
using Wpf.Ui;
+using Wpf.Ui.Appearance;
using Wpf.Ui.Controls;
namespace PipManager.ViewModels.Pages.Search;
@@ -35,7 +36,7 @@ public record SearchDetailMessage(QueryListItemModel Package);
private int _themeTypeInInteger = 16448250;
- private const string _htmlModel = """
+ private const string HtmlModel = """
@@ -72,17 +73,21 @@ public void OnNavigatedTo()
_navigationService.GetNavigationControl().BreadcrumbBar!.Visibility = Visibility.Collapsed;
switch (_themeService.GetTheme())
{
- case Wpf.Ui.Appearance.ApplicationTheme.Light:
+ case ApplicationTheme.Light:
_themeType = "light";
ThemeTypeInHex = "#FFFFFF";
_themeTypeInInteger = 16777215;
break;
- case Wpf.Ui.Appearance.ApplicationTheme.Dark:
+ case ApplicationTheme.Dark:
_themeType = "dark";
ThemeTypeInHex = "#0D1117";
_themeTypeInInteger = 856343;
break;
+ case ApplicationTheme.Unknown:
+ case ApplicationTheme.HighContrast:
+ default:
+ throw new ArgumentOutOfRangeException();
}
SearchDetailPage.ProjectDescriptionWebView!.DefaultBackgroundColor = Color.FromArgb(_themeTypeInInteger);
}
@@ -118,7 +123,7 @@ private async Task InstallPackage()
}
}
- public void Receive(object recipient, SearchDetailMessage message)
+ private void Receive(object recipient, SearchDetailMessage message)
{
Package = message.Package;
@@ -149,7 +154,7 @@ public void Receive(object recipient, SearchDetailMessage message)
var html = await _httpClient.GetStringAsync(projectDescriptionUrl);
var htmlDocument = new HtmlDocument();
htmlDocument.LoadHtml(html);
- string projectDescriptionHtml = string.Format(_htmlModel, _themeType, ThemeTypeInHex, htmlDocument.DocumentNode.SelectSingleNode("//*[@id=\"description\"]/div").InnerHtml);
+ string projectDescriptionHtml = string.Format(HtmlModel, _themeType, ThemeTypeInHex, htmlDocument.DocumentNode.SelectSingleNode("//*[@id=\"description\"]/div").InnerHtml);
SearchDetailPage.ProjectDescriptionWebView.CoreWebView2.Profile.PreferredColorScheme = CoreWebView2PreferredColorScheme.Dark;
SearchDetailPage.ProjectDescriptionWebView.NavigateToString(projectDescriptionHtml);
@@ -158,7 +163,7 @@ public void Receive(object recipient, SearchDetailMessage message)
{
Log.Error(ex.Message);
_toastService.Error(Lang.SearchDetail_ProjectDescription_LoadFailed);
- string projectDescriptionHtml = string.Format(_htmlModel, _themeType, ThemeTypeInHex, $"{Lang.SearchDetail_ProjectDescription_LoadFailed}
");
+ string projectDescriptionHtml = string.Format(HtmlModel, _themeType, ThemeTypeInHex, $"{Lang.SearchDetail_ProjectDescription_LoadFailed}
");
SearchDetailPage.ProjectDescriptionWebView.CoreWebView2.Profile.PreferredColorScheme = CoreWebView2PreferredColorScheme.Dark;
SearchDetailPage.ProjectDescriptionWebView.NavigateToString(projectDescriptionHtml);
diff --git a/src/PipManager/ViewModels/Pages/Search/SearchViewModel.cs b/src/PipManager/ViewModels/Pages/Search/SearchViewModel.cs
index d16c340..2361be0 100644
--- a/src/PipManager/ViewModels/Pages/Search/SearchViewModel.cs
+++ b/src/PipManager/ViewModels/Pages/Search/SearchViewModel.cs
@@ -74,7 +74,7 @@ private void ToDetailPage(object parameter)
#endregion Details
[RelayCommand]
- public async Task ToPreviousPage()
+ private async Task ToPreviousPage()
{
if (CurrentPage == 1)
{
@@ -89,7 +89,7 @@ public async Task ToPreviousPage()
}
[RelayCommand]
- public async Task ToNextPage()
+ private async Task ToNextPage()
{
if (CurrentPage == MaxPage)
{
@@ -113,12 +113,9 @@ private void Process(QueryWrapper queryWrapper)
{
if (queryWrapper.Status == QueryStatus.Success)
{
- foreach (var resultItem in queryWrapper.Results!)
+ foreach (var resultItem in queryWrapper.Results!.Where(resultItem => string.IsNullOrEmpty(resultItem.Description)))
{
- if (string.IsNullOrEmpty(resultItem.Description))
- {
- resultItem.Description = Lang.Search_List_NoDescription;
- }
+ resultItem.Description = Lang.Search_List_NoDescription;
}
QueryList = new ObservableCollection(queryWrapper.Results!);
TotalResultNumber = queryWrapper.ResultCount!;
@@ -128,13 +125,18 @@ private void Process(QueryWrapper queryWrapper)
}
else
{
- if (queryWrapper.Status == QueryStatus.NoResults)
+ switch (queryWrapper.Status)
{
- toastService.Error(Lang.Search_Query_NoResults);
- }
- else if (queryWrapper.Status == QueryStatus.Timeout)
- {
- toastService.Error(Lang.Search_Query_Timeout);
+ case QueryStatus.NoResults:
+ toastService.Error(Lang.Search_Query_NoResults);
+ break;
+ case QueryStatus.Timeout:
+ toastService.Error(Lang.Search_Query_Timeout);
+ break;
+ case QueryStatus.Success:
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
}
QueryList.Clear();
TotalResultNumber = "";
@@ -144,7 +146,7 @@ private void Process(QueryWrapper queryWrapper)
}
[RelayCommand]
- public async Task Search(string? parameter)
+ private async Task Search(string? parameter)
{
if (parameter != null && !string.IsNullOrEmpty(parameter))
{
diff --git a/src/PipManager/ViewModels/Pages/Settings/SettingsViewModel.cs b/src/PipManager/ViewModels/Pages/Settings/SettingsViewModel.cs
index 1899124..ffe0275 100644
--- a/src/PipManager/ViewModels/Pages/Settings/SettingsViewModel.cs
+++ b/src/PipManager/ViewModels/Pages/Settings/SettingsViewModel.cs
@@ -11,7 +11,6 @@
using System.Globalization;
using System.IO;
using System.Net.Http;
-using PipManager.Views.Windows;
using Wpf.Ui;
using Wpf.Ui.Appearance;
using Wpf.Ui.Controls;
From 94e86e09798a920332856cd3f2cdcd7928f37e4a Mon Sep 17 00:00:00 2001
From: Mccree Lee <2935876049@qq.com>
Date: Fri, 12 Apr 2024 23:50:15 +0800
Subject: [PATCH 09/17] feat: Overlay (part)
---
src/PipManager/App.xaml | 4 +-
src/PipManager/App.xaml.cs | 7 +
src/PipManager/PipManager.csproj | 1 +
src/PipManager/Resources/Animations.xaml | 259 ++++++++++++++++++
.../Services/Overlay/IOverlayService.cs | 6 +
.../Services/Overlay/OverlayService.cs | 16 ++
.../ViewModels/Pages/Lab/LabViewModel.cs | 9 +-
.../Pages/Overlay/OverlayViewModel.cs | 18 ++
src/PipManager/Views/Pages/Lab/LabPage.xaml | 2 +-
.../Views/Pages/Overlay/OverlayPage.xaml | 23 ++
.../Views/Pages/Overlay/OverlayPage.xaml.cs | 16 ++
.../Views/Pages/Settings/SettingsPage.xaml | 3 +-
src/PipManager/Views/Windows/MainWindow.xaml | 10 +-
13 files changed, 364 insertions(+), 10 deletions(-)
create mode 100644 src/PipManager/Resources/Animations.xaml
create mode 100644 src/PipManager/Services/Overlay/IOverlayService.cs
create mode 100644 src/PipManager/Services/Overlay/OverlayService.cs
create mode 100644 src/PipManager/ViewModels/Pages/Overlay/OverlayViewModel.cs
create mode 100644 src/PipManager/Views/Pages/Overlay/OverlayPage.xaml
create mode 100644 src/PipManager/Views/Pages/Overlay/OverlayPage.xaml.cs
diff --git a/src/PipManager/App.xaml b/src/PipManager/App.xaml
index 3c7c0a3..ad3dcdf 100644
--- a/src/PipManager/App.xaml
+++ b/src/PipManager/App.xaml
@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:valueConverters="clr-namespace:ValueConverters;assembly=ValueConverters"
+ xmlns:xamlFlair="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
DispatcherUnhandledException="OnDispatcherUnhandledException"
Exit="OnExit"
Startup="OnStartup">
@@ -13,7 +14,8 @@
-
+
+
diff --git a/src/PipManager/App.xaml.cs b/src/PipManager/App.xaml.cs
index 56f99d6..be3d1ac 100644
--- a/src/PipManager/App.xaml.cs
+++ b/src/PipManager/App.xaml.cs
@@ -31,6 +31,9 @@
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Windows.Threading;
+using PipManager.Services.Overlay;
+using PipManager.ViewModels.Pages.Overlay;
+using PipManager.Views.Pages.Overlay;
using Wpf.Ui;
using AboutViewModel = PipManager.ViewModels.Pages.About.AboutViewModel;
using ActionViewModel = PipManager.ViewModels.Pages.Action.ActionViewModel;
@@ -74,6 +77,7 @@ public partial class App
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
@@ -90,6 +94,9 @@ public partial class App
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
diff --git a/src/PipManager/PipManager.csproj b/src/PipManager/PipManager.csproj
index 196f3de..c3c2025 100644
--- a/src/PipManager/PipManager.csproj
+++ b/src/PipManager/PipManager.csproj
@@ -43,6 +43,7 @@
+
diff --git a/src/PipManager/Resources/Animations.xaml b/src/PipManager/Resources/Animations.xaml
new file mode 100644
index 0000000..56a6145
--- /dev/null
+++ b/src/PipManager/Resources/Animations.xaml
@@ -0,0 +1,259 @@
+
+
+ 24
+ 0.75
+ 1.25
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/PipManager/Services/Overlay/IOverlayService.cs b/src/PipManager/Services/Overlay/IOverlayService.cs
new file mode 100644
index 0000000..b0dba65
--- /dev/null
+++ b/src/PipManager/Services/Overlay/IOverlayService.cs
@@ -0,0 +1,6 @@
+namespace PipManager.Services.Overlay;
+
+public interface IOverlayService
+{
+ public void ShowOverlay();
+}
diff --git a/src/PipManager/Services/Overlay/OverlayService.cs b/src/PipManager/Services/Overlay/OverlayService.cs
new file mode 100644
index 0000000..94a9b16
--- /dev/null
+++ b/src/PipManager/Services/Overlay/OverlayService.cs
@@ -0,0 +1,16 @@
+using PipManager.ViewModels.Pages.Overlay;
+
+namespace PipManager.Services.Overlay;
+
+public class OverlayService: IOverlayService
+{
+ private OverlayViewModel _overlayViewModel;
+ public OverlayService(OverlayViewModel overlayViewModel)
+ {
+ _overlayViewModel = overlayViewModel;
+ }
+ public void ShowOverlay()
+ {
+ _overlayViewModel.IsOverlayVisible = true;
+ }
+}
diff --git a/src/PipManager/ViewModels/Pages/Lab/LabViewModel.cs b/src/PipManager/ViewModels/Pages/Lab/LabViewModel.cs
index c791709..58437a1 100644
--- a/src/PipManager/ViewModels/Pages/Lab/LabViewModel.cs
+++ b/src/PipManager/ViewModels/Pages/Lab/LabViewModel.cs
@@ -1,11 +1,12 @@
using PipManager.Models.Action;
using PipManager.Services.Action;
+using PipManager.Services.Overlay;
using Serilog;
using Wpf.Ui.Controls;
namespace PipManager.ViewModels.Pages.Lab;
-public partial class LabViewModel(IActionService actionService)
+public partial class LabViewModel(IActionService actionService, IOverlayService overlayService)
: ObservableObject, INavigationAware
{
private bool _isInitialized;
@@ -21,6 +22,12 @@ private void ActionTest()
));
}
+ [RelayCommand]
+ private void OverlayTest()
+ {
+ overlayService.ShowOverlay();
+ }
+
public void OnNavigatedTo()
{
if (!_isInitialized)
diff --git a/src/PipManager/ViewModels/Pages/Overlay/OverlayViewModel.cs b/src/PipManager/ViewModels/Pages/Overlay/OverlayViewModel.cs
new file mode 100644
index 0000000..34c7667
--- /dev/null
+++ b/src/PipManager/ViewModels/Pages/Overlay/OverlayViewModel.cs
@@ -0,0 +1,18 @@
+using PipManager.Views.Pages.Overlay;
+
+namespace PipManager.ViewModels.Pages.Overlay;
+
+public partial class OverlayViewModel : ObservableObject
+{
+ [ObservableProperty]
+ private int _testValue;
+
+ [ObservableProperty]
+ private bool _isOverlayVisible;
+
+ [RelayCommand]
+ private void CloseOverlay()
+ {
+ IsOverlayVisible = false;
+ }
+}
diff --git a/src/PipManager/Views/Pages/Lab/LabPage.xaml b/src/PipManager/Views/Pages/Lab/LabPage.xaml
index c91aa61..f151b16 100644
--- a/src/PipManager/Views/Pages/Lab/LabPage.xaml
+++ b/src/PipManager/Views/Pages/Lab/LabPage.xaml
@@ -18,6 +18,6 @@
mc:Ignorable="d">
-
+