WIP, probably won't use this code

This commit is contained in:
Timothy Baldridge 2022-05-19 15:47:15 -06:00
parent 5907fc6fcb
commit 87f8d8ff24
7 changed files with 114 additions and 68 deletions

View File

@ -19,7 +19,7 @@ public class ManualDownloadHandler : BrowserTabViewModel
var md = Intervention.Archive.State as Manual;
HeaderText = $"Manual download ({md.Url.Host})";
Instructions = string.IsNullOrWhiteSpace(md.Prompt) ? $"Please download {archive.Name}" : md.Prompt;
await NavigateTo(md.Url);

View File

@ -1,4 +1,4 @@
<TabItem x:Class="Wabbajack.Views.BrowserTabView"
<UserControl x:Class="Wabbajack.Views.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"
@ -7,17 +7,10 @@
xmlns:views="clr-namespace:Wabbajack.Views"
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>
</StackPanel>
</TabItem.Header>
<Grid>
<views:BrowserView x:Name="Browser">
</views:BrowserView>
</Grid>
</TabItem>
</UserControl>

View File

@ -13,19 +13,21 @@ public partial class BrowserTabView : IDisposable
{
private readonly CompositeDisposable _compositeDisposable;
public BrowserTabView(BrowserTabViewModel vm)
public BrowserTabView()
{
_compositeDisposable = new CompositeDisposable();
InitializeComponent();
Browser.Browser.Source = new Uri("http://www.google.com");
/*
vm.Browser = Browser;
DataContext = vm;
vm.WhenAnyValue(vm => vm.HeaderText)
.BindTo(this, view => view.HeaderText.Text)
.DisposeWith(_compositeDisposable);
*/
Start().FireAndForget();
//Start().FireAndForget();
}
private async Task Start()

View File

@ -9,6 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
xmlns:behaviors="clr-namespace:IKriv.Windows.Controls.Behaviors"
xmlns:views="clr-namespace:Wabbajack.Views"
ShowTitleBar="False"
Title="WABBAJACK"
Width="1280"
@ -23,6 +24,33 @@
UseLayoutRounding="True"
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
mc:Ignorable="d">
<Window.Resources>
<DataTemplate x:Key="HeaderTemplate">
<ContentPresenter Grid.Row="0" Content="{Binding}">
<ContentPresenter.Resources>
<DataTemplate DataType="{x:Type local:MainWindowVM}">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="16" Margin="0, 0, 8, 0">WABBAJACK 3.0.0</TextBlock>
<Button Name="SettingsButton">
<icon:Material Kind="Cog"></icon:Material>
</Button>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="{x:Type local:BrowserTabViewModel}">
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="16" Margin="0, 0, 8, 0" Text="{Binding HeaderText}"></TextBlock>
<Button Name="SettingsButton">
<icon:Material Kind="Close"></icon:Material>
</Button>
</StackPanel>
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
</DataTemplate>
</Window.Resources>
<Grid Background="#121212" MouseDown="UIElement_OnMouseDown">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
@ -35,53 +63,23 @@
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<TabControl Grid.Row="0" x:Name="Tabs" behaviors:TabContent.IsCached="True">
<TabControl Grid.Row="0" x:Name="Tabs" behaviors:TabContent.IsCached="True"
ItemTemplate="{DynamicResource HeaderTemplate}">
<behaviors:TabContent.Template>
<DataTemplate>
<Button>Sup></Button>
</DataTemplate>
</behaviors:TabContent.Template>
<!--
<TabItem>
<TabItem.Header>
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="16" Margin="0, 0, 8, 0">WABBAJACK 3.0.0</TextBlock>
<Button Name="SettingsButton"><icon:Material Kind="Cog"></icon:Material></Button>
</StackPanel>
</TabItem.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Content="{Binding ActivePane}">
<ContentPresenter Content="{Binding}">
<ContentPresenter.Resources>
<DataTemplate DataType="{x:Type local:CompilerVM}">
<local:CompilerView ViewModel="{Binding}" />
<DataTemplate DataType="{x:Type local:MainWindowVM}">
<local:MainWindowContent></local:MainWindowContent>
</DataTemplate>
<DataTemplate DataType="{x:Type local:InstallerVM}">
<local:InstallationView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModeSelectionVM}">
<local:ModeSelectionView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModListGalleryVM}">
<local:ModListGalleryView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:WebBrowserVM}">
<local:WebBrowserView />
</DataTemplate>
<DataTemplate DataType="{x:Type local:SettingsVM}">
<local:SettingsView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModels:ModListContentsVM}">
<local:ModListContentsView ViewModel="{Binding}" />
<DataTemplate DataType="{x:Type local:BrowserTabViewModel}">
<views:BrowserTabView></views:BrowserTabView>
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<TextBlock Grid.Row="1" Margin="5, 0" Name="ResourceUsage" HorizontalAlignment="Right"></TextBlock>
</Grid>
</TabItem> -->
</DataTemplate>
</behaviors:TabContent.Template>
</TabControl>
</Grid>
@ -96,12 +94,12 @@
Command="{Binding CopyVersionCommand}"
Content="{Binding VersionDisplay}">
<Button.ToolTip>
<ToolTip Content="Wabbajack Version&#x0a;Click to copy to clipboard"/>
<ToolTip Content="Wabbajack Version&#x0a;Click to copy to clipboard" />
</Button.ToolTip>
</Button>
<Button Grid.Column="1"
Margin="5,0"
Command="{Binding OpenSettingsCommand}">
Margin="5,0"
Command="{Binding OpenSettingsCommand}">
<icon:PackIconMaterial
Width="17"
Height="17"
@ -112,4 +110,4 @@
<Window.TaskbarItemInfo>
<TaskbarItemInfo x:Name="TaskbarItemInfo"></TaskbarItemInfo>
</Window.TaskbarItemInfo>
</mahapps:MetroWindow>
</mahapps:MetroWindow>

View File

@ -1,16 +1,24 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using DynamicData;
using DynamicData.Binding;
using MahApps.Metro.Controls;
using Microsoft.Extensions.Logging;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Wabbajack.Common;
using Wabbajack.DTOs;
using Wabbajack.DTOs.DownloadStates;
using Wabbajack.DTOs.Interventions;
using Wabbajack.Messages;
using Wabbajack.Paths.IO;
using Wabbajack.UserIntervention;
using Wabbajack.Util;
using Wabbajack.Views;
@ -26,11 +34,17 @@ namespace Wabbajack
private readonly ILogger<MainWindow> _logger;
private readonly SystemParametersConstructor _systemParams;
private ObservableCollection<ViewModel> TabVMs = new ObservableCollectionExtended<ViewModel>();
public MainWindow(ILogger<MainWindow> logger, SystemParametersConstructor systemParams, LauncherUpdater updater, MainWindowVM vm)
{
InitializeComponent();
_mwvm = vm;
DataContext = _mwvm;
Tabs.ItemsSource = TabVMs;
TabVMs.Add(vm);
TabVMs.Add(new ManualDownloadHandler() {Intervention = new ManualDownload(new Archive() {State = new Manual(){Url = new Uri("https://www.wabbajack.org")}})});
Tabs.SelectedItem = TabVMs.Last();
_logger = logger;
_systemParams = systemParams;
@ -206,9 +220,9 @@ namespace Wabbajack
private void OnOpenBrowserTab(OpenBrowserTab msg)
{
var tab = new BrowserTabView(msg.ViewModel);
Tabs.Items.Add(tab);
Tabs.SelectedItem = tab;
//var tab = new BrowserTabView(msg.ViewModel);
//Tabs.Items.Add(tab);
//Tabs.SelectedItem = tab;
}
private void OnCloseBrowserTab(CloseBrowserTab msg)

View File

@ -1,12 +1,51 @@
<UserControl x:Class="Wabbajack.App.Wpf.Views.MainWindowContent"
<UserControl x:Class="Wabbajack.MainWindowContent"
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.Wpf.Views"
xmlns:local="clr-namespace:Wabbajack"
xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
</Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<ContentPresenter Grid.Row="0" Content="{Binding ActivePane}">
<ContentPresenter.Resources>
<DataTemplate DataType="{x:Type local:CompilerVM}">
<local:CompilerView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:InstallerVM}">
<local:InstallationView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModeSelectionVM}">
<local:ModeSelectionView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:ModListGalleryVM}">
<local:ModListGalleryView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type local:WebBrowserVM}">
<local:WebBrowserView />
</DataTemplate>
<DataTemplate DataType="{x:Type local:SettingsVM}">
<local:SettingsView ViewModel="{Binding}" />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModels:ModListContentsVM}">
<local:ModListContentsView ViewModel="{Binding}" />
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
<TextBlock Grid.Row="1" Margin="5, 0" Name="ResourceUsage" HorizontalAlignment="Right"></TextBlock>
</Grid>
<!--
<TabItem>
<TabItem.Header>
</TabItem.Header>
</TabItem>-->
</UserControl>

View File

@ -1,6 +1,6 @@
using System.Windows.Controls;
namespace Wabbajack.App.Wpf.Views;
namespace Wabbajack;
public partial class MainWindowContent : UserControl
{