wabbajack/Wabbajack/Views/ModeSelectionWindow.xaml.cs

98 lines
3.2 KiB
C#
Raw Normal View History

2019-11-21 14:25:40 +00:00
using System.ComponentModel;
2019-09-27 11:51:37 +00:00
using System.Diagnostics;
using System.IO;
2019-10-07 17:33:34 +00:00
using System.Windows;
2019-09-27 04:07:54 +00:00
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
2019-10-20 11:26:42 +00:00
using Wabbajack.UI;
2019-09-27 04:07:54 +00:00
namespace Wabbajack
{
/// <summary>
/// Interaction logic for ModeSelectionWindow.xaml
/// </summary>
public partial class ModeSelectionWindow : Window
{
2019-11-21 15:45:00 +00:00
MainSettings _settings;
2019-10-20 11:26:42 +00:00
2019-09-27 04:07:54 +00:00
public ModeSelectionWindow()
{
InitializeComponent();
2019-10-22 01:08:26 +00:00
var bannerImage = UIUtils.BitmapImageFromResource("Wabbajack.Resources.banner_small_dark.png");
2019-09-27 11:51:37 +00:00
Banner.Source = bannerImage;
2019-10-22 01:08:26 +00:00
var patreonIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.patreon_light.png");
2019-09-27 11:51:37 +00:00
Patreon.Source = patreonIcon;
2019-10-22 01:08:26 +00:00
var githubIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.github_light.png");
2019-09-27 11:51:37 +00:00
GitHub.Source = githubIcon;
2019-10-22 01:08:26 +00:00
var discordIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.discord.png");
2019-09-27 11:51:37 +00:00
Discord.Source = discordIcon;
2019-10-20 11:26:42 +00:00
2019-11-21 15:45:00 +00:00
_settings = MainSettings.LoadSettings();
2019-11-02 20:55:14 +00:00
DataContext = new ModeSelectionWindowVM();
2019-09-27 04:07:54 +00:00
}
private void CreateModlist_Click(object sender, RoutedEventArgs e)
{
ShutdownOnClose = false;
2019-11-21 15:45:00 +00:00
var window = new MainWindow(RunMode.Compile, null, _settings);
2019-11-21 15:04:33 +00:00
window.Left = Left;
window.Top = Top;
window.Show();
Close();
2019-09-27 04:07:54 +00:00
}
private void InstallModlist_Click(object sender, RoutedEventArgs e)
{
2019-11-02 20:55:14 +00:00
var result = ((ModeSelectionWindowVM)DataContext).Download();
2019-10-20 19:30:39 +00:00
if (result != null)
{
OpenMainWindowInstall(result);
2019-10-20 19:30:39 +00:00
}
2019-09-27 04:07:54 +00:00
}
private void InstallFromList_Click(object sender, RoutedEventArgs e)
{
OpenMainWindowInstall(
UIUtils.OpenFileDialog(
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}",
2019-11-21 15:45:00 +00:00
initialDirectory: _settings.Installer.LastInstalledListLocation));
}
private void OpenMainWindowInstall(string file)
{
if (file == null) return;
ShutdownOnClose = false;
2019-11-21 15:45:00 +00:00
_settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
var window = new MainWindow(RunMode.Install, file, _settings);
2019-11-21 15:04:33 +00:00
window.Left = Left;
window.Top = Top;
window.Show();
Close();
}
2019-09-27 04:07:54 +00:00
public void Close_Window(object sender, CancelEventArgs e)
{
if (ShutdownOnClose)
Application.Current.Shutdown();
}
public bool ShutdownOnClose { get; set; } = true;
2019-09-27 11:51:37 +00:00
private void GitHub_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
2019-10-01 03:04:21 +00:00
Process.Start("https://github.com/wabbajack-tools/wabbajack");
2019-09-27 11:51:37 +00:00
}
private void Patreon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Process.Start("https://www.patreon.com/user?u=11907933");
}
private void Discord_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Process.Start("https://discord.gg/zgbrkmA");
}
2019-09-27 04:07:54 +00:00
}
}