|
1 | | -using CommunityToolkit.Mvvm.Input; |
| 1 | +using CommunityToolkit.Mvvm.Input; |
2 | 2 | using GeneralUpdate.AspNetCore.DTO; |
3 | 3 | using GeneralUpdate.Core.Utils; |
4 | 4 | using GeneralUpdate.Differential; |
|
10 | 10 | using System.IO; |
11 | 11 | using System.Text; |
12 | 12 | using System.Windows; |
| 13 | +using Microsoft.WindowsAPICodePack.Dialogs; |
13 | 14 |
|
14 | 15 | namespace GeneralUpdate.Packet.ViewModels |
15 | 16 | { |
@@ -49,7 +50,7 @@ internal PacketViewModel() |
49 | 50 | public bool IsPublish { get => isPublish; set => SetProperty(ref isPublish, value); } |
50 | 51 | public string Url { get => url; set => SetProperty(ref url, value); } |
51 | 52 | public string PacketName { get => packetName; set => SetProperty(ref packetName, value); } |
52 | | - public string DriverDir { get => packetName; set => SetProperty(ref driverDir, value); } |
| 53 | + public string DriverDir { get => driverDir; set => SetProperty(ref driverDir, value); } |
53 | 54 |
|
54 | 55 | public AsyncRelayCommand<string> SelectFolderCommand |
55 | 56 | { |
@@ -146,33 +147,35 @@ public string CurrentAppType |
146 | 147 | /// <param name="value"></param> |
147 | 148 | private async Task SelectFolderAction(string value) |
148 | 149 | { |
149 | | - var openFileDialog = new OpenFileDialog(); |
150 | | - openFileDialog.InitialDirectory = @"D:\"; |
151 | | - openFileDialog.Filter = "All files (*.*)|*.*"; |
152 | | - if (openFileDialog.ShowDialog() == false) |
| 150 | + using (var dialog = new CommonOpenFileDialog()) |
153 | 151 | { |
154 | | - await ShowMessage("Pick options", "No results were selected !"); |
155 | | - return; |
156 | | - } |
157 | | - |
158 | | - string selectedFilePath = openFileDialog.FileName; |
159 | | - switch (value) |
160 | | - { |
161 | | - case "Source": |
162 | | - SourcePath = selectedFilePath; |
163 | | - break; |
| 152 | + dialog.InitialDirectory = @"D:\"; |
| 153 | + dialog.IsFolderPicker = true; |
| 154 | + CommonFileDialogResult result = dialog.ShowDialog(); |
| 155 | + if (result != CommonFileDialogResult.Ok) |
| 156 | + { |
| 157 | + await ShowMessage("Pick options", "No results were selected !"); |
| 158 | + return; |
| 159 | + } |
| 160 | + string selectedFilePath = dialog.FileName; |
| 161 | + switch (value) |
| 162 | + { |
| 163 | + case "Source": |
| 164 | + SourcePath = selectedFilePath; |
| 165 | + break; |
164 | 166 |
|
165 | | - case "Target": |
166 | | - TargetPath = selectedFilePath; |
167 | | - break; |
| 167 | + case "Target": |
| 168 | + TargetPath = selectedFilePath; |
| 169 | + break; |
168 | 170 |
|
169 | | - case "Patch": |
170 | | - PatchPath = selectedFilePath; |
171 | | - break; |
| 171 | + case "Patch": |
| 172 | + PatchPath = selectedFilePath; |
| 173 | + break; |
172 | 174 |
|
173 | | - case "Driver": |
174 | | - DriverDir = selectedFilePath; |
175 | | - break; |
| 175 | + case "Driver": |
| 176 | + DriverDir = selectedFilePath; |
| 177 | + break; |
| 178 | + } |
176 | 179 | } |
177 | 180 | } |
178 | 181 |
|
|
0 commit comments