mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
commit
e327f86081
1
Branding/SVGs/MiddleMouseButton.svg
Normal file
1
Branding/SVGs/MiddleMouseButton.svg
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 1000 1000" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><rect id="Artboard1" x="0" y="0" width="1000" height="1000" style="fill:none;"/><g id="Artboard11" serif:id="Artboard1"><circle cx="500" cy="500" r="425" style="fill:#fff;fill-opacity:0;stroke:#fff;stroke-width:40px;"/><path d="M468.763,410.75l-58.013,0l89.25,-267.75l89.25,267.75l-58.013,0l0,178.5l58.013,0l-89.25,267.75l-89.25,-267.75l58.013,0l0,-178.5Z" style="fill:#fff;fill-opacity:0;stroke:#fff;stroke-width:40px;"/></g></svg>
|
After Width: | Height: | Size: 899 B |
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
@ -18,5 +16,7 @@ namespace Wabbajack
|
||||
UIUtils.BitmapImageFromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/MO2Button.png")).Stream));
|
||||
public static Lazy<BitmapImage> VortexButton { get; } = new Lazy<BitmapImage>(() =>
|
||||
UIUtils.BitmapImageFromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/VortexButton.png")).Stream));
|
||||
public static Lazy<BitmapImage> MiddleMouseButton { get; } = new Lazy<BitmapImage>(() =>
|
||||
UIUtils.BitmapImageFromStream(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/middle_mouse_button.png")).Stream));
|
||||
}
|
||||
}
|
||||
|
BIN
Wabbajack/Resources/middle_mouse_button.png
Normal file
BIN
Wabbajack/Resources/middle_mouse_button.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -1,4 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
@ -16,9 +21,34 @@ namespace Wabbajack
|
||||
|
||||
public IEnumerable<Archive> Archives => Manifest.Archives;
|
||||
|
||||
[Reactive]
|
||||
public string SearchTerm { get; set; }
|
||||
|
||||
private readonly ObservableAsPropertyHelper<IEnumerable<Archive>> _searchResults;
|
||||
public IEnumerable<Archive> SearchResults => _searchResults.Value;
|
||||
|
||||
public ManifestVM(Manifest manifest)
|
||||
{
|
||||
Manifest = manifest;
|
||||
|
||||
_searchResults =
|
||||
this.WhenAnyValue(x => x.SearchTerm)
|
||||
.Throttle(TimeSpan.FromMilliseconds(800))
|
||||
.Select(term => term?.Trim())
|
||||
.DistinctUntilChanged()
|
||||
.Select(term =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(term))
|
||||
return Archives;
|
||||
|
||||
return Archives.Where(x =>
|
||||
{
|
||||
if (term.StartsWith("hash:"))
|
||||
return x.Hash.StartsWith(term.Replace("hash:", ""));
|
||||
return x.Name.StartsWith(term);
|
||||
});
|
||||
})
|
||||
.ToGuiProperty(this, nameof(SearchResults), Archives);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
xmlns:reactiveUi="http://reactiveui.net"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ScrollViewer>
|
||||
<Grid>
|
||||
<ScrollViewer MouseDown="ScrollViewer_MouseDown" MouseUp="ScrollViewer_MouseUp" MouseMove="ScrollViewer_MouseMove">
|
||||
<ScrollViewer.Resources>
|
||||
<Style x:Key="HeaderStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#03DAC6"/>
|
||||
@ -15,18 +16,22 @@
|
||||
<Style x:Key="HyperlinkStyle" TargetType="{x:Type Hyperlink}">
|
||||
<Setter Property="Foreground" Value="#BB76FC"/>
|
||||
</Style>
|
||||
<Style x:Key="ModTitleStyle" TargetType="{x:Type TextBlock}">
|
||||
<Style x:Key="ModTitleStyle" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Foreground" Value="#C7FC86"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
<SolidColorBrush x:Key="SearchBarBrush" Color="White" Opacity="50"/>
|
||||
</ScrollViewer.Resources>
|
||||
<StackPanel Margin="8">
|
||||
<StackPanel Margin="8" x:Name="DynamicStackPanel">
|
||||
<TextBlock x:Name="Name" FontSize="32" HorizontalAlignment="Center" Style="{StaticResource HeaderStyle}"/>
|
||||
<TextBlock x:Name="Author" FontSize="14" Padding="0 3 0 3"/>
|
||||
<TextBlock x:Name="Description" FontSize="14" TextWrapping="Wrap"/>
|
||||
<TextBlock x:Name="Author" FontSize="14" Padding="0 12 0 3"/>
|
||||
<TextBlock x:Name="Description" FontSize="18" TextWrapping="Wrap"/>
|
||||
|
||||
<TextBlock FontSize="26" Padding="0 6 0 0" Text="Mods"/>
|
||||
<TextBlock x:Name="InstallSize" FontSize="20"/>
|
||||
<TextBlock x:Name="DownloadSize" FontSize="20" Padding="0 0 0 3"/>
|
||||
<TextBlock x:Name="InstallSize" Padding="0 24 0 0" FontSize="24"/>
|
||||
<TextBlock x:Name="DownloadSize" FontSize="24" Padding="0 0 0 12"/>
|
||||
|
||||
<TextBlock Padding="6 0 0 0" FontSize="20" Text="Search:"/>
|
||||
<TextBox x:Name="SearchBar" BorderThickness="2" BorderBrush="{StaticResource SearchBarBrush}" FontSize="16" MaxLength="100"/>
|
||||
|
||||
<ItemsControl Padding="0 3 0 6" x:Name="ModsList">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@ -37,7 +42,7 @@
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0 3 0 3">
|
||||
<Grid Margin="0 6 0 6">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
@ -46,15 +51,17 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="0" FontSize="16" Text="{Binding Path=Name}" Style="{StaticResource ModTitleStyle}"/>
|
||||
<TextBlock Padding="3 0 0 0" Grid.Column="1" Grid.Row="0" FontSize="16">
|
||||
<TextBox Padding="6 0 0 0" Grid.Column="0" Grid.Row="0" FontSize="18" Text="{Binding Path=Name}" Style="{StaticResource ModTitleStyle}" IsReadOnly="True" BorderThickness="0"/>
|
||||
<TextBlock Padding="3 0 0 0" Grid.Column="1" Grid.Row="0" FontSize="18">
|
||||
<Hyperlink NavigateUri="{Binding Path=Name}" Style="{StaticResource HyperlinkStyle}" RequestNavigate="Hyperlink_OnRequestNavigate">Link</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="1" FontSize="12" Text="{Binding Path=Hash}"/>
|
||||
<TextBox Padding="6 0 0 0" Grid.Column="0" Grid.Row="1" FontSize="15" Text="{Binding Path=Hash}" IsReadOnly="True"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Canvas x:Name="TopLayer" IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
</reactiveUi:ReactiveUserControl>
|
||||
|
@ -1,9 +1,15 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack
|
||||
@ -30,12 +36,14 @@ namespace Wabbajack
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Description, x => x.Description.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Archives, x => x.ModsList.ItemsSource)
|
||||
this.OneWayBind(ViewModel, x => x.SearchResults, x => x.ModsList.ItemsSource)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.InstallSize, x => x.InstallSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.DownloadSize, x => x.DownloadSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.Bind(ViewModel, x => x.SearchTerm, x => x.SearchBar.Text)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
|
||||
@ -55,5 +63,78 @@ namespace Wabbajack
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
//solution from https://stackoverflow.com/questions/5426232/how-can-i-make-wpf-scrollviewer-middle-click-scroll/5446307#5446307
|
||||
|
||||
private bool _isMoving; //False - ignore mouse movements and don't scroll
|
||||
private bool _isDeferredMovingStarted; //True - Mouse down -> Mouse up without moving -> Move; False - Mouse down -> Move
|
||||
private Point? _startPosition;
|
||||
private const double Slowdown = 10; //smaller = faster
|
||||
|
||||
private void ScrollViewer_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (_isMoving)
|
||||
CancelScrolling();
|
||||
else if (e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
|
||||
{
|
||||
if (_isMoving) return;
|
||||
|
||||
_isMoving = true;
|
||||
_startPosition = e.GetPosition(sender as IInputElement);
|
||||
_isDeferredMovingStarted = true;
|
||||
|
||||
AddScrollSign(e.GetPosition(TopLayer).X, e.GetPosition(TopLayer).Y);
|
||||
}
|
||||
}
|
||||
|
||||
private void ScrollViewer_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Released && _isDeferredMovingStarted != true)
|
||||
CancelScrolling();
|
||||
}
|
||||
|
||||
private void ScrollViewer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!_isMoving || !(sender is ScrollViewer sv))
|
||||
return;
|
||||
|
||||
_isDeferredMovingStarted = false;
|
||||
|
||||
var currentPosition = e.GetPosition(sv);
|
||||
if (_startPosition == null)
|
||||
return;
|
||||
|
||||
var offset = currentPosition - _startPosition.Value;
|
||||
offset.Y /= Slowdown;
|
||||
offset.X /= Slowdown;
|
||||
|
||||
sv.ScrollToVerticalOffset(sv.VerticalOffset + offset.Y);
|
||||
sv.ScrollToHorizontalOffset(sv.HorizontalOffset + offset.X);
|
||||
}
|
||||
|
||||
private void CancelScrolling()
|
||||
{
|
||||
_isMoving = false;
|
||||
_startPosition = null;
|
||||
_isDeferredMovingStarted = false;
|
||||
RemoveScrollSign();
|
||||
}
|
||||
|
||||
private void AddScrollSign(double x, double y)
|
||||
{
|
||||
const double size = 50.0;
|
||||
var img = ResourceLinks.MiddleMouseButton.Value;
|
||||
var icon = new Image {Source = img, Width = size, Height = size};
|
||||
//var icon = new Ellipse { Stroke = Brushes.Red, StrokeThickness = 2.0, Width = 20, Height = 20 };
|
||||
|
||||
TopLayer.Children.Add(icon);
|
||||
Canvas.SetLeft(icon, x - size / 2);
|
||||
Canvas.SetTop(icon, y - size / 2);
|
||||
}
|
||||
|
||||
private void RemoveScrollSign()
|
||||
{
|
||||
TopLayer.Children.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@
|
||||
<None Remove="Readme.md" />
|
||||
<None Remove="Resources\GameGridIcons\Fallout4.png" />
|
||||
<None Remove="Resources\GameGridIcons\SkyrimSpecialEdition.png" />
|
||||
<None Remove="Resources\Icons\middle_mouse_button.png" />
|
||||
<None Remove="Resources\MO2Button.png" />
|
||||
<None Remove="Resources\VortexButton.png" />
|
||||
<None Remove="Resources\Wabba_Ded.png" />
|
||||
@ -81,6 +82,7 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\GameGridIcons\Fallout4.png" />
|
||||
<Resource Include="Resources\GameGridIcons\SkyrimSpecialEdition.png" />
|
||||
<Resource Include="Resources\middle_mouse_button.png" />
|
||||
<Resource Include="Resources\MO2Button.png" />
|
||||
<Resource Include="Resources\VortexButton.png" />
|
||||
<Resource Include="Resources\Wabba_Ded.png" />
|
||||
|
Loading…
Reference in New Issue
Block a user