Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Dialog and contributors page #132

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions OpenKh.Tools.BarEditor/ViewModels/BarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public BarViewModel(ToolInvokeDesc desc) :
NewCommand = new RelayCommand(x => { }, x => false);
OpenCommand = new RelayCommand(x => { }, x => false);
SaveCommand = new RelayCommand(x =>
{
var memoryStream = new MemoryStream();
Bar.Write(memoryStream, Items.Select(item => item.Entry));
{
var memoryStream = new MemoryStream();

Bar.Write(memoryStream, Items.Select(item => item.Entry));

var stream = _toolInvokeDesc.SelectedEntry.Stream;

Expand Down Expand Up @@ -100,7 +100,7 @@ public BarViewModel(IEnumerable<BarEntryModel> list) :

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

OpenItemCommand = new RelayCommand(x =>
Expand Down Expand Up @@ -182,13 +182,13 @@ public void OpenFileName(string fileName)

private void SaveToFile(string fileName)
{
var memoryStream = new MemoryStream();
Bar.Write(memoryStream, Items.Select(item => item.Entry));
var memoryStream = new MemoryStream();
Bar.Write(memoryStream, Items.Select(item => item.Entry));

using (var stream = File.Open(fileName, FileMode.Create))
{
memoryStream.Position = 0;
memoryStream.CopyTo(stream);
using (var stream = File.Open(fileName, FileMode.Create))
{
memoryStream.Position = 0;
memoryStream.CopyTo(stream);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

EventsViewModel = new EventsViewModel();
Expand Down
136 changes: 136 additions & 0 deletions OpenKh.Tools.Common/Dialogs/AboutDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<Window x:Class="OpenKh.Tools.Common.Dialogs.AboutDialog"
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:OpenKh.Tools.Common"
xmlns:ext="clr-namespace:Xe.Tools.Wpf.Extensions;assembly=Xe.Tools.Wpf"
xmlns:system="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="{Binding ToolName, StringFormat=About {0}}" Height="Auto" Width="Auto"
Background="#2d2d30" ResizeMode="NoResize"
SizeToContent="WidthAndHeight" AllowsTransparency="True"
WindowStartupLocation="CenterScreen" WindowStyle="None"
Loaded="Window_Loaded">
<Window.Resources>
<system:Double x:Key="textHeaderSize">24.0</system:Double>
<system:Double x:Key="textSize">18.0</system:Double>
<SolidColorBrush x:Key="textForeground" Color="#F1F1F1" />
<SolidColorBrush x:Key="textHyperlink" Color="#569CD6" />

<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="{DynamicResource textSize}" />
<Setter Property="Foreground" Value="{DynamicResource textForeground}" />
</Style>

<Style TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="{DynamicResource textForeground}" />
</Style>

</Window.Resources>

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="24"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="16"/>
</Grid.RowDefinitions>

<DockPanel Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0">
<Canvas DockPanel.Dock="Bottom"
HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<Rectangle RenderTransformOrigin="0.5, 0.5"
Fill="#FF4C4C4F"
Canvas.Left="-56" Canvas.Top="-40"
Width="88" Height="80">

<Rectangle.RenderTransform>
<RotateTransform/>
</Rectangle.RenderTransform>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Rectangle.RenderTransform).(RotateTransform.Angle)"
To="360" Duration="0:0:30" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>
</Canvas>
</DockPanel>

<Button Grid.Column="1" Height="24" VerticalAlignment="Top"
Background="#FFD85050" BorderBrush="#FFD85050"
FontFamily="Segoe MDL2 Assets" Content="&#xE8BB;"
IsCancel="True"/>

<StackPanel Margin="20 20 20 10" Grid.Column="0" Grid.ColumnSpan="2">
<StackPanel>
<StackPanel.RenderTransform>
<TranslateTransform/>
</StackPanel.RenderTransform>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(RenderTransform).(TranslateTransform.X)"
From="-10" To="0" Duration="0:0:0.5" DecelerationRatio="0.5"/>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="-1" To="1" Duration="0:0:0.5" DecelerationRatio="0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>

<TextBlock Text="{Binding ToolName}" FontWeight="Bold" Margin="0 0 0 5"
FontSize="{DynamicResource textHeaderSize}"/>
<TextBlock Text="{Binding Version, StringFormat=Version {0}}" Margin="0 0 0 5"/>
<TextBlock Margin="0 0 0 5">
<Hyperlink NavigateUri="{Binding Website}" ext:HyperlinkExtensions.IsExternal="True" TextDecorations="{x:Null}">
<TextBlock Text="{Binding Website}" Foreground="{DynamicResource textHyperlink}"/>
</Hyperlink>
</TextBlock>
</StackPanel>
<Rectangle Margin="0 10 0 10" Fill="#FF4C4C4F" Height="4"/>
<StackPanel>
<StackPanel.RenderTransform>
<TranslateTransform/>
</StackPanel.RenderTransform>
<StackPanel.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(RenderTransform).(TranslateTransform.X)"
From="-15" To="0" Duration="0:0:0.75" DecelerationRatio="0.5"/>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
From="-0.5" To="1" Duration="0:0:0.75" DecelerationRatio="0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</StackPanel.Triggers>

<TextBlock Text="{Binding Author, StringFormat=Developed by {0}}" Margin="0 0 0 5"/>
<TextBlock Text="{Binding PoweredBy, StringFormat=Powered by {0}}" Margin="0 0 0 5"/>
<TextBlock Margin="0 0 0 5">
<Hyperlink NavigateUri="{Binding AuthorWebsite}"
ext:HyperlinkExtensions.IsExternal="true" TextDecorations="{x:Null}">
<TextBlock Text="{Binding AuthorWebsite}" Foreground="{DynamicResource textHyperlink}"/>
</Hyperlink>
</TextBlock>
</StackPanel>
</StackPanel>

<Rectangle Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" Fill="#FF4C4C4F"/>
</Grid>
</Window>
102 changes: 102 additions & 0 deletions OpenKh.Tools.Common/Dialogs/AboutDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;

namespace OpenKh.Tools.Common.Dialogs
{
/// <summary>
/// Interaction logic for AboutDialog.xaml
/// </summary>
public partial class AboutDialog : Window, INotifyPropertyChanged
{
private string name;
private string version;
private string website;
private string author;
private string powered;
private string authorwebsite;

public AboutDialog(Assembly assembly = null)
{
InitializeComponent();

assembly = assembly ?? Assembly.GetExecutingAssembly();
var assemblyName = assembly.GetName();
var fvi = FileVersionInfo.GetVersionInfo(assembly.Location);

name = fvi.ProductName;
website = fvi.Comments;
version = $"compiled date time or git hash and branch?";
author = "OpenKh blabla";
powered = "blablablabla";
authorwebsite = "https://openkh.dev";

DataContext = this;
MouseDown += (o, e) =>
{
if (e.ChangedButton == MouseButton.Left)
DragMove();
};
}

public event PropertyChangedEventHandler PropertyChanged;

public string ToolName
{
get => name;
set => name = OnPropertyChanged(value);
}

public string Version
{
get => version;
set => version = OnPropertyChanged(value);
}

public string Website
{
get => website;
set => website = OnPropertyChanged(value);
}

public string Author
{
get => author;
set => author = OnPropertyChanged(value);
}

public string PoweredBy
{
get => powered;
set => powered = OnPropertyChanged(value);
}

public string AuthorWebsite
{
get => authorwebsite;
set => authorwebsite = OnPropertyChanged(value);
}

private T OnPropertyChanged<T>(T obj, [CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
return obj;
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
BeginAnimation(OpacityProperty, new DoubleAnimation()
{
From = 0.0,
To = 1.0,
EasingFunction = new CubicEase(),
Duration = new Duration(TimeSpan.FromSeconds(0.5))
});
}
}
}
2 changes: 1 addition & 1 deletion OpenKh.Tools.CtdEditor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

CtdViewModel = new CtdViewModel(_drawHandler);
Expand Down
1 change: 1 addition & 0 deletions OpenKh.Tools.DpdViewer/OpenKh.Tools.DpdViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<ProjectReference Include="..\OpenKh.Kh2\OpenKh.Kh2.csproj" />
<ProjectReference Include="..\OpenKh.Tools.Common\OpenKh.Tools.Common.csproj" />
<ProjectReference Include="..\XeEngine.Tools.Public\Xe.Tools.Wpf\Xe.Tools.Wpf.csproj" />
<ProjectReference Include="..\XeEngine.Tools.Public\Xe.Tools\Xe.Tools.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.DpdViewer/ViewModels/DpdViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public DpdViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ImageViewerViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

ExportCommand = new RelayCommand(x =>
Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.Kh2BattleEditor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

CreateBattleItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public PlaceEditorViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

ExportAsCsvCommand = new RelayCommand(_ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public SystemEditorViewModel()

ExitCommand = new RelayCommand(x => Window.Close());

AboutCommand = new RelayCommand(x => new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog());
AboutCommand = new RelayCommand(x => new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog());

LoadSupportIdxCommand = new RelayCommand(_ => Utilities.Catch(() =>
{
Expand Down
4 changes: 2 additions & 2 deletions OpenKh.Tools.Kh2TextEditor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using OpenKh.Tools.Common;
using OpenKh.Tools.Common;
using OpenKh.Common;
using OpenKh.Kh2;
using OpenKh.Kh2.Contextes;
Expand Down Expand Up @@ -220,7 +220,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);

TextEditor = new TextEditorViewModel();
Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.LayoutViewer/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);
}

Expand Down
2 changes: 1 addition & 1 deletion OpenKh.Tools.ObjentryEditor/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public MainViewModel()

AboutCommand = new RelayCommand(x =>
{
new AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
new OpenKh.Tools.Common.Dialogs.AboutDialog(Assembly.GetExecutingAssembly()).ShowDialog();
}, x => true);
}

Expand Down
Loading