-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
111 lines (101 loc) · 3.93 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows;
using System.Collections;
using Ookii.Dialogs.Wpf;
namespace SongNameCleaner
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ArrayList songList;
public MainWindow()
{
InitializeComponent();
//string a = "Jos", b = null;
//TestLabel.Content = a + b;
//string selectedFolder = @"D:\house";
//selectedFolderLBL.Content = selectedFolder;
//songList = Extractor.GetSongObjects(GetFileNames(selectedFolder));
}
private void browseBTN_Click(object sender, RoutedEventArgs e)
{
VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog();
string selectedFolder = "";
if (dialog.ShowDialog() == true)
{
selectedFolder = dialog.SelectedPath;
}
selectedFolderLBL.Content = selectedFolder;
if (selectedFolder != String.Empty)
{
try
{
songList = Extractor.GetSongObjects(GetFileNames(selectedFolder));
}
catch (Exception)
{
MessageBox.Show("Unable to find or access this folder. It might not exist or you might not have sufficient permissions to access it.\n\rNo Files where selected. Please try again.", "Folder inaccessible", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
private void FilenamesRewriteBTN_Click(object sender, RoutedEventArgs e)
{
fileNamesResultLBL.Content = "Working...";
try
{
int result = Modifier.Rename(songList);
if (result == 0)
fileNamesResultLBL.Content = "Completed.";
else if (result == 1)
fileNamesResultLBL.Content = "Completed with errors. " + result + " file was not renamed.";
else
fileNamesResultLBL.Content = "Completed with errors. " + result + " files where not renamed.";
}
catch (NullReferenceException ex)
{
fileNamesResultLBL.Content = "No files where selected or processed.";
Console.Error.Write(ex.StackTrace);
}
}
private void Id3RewriteBTN_Click(object sender, RoutedEventArgs e)
{
id3ResultLBL.Content = "Working...";
try
{
int result = Modifier.WriteNewId3Tags(songList);
if (result == 0)
id3ResultLBL.Content = "Completed.";
else if (result == 1)
id3ResultLBL.Content = "Completed with errors. The ID3-tags of " + result + " file could not be rewritten.";
else
id3ResultLBL.Content = "Completed with errors. The ID3-tags of " + result + " files could not be rewritten.";
}
catch (NullReferenceException ex)
{
id3ResultLBL.Content = "No files where selected or processed.";
Console.Error.Write(ex.StackTrace);
}
}
private string[] GetFileNames(string selectedFolder)
{
//string[] absolutePathsSongs = Directory.GetFiles(selectedFolder, "*.*", SearchOption.AllDirectories);
string[] absolutePathsSongs = null;
absolutePathsSongs = Directory.GetFiles(selectedFolder, "*.*");
return absolutePathsSongs;
}
}
}