mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Can create, display, and delete tabs
This commit is contained in:
parent
ebc3172f74
commit
c26d8e4d98
23
Wabbajack.App.Blazor/Browser/BrowserTabView.xaml
Normal file
23
Wabbajack.App.Blazor/Browser/BrowserTabView.xaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<TabItem x:Class="Wabbajack.App.Blazor.Browser.BrowserTabView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Wabbajack.App.Blazor.Browser"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<TabItem.Style>
|
||||||
|
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}"></Style>
|
||||||
|
</TabItem.Style>
|
||||||
|
<TabItem.Header>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock FontSize="16" x:Name="HeaderText">_</TextBlock>
|
||||||
|
<Button Click="ButtonBase_OnClick">X</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</TabItem.Header>
|
||||||
|
<Grid>
|
||||||
|
<local:BrowserView x:Name="Browser">
|
||||||
|
</local:BrowserView>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
37
Wabbajack.App.Blazor/Browser/BrowserTabView.xaml.cs
Normal file
37
Wabbajack.App.Blazor/Browser/BrowserTabView.xaml.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Browser;
|
||||||
|
|
||||||
|
public partial class BrowserTabView : IDisposable
|
||||||
|
{
|
||||||
|
private readonly CompositeDisposable _compositeDisposable;
|
||||||
|
|
||||||
|
public BrowserTabView(BrowserTabViewModel vm)
|
||||||
|
{
|
||||||
|
_compositeDisposable = new CompositeDisposable();
|
||||||
|
InitializeComponent();
|
||||||
|
Browser.Browser.Source = new Uri("http://www.google.com");
|
||||||
|
DataContext = vm;
|
||||||
|
|
||||||
|
vm.WhenAnyValue(vm => vm.HeaderText)
|
||||||
|
.BindTo(this, view => view.HeaderText.Text)
|
||||||
|
.DisposeWith(_compositeDisposable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_compositeDisposable.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var tc = (TabControl) this.Parent;
|
||||||
|
tc.Items.Remove(this);
|
||||||
|
this.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
10
Wabbajack.App.Blazor/Browser/BrowserTabViewModel.cs
Normal file
10
Wabbajack.App.Blazor/Browser/BrowserTabViewModel.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using ReactiveUI.Fody.Helpers;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Browser;
|
||||||
|
|
||||||
|
public class BrowserTabViewModel : ViewModel
|
||||||
|
{
|
||||||
|
[Reactive]
|
||||||
|
public string HeaderText { get; set; }
|
||||||
|
|
||||||
|
}
|
16
Wabbajack.App.Blazor/Browser/BrowserView.xaml
Normal file
16
Wabbajack.App.Blazor/Browser/BrowserView.xaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<reactiveUi:ReactiveUserControl x:TypeArguments="local:BrowserTabViewModel"
|
||||||
|
x:Class="Wabbajack.App.Blazor.Browser.BrowserView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Wabbajack.App.Blazor.Browser"
|
||||||
|
xmlns:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||||
|
xmlns:reactiveUi="http://reactiveui.net"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
<wpf:WebView2 x:Name="Browser"></wpf:WebView2>
|
||||||
|
</Grid>
|
||||||
|
</reactiveUi:ReactiveUserControl>
|
||||||
|
|
13
Wabbajack.App.Blazor/Browser/BrowserView.xaml.cs
Normal file
13
Wabbajack.App.Blazor/Browser/BrowserView.xaml.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Browser;
|
||||||
|
|
||||||
|
public partial class BrowserView
|
||||||
|
{
|
||||||
|
public BrowserView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
8
Wabbajack.App.Blazor/Browser/ViewModel.cs
Normal file
8
Wabbajack.App.Blazor/Browser/ViewModel.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Browser;
|
||||||
|
|
||||||
|
public class ViewModel : ReactiveObject, IActivatableViewModel
|
||||||
|
{
|
||||||
|
public ViewModelActivator Activator { get; } = new();
|
||||||
|
}
|
11
Wabbajack.App.Blazor/Browser/ViewModels/NexusLogin.cs
Normal file
11
Wabbajack.App.Blazor/Browser/ViewModels/NexusLogin.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Wabbajack.DTOs.Logins;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Browser.ViewModels;
|
||||||
|
|
||||||
|
public class NexusLogin : BrowserTabViewModel
|
||||||
|
{
|
||||||
|
public NexusLogin()
|
||||||
|
{
|
||||||
|
HeaderText = "Nexus Login";
|
||||||
|
}
|
||||||
|
}
|
3
Wabbajack.App.Blazor/FodyWeavers.xml
Normal file
3
Wabbajack.App.Blazor/FodyWeavers.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||||
|
<ReactiveUI />
|
||||||
|
</Weavers>
|
26
Wabbajack.App.Blazor/FodyWeavers.xsd
Normal file
26
Wabbajack.App.Blazor/FodyWeavers.xsd
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||||
|
<xs:element name="Weavers">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="ReactiveUI" minOccurs="0" maxOccurs="1" type="xs:anyType" />
|
||||||
|
</xs:all>
|
||||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:attribute>
|
||||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:attribute>
|
||||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:attribute>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
@ -10,7 +10,7 @@
|
|||||||
ShowTitleBar="False"
|
ShowTitleBar="False"
|
||||||
Title="WABBAJACK" Height="750" Width="1200" MinHeight="750" MinWidth="1200">
|
Title="WABBAJACK" Height="750" Width="1200" MinHeight="750" MinWidth="1200">
|
||||||
<Grid Background="#121212" MouseDown="UIElement_OnMouseDown">
|
<Grid Background="#121212" MouseDown="UIElement_OnMouseDown">
|
||||||
<TabControl>
|
<TabControl x:Name="Tabs">
|
||||||
<TabItem>
|
<TabItem>
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
<TextBlock FontSize="16" Margin="0, 0, 8, 0">WABBAJACK 3.0.0</TextBlock>
|
<TextBlock FontSize="16" Margin="0, 0, 8, 0">WABBAJACK 3.0.0</TextBlock>
|
||||||
|
@ -1,16 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using ReactiveUI;
|
||||||
|
using Wabbajack.App.Blazor.Browser;
|
||||||
|
using Wabbajack.App.Blazor.Messages;
|
||||||
using Wabbajack.App.Blazor.State;
|
using Wabbajack.App.Blazor.State;
|
||||||
|
|
||||||
namespace Wabbajack.App.Blazor;
|
namespace Wabbajack.App.Blazor;
|
||||||
|
|
||||||
public partial class MainWindow
|
public partial class MainWindow : IDisposable
|
||||||
{
|
{
|
||||||
private Point _lastPosition;
|
private Point _lastPosition;
|
||||||
|
private readonly CompositeDisposable _compositeDisposable;
|
||||||
|
|
||||||
public MainWindow(IServiceProvider serviceProvider, IStateContainer stateContainer)
|
public MainWindow(IServiceProvider serviceProvider, IStateContainer stateContainer)
|
||||||
{
|
{
|
||||||
|
_compositeDisposable = new CompositeDisposable();
|
||||||
|
|
||||||
stateContainer.TaskBarStateObservable.Subscribe(state =>
|
stateContainer.TaskBarStateObservable.Subscribe(state =>
|
||||||
{
|
{
|
||||||
Dispatcher.InvokeAsync(() =>
|
Dispatcher.InvokeAsync(() =>
|
||||||
@ -21,6 +29,10 @@ public partial class MainWindow
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MessageBus.Current.Listen<OpenBrowserTab>()
|
||||||
|
.Subscribe(OnOpenBrowserTab)
|
||||||
|
.DisposeWith(_compositeDisposable);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BlazorWebView.Services = serviceProvider;
|
BlazorWebView.Services = serviceProvider;
|
||||||
}
|
}
|
||||||
@ -29,6 +41,18 @@ public partial class MainWindow
|
|||||||
{
|
{
|
||||||
this.DragMove();
|
this.DragMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnOpenBrowserTab(OpenBrowserTab msg)
|
||||||
|
{
|
||||||
|
var tab = new BrowserTabView(msg.ViewModel);
|
||||||
|
Tabs.Items.Add(tab);
|
||||||
|
Tabs.SelectedItem = tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_compositeDisposable.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required so compiler doesn't complain about not finding the type. [MC3050]
|
// Required so compiler doesn't complain about not finding the type. [MC3050]
|
||||||
|
13
Wabbajack.App.Blazor/Messages/OpenBrowserTab.cs
Normal file
13
Wabbajack.App.Blazor/Messages/OpenBrowserTab.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using Wabbajack.App.Blazor.Browser;
|
||||||
|
|
||||||
|
namespace Wabbajack.App.Blazor.Messages;
|
||||||
|
|
||||||
|
public class OpenBrowserTab
|
||||||
|
{
|
||||||
|
public BrowserTabViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
|
public OpenBrowserTab(BrowserTabViewModel viewModel)
|
||||||
|
{
|
||||||
|
ViewModel = viewModel;
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,21 @@
|
|||||||
@page "/settings"
|
@page "/settings"
|
||||||
|
@using ReactiveUI
|
||||||
|
@using Wabbajack.App.Blazor.Browser.ViewModels
|
||||||
|
@using Wabbajack.App.Blazor.Messages
|
||||||
@namespace Wabbajack.App.Blazor.Pages
|
@namespace Wabbajack.App.Blazor.Pages
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div class="resources">
|
<div class="resources">
|
||||||
|
|
||||||
|
<button onclick="@LoginToNexus">Login To Nexus</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
public const string Route = "/settings";
|
public const string Route = "/settings";
|
||||||
|
|
||||||
|
public void LoginToNexus()
|
||||||
|
{
|
||||||
|
MessageBus.Current.SendMessage(new OpenBrowserTab(new NexusLogin()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
<PackageReference Include="NLog" Version="4.7.13" />
|
<PackageReference Include="NLog" Version="4.7.13" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
||||||
<PackageReference Include="PInvoke.User32" Version="0.7.104" />
|
<PackageReference Include="PInvoke.User32" Version="0.7.104" />
|
||||||
|
<PackageReference Include="ReactiveUI" Version="17.1.17" />
|
||||||
|
<PackageReference Include="ReactiveUI.Fody" Version="17.1.17" />
|
||||||
|
<PackageReference Include="ReactiveUI.WPF" Version="17.1.17" />
|
||||||
<PackageReference Include="Silk.NET.DXGI" Version="2.12.0" />
|
<PackageReference Include="Silk.NET.DXGI" Version="2.12.0" />
|
||||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user