Skip to content

Commit 69a700b

Browse files
Added disable for archive additions if something is currently being worked on.
1 parent 5f440a8 commit 69a700b

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

DazContentInstaller/ViewModels/MainWindowViewModel.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ public string InstalledAssetsSearch
7979
}
8080
}
8181

82+
public bool AllowArchiveLoad
83+
{
84+
get => _allowArchiveLoad;
85+
set => SetProperty(ref _allowArchiveLoad, value);
86+
}
87+
8288
public bool UninstallButtonEnabled => SelectedInstallNodes.Any() && SelectedInstallNodes.All(d => d.Parent is null);
8389

8490
private string _statusText = "Ready";
@@ -87,6 +93,7 @@ public string InstalledAssetsSearch
8793
private int _statusProgress;
8894
private int _statusBarMax = 100;
8995
private IImmutableSolidColorBrush _statusBarColor = Brushes.DodgerBlue;
96+
private bool _allowArchiveLoad;
9097

9198
public string StatusText
9299
{
@@ -202,6 +209,7 @@ private async Task InstallArchives()
202209
if (CurrentSelectedAssetLibrary is null)
203210
return;
204211

212+
AllowArchiveLoad = false;
205213
var archivesToInstall =
206214
SelectedArchives.Count > 0 ? SelectedArchives.ToList() : LoadedArchives.ToList();
207215

@@ -252,10 +260,15 @@ await Task.Run(async () =>
252260
}
253261
});
254262

255-
await LoadInstalledArchivesAsync();
263+
await Task.Run(async () =>
264+
{
265+
await LoadInstalledArchivesAsync();
266+
});
267+
256268
messageProgress.Report($"Installed {archivesToInstall.Count} archives");
257269
percentageProgress.Report(100);
258270
StatusBarColor = Brushes.Green;
271+
AllowArchiveLoad = true;
259272
}
260273

261274
private static string GetLoadedArchiveName(LoadedArchive archiveOld) =>
@@ -268,6 +281,7 @@ private async Task UninstallArchiveAsync()
268281
if (!SelectedInstallNodes.Any())
269282
return;
270283

284+
AllowArchiveLoad = false;
271285
await using var dbContext = await _dbContextFactory.CreateDbContextAsync();
272286

273287
var selectedInstallArchiveIds = SelectedInstallNodes.Select(n => n.DbId).ToArray();
@@ -322,14 +336,20 @@ await Task.Run(async () =>
322336
StatusBarColor = Brushes.Green;
323337
});
324338

325-
await LoadInstalledArchivesAsync();
339+
await Task.Run(async () =>
340+
{
341+
await LoadInstalledArchivesAsync();
342+
});
343+
344+
AllowArchiveLoad = true;
326345
}
327346

328347
public async Task LoadArchiveFilesAsync(List<string> filePaths)
329348
{
330349
StatusBarMax = 100 * filePaths.Count;
331350
StatusProgress = 0;
332351
StatusBarColor = Brushes.DodgerBlue;
352+
AllowArchiveLoad = false;
333353

334354
var index = 0;
335355

@@ -356,6 +376,7 @@ await Task.Run(async () =>
356376

357377
StatusBarMax = 100;
358378
StatusBarColor = Brushes.Green;
379+
AllowArchiveLoad = true;
359380
}
360381

361382
private void FilterInstalledAssetsTree(string? searchTerm)

DazContentInstaller/Views/MainWindow.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@
5757

5858
<!-- Drop Zone -->
5959
<Border Grid.Row="1" Name="DropZone" Background="#F8F8F8" BorderBrush="#CCCCCC" BorderThickness="2"
60-
CornerRadius="8" Height="120" Margin="0,0,0,15" DragDrop.AllowDrop="True">
60+
CornerRadius="8" Height="120" Margin="0,0,0,15" DragDrop.AllowDrop="{Binding AllowArchiveLoad}">
6161
<DockPanel>
6262
<StackPanel DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Center">
6363
<TextBlock Text="📦" FontSize="32" HorizontalAlignment="Center" Margin="0,0,0,5" />
6464
<TextBlock Text="Drop ZIP Files here or click to browse"
6565
FontSize="14" HorizontalAlignment="Center" Foreground="#666666" />
6666
<Button Name="BrowseButton" Content="Browse Files" Margin="0,10,0,0" Padding="15,5"
67-
HorizontalAlignment="Center" />
67+
HorizontalAlignment="Center" IsEnabled="{Binding AllowArchiveLoad}"/>
6868
</StackPanel>
6969
</DockPanel>
7070
</Border>

0 commit comments

Comments
 (0)