48 lines
1.3 KiB
C#

using System.Windows;
using System.Windows.Controls;
namespace MyApp
{
/// <summary>
/// Interaction logic for EditWindow.xaml
/// </summary>
public partial class EditWindow : Window
{
ProgramData data;
internal EditWindow(ProgramData data)
{
InitializeComponent();
this.data = data;
this.DataContext = data.SelectedItem;
comboBox.ItemsSource = data.GenreList;
}
private void Image_Button_Click(object sender, RoutedEventArgs e)
{
var dialog = new Microsoft.Win32.OpenFileDialog();
//dialog.FileName = "Document"; // Default file name
dialog.DefaultExt = "*.*"; // Default file extension
dialog.Filter = "Image Files|*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIFF;*.PNG;";
bool? result = dialog.ShowDialog();
if (result == true)
{
data.SelectedItem.IconSource = dialog.FileName;
}
}
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if(comboBox.SelectedItem is string s)
{
data.SelectedItem.Genra = s;
}
}
}
}