Skip to content

Commit

Permalink
Update AboutWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Jan 6, 2024
1 parent 3d82c46 commit 3b21422
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 34 deletions.
33 changes: 15 additions & 18 deletions src/HUDMerger/AboutWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<Window x:Class="HUDMerger.AboutWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:HUDMerger" mc:Ignorable="d" Title="About HUD Merger" SizeToContent="WidthAndHeight" Icon="Resources\favicon.ico" WindowStartupLocation="CenterScreen">
<Grid>
<StackPanel Margin="50,10">
<StackPanel.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
</StackPanel.Resources>
<Image Source="Resources\favicon.ico" Width="64" Height="64" Margin="0,0,0,10" />
<Label FontSize="28">HUD Merger</Label>
<Label FontSize="15">Version 1.2.6</Label>
<Label FontSize="15">Revan</Label>
<WrapPanel HorizontalAlignment="Center" Margin="0,5,0,5" RenderOptions.BitmapScalingMode="Fant">
<Image Source="Resources/Images/github.png" Width="42" Margin="5" Cursor="Hand" MouseLeftButtonUp="Open_Github" />
<Image Source="Resources/Images/teamfortresstv.png" Width="42" Margin="5" Cursor="Hand" MouseLeftButtonUp="Open_TeamFortressTV" />
</WrapPanel>
</StackPanel>
</Grid>
<Window x:Class="HUDMerger.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HUDMerger"
xmlns:views="clr-namespace:HUDMerger.Views"
mc:Ignorable="d"
Title="About HUD Merger"
SizeToContent="WidthAndHeight"
Icon="Resources\favicon.ico"
WindowStartupLocation="CenterScreen">
<Grid>
<views:AboutWindowView />
</Grid>
</Window>
13 changes: 1 addition & 12 deletions src/HUDMerger/AboutWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System;
using System.Windows;
using System.Windows.Input;

namespace HUDMerger;

Expand All @@ -13,14 +12,4 @@ public AboutWindow()
{
InitializeComponent();
}

private void Open_Github(object sender, MouseButtonEventArgs e)
{
Process.Start("explorer", "https://github.com/cooolbros/hud-merger");
}

private void Open_TeamFortressTV(object sender, MouseButtonEventArgs e)
{
Process.Start("explorer", "https://www.teamfortress.tv/60220/hud-merger");
}
}
28 changes: 28 additions & 0 deletions src/HUDMerger/ViewModels/AboutWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Diagnostics;
using System.Windows.Input;
using Microsoft.Toolkit.Mvvm.Input;

namespace HUDMerger.ViewModels;

public class AboutWindowViewModel : ViewModelBase
{
public ICommand OpenGithubCommand { get; }
public ICommand OpenTeamFortressTVCommand { get; }

public AboutWindowViewModel()
{
OpenGithubCommand = new RelayCommand(OpenGithub);
OpenTeamFortressTVCommand = new RelayCommand(OpenTeamFortressTV);
}

private void OpenGithub()
{
Process.Start("explorer", "https://github.com/cooolbros/hud-merger");
}

private void OpenTeamFortressTV()
{
Process.Start("explorer", "https://www.teamfortress.tv/60220/hud-merger");
}
}
15 changes: 11 additions & 4 deletions src/HUDMerger/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MainWindowViewModel()
ShowSettingsWindowCommand = new RelayCommand(ShowSettingsWindow);
QuitCommand = new RelayCommand(Application.Current.Shutdown);

ShowAboutWindowCommand = new RelayCommand(() => ShowWindow(new AboutWindow()));
ShowAboutWindowCommand = new RelayCommand(ShowAboutWindow);

SourceHUDInfoViewModel = new HUDInfoViewModel("from", SourceHUD);
TargetHUDInfoViewModel = new HUDInfoViewModel("to", TargetHUD);
Expand Down Expand Up @@ -117,10 +117,17 @@ void OnClose(object? sender, EventArgs args)
settingsWindow.Show();
}

private static void ShowWindow(Window window)
private void ShowAboutWindow()
{
window.Owner ??= Application.Current.MainWindow;
window.Show();
using AboutWindowViewModel aboutWindowViewModel = new();

AboutWindow aboutWindow = new()
{
DataContext = aboutWindowViewModel,
Owner = Application.Current.MainWindow
};

aboutWindow.Show();
}

private void LoadSourceHUD()
Expand Down
58 changes: 58 additions & 0 deletions src/HUDMerger/Views/AboutWindowView.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<UserControl x:Class="HUDMerger.Views.AboutWindowView"
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:HUDMerger.Views"
xmlns:viewmodels="clr-namespace:HUDMerger.ViewModels"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type={x:Type viewmodels:AboutWindowViewModel}}">
<Grid>
<StackPanel Margin="50,10">
<StackPanel.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style x:Key="ImageButton" TargetType="{x:Type Button}">
<Setter Property="Margin" Value="5" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="buttonBorder" Background="Transparent" BorderThickness="0" BorderBrush="Transparent" SnapsToDevicePixels="True">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<ControlTemplate.Triggers>
<!-- MouseOver -->
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="buttonBorder" Property="Background" Value="Transparent" />
</Trigger>
<!-- Pressed -->
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="buttonBorder" Property="Background" Value="Transparent" />
</Trigger>
<!-- Disabled -->
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="buttonBorder" Property="Background" Value="Transparent" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</StackPanel.Resources>
<Image Source="/Resources/favicon.ico" Width="64" Height="64" Margin="0,0,0,10" />
<Label FontSize="28">HUD Merger</Label>
<Label FontSize="15">Version 1.2.6</Label>
<Label FontSize="15">Revan</Label>
<WrapPanel HorizontalAlignment="Center" Margin="0,5,0,5" RenderOptions.BitmapScalingMode="Fant">
<Button Style="{StaticResource ImageButton}" Command="{Binding OpenGithubCommand}">
<Image Source="/Resources/Images/github.png" Width="42" Height="42" />
</Button>
<Button Style="{StaticResource ImageButton}" Command="{Binding OpenTeamFortressTVCommand}">
<Image Source="/Resources/Images/teamfortresstv.png" Width="42" Height="42" />
</Button>
</WrapPanel>
</StackPanel>
</Grid>
</UserControl>
15 changes: 15 additions & 0 deletions src/HUDMerger/Views/AboutWindowView.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Windows.Controls;

namespace HUDMerger.Views;

/// <summary>
/// Interaction logic for AboutWindowView.xaml
/// </summary>
public partial class AboutWindowView : UserControl
{
public AboutWindowView()
{
InitializeComponent();
}
}

0 comments on commit 3b21422

Please sign in to comment.