返回提交历史

XFEstudio/MyFirstRespo

为下载详情页面添加部分内容

bcd4361
X
XFEstudio <mail@xfegzs.com>
提交于

代码差异

3 个文件 +91 -25
Modified XFEToolBox/ViewModel/Pages/DownloadInfoPageViewModel.cs +8 -0
@@ -1,4 +1,5 @@
1 1 using CommunityToolkit.Mvvm.ComponentModel;
2 using CommunityToolkit.Mvvm.Input;
2 3 using XFEToolBox.Views.Pages;
3 4
4 5 namespace XFEToolBox.ViewModel.Pages;
@@ -7,6 +8,13 @@ public partial class DownloadInfoPageViewModel(DownloadInfoPage viewPage) : Obse
7 8 {
8 9 [ObservableProperty]
9 10 string appTitle = "";
11 [ObservableProperty]
12 string downloadButtonName = "下载";
10 13 public DownloadInfoPage ViewPage { get; set; } = viewPage;
11 14
15 [RelayCommand]
16 void DownloadClick()
17 {
18
19 }
12 20 }
Modified XFEToolBox/Views/Pages/DownloadInfoPage.xaml +20 -3
@@ -32,16 +32,33 @@
32 32 <Image Source="/Resources/Image/DownloadImage/steam_logo.png"/>
33 33 <TextBlock Grid.Column="1" Text="{Binding AppTitle,StringFormat='软件名称:{0}'}" Foreground="White" FontSize="20" FontWeight="Bold" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="10,0,0,0"/>
34 34 </Grid>
35 <Grid Grid.Row="1" Height="100" VerticalAlignment="Bottom">
35 <Grid x:Name="bottomGrid" Grid.Row="1" Height="300" VerticalAlignment="Bottom">
36 36 <Grid.ColumnDefinitions>
37 37 <ColumnDefinition Width="*"/>
38 38 <ColumnDefinition Width="3*"/>
39 39 <ColumnDefinition Width="*"/>
40 40 </Grid.ColumnDefinitions>
41 41 <Border Grid.ColumnSpan="3" CornerRadius="15,15,0,0" Background="White" Opacity="0.8"/>
42 <ctr:RoundButton Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch">
43 <TextBlock Text="下载" Foreground="{DynamicResource MainColor}" FontSize="25" Margin="0,10" VerticalAlignment="Center" HorizontalAlignment="Center"/>
42 <ctr:RoundButton Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Stretch" Command="{Binding DownloadClickCommand}">
43 <TextBlock Text="{Binding DownloadButtonName}" Foreground="{DynamicResource MainColor}" FontSize="25" Margin="0,10" VerticalAlignment="Center" HorizontalAlignment="Center"/>
44 44 </ctr:RoundButton>
45 <Canvas Grid.ColumnSpan="3" Width="200" Height="200" HorizontalAlignment="Center" VerticalAlignment="Center">
46 <!-- Path 用于绘制圆环 -->
47 <Path Stroke="Blue" StrokeThickness="10">
48 <Path.Data>
49 <PathGeometry>
50 <PathFigure StartPoint="100,50">
51 <!-- ArcSegment 动态绘制圆弧 -->
52 <ArcSegment x:Name="arcSegment"
53 Size="100,100"
54 SweepDirection="Clockwise"
55 IsLargeArc="False"
56 Point="200,100" />
57 </PathFigure>
58 </PathGeometry>
59 </Path.Data>
60 </Path>
61 </Canvas>
45 62 </Grid>
46 63 </Grid>
47 64 </Grid>
Modified XFEToolBox/Views/Pages/DownloadInfoPage.xaml.cs +63 -22
@@ -1,28 +1,69 @@
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading.Tasks;
6 using System.Windows;
1 using System.Windows;
7 2 using System.Windows.Controls;
8 using System.Windows.Data;
9 using System.Windows.Documents;
10 using System.Windows.Input;
11 using System.Windows.Media;
12 using System.Windows.Media.Imaging;
13 using System.Windows.Navigation;
14 using System.Windows.Shapes;
15
16 namespace XFEToolBox.Views.Pages
3 using System.Windows.Media.Animation;
4 using XFEToolBox.ViewModel.Pages;
5
6 namespace XFEToolBox.Views.Pages;
7
8 /// <summary>
9 /// DownloadInfoPage.xaml 的交互逻辑
10 /// </summary>
11 public partial class DownloadInfoPage : Page
17 12 {
18 /// <summary>
19 /// DownloadInfoPage.xaml 的交互逻辑
20 /// </summary>
21 public partial class DownloadInfoPage : Page
13 public DownloadInfoPageViewModel ViewModel { get; set; }
14
15 private bool downloadMode;
16
17 public bool DownloadMode
18 {
19 get { return downloadMode; }
20 set { downloadMode = value; ViewModel.DownloadButtonName = value ? "下载" : "浏览器中打开"; }
21 }
22
23 public DownloadInfoPage()
24 {
25 DataContext = ViewModel = new(this);
26 InitializeComponent();
27 UpdateArc(180);
28 }
29
30 public void UpdateArc(double angle)
31 {
32 double radius = 100; // 圆的半径
33 double radians = Math.PI * angle / 180.0;
34
35 // 计算圆弧的终点坐标
36 double x = 100 + radius * Math.Cos(radians);
37 double y = 100 - radius * Math.Sin(radians);
38
39 // 更新 ArcSegment 的终点
40 arcSegment.Point = new Point(x, y);
41
42 // 根据角度判断是否需要大圆弧
43 arcSegment.IsLargeArc = angle > 180.0;
44 }
45
46 public void UpperTheGrid()
47 {
48 bottomGrid.BeginAnimation(HeightProperty, null);
49 var doubleAnimation = new DoubleAnimation
50 {
51 To = 400,
52 Duration = TimeSpan.FromMilliseconds(500),
53 EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
54 };
55 bottomGrid.BeginAnimation(HeightProperty, doubleAnimation);
56 }
57
58 public void LowerTheGrid()
22 59 {
23 public DownloadInfoPage()
60 bottomGrid.BeginAnimation(HeightProperty, null);
61 var doubleAnimation = new DoubleAnimation
24 62 {
25 InitializeComponent();
26 }
63 To = 100,
64 Duration = TimeSpan.FromMilliseconds(500),
65 EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
66 };
67 bottomGrid.BeginAnimation(HeightProperty, doubleAnimation);
27 68 }
28 69 }