mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Add favicons to login manager
This commit is contained in:
parent
c5dd1d6388
commit
2d457ad12d
@ -556,6 +556,7 @@ namespace Wabbajack.Common
|
|||||||
|
|
||||||
public static AbsolutePath RelativeTo(this string str, AbsolutePath path)
|
public static AbsolutePath RelativeTo(this string str, AbsolutePath path)
|
||||||
{
|
{
|
||||||
|
if (Path.IsPathRooted(str)) return (AbsolutePath)str;
|
||||||
return ((RelativePath)str).RelativeTo(path);
|
return ((RelativePath)str).RelativeTo(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
public string SiteName => "Bethesda.NET";
|
public string SiteName => "Bethesda.NET";
|
||||||
public IObservable<string> MetaInfo => Observable.Return(""); //"Wabbajack will start the game, then exit once you enter the Mods page";
|
public IObservable<string> MetaInfo => Observable.Return(""); //"Wabbajack will start the game, then exit once you enter the Mods page";
|
||||||
public Uri SiteURL => new Uri("https://bethesda.net");
|
public Uri SiteURL => new Uri("https://bethesda.net");
|
||||||
public Uri? IconUri { get; }
|
public Uri? IconUri => new Uri("https://bethesda.net/favicon.ico");
|
||||||
|
|
||||||
public BethesdaNetDownloader()
|
public BethesdaNetDownloader()
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,8 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
{
|
{
|
||||||
#region INeedsDownload
|
#region INeedsDownload
|
||||||
public override string SiteName => "TESALL";
|
public override string SiteName => "TESALL";
|
||||||
public override Uri SiteURL => new Uri("http://tesall.ru");
|
public override Uri SiteURL => new Uri("https://tesall.ru");
|
||||||
public override Uri IconUri => new Uri("http://tesall.ru/favicon.ico");
|
public override Uri IconUri => new Uri("https://tesall.ru/favicon.ico");
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public TESAllDownloader() : base(new Uri("https://tesall.ru/index.php?app=core&module=global§ion=login"),
|
public TESAllDownloader() : base(new Uri("https://tesall.ru/index.php?app=core&module=global§ion=login"),
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.Lib;
|
using Wabbajack.Lib;
|
||||||
using Wabbajack.Lib.Downloaders;
|
using Wabbajack.Lib.Downloaders;
|
||||||
|
|
||||||
@ -21,6 +29,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
Downloaders = DownloadDispatcher.Downloaders
|
Downloaders = DownloadDispatcher.Downloaders
|
||||||
.OfType<INeedsLogin>()
|
.OfType<INeedsLogin>()
|
||||||
|
.OrderBy(x => x.SiteName)
|
||||||
.Select(x => new LoginTargetVM(x))
|
.Select(x => new LoginTargetVM(x))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@ -37,10 +46,16 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> TriggerCredentialsLogin;
|
public ReactiveCommand<Unit, Unit> TriggerCredentialsLogin;
|
||||||
|
|
||||||
|
private ImageSource _favicon = null;
|
||||||
|
|
||||||
|
public ImageSource Favicon { get => _favicon; set => RaiseAndSetIfChanged(ref _favicon, value); }
|
||||||
|
|
||||||
public LoginTargetVM(INeedsLogin login)
|
public LoginTargetVM(INeedsLogin login)
|
||||||
{
|
{
|
||||||
Login = login;
|
Login = login;
|
||||||
|
|
||||||
|
LoadImage();
|
||||||
|
|
||||||
if (login is INeedsLoginCredentials loginWithCredentials)
|
if (login is INeedsLoginCredentials loginWithCredentials)
|
||||||
{
|
{
|
||||||
UsesCredentials = true;
|
UsesCredentials = true;
|
||||||
@ -62,5 +77,30 @@ namespace Wabbajack
|
|||||||
loginWindow.Show();
|
loginWindow.Show();
|
||||||
}, LoginWithCredentials.IsLoggedIn.Select(b => !b).ObserveOnGuiThread());
|
}, LoginWithCredentials.IsLoggedIn.Select(b => !b).ObserveOnGuiThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadImage()
|
||||||
|
{
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
if (Login.IconUri == null) return;
|
||||||
|
|
||||||
|
using var img = await new Common.Http.Client().GetAsync(Login.IconUri, errorsAsExceptions:false);
|
||||||
|
if (!img.IsSuccessStatusCode) return;
|
||||||
|
|
||||||
|
var icoData = new MemoryStream(await img.Content.ReadAsByteArrayAsync());
|
||||||
|
|
||||||
|
var data = new Icon(icoData);
|
||||||
|
var ms = new MemoryStream();
|
||||||
|
data.ToBitmap().Save(ms, ImageFormat.Png);
|
||||||
|
ms.Position = 0;
|
||||||
|
|
||||||
|
var source = new BitmapImage();
|
||||||
|
source.BeginInit();
|
||||||
|
source.StreamSource = ms;
|
||||||
|
source.EndInit();
|
||||||
|
source.Freeze();
|
||||||
|
Favicon = source;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,28 +12,34 @@
|
|||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Grid Height="30" Margin="5">
|
<Grid Height="30" Margin="5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="32"/>
|
||||||
<ColumnDefinition Width="Auto" MinWidth="150" />
|
<ColumnDefinition Width="Auto" MinWidth="150" />
|
||||||
<ColumnDefinition Width="100" />
|
<ColumnDefinition Width="100" />
|
||||||
<ColumnDefinition Width="100" />
|
<ColumnDefinition Width="100" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
<Image
|
||||||
|
Margin="4"
|
||||||
|
x:Name="Favicon"
|
||||||
|
Grid.Column="0"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="SiteNameText"
|
x:Name="SiteNameText"
|
||||||
Grid.Column="0"
|
Grid.Column="1"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="LoginButton"
|
x:Name="LoginButton"
|
||||||
Grid.Column="1"
|
Grid.Column="2"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
Content="Login" />
|
Content="Login" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="LogoutButton"
|
x:Name="LogoutButton"
|
||||||
Grid.Column="2"
|
Grid.Column="3"
|
||||||
Margin="5"
|
Margin="5"
|
||||||
Content="Logout" />
|
Content="Logout" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
x:Name="MetaText"
|
x:Name="MetaText"
|
||||||
Grid.Column="3"
|
Grid.Column="4"
|
||||||
FontSize="14" />
|
FontSize="14" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</rxui:ReactiveUserControl>
|
</rxui:ReactiveUserControl>
|
||||||
|
@ -12,6 +12,11 @@ namespace Wabbajack
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(disposable =>
|
this.WhenActivated(disposable =>
|
||||||
{
|
{
|
||||||
|
this.WhenAny(x => x.ViewModel.Favicon)
|
||||||
|
.ObserveOnGuiThread()
|
||||||
|
.Subscribe(x => Favicon.Source = x)
|
||||||
|
.DisposeWith(disposable);
|
||||||
|
|
||||||
this.OneWayBindStrict(ViewModel, x => x.Login.SiteName, x => x.SiteNameText.Text)
|
this.OneWayBindStrict(ViewModel, x => x.Login.SiteName, x => x.SiteNameText.Text)
|
||||||
.DisposeWith(disposable);
|
.DisposeWith(disposable);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user