XFEstudio/MyFirstRespo
为用户在下载前弹出下载知情同意书
d147e96
代码差异
14 个文件
+216
-27
@@ -0,0 +1,8 @@
1
using XFEToolBox.Views.Windows;
2
3
namespace XFEToolBox.Model;
4
5
public interface IPopupPage
6
{
7
public PopupWindow? PopupWindow { get; set; }
8
}
@@ -383,7 +383,7 @@
383
383
<Setter Property="Template">
384
384
<Setter.Value>
385
385
<ControlTemplate TargetType="{x:Type ctr:CheckButton}">
386
<Grid>
386
<Grid x:Name="mainGrid">
387
387
<Grid.ColumnDefinitions>
388
388
<ColumnDefinition Width="25"/>
389
389
<ColumnDefinition Width="*"/>
@@ -398,6 +398,9 @@
398
398
<Trigger Property="IsChecked" Value="True">
399
399
<Setter TargetName="checkImage" Property="Visibility" Value="Visible"/>
400
400
</Trigger>
401
<Trigger Property="IsEnabled" Value="False">
402
<Setter TargetName="mainGrid" Property="Opacity" Value="0.5"/>
403
</Trigger>
401
404
</ControlTemplate.Triggers>
402
405
</ControlTemplate>
403
406
</Setter.Value>
@@ -2,6 +2,7 @@
2
2
using System.Windows.Controls;
3
3
using System.Windows.Controls.Primitives;
4
4
using System.Windows.Media;
5
using XFEToolBox.Model;
5
6
using XFEToolBox.Views.Pages.Popups;
6
7
using XFEToolBox.Views.Windows;
7
8
@@ -71,13 +72,17 @@ public static class PopupHelper
71
72
72
73
public static MessageBoxResult? ShowYesOrNoDialog(string text, bool showCancelButton = false, string yesText = "是", string noText = "否") => ShowYesOrNoDialog(text, Colors.Black, showCancelButton, yesText, noText);
73
74
74
public static MessageBoxResult? ShowDialog(object content)
75
public static MessageBoxResult? ShowDialog(object content, double width = 320, double height = 230)
75
76
{
76
var popupWindow = new PopupWindow();
77
var popupWindow = new PopupWindow
78
{
79
Width = width,
80
Height = height
81
};
77
82
popupWindow.ViewModel.Content = content;
78
if (content is NormalDialogPopupPage normalDialogPopupPage)
79
normalDialogPopupPage.PopupWindow = popupWindow;
83
if (content is IPopupPage popupPage)
84
popupPage.PopupWindow = popupWindow;
80
85
popupWindow.ShowDialog();
81
86
return popupWindow.Result;
82
87
}
83
}
88
}
@@ -1,9 +1,61 @@
1
1
using CommunityToolkit.Mvvm.ComponentModel;
2
using CommunityToolkit.Mvvm.Input;
3
using XFEToolBox.Profiles.CrossVersionProfiles;
4
using XFEToolBox.Resources.Resource;
5
using XFEToolBox.Utilities;
6
using XFEToolBox.Views.Controls;
2
7
using XFEToolBox.Views.Pages;
8
using XFEToolBox.Views.Pages.Popups;
3
9
4
10
namespace XFEToolBox.ViewModel.Pages;
5
11
6
public class DownloadPageViewModel(DownloadPage viewPage) : ObservableObject
12
public partial class DownloadPageViewModel(DownloadPage viewPage) : ObservableObject
7
13
{
8
14
public DownloadPage ViewPage { get; set; } = viewPage;
15
16
[RelayCommand]
17
void GotoDownloadPage(MiniToolButton miniToolButton)
18
{
19
if (!DownloadProfile.DownloadAgreementAccepted)
20
{
21
var result = PopupHelper.ShowDialog(new AgreementDialogPopupPage()
22
{
23
Title = "下载协议同意书",
24
Agreement = """
25
软件免责协议:
26
27
28
1. 免责声明
29
30
本软件(以下简称“本软件”)仅用于提供下载服务。用户使用本软件下载的任何内容,均由用户自行负责。本软件的开发者(以下简称“开发者”)对用户使用本软件下载的内容的合法性、准确性、安全性及任何其他形式的风险不承担任何责任。
31
32
33
2. 不提供担保
34
35
本软件按照“现状”提供,没有任何形式的担保,无论是明示的还是暗示的。开发者不对本软件的功能、运行或可用性做出任何保证。开发者不保证本软件无故障、无病毒或其他有害组件。
36
37
38
3. 责任限制
39
40
在适用法律允许的最大范围内,开发者对因使用或无法使用本软件所引起的任何直接、间接、偶然、特殊、或后果性的损害(包括但不限于数据丢失、业务中断、经济损失等)不承担任何责任,即使开发者已被告知此类损害的可能性。
41
42
43
4. 用户责任
44
45
用户在使用本软件时,应遵守相关法律法规和政策。用户不得利用本软件从事任何非法活动或侵犯第三方权利的行为。因用户不当使用本软件造成的所有后果,均由用户自行承担。
46
47
48
5. 协议的接受
49
50
通过安装、复制或以其他方式使用本软件,用户表示已阅读、理解并同意受本免责协议的条款约束。如果用户不同意本免责协议的条款,请勿安装或使用本软件。
51
"""
52
}, 480, 420);
53
if (result == System.Windows.MessageBoxResult.Yes)
54
DownloadProfile.DownloadAgreementAccepted = true;
55
}
56
if (DownloadProfile.DownloadAgreementAccepted && miniToolButton.Tag is string gotoUrl)
57
{
58
var urlString = DownloadInfoResource.ResourceManager.GetString(gotoUrl);
59
}
60
}
9
61
}
@@ -0,0 +1,48 @@
1
using CommunityToolkit.Mvvm.ComponentModel;
2
using CommunityToolkit.Mvvm.Input;
3
using XFEToolBox.Utilities;
4
using XFEToolBox.Views.Controls;
5
using XFEToolBox.Views.Pages.Popups;
6
7
namespace XFEToolBox.ViewModel.Pages.Popups;
8
9
public partial class AgreementDialogPopupPageViewModel(AgreementDialogPopupPage viewPage) : ObservableObject
10
{
11
[ObservableProperty]
12
string agreementContent = "";
13
[ObservableProperty]
14
bool acceptButtonEnable = false;
15
[ObservableProperty]
16
bool readCheckButtonEnable = false;
17
public AgreementDialogPopupPage ViewPage { get; set; } = viewPage;
18
19
[RelayCommand]
20
void Agree()
21
{
22
if (ViewPage.PopupWindow is not null)
23
{
24
if (AcceptButtonEnable)
25
{
26
ViewPage.PopupWindow.Result = System.Windows.MessageBoxResult.Yes;
27
ViewPage.PopupWindow.Close();
28
}
29
else
30
{
31
PopupHelper.ShowConfirmDialog("请先阅读以上内容并勾选 “我已知晓” 选项!");
32
}
33
}
34
}
35
36
[RelayCommand]
37
void Refuse()
38
{
39
if (ViewPage.PopupWindow is not null)
40
{
41
ViewPage.PopupWindow.Result = System.Windows.MessageBoxResult.No;
42
ViewPage.PopupWindow.Close();
43
}
44
}
45
46
[RelayCommand]
47
void ReadCheck(CheckButton checkButton) => AcceptButtonEnable = checkButton.IsChecked is true;
48
}
@@ -141,7 +141,7 @@ public partial class SettingPageViewModel(SettingPage viewPage) : ObservableObje
141
141
if (!ignoreNextScroll)
142
142
{
143
143
var results = FindType<TabUnderLineButton>(parent);
144
var bestResult = results.FirstOrDefault();
144
var bestResult = results.First();
145
145
double mostNearDistance = double.MinValue;
146
146
foreach (var tabUnderLineButton in results)
147
147
{
@@ -12,7 +12,7 @@
12
12
<RowDefinition Height="Auto"/>
13
13
<RowDefinition Height="25"/>
14
14
</Grid.RowDefinitions>
15
<Button Width="50" Height="50" Command="{Binding Command,ElementName=toolButton}" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave">
15
<Button Width="50" Height="50" Command="{Binding Command,ElementName=toolButton}" CommandParameter="{Binding CommandParameter,ElementName=toolButton}" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave">
16
16
<Button.Style>
17
17
<Style TargetType="Button">
18
18
<Setter Property="Template">
@@ -19,6 +19,13 @@ public partial class MiniToolButton : UserControl
19
19
}
20
20
public static readonly DependencyProperty ToolNameProperty = DependencyProperty.Register("ToolName", typeof(string), typeof(MiniToolButton), new PropertyMetadata("未命名工具"));
21
21
22
public object CommandParameter
23
{
24
get { return (object)GetValue(CommandParameterProperty); }
25
set { SetValue(CommandParameterProperty, value); }
26
}
27
public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(MiniToolButton), new PropertyMetadata(null));
28
22
29
public ImageSource IconSource
23
30
{
24
31
get { return (ImageSource)GetValue(IconSourceProperty); }
@@ -6,8 +6,8 @@
6
6
xmlns:local="clr-namespace:XFEToolBox.Views.Controls"
7
7
mc:Ignorable="d"
8
8
d:DesignHeight="450" d:DesignWidth="800" Name="scrollTextBlock" Loaded="ScrollTextBlock_Loaded">
9
<ScrollViewer x:Name="scrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" MaxWidth="{Binding MaxWidth, ElementName=scrollTextBlock}" MinWidth="{Binding MinWidth, ElementName=scrollTextBlock}" Width="{Binding Width,ElementName=scrollTextBlock}" Height="{Binding Height,ElementName=scrollTextBlock}">
10
<StackPanel x:Name="stackPanel" Orientation="Horizontal">
9
<ScrollViewer x:Name="scrollViewer" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" MaxWidth="{Binding MaxWidth, ElementName=scrollTextBlock}" MinWidth="{Binding MinWidth, ElementName=scrollTextBlock}" Width="{Binding Width,ElementName=scrollTextBlock}" Height="{Binding Height,ElementName=scrollTextBlock}">
10
<StackPanel x:Name="stackPanel" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
11
11
<TextBlock x:Name="textBlock" Foreground="{Binding InnerForeground, ElementName=scrollTextBlock}" Background="{Binding InnerBackground, ElementName=scrollTextBlock}" Text="{Binding InnerText, ElementName=scrollTextBlock}" FontSize="{Binding InnerFontSize, ElementName=scrollTextBlock}" FontFamily="{Binding InnerFontFamily, ElementName=scrollTextBlock}" FontWeight="{Binding InnerFontWeight, ElementName=scrollTextBlock}" TextAlignment="{Binding InnerTextAlignment, ElementName=scrollTextBlock}" TextDecorations="{Binding InnerTextDecorations, ElementName=scrollTextBlock}" VerticalAlignment="{Binding InnerTextVerticalAlignment, ElementName=scrollTextBlock}" HorizontalAlignment="{Binding InnerTextHorizontalAlignment, ElementName=scrollTextBlock}"/>
12
12
</StackPanel>
13
13
</ScrollViewer>
@@ -8,11 +8,12 @@ namespace XFEToolBox.Views.Controls;
8
8
public class SmoothScrollViewer : ScrollViewer
9
9
{
10
10
public long AnimateMilliseconds { get; set; } = 300;
11
public double ScrollDistanceMultiplier { get; set; } = 1;
11
12
private double lastLocation = 0;
12
13
protected override void OnMouseWheel(MouseWheelEventArgs e)
13
14
{
14
15
double wheelChange = e.Delta;
15
double newOffset = lastLocation - wheelChange;
16
double newOffset = lastLocation - wheelChange * ScrollDistanceMultiplier;
16
17
ScrollToVerticalOffset(lastLocation);
17
18
if (newOffset < 0)
18
19
newOffset = 0;
@@ -9,17 +9,17 @@
9
9
mc:Ignorable="d"
10
10
d:DesignHeight="450" d:DesignWidth="800"
11
11
Title="DownloadPage" d:DataContext="{d:DesignInstance Type=viewmodel:DownloadPageViewModel}">
12
12
13
13
<Grid>
14
14
<ScrollViewer HorizontalScrollBarVisibility="Disabled" Padding="5">
15
15
<ScrollViewer.Resources>
16
16
<Style TargetType="ScrollBar" BasedOn="{StaticResource ConsoleScrollBar}"/>
17
17
</ScrollViewer.Resources>
18
18
<WrapPanel>
19
<ctr:MiniToolButton ToolName="Steam" IconSource="/Resources/Image/DownloadImage/steam_logo.png" Tag="Steam"/>
20
<ctr:MiniToolButton ToolName="Steam++(Watt Toolkit)" IconSource="/Resources/Image/DownloadImage/steampp.png" Tag="Steampp"/>
21
<ctr:MiniToolButton ToolName="Visual Studio" IconSource="/Resources/Image/DownloadImage/visual_studio.png" Tag="VisualStudio"/>
22
<ctr:MiniToolButton ToolName="Cheat Engine" IconSource="/Resources/Image/DownloadImage/cheat_engine.png" Tag="CheatEngine"/>
19
<ctr:MiniToolButton ToolName="Steam" IconSource="/Resources/Image/DownloadImage/steam_logo.png" Tag="Steam" Margin="5" Command="{Binding GotoDownloadPageCommand}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}"/>
20
<ctr:MiniToolButton ToolName="Steam++(Watt Toolkit)" IconSource="/Resources/Image/DownloadImage/steampp.png" Tag="Steampp" Margin="5" Command="{Binding GotoDownloadPageCommand}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}"/>
21
<ctr:MiniToolButton ToolName="Visual Studio" IconSource="/Resources/Image/DownloadImage/visual_studio.png" Tag="VisualStudio" Margin="5" Command="{Binding GotoDownloadPageCommand}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}"/>
22
<ctr:MiniToolButton ToolName="Cheat Engine" IconSource="/Resources/Image/DownloadImage/cheat_engine.png" Tag="CheatEngine" Margin="5" Command="{Binding GotoDownloadPageCommand}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}"/>
23
23
</WrapPanel>
24
24
</ScrollViewer>
25
25
</Grid>
@@ -0,0 +1,44 @@
1
<Page x:Class="XFEToolBox.Views.Pages.Popups.AgreementDialogPopupPage"
2
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
xmlns:local="clr-namespace:XFEToolBox.Views.Pages.Popups"
7
xmlns:viewmodel="clr-namespace:XFEToolBox.ViewModel.Pages.Popups"
8
xmlns:ctr="clr-namespace:XFEToolBox.Views.Controls"
9
mc:Ignorable="d"
10
d:DesignHeight="450" d:DesignWidth="800"
11
d:DataContext="{d:DesignInstance Type=viewmodel:AgreementDialogPopupPageViewModel}"
12
Title="协议同意书" Name="agreementDialogPopupPage">
13
14
<Grid>
15
<Grid.ColumnDefinitions>
16
<ColumnDefinition Width="*"/>
17
<ColumnDefinition Width="*"/>
18
</Grid.ColumnDefinitions>
19
<Grid.RowDefinitions>
20
<RowDefinition Height="Auto"/>
21
<RowDefinition Height="*"/>
22
<RowDefinition Height="40"/>
23
<RowDefinition Height="50"/>
24
</Grid.RowDefinitions>
25
<TextBlock Grid.ColumnSpan="2" Text="{Binding Title,ElementName=agreementDialogPopupPage}" Foreground="{DynamicResource MainColor}" FontSize="25" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,5,0,0" TextAlignment="Center"/>
26
<Border Grid.ColumnSpan="2" Grid.Row="1" CornerRadius="5" BorderThickness="0,2,0,2" BorderBrush="{DynamicResource MainColor}" Margin="0,5,0,0" Padding="5,5,0,5">
27
<ctr:SmoothScrollViewer AnimateMilliseconds="800" ScrollDistanceMultiplier="0.5" ScrollChanged="SmoothScrollViewer_ScrollChanged">
28
<ctr:SmoothScrollViewer.Resources>
29
<Style TargetType="ScrollBar" BasedOn="{StaticResource ConsoleScrollBar}"/>
30
</ctr:SmoothScrollViewer.Resources>
31
<TextBlock Text="{Binding AgreementContent}" TextWrapping="Wrap"/>
32
</ctr:SmoothScrollViewer>
33
</Border>
34
<ctr:CheckButton Grid.ColumnSpan="2" Grid.Row="2" Command="{Binding ReadCheckCommand}" CommandParameter="{Binding RelativeSource={x:Static RelativeSource.Self}}" IsEnabled="{Binding ReadCheckButtonEnable}" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,5,0,0">
35
<TextBlock Text="我已阅读并知晓以上内容" VerticalAlignment="Center" Margin="5,0,0,0"/>
36
</ctr:CheckButton>
37
<ctr:RoundButton Grid.Row="3" VerticalAlignment="Center" HorizontalAlignment="Center" Command="{Binding AgreeCommand}">
38
<TextBlock Text="我同意" Foreground="#9898e7" Margin="16,8" IsEnabled="{Binding AcceptButtonEnable}"/>
39
</ctr:RoundButton>
40
<ctr:RoundButton Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center" Command="{Binding RefuseCommand}">
41
<TextBlock Text="我拒绝" Foreground="#9898e7" Margin="16,8"/>
42
</ctr:RoundButton>
43
</Grid>
44
</Page>
@@ -0,0 +1,27 @@
1
using System.Windows.Controls;
2
using XFEToolBox.Model;
3
using XFEToolBox.ViewModel.Pages.Popups;
4
using XFEToolBox.Views.Windows;
5
6
namespace XFEToolBox.Views.Pages.Popups;
7
8
/// <summary>
9
/// AgreementDialogPopupPage.xaml 的交互逻辑
10
/// </summary>
11
public partial class AgreementDialogPopupPage : Page, IPopupPage
12
{
13
public AgreementDialogPopupPageViewModel ViewModel { get; set; }
14
public PopupWindow? PopupWindow { get; set; }
15
public string Agreement { get => ViewModel.AgreementContent; set => ViewModel.AgreementContent = value; }
16
public AgreementDialogPopupPage()
17
{
18
DataContext = ViewModel = new(this);
19
InitializeComponent();
20
}
21
22
private void SmoothScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
23
{
24
if (e.VerticalOffset + e.ViewportHeight == e.ExtentHeight)
25
ViewModel.ReadCheckButtonEnable = true;
26
}
27
}
@@ -1,5 +1,5 @@
1
using System.Windows;
2
using System.Windows.Controls;
1
using System.Windows.Controls;
2
using XFEToolBox.Model;
3
3
using XFEToolBox.ViewModel.Pages.Popups;
4
4
using XFEToolBox.Views.Windows;
5
5
@@ -8,16 +8,10 @@ namespace XFEToolBox.Views.Pages.Popups;
8
8
/// <summary>
9
9
/// NormalDialogPopupPage.xaml 的交互逻辑
10
10
/// </summary>
11
public partial class NormalDialogPopupPage : Page
11
public partial class NormalDialogPopupPage : Page, IPopupPage
12
12
{
13
13
public NormalDialogPopupPageViewModel ViewModel { get; set; }
14
private PopupWindow? popupWindow;
15
16
public PopupWindow? PopupWindow
17
{
18
get { return popupWindow; }
19
set { popupWindow = value; }
20
}
14
public PopupWindow? PopupWindow { get; set; }
21
15
22
16
public NormalDialogPopupPage()
23
17
{