mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-09-19 23:05:03 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fe9eeb32f |
@@ -44,8 +44,8 @@ namespace Daybreak.Controls
|
||||
private bool canNavigate;
|
||||
[GenerateDependencyProperty(InitialValue = true)]
|
||||
private bool controlsEnabled;
|
||||
[GenerateDependencyProperty]
|
||||
private bool browserSupported;
|
||||
[GenerateDependencyProperty(InitialValue = null)]
|
||||
private bool? browserSupported;
|
||||
[GenerateDependencyProperty]
|
||||
private bool addressBarReadonly;
|
||||
[GenerateDependencyProperty]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Extensions;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
@@ -19,7 +20,7 @@ namespace Daybreak.Converters
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return GetVisibility(value);
|
||||
return this.GetVisibility(value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
@@ -29,17 +30,24 @@ namespace Daybreak.Converters
|
||||
|
||||
private object GetVisibility(object value)
|
||||
{
|
||||
if (!(value is bool))
|
||||
return DependencyProperty.UnsetValue;
|
||||
bool objValue = (bool)value;
|
||||
if (value is not bool)
|
||||
{
|
||||
return this.IsHidden ?
|
||||
Visibility.Hidden :
|
||||
Visibility.Collapsed;
|
||||
}
|
||||
|
||||
var objValue = value.Cast<bool>();
|
||||
if ((objValue && TriggerValue && IsHidden) || (!objValue && !TriggerValue && IsHidden))
|
||||
{
|
||||
return Visibility.Hidden;
|
||||
}
|
||||
|
||||
if ((objValue && TriggerValue && !IsHidden) || (!objValue && !TriggerValue && !IsHidden))
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
return Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
|
||||
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
|
||||
<Version>0.9.3.6</Version>
|
||||
<Version>0.9.3.7</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -104,8 +104,8 @@
|
||||
</Grid>
|
||||
<wcl:Border OnResize="Border_OnResize" Grid.RowSpan="2" Active="True"></wcl:Border>
|
||||
<webview:WebView2 x:Name="BackgroundWebView"
|
||||
VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Visibility="Collapsed"
|
||||
Grid.Row="1"></webview:WebView2>
|
||||
</Grid>
|
||||
|
||||
@@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.Wpf;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Core.Extensions;
|
||||
using System.Extensions;
|
||||
@@ -98,11 +99,40 @@ namespace Daybreak.Services.IconRetrieve
|
||||
return;
|
||||
}
|
||||
|
||||
this.iconBrowser.InitializeWebView(this.browserWrapper, this.cancellationTokenSource.Token);
|
||||
var progressIncrement = 100d / Skill.Skills.Count();
|
||||
var incomplete = false;
|
||||
var progressValue = 0d;
|
||||
foreach (var skill in Skill.Skills.OrderBy(s => s.Name))
|
||||
var skillsToDownload = new List<Skill>();
|
||||
foreach(var skill in Skill.Skills.OrderBy(s => s.Name))
|
||||
{
|
||||
if (skill == Skill.NoSkill)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var logger = this.logger.CreateScopedLogger(nameof(this.DownloadIcons), skill.Name);
|
||||
logger.LogInformation("Verifying if icon exists");
|
||||
this.iconDownloadStatus.CurrentStep = IconDownloadStatus.Checking(skill.Name, progressValue);
|
||||
if ((await this.iconCache.GetIconUri(skill)).ExtractValue() is not null)
|
||||
{
|
||||
progressValue += progressIncrement;
|
||||
await Task.Delay(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
skillsToDownload.Add(skill);
|
||||
}
|
||||
|
||||
if (skillsToDownload.Count == 0)
|
||||
{
|
||||
this.logger.LogInformation("No icons missing. Stopping download");
|
||||
this.iconDownloadStatus.CurrentStep = IconDownloadStatus.Finished;
|
||||
return;
|
||||
}
|
||||
|
||||
this.iconBrowser.InitializeWebView(this.browserWrapper, this.cancellationTokenSource.Token);
|
||||
|
||||
var incomplete = false;
|
||||
foreach (var skill in skillsToDownload)
|
||||
{
|
||||
if (this.cancellationTokenSource?.IsCancellationRequested is null or true)
|
||||
{
|
||||
@@ -114,17 +144,7 @@ namespace Daybreak.Services.IconRetrieve
|
||||
{
|
||||
progressValue += progressIncrement;
|
||||
continue;
|
||||
}
|
||||
|
||||
var logger = this.logger.CreateScopedLogger(nameof(this.DownloadIcons), skill.Name);
|
||||
logger.LogInformation("Verifying if icon exists");
|
||||
this.iconDownloadStatus.CurrentStep = IconDownloadStatus.Checking(skill.Name, progressValue);
|
||||
if ((await this.iconCache.GetIconUri(skill)).ExtractValue() is not null)
|
||||
{
|
||||
logger.LogInformation("Icon exists");
|
||||
progressValue += progressIncrement;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
logger.LogInformation("Downloading icon");
|
||||
this.iconDownloadStatus.CurrentStep = IconDownloadStatus.Downloading(skill.Name, progressValue);
|
||||
@@ -156,6 +176,12 @@ namespace Daybreak.Services.IconRetrieve
|
||||
}
|
||||
else
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
this.browserWrapper.IsEnabled = false;
|
||||
this.browserWrapper.Dispose();
|
||||
});
|
||||
this.iconDownloadStatus.CurrentStep = IconDownloadStatus.Finished;
|
||||
this.DownloadComplete = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user