Skip to content

Commit 96cda36

Browse files
committed
完成LayUI,WPF升级UI示例代码
1 parent bb626c6 commit 96cda36

File tree

22 files changed

+1520
-0
lines changed

22 files changed

+1520
-0
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
{
2+
"Version": 1,
3+
"WorkspaceRootPath": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\",
4+
"Documents": [
5+
{
6+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\views\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
7+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\views\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
8+
},
9+
{
10+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\views\\alert.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
11+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\views\\alert.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
12+
},
13+
{
14+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\services\\mockdownloadservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
15+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\services\\mockdownloadservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
16+
},
17+
{
18+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\services\\idownloadservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
19+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\services\\idownloadservice.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
20+
},
21+
{
22+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\viewmodels\\alertviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
23+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\viewmodels\\alertviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
24+
},
25+
{
26+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\models\\downloadstatistics.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
27+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\models\\downloadstatistics.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
28+
},
29+
{
30+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\viewmodels\\mainwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
31+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\viewmodels\\mainwindowviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
32+
},
33+
{
34+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\app.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
35+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\app.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
36+
},
37+
{
38+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\views\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
39+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\views\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
40+
},
41+
{
42+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
43+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
44+
},
45+
{
46+
"AbsoluteMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|d:\\github\\generalupdate-samples\\ui\\layui\\upgrade\\upgrade.wpf\\mvvm\\bindablebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
47+
"RelativeMoniker": "D:0:0:{5B6EF66D-66B2-4563-BF80-58E8BCC98D8B}|Upgrade.WPF\\Upgrade.WPF.csproj|solutionrelative:upgrade.wpf\\mvvm\\bindablebase.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
48+
},
49+
{
50+
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|C:\\Users\\ywk13\\AppData\\Local\\Temp\\.vsdbgsrc\\b49ace08f4cd26a4f275d628999a0f91ccb8a1892704530d9e6f5bd1284082f1\\ResourcePart.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
51+
}
52+
],
53+
"DocumentGroupContainers": [
54+
{
55+
"Orientation": 0,
56+
"VerticalTabListWidth": 256,
57+
"DocumentGroups": [
58+
{
59+
"DockedWidth": 200,
60+
"SelectedChildIndex": 7,
61+
"Children": [
62+
{
63+
"$type": "Document",
64+
"DocumentIndex": 2,
65+
"Title": "MockDownloadService.cs",
66+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Services\\MockDownloadService.cs",
67+
"RelativeDocumentMoniker": "Upgrade.WPF\\Services\\MockDownloadService.cs",
68+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Services\\MockDownloadService.cs",
69+
"RelativeToolTip": "Upgrade.WPF\\Services\\MockDownloadService.cs",
70+
"ViewState": "AQIAADwAAAAAAAAAAAAAABMAAAAvAAAA",
71+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
72+
"WhenOpened": "2024-12-17T17:20:42.268Z",
73+
"EditorCaption": ""
74+
},
75+
{
76+
"$type": "Document",
77+
"DocumentIndex": 8,
78+
"Title": "MainWindow.xaml.cs",
79+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\MainWindow.xaml.cs",
80+
"RelativeDocumentMoniker": "Upgrade.WPF\\Views\\MainWindow.xaml.cs",
81+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\MainWindow.xaml.cs",
82+
"RelativeToolTip": "Upgrade.WPF\\Views\\MainWindow.xaml.cs",
83+
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
84+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
85+
"WhenOpened": "2024-12-17T16:58:11.118Z",
86+
"EditorCaption": ""
87+
},
88+
{
89+
"$type": "Document",
90+
"DocumentIndex": 6,
91+
"Title": "MainWindowViewModel.cs",
92+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\ViewModels\\MainWindowViewModel.cs",
93+
"RelativeDocumentMoniker": "Upgrade.WPF\\ViewModels\\MainWindowViewModel.cs",
94+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\ViewModels\\MainWindowViewModel.cs",
95+
"RelativeToolTip": "Upgrade.WPF\\ViewModels\\MainWindowViewModel.cs",
96+
"ViewState": "AQIAAAwAAAAAAAAAAAAAABEAAAAiAAAA",
97+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
98+
"WhenOpened": "2024-12-17T16:57:59.199Z",
99+
"EditorCaption": ""
100+
},
101+
{
102+
"$type": "Document",
103+
"DocumentIndex": 4,
104+
"Title": "AlertViewModel.cs",
105+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\ViewModels\\AlertViewModel.cs",
106+
"RelativeDocumentMoniker": "Upgrade.WPF\\ViewModels\\AlertViewModel.cs",
107+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\ViewModels\\AlertViewModel.cs",
108+
"RelativeToolTip": "Upgrade.WPF\\ViewModels\\AlertViewModel.cs",
109+
"ViewState": "AQIAAAAAAAAAAAAAAAAAABIAAAArAAAA",
110+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
111+
"WhenOpened": "2024-12-17T16:54:24.708Z",
112+
"EditorCaption": ""
113+
},
114+
{
115+
"$type": "Document",
116+
"DocumentIndex": 1,
117+
"Title": "Alert.xaml",
118+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\Alert.xaml",
119+
"RelativeDocumentMoniker": "Upgrade.WPF\\Views\\Alert.xaml",
120+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\Alert.xaml",
121+
"RelativeToolTip": "Upgrade.WPF\\Views\\Alert.xaml",
122+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
123+
"WhenOpened": "2024-12-17T16:54:08.592Z",
124+
"EditorCaption": ""
125+
},
126+
{
127+
"$type": "Document",
128+
"DocumentIndex": 5,
129+
"Title": "DownloadStatistics.cs",
130+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Models\\DownloadStatistics.cs",
131+
"RelativeDocumentMoniker": "Upgrade.WPF\\Models\\DownloadStatistics.cs",
132+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Models\\DownloadStatistics.cs",
133+
"RelativeToolTip": "Upgrade.WPF\\Models\\DownloadStatistics.cs",
134+
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAgAAAABAAAA",
135+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
136+
"WhenOpened": "2024-12-16T16:24:44.72Z",
137+
"EditorCaption": ""
138+
},
139+
{
140+
"$type": "Document",
141+
"DocumentIndex": 10,
142+
"Title": "BindableBase.cs",
143+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Mvvm\\BindableBase.cs",
144+
"RelativeDocumentMoniker": "Upgrade.WPF\\Mvvm\\BindableBase.cs",
145+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Mvvm\\BindableBase.cs",
146+
"RelativeToolTip": "Upgrade.WPF\\Mvvm\\BindableBase.cs",
147+
"ViewState": "AQIAAAYAAAAAAAAAAAAAAA4AAAAfAAAA",
148+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
149+
"WhenOpened": "2024-12-16T16:03:04.339Z"
150+
},
151+
{
152+
"$type": "Document",
153+
"DocumentIndex": 0,
154+
"Title": "MainWindow.xaml",
155+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\MainWindow.xaml",
156+
"RelativeDocumentMoniker": "Upgrade.WPF\\Views\\MainWindow.xaml",
157+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Views\\MainWindow.xaml",
158+
"RelativeToolTip": "Upgrade.WPF\\Views\\MainWindow.xaml",
159+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
160+
"WhenOpened": "2024-12-16T15:37:21.759Z",
161+
"EditorCaption": ""
162+
},
163+
{
164+
"$type": "Document",
165+
"DocumentIndex": 9,
166+
"Title": "App.xaml",
167+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\App.xaml",
168+
"RelativeDocumentMoniker": "Upgrade.WPF\\App.xaml",
169+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\App.xaml",
170+
"RelativeToolTip": "Upgrade.WPF\\App.xaml",
171+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
172+
"WhenOpened": "2024-12-16T15:33:11.953Z",
173+
"EditorCaption": ""
174+
},
175+
{
176+
"$type": "Document",
177+
"DocumentIndex": 7,
178+
"Title": "App.xaml.cs",
179+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\App.xaml.cs",
180+
"RelativeDocumentMoniker": "Upgrade.WPF\\App.xaml.cs",
181+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\App.xaml.cs",
182+
"RelativeToolTip": "Upgrade.WPF\\App.xaml.cs",
183+
"ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAJAAAA",
184+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
185+
"WhenOpened": "2024-12-16T16:06:39.289Z",
186+
"EditorCaption": ""
187+
},
188+
{
189+
"$type": "Document",
190+
"DocumentIndex": 11,
191+
"Title": "ResourcePart.cs",
192+
"DocumentMoniker": "C:\\Users\\ywk13\\AppData\\Local\\Temp\\.vsdbgsrc\\b49ace08f4cd26a4f275d628999a0f91ccb8a1892704530d9e6f5bd1284082f1\\ResourcePart.cs",
193+
"ToolTip": "C:\\Users\\ywk13\\AppData\\Local\\Temp\\.vsdbgsrc\\b49ace08f4cd26a4f275d628999a0f91ccb8a1892704530d9e6f5bd1284082f1\\ResourcePart.cs [\u53EA\u8BFB]",
194+
"ViewState": "AQIAABcAAAAAAAAAAIAzwCcAAAAEAAAA",
195+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
196+
"WhenOpened": "2024-12-16T15:38:08.868Z",
197+
"EditorCaption": " [\u53EA\u8BFB]"
198+
},
199+
{
200+
"$type": "Document",
201+
"DocumentIndex": 3,
202+
"Title": "IDownloadService.cs",
203+
"DocumentMoniker": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Services\\IDownloadService.cs",
204+
"RelativeDocumentMoniker": "Upgrade.WPF\\Services\\IDownloadService.cs",
205+
"ToolTip": "D:\\Github\\GeneralUpdate-Samples\\UI\\LayUI\\Upgrade\\Upgrade.WPF\\Services\\IDownloadService.cs",
206+
"RelativeToolTip": "Upgrade.WPF\\Services\\IDownloadService.cs",
207+
"ViewState": "AQIAAAEAAAAAAAAAAIAzwAwAAAASAAAA",
208+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
209+
"WhenOpened": "2024-12-16T16:29:16.842Z",
210+
"EditorCaption": ""
211+
}
212+
]
213+
}
214+
]
215+
}
216+
]
217+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Application
2+
x:Class="Upgrade.WPF.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="clr-namespace:Upgrade.WPF"
6+
StartupUri="Views/MainWindow.xaml">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<ResourceDictionary Source="pack://application:,,,/LayUI.Wpf;component/Themes/Default.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using LayUI.Wpf.Global;
2+
using Microsoft.Win32;
3+
using System.Configuration;
4+
using System.Data;
5+
using System.Windows;
6+
using Upgrade.WPF.ViewModels;
7+
using Upgrade.WPF.Views;
8+
9+
namespace Upgrade.WPF
10+
{
11+
/// <summary>
12+
/// Interaction logic for App.xaml
13+
/// </summary>
14+
public partial class App : Application
15+
{
16+
protected override void OnStartup(StartupEventArgs e)
17+
{
18+
RegisterDialogs();
19+
base.OnStartup(e);
20+
}
21+
22+
private void RegisterDialogs()
23+
{
24+
LayDialog.RegisterDialog<Alert>(nameof(Alert));
25+
}
26+
}
27+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Windows;
2+
3+
[assembly: ThemeInfo(
4+
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5+
//(used if a resource is not found in the page,
6+
// or application resource dictionaries)
7+
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8+
//(used if a resource is not found in the page,
9+
// app, or any theme specific resource dictionaries)
10+
)]
16.3 KB
Loading
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Upgrade.WPF.Models
9+
{
10+
/// <summary>
11+
/// 代码参考 SemiUrsa
12+
/// </summary>
13+
public class DownloadStatistics: BindableBase
14+
{
15+
private object? _Version;
16+
[Description("当前下载版本")]
17+
public object? Version
18+
{
19+
get { return _Version; }
20+
set { SetProperty(ref _Version, value); }
21+
}
22+
private double _Speed;
23+
[Description("下载速度")]
24+
public double Speed
25+
{
26+
get { return _Speed; }
27+
set { SetProperty(ref _Speed, value); }
28+
}
29+
private TimeSpan _Remaining;
30+
[Description("剩余下载时间")]
31+
public TimeSpan Remaining
32+
{
33+
get { return _Remaining; }
34+
set { SetProperty(ref _Remaining, value); }
35+
}
36+
private long _TotalBytesToReceive;
37+
[Description("总大小")]
38+
public long TotalBytesToReceive
39+
{
40+
get { return _TotalBytesToReceive; }
41+
set
42+
{
43+
SetProperty(ref _TotalBytesToReceive, value);
44+
RaisePropertyChanged(nameof(TotalBytesToReceiveInMB));
45+
}
46+
}
47+
private long _BytesReceived;
48+
[Description("已下载大小")]
49+
public long BytesReceived
50+
{
51+
get { return _BytesReceived; }
52+
set
53+
{
54+
SetProperty(ref _BytesReceived, value);
55+
RaisePropertyChanged(nameof(BytesReceivedInMB));
56+
}
57+
}
58+
private double _ProgressPercentage;
59+
[Description("进度百分比")]
60+
public double ProgressPercentage
61+
{
62+
get { return _ProgressPercentage; }
63+
set { SetProperty(ref _ProgressPercentage, value); }
64+
}
65+
public double BytesReceivedInMB => (double)BytesReceived / 1024 / 1024;
66+
public double TotalBytesToReceiveInMB => (double)TotalBytesToReceive / 1024 / 1024;
67+
}
68+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Linq;
5+
using System.Runtime.CompilerServices;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Upgrade.WPF
10+
{
11+
public abstract class BindableBase : INotifyPropertyChanged
12+
{
13+
public event PropertyChangedEventHandler PropertyChanged;
14+
15+
protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged = null, [CallerMemberName] string propertyName = null)
16+
{
17+
// 检查新值是否与当前值相等
18+
if (EqualityComparer<T>.Default.Equals(storage, value))
19+
{
20+
return false; // 如果相等,返回 false
21+
}
22+
23+
storage = value; // 更新存储的值
24+
onChanged?.Invoke(); // 调用可选的 onChanged 回调
25+
OnPropertyChanged(propertyName); // 触发属性变化通知
26+
return true; // 返回 true 表示值已更改
27+
}
28+
29+
public void OnPropertyChanged([CallerMemberName] string propertyName = null) =>
30+
OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); // 触发属性变化事件
31+
public void RaisePropertyChanged([CallerMemberName] string propertyName = null) =>
32+
OnPropertyChanged(propertyName);
33+
protected void OnPropertyChanged(PropertyChangedEventArgs args) =>
34+
PropertyChanged?.Invoke(this, args); // 通知所有订阅者
35+
}
36+
}

0 commit comments

Comments
 (0)