wabbajack/Wabbajack.App.Blazor/MainWindow.xaml.cs

60 lines
1.6 KiB
C#
Raw Normal View History

2022-01-09 13:33:22 +00:00
using System;
2022-01-29 22:32:46 +00:00
using System.Reactive.Disposables;
2022-01-29 06:15:17 +00:00
using System.Windows;
2022-01-29 22:32:46 +00:00
using System.Windows.Controls;
2022-01-29 06:15:17 +00:00
using System.Windows.Input;
2022-01-29 22:32:46 +00:00
using ReactiveUI;
using Wabbajack.App.Blazor.Browser;
using Wabbajack.App.Blazor.Messages;
2022-01-21 04:57:59 +00:00
using Wabbajack.App.Blazor.State;
2022-01-09 13:33:22 +00:00
2022-01-20 08:34:38 +00:00
namespace Wabbajack.App.Blazor;
2022-01-29 22:32:46 +00:00
public partial class MainWindow : IDisposable
2022-01-09 13:33:22 +00:00
{
2022-01-29 06:15:17 +00:00
private Point _lastPosition;
2022-01-29 22:32:46 +00:00
private readonly CompositeDisposable _compositeDisposable;
2022-01-29 06:15:17 +00:00
2022-01-21 13:54:22 +00:00
public MainWindow(IServiceProvider serviceProvider, IStateContainer stateContainer)
2022-01-09 13:33:22 +00:00
{
2022-01-29 22:32:46 +00:00
_compositeDisposable = new CompositeDisposable();
2022-01-21 13:54:22 +00:00
stateContainer.TaskBarStateObservable.Subscribe(state =>
2022-01-21 04:57:59 +00:00
{
Dispatcher.InvokeAsync(() =>
{
TaskBarItem.Description = state.Description;
TaskBarItem.ProgressState = state.State;
TaskBarItem.ProgressValue = state.ProgressValue;
});
2022-01-21 13:41:37 +00:00
});
2022-01-29 22:32:46 +00:00
MessageBus.Current.Listen<OpenBrowserTab>()
.Subscribe(OnOpenBrowserTab)
.DisposeWith(_compositeDisposable);
2022-01-20 08:34:38 +00:00
InitializeComponent();
BlazorWebView.Services = serviceProvider;
2022-01-09 13:33:22 +00:00
}
2022-01-29 06:15:17 +00:00
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
2022-01-29 22:32:46 +00:00
private void OnOpenBrowserTab(OpenBrowserTab msg)
{
var tab = new BrowserTabView(msg.ViewModel);
Tabs.Items.Add(tab);
Tabs.SelectedItem = tab;
}
public void Dispose()
{
_compositeDisposable.Dispose();
}
}
2022-01-20 08:34:38 +00:00
// Required so compiler doesn't complain about not finding the type. [MC3050]
public partial class Main { }