wabbajack/Wabbajack.App.Wpf/Views/BrowserWindow.xaml.cs

54 lines
1.4 KiB
C#
Raw Normal View History

2022-05-20 03:23:16 +00:00
using System;
2022-05-21 17:20:28 +00:00
using System.Reactive.Disposables;
using System.Reactive.Linq;
2022-05-20 03:23:16 +00:00
using System.Threading;
using System.Windows;
using System.Windows.Input;
using MahApps.Metro.Controls;
2022-05-21 17:20:28 +00:00
using ReactiveUI;
2022-05-20 03:23:16 +00:00
using Wabbajack.Common;
namespace Wabbajack;
public partial class BrowserWindow : MetroWindow
{
2022-05-21 17:20:28 +00:00
private readonly CompositeDisposable _disposable;
2022-05-20 03:23:16 +00:00
public BrowserWindow()
{
InitializeComponent();
2022-05-21 17:20:28 +00:00
_disposable = new CompositeDisposable();
2022-05-20 03:23:16 +00:00
}
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
{
base.DragMove();
}
private void BrowserWindow_OnActivated(object sender, EventArgs e)
{
var vm = ((BrowserWindowViewModel) DataContext);
vm.Browser = this;
2022-05-21 17:20:28 +00:00
vm.WhenAnyValue(vm => vm.HeaderText)
.BindToStrict(this, view => view.Header.Text)
.DisposeWith(_disposable);
vm.WhenAnyValue(vm => vm.Instructions)
.BindToStrict(this, view => view.Instructions.Text)
.DisposeWith(_disposable);
vm.WhenAnyValue(vm => vm.Address)
.BindToStrict(this, view => view.AddressBar.Text)
.DisposeWith(_disposable);
this.CopyButton.Command = ReactiveCommand.Create(() =>
{
Clipboard.SetText(vm.Address.ToString());
});
2022-05-20 03:23:16 +00:00
vm.RunWrapper(CancellationToken.None)
.ContinueWith(_ => Dispatcher.Invoke(Close));
}
}