diff --git a/png2xnb.sln b/png2xnb.sln index bdf0b2d..a812a11 100644 --- a/png2xnb.sln +++ b/png2xnb.sln @@ -19,8 +19,8 @@ Global {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Debug|x86.Build.0 = Debug|Any CPU {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|Any CPU.Build.0 = Release|Any CPU - {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|x86.ActiveCfg = Release|x86 - {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|x86.Build.0 = Release|x86 + {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|x86.ActiveCfg = Release|Any CPU + {E6E83894-E69B-41E5-B6EA-4A9BFD22E8F3}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/png2xnb/Models/FileWatcher.cs b/png2xnb/Models/FileWatcher.cs index 66c5e11..6d701f0 100644 --- a/png2xnb/Models/FileWatcher.cs +++ b/png2xnb/Models/FileWatcher.cs @@ -14,7 +14,6 @@ public class FileWatcher : FileSystemWatcher public FileWatcher() : base() { NotifyFilter = - NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; @@ -39,7 +38,7 @@ public void Update(string path) else { Path = path; - Filter = "*.*"; + Filter = "*.png"; IncludeSubdirectories = true; } diff --git a/png2xnb/ViewModels/MainWindowViewModel.cs b/png2xnb/ViewModels/MainWindowViewModel.cs index 2fd960d..d648411 100644 --- a/png2xnb/ViewModels/MainWindowViewModel.cs +++ b/png2xnb/ViewModels/MainWindowViewModel.cs @@ -471,47 +471,75 @@ public IEnumerable GetErrors(string propertyName) private void OnFileChanged(object sender, FileSystemEventArgs e) { - Debug.WriteLine("Changed: " + e.FullPath); - string relative = GetRelativePath(e.FullPath, Input); - string newfolder = Output + "\\" + Path.GetDirectoryName(relative); - string newFile = newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"; - Debug.WriteLine("Changed: " + newFile); + try + { + //Debug.WriteLine("Changed: " + e.FullPath); + string relative = GetRelativePath(e.FullPath, Input); + string newfolder = Output + "\\" + Path.GetDirectoryName(relative); + string newFile = newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"; + //Debug.WriteLine("Changed: " + newFile); - RunConvert(e.FullPath, newFile, Settings.Instance.IsCompressed, Settings.Instance.Format, Settings.Instance.PremultiplyAlpha); + RunConvert(e.FullPath, newFile, Settings.Instance.IsCompressed, Settings.Instance.Format, Settings.Instance.PremultiplyAlpha); + } + catch (Exception ex) + { + MessageBox.Show(ex.StackTrace, ex.Message); + } } private void OnFileCreated(object sender, FileSystemEventArgs e) { - Debug.WriteLine("Created: " + e.FullPath); - string relative = GetRelativePath(e.FullPath, Input); - string newfolder = Output + "\\" + Path.GetDirectoryName(relative); - Debug.WriteLine("Created: " + newfolder); - - RunConvert(e.FullPath, newfolder, Settings.Instance.IsCompressed, Settings.Instance.Format, Settings.Instance.PremultiplyAlpha); + try + { + //Debug.WriteLine("Created: " + e.FullPath); + string relative = GetRelativePath(e.FullPath, Input); + string newfolder = Output + "\\" + Path.GetDirectoryName(relative); + //Debug.WriteLine("Created: " + newfolder); + + RunConvert(e.FullPath, newfolder, Settings.Instance.IsCompressed, Settings.Instance.Format, Settings.Instance.PremultiplyAlpha); + } + catch (Exception ex) + { + MessageBox.Show(ex.StackTrace, ex.Message); + } } private void OnFileDeleted(object sender, FileSystemEventArgs e) { - Debug.WriteLine("Deleted: " + e.FullPath); - string relative = GetRelativePath(e.FullPath, Input); - string newfolder = Output + "\\" + Path.GetDirectoryName(relative); - Debug.WriteLine("Deleted: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); - - File.Delete(newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); + try + { + //Debug.WriteLine("Deleted: " + e.FullPath); + string relative = GetRelativePath(e.FullPath, Input); + string newfolder = Output + "\\" + Path.GetDirectoryName(relative); + //Debug.WriteLine("Deleted: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); + + File.Delete(newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); + } + catch (Exception ex) + { + MessageBox.Show(ex.StackTrace, ex.Message); + } } private void OnFileRenamed(object sender, RenamedEventArgs e) { - Debug.WriteLine("Renamed: " + e.OldFullPath); - string relative = GetRelativePath(e.OldFullPath, Input); - string newfolder = Output + "\\" + Path.GetDirectoryName(relative); - Debug.WriteLine("Renamed from: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.OldFullPath) + ".xnb"); - Debug.WriteLine("Renamed to: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); - - File.Move( - newfolder + "\\" + Path.GetFileNameWithoutExtension(e.OldFullPath) + ".xnb", - newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb" - ); + try + { + //Debug.WriteLine("Renamed: " + e.OldFullPath); + string relative = GetRelativePath(e.OldFullPath, Input); + string newfolder = Output + "\\" + Path.GetDirectoryName(relative); + //Debug.WriteLine("Renamed from: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.OldFullPath) + ".xnb"); + //Debug.WriteLine("Renamed to: " + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb"); + + File.Move( + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.OldFullPath) + ".xnb", + newfolder + "\\" + Path.GetFileNameWithoutExtension(e.FullPath) + ".xnb" + ); + } + catch (Exception ex) + { + MessageBox.Show(ex.StackTrace, ex.Message); + } } #endregion } diff --git a/png2xnb/png2xnb.csproj b/png2xnb/png2xnb.csproj index 96a045d..f55151e 100644 --- a/png2xnb/png2xnb.csproj +++ b/png2xnb/png2xnb.csproj @@ -6,6 +6,7 @@ 10.0 true applicationIcon.ico + README.md