70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using JDSongConverter.Converters;
|
|
using JD.Core;
|
|
using Application = TeaBox.ObjectModel.Application;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
|
|
namespace JDSongConverter.View
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MapSelector.xaml
|
|
/// </summary>
|
|
public partial class MapSelectorControl : UserControl
|
|
{
|
|
private readonly CollectionViewSource _collectionViewSource;
|
|
|
|
public MapSelectorControl()
|
|
{
|
|
InitializeComponent();
|
|
|
|
_collectionViewSource = FindResource("cvsSongs") as CollectionViewSource;
|
|
|
|
SongsDirs.Text = DataRoot.ToAbsolutePath("world/MAPS/");
|
|
OutputDir.Text = System.IO.Path.GetFullPath(DataRoot.ToAbsolutePath("world/MAPS/"));
|
|
OutputVersion.ItemsSource = new List<JDSongVersion> { JDSongVersion.JD2016, JDSongVersion.JD2015, JDSongVersion.JD5 };
|
|
}
|
|
|
|
private JDSongCollection Songs { get; set; }
|
|
|
|
private void Start_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var songs = DataGrid.SelectedItems.OfType<JDSong>();
|
|
if (!songs.Any())
|
|
{
|
|
songs = Songs;
|
|
}
|
|
var context = new ConversionContext
|
|
{
|
|
Songs = new JDSongCollection(songs),
|
|
OutputDir = OutputDir.Text,
|
|
OutputVersion = (JDSongVersion)OutputVersion.SelectedItem
|
|
};
|
|
ConversionMacros.CallConversionMacro(context);
|
|
|
|
}
|
|
|
|
private void Refresh()
|
|
{
|
|
string[] songsDirs = SongsDirs.Text.Split(';');
|
|
Application.Main.Dispatcher.DoLongOperationAsync(() =>
|
|
{
|
|
var finder = new JDSongFinder();
|
|
var songCollection = new JDSongCollection(finder.FindSongs(songsDirs));
|
|
Application.Main.Dispatcher.DispatchAsync(() =>
|
|
{
|
|
Songs = songCollection;
|
|
if (_collectionViewSource != null) _collectionViewSource.Source = Songs;
|
|
|
|
}, forceAsync:true);
|
|
});
|
|
}
|
|
|
|
private void SongsDirs_TextChanged(object sender, TextChangedEventArgs e)
|
|
{
|
|
Refresh();
|
|
}
|
|
}
|
|
}
|