wabbajack/Wabbajack/UI/ModlistPropertiesWindow.xaml.cs

75 lines
2.3 KiB
C#
Raw Normal View History

2019-10-07 12:02:31 +00:00
using System;
2019-10-07 12:13:53 +00:00
using System.ComponentModel;
2019-10-07 12:02:31 +00:00
using System.Windows;
using System.Windows.Media.Imaging;
namespace Wabbajack
{
/// <summary>
/// Interaction logic for ModlistPropertiesWindow.xaml
/// </summary>
public partial class ModlistPropertiesWindow : Window
{
internal string newBannerFile;
internal readonly AppState state;
internal ModlistPropertiesWindow(AppState _state)
2019-10-07 12:02:31 +00:00
{
InitializeComponent();
var bannerImage = UIUtils.BitmapImageFromResource("Wabbajack.UI.banner.png");
2019-10-07 12:40:19 +00:00
SplashScreenProperty.Source = bannerImage;
newBannerFile = null;
state = _state;
2019-10-07 12:02:31 +00:00
}
2019-10-07 12:13:53 +00:00
2019-10-07 12:40:19 +00:00
private void SetSplashScreen_Click(object sender, RoutedEventArgs e)
{
var file = UIUtils.OpenFileDialog("Banner image|*.png");
2019-10-07 17:33:34 +00:00
if (file != null)
2019-10-07 12:40:19 +00:00
{
newBannerFile = file;
2019-10-07 12:40:19 +00:00
SplashScreenProperty.Source = new BitmapImage(new Uri(file));
}
}
private void SaveProperties_Click(object sender, RoutedEventArgs e)
{
if (state.UIReady)
{
if (newBannerFile != null)
{
BitmapImage splashScreen = new BitmapImage(new Uri(newBannerFile));
state.newImagePath = newBannerFile;
2019-10-13 22:08:50 +00:00
state.Slideshow.Image = splashScreen;
}
2019-10-13 22:08:50 +00:00
state.Slideshow.ModName = ModlistNameProperty.Text;
state.Slideshow.Summary = ModlistDescriptionProperty.Text;
state.Slideshow.AuthorName = ModlistAuthorProperty.Text;
2019-10-14 01:15:41 +00:00
state.Slideshow.NexusSiteURL = ModlistWebsiteProperty.Text;
2019-10-11 12:57:42 +00:00
state.readmePath = ModlistReadmeProperty.Text;
state.ChangedProperties = true;
Hide();
}
}
public bool IsClosed { get; private set; }
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
IsClosed = true;
}
2019-10-11 12:57:42 +00:00
private void ChooseReadme_Click(object sender, RoutedEventArgs e)
{
var file = UIUtils.OpenFileDialog("Readme|*.txt");
if (file != null)
{
ModlistReadmeProperty.Text = file;
}
}
2019-10-07 12:02:31 +00:00
}
}