Skip to content

Commit 3cfede7

Browse files
committed
ライセンスページ追加
1 parent e071178 commit 3cfede7

File tree

12 files changed

+211
-7
lines changed

12 files changed

+211
-7
lines changed

RemoteLogViewer/RemoteLogViewer.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
<Content Remove="Assets\icon256x256.ico" />
3030
</ItemGroup>
3131

32+
<ItemGroup>
33+
<None Remove="Views\Info\LicensePage.xaml" />
34+
</ItemGroup>
35+
3236
<ItemGroup>
3337
<Content Include="Assets\SplashScreen.scale-200.png" />
3438
<Content Include="Assets\LockScreenLogo.scale-200.png" />
@@ -77,6 +81,12 @@
7781
<Resource Include="Assets\icon256x256.ico" />
7882
</ItemGroup>
7983

84+
<ItemGroup>
85+
<Page Update="Views\Info\LicensePage.xaml">
86+
<Generator>MSBuild:Compile</Generator>
87+
</Page>
88+
</ItemGroup>
89+
8090
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
8191
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
8292
</PropertyGroup>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace RemoteLogViewer.ViewModels.Info;
4+
5+
public interface IInfoPageViewModel {
6+
public string PageName {
7+
get;
8+
}
9+
}
10+
11+
public abstract class InfoPageViewModel<T> : ViewModelBase<T>, IInfoPageViewModel where T : InfoPageViewModel<T> {
12+
public string PageName {
13+
get;
14+
}
15+
16+
protected InfoPageViewModel(string pageName, ILogger<T> logger) : base(logger) {
17+
this.PageName = pageName;
18+
}
19+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections.Generic;
2+
3+
using Microsoft.Extensions.Logging;
4+
5+
namespace RemoteLogViewer.ViewModels.Info;
6+
7+
[AddSingleton]
8+
public class InfoWindowViewModel : ViewModelBase<InfoWindowViewModel> {
9+
public ObservableList<string> Categories {
10+
get;
11+
} = [];
12+
13+
public BindableReactiveProperty<IInfoPageViewModel> SelectedSettingsPage {
14+
get;
15+
} = new();
16+
17+
public List<IInfoPageViewModel> Pages {
18+
get;
19+
} = [];
20+
21+
public LicensePageViewModel LicensePageViewModel {
22+
get;
23+
}
24+
25+
public ReactiveCommand SaveCommand {
26+
get;
27+
} = new();
28+
29+
public InfoWindowViewModel(LicensePageViewModel licensePageViewModel, ILogger<InfoWindowViewModel> logger) : base(logger) {
30+
this.LicensePageViewModel = licensePageViewModel;
31+
32+
this.Pages.AddRange([this.LicensePageViewModel]);
33+
this.SelectedSettingsPage.Value = this.Pages[0];
34+
}
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.Logging;
2+
using System.Collections.Generic;
3+
4+
namespace RemoteLogViewer.ViewModels.Info;
5+
6+
[AddSingleton]
7+
public class LicensePageViewModel : InfoPageViewModel<LicensePageViewModel> {
8+
public LicensePageViewModel(ILogger<LicensePageViewModel> logger) : base("Licenses", logger) {
9+
}
10+
11+
public List<LicenseInfo> Licenses { get; } = [
12+
new("CommunityToolkit.Mvvm", "MIT", "https://github.com/CommunityToolkit/dotnet/blob/main/License.md"),
13+
new("CommunityToolkit.WinUI", "MIT", "https://github.com/CommunityToolkit/Windows/blob/main/License.md"),
14+
new("Microsoft.Extensions.DependencyInjection", "MIT", "https://github.com/dotnet/dotnet/blob/main/LICENSE.TXT"),
15+
new("Microsoft.WindowsAppSDK", "MIT", "https://github.com/microsoft/WindowsAppSDK/blob/main/LICENSE"),
16+
new("ObservableCollections", "MIT", "https://github.com/Cysharp/ObservableCollections/blob/master/LICENSE"),
17+
new("R3", "MIT", "https://github.com/Cysharp/R3/blob/main/LICENSE"),
18+
new("Serilog", "Apache-2.0", "https://github.com/serilog/serilog/blob/dev/LICENSE"),
19+
new("SSH.NET", "MIT", "https://github.com/sshnet/SSH.NET/blob/develop/LICENSE"),
20+
new("System.Linq.Async", "MIT", "https://github.com/dotnet/reactive/blob/main/LICENSE")
21+
];
22+
}
23+
24+
public record LicenseInfo(string Name, string License, string Url);

RemoteLogViewer/ViewModels/Settings/SettingsPageViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace RemoteLogViewer.ViewModels.Settings;
44

55
public interface ISettingsPageViewModel {
6-
string PageName { get; }
6+
public string PageName { get; }
77
}
88

99
public abstract class SettingsPageViewModel<T> : ViewModelBase<T>, ISettingsPageViewModel where T : SettingsPageViewModel<T> {

RemoteLogViewer/ViewModels/Settings/SettingsWindowViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@ public SettingsWindowViewModel(SettingsStoreModel model, WorkspaceSettingsPageVi
4848
this.SaveCommand.Subscribe(_ => {
4949
model.Save();
5050
});
51-
this.TextViewerSettings = textViewerSettings;
5251
}
5352
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Window
2+
x:Class="RemoteLogViewer.Views.Info.InfoWindow"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
8+
xmlns:info="using:RemoteLogViewer.ViewModels.Info"
9+
mc:Ignorable="d"
10+
Title="Informations">
11+
<Grid ColumnDefinitions="220,*" RowDefinitions="*,Auto" ColumnSpacing="8">
12+
<StackPanel Grid.Column="0" Padding="12" Spacing="8" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}">
13+
<ListView x:Name="CategoryList" ItemsSource="{x:Bind ViewModel.Pages}" SelectedItem="{x:Bind ViewModel.SelectedSettingsPage.Value, Mode=TwoWay}">
14+
<ListView.ItemTemplate>
15+
<DataTemplate x:DataType="info:IInfoPageViewModel">
16+
<TextBlock Text="{Binding PageName}"/>
17+
</DataTemplate>
18+
</ListView.ItemTemplate>
19+
</ListView>
20+
</StackPanel>
21+
<Frame x:Name="ContentFrame" Grid.Column="1"/>
22+
</Grid>
23+
</Window>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Microsoft.UI.Xaml;
2+
3+
using RemoteLogViewer.ViewModels.Info;
4+
5+
namespace RemoteLogViewer.Views.Info;
6+
7+
[AddTransient]
8+
public sealed partial class InfoWindow : Window {
9+
public InfoWindowViewModel ViewModel {
10+
get;
11+
}
12+
13+
public InfoWindow(InfoWindowViewModel vm) {
14+
this.ViewModel = vm;
15+
this.InitializeComponent();
16+
this.AppWindow?.Resize(new Windows.Graphics.SizeInt32(1200, 800));
17+
this.ViewModel.SelectedSettingsPage.Subscribe(vm => {
18+
if (vm is null) {
19+
return;
20+
}
21+
Type view;
22+
switch (vm) {
23+
case LicensePageViewModel _:
24+
view = typeof(LicensePage);
25+
break;
26+
default:
27+
return;
28+
}
29+
30+
this.ContentFrame.Navigate(view, vm);
31+
});
32+
}
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Page
2+
x:Class="RemoteLogViewer.Views.Info.LicensePage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:RemoteLogViewer.Views.Info"
6+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8+
xmlns:vm="using:RemoteLogViewer.ViewModels.Info"
9+
mc:Ignorable="d">
10+
11+
<Grid>
12+
<ScrollViewer VerticalScrollBarVisibility="Auto">
13+
<ListView ItemsSource="{x:Bind ViewModel.Licenses}" SelectionMode="None">
14+
<ListView.ItemTemplate>
15+
<DataTemplate x:DataType="vm:LicenseInfo">
16+
<Border BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}" BorderThickness="1" CornerRadius="4" Margin="0,0,0,8" Padding="12">
17+
<StackPanel Spacing="4">
18+
<TextBlock>
19+
<Run Text="{x:Bind Name}" FontWeight="SemiBold"/>
20+
<Run Text="{x:Bind License}" FontFamily="Consolas" Foreground="DarkGray"/>
21+
</TextBlock>
22+
<HyperlinkButton Content="{x:Bind Url}" NavigateUri="{x:Bind Url}"/>
23+
</StackPanel>
24+
</Border>
25+
</DataTemplate>
26+
</ListView.ItemTemplate>
27+
</ListView>
28+
</ScrollViewer>
29+
</Grid>
30+
</Page>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.UI.Xaml.Controls;
2+
using Microsoft.UI.Xaml.Navigation;
3+
using RemoteLogViewer.ViewModels.Info;
4+
5+
namespace RemoteLogViewer.Views.Info {
6+
public sealed partial class LicensePage : Page {
7+
public LicensePageViewModel? ViewModel {
8+
get;
9+
set;
10+
}
11+
12+
public LicensePage() {
13+
this.InitializeComponent();
14+
this.DataContext = this;
15+
}
16+
17+
protected override void OnNavigatedTo(NavigationEventArgs e) {
18+
if (e.Parameter is LicensePageViewModel vm) {
19+
this.ViewModel = vm;
20+
}
21+
base.OnNavigatedTo(e);
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)