Skip to content

Commit 440ff10

Browse files
committed
Cleanup, fix imported folders not persisting folder names
1 parent eaa4328 commit 440ff10

16 files changed

Lines changed: 918 additions & 932 deletions

BatchImageProcessor.CLI/Program.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.Drawing;
54
using System.IO;
65
using System.Linq;
@@ -166,15 +165,14 @@ private static void Main(string[] args)
166165
x.WatermarkOptions.WatermarkFont = new Font(fontname, fontsize);
167166

168167
if ((extra == null || !extra.Any()) && string.IsNullOrEmpty(manifest)) return;
169-
170-
Debug.Assert(extra != null, "extra != null");
171-
var badfiles = extra.Where(o => !File.Exists(o)).ToList();
172-
if (badfiles.Count > 0)
168+
169+
var badfiles = extra?.Where(o => !File.Exists(o)).ToList();
170+
if (badfiles?.Count > 0)
173171
{
174172
Console.WriteLine("Bad Filename(s):");
175173
badfiles.ForEach(o => Console.Write("\t\"{0}\"", o));
176174
}
177-
if (extra.Any())
175+
if (extra != null && extra.Any())
178176
files.AddRange(extra);
179177
else
180178
{

BatchImageProcessor.Model/File.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Linq;
1+
using System.Collections.Generic;
52
using BatchImageProcessor.Model.Interface;
63
using BatchImageProcessor.Model.Types;
74
using BatchImageProcessor.Model.Types.Enums;
@@ -30,16 +27,16 @@ public class File : IoObject, IFolderable, IFile
3027
public bool IsValidName { get; set; }
3128

3229
public File(string path) : base(path)
33-
{
30+
{
3431
Options.OutputOptions.OutputFormat = Format.Default;
35-
}
32+
}
3633

37-
#region Properties
34+
#region Properties
3835

39-
40-
public int ImageNumber { get; set; }
41-
public string OutputPath { get; set; }
36+
37+
public int ImageNumber { get; set; }
38+
public string OutputPath { get; set; }
4239

43-
#endregion
40+
#endregion
4441
}
4542
}

BatchImageProcessor.Model/IoObject.cs

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@ namespace BatchImageProcessor.Model
99
{
1010
public abstract class IoObject : INotifyPropertyChanged, IDisposable, IIoObject
1111
{
12-
private readonly FileSystemWatcher _watcher;
13-
private string _path;
12+
private readonly FileSystemWatcher _watcher;
13+
private string _path;
1414
private string _name;
1515

1616
protected IoObject(string path)
17-
{
18-
var file = System.IO.File.Exists(path);
19-
if (!(file || Directory.Exists(path)))
20-
throw new FileNotFoundException($@"File/folder at ""{path}"" does not exist.");
17+
{
18+
var file = System.IO.File.Exists(path);
19+
if (!(file || Directory.Exists(path)))
20+
throw new FileNotFoundException($@"File/folder at ""{path}"" does not exist.");
2121

22-
IsFile = file;
23-
Path = path;
22+
IsFile = file;
23+
Path = path;
2424

25-
Name = GetName(path);
25+
Name = GetName(path);
2626

2727

28-
var directoryInfo = new FileInfo(Path).Directory;
29-
if (directoryInfo != null)
30-
_watcher = new FileSystemWatcher(IsFile ? directoryInfo.FullName : Path);
31-
if (IsFile)
32-
_watcher.Filter = System.IO.Path.GetFileName(path);
28+
var directoryInfo = new FileInfo(Path).Directory;
29+
if (directoryInfo != null)
30+
_watcher = new FileSystemWatcher(IsFile ? directoryInfo.FullName : Path);
31+
if (IsFile)
32+
_watcher.Filter = System.IO.Path.GetFileName(path);
3333

34-
_watcher.Renamed += watcher_Renamed;
35-
_watcher.Deleted += Watcher_Deleted;
36-
_watcher.EnableRaisingEvents = true;
37-
}
34+
_watcher.Renamed += watcher_Renamed;
35+
_watcher.Deleted += Watcher_Deleted;
36+
_watcher.EnableRaisingEvents = true;
37+
}
3838

39-
protected IoObject()
40-
{
41-
}
39+
protected IoObject()
40+
{
41+
}
4242

4343
public string Name
4444
{
@@ -47,33 +47,34 @@ public string Name
4747
}
4848

4949
public string Path
50-
{
51-
get { return _path; }
52-
set
53-
{
54-
_path = value;
50+
{
51+
get { return _path; }
52+
set
53+
{
54+
_path = value;
55+
// ReSharper disable once ExplicitCallerInfoArgument
5556
PropChanged(nameof(Name));
5657
PropChanged();
57-
}
58-
}
58+
}
59+
}
5960

60-
public bool IsFile { get; set; }
61+
public bool IsFile { get; set; }
6162

62-
public void Dispose()
63-
{
64-
_watcher.Dispose();
65-
}
63+
public void Dispose()
64+
{
65+
_watcher.Dispose();
66+
}
6667

67-
private static void Watcher_Deleted(object sender, FileSystemEventArgs e)
68-
{
69-
}
68+
private static void Watcher_Deleted(object sender, FileSystemEventArgs e)
69+
{
70+
}
7071

71-
private void watcher_Renamed(object sender, RenamedEventArgs e)
72-
{
73-
if (!IsFile) return;
74-
Path = e.FullPath;
75-
_watcher.Filter = e.Name;
76-
}
72+
private void watcher_Renamed(object sender, RenamedEventArgs e)
73+
{
74+
if (!IsFile) return;
75+
Path = e.FullPath;
76+
_watcher.Filter = e.Name;
77+
}
7778
public static string GetName(string path)
7879
{
7980
if (Directory.Exists(path) &&

BatchImageProcessor/BatchImageProcessor.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<StartupObject>BatchImageProcessor.EntryPoint</StartupObject>
7070
</PropertyGroup>
7171
<PropertyGroup>
72-
<ManifestCertificateThumbprint>B7884CF99F3EBB4809520DFEAED585E96CEDD123</ManifestCertificateThumbprint>
72+
<ManifestCertificateThumbprint>5FF27F20160E587AD4BF8F9CD3DA2F4E1483EE95</ManifestCertificateThumbprint>
7373
</PropertyGroup>
7474
<PropertyGroup>
7575
<ManifestKeyFile>BatchImageProcessor_TemporaryKey.pfx</ManifestKeyFile>
@@ -214,6 +214,7 @@
214214
<SubType>Designer</SubType>
215215
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
216216
</EmbeddedResource>
217+
<None Include="BatchImageProcessor_1_TemporaryKey.pfx" />
217218
<None Include="BatchImageProcessor_TemporaryKey.pfx" />
218219
<None Include="packages.config" />
219220
<None Include="Properties\Settings.settings">
16 Bytes
Binary file not shown.

BatchImageProcessor/Controls/SplitButton.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ public SplitButton()
1717
DataContext = this;
1818
}
1919

20-
public event Action<Object, EventArgs> Click = delegate { };
20+
public event Action<object, EventArgs> Click = delegate { };
2121

2222
private void Button_Click_1(object sender, RoutedEventArgs e)
2323
{
24+
if (ContextMenu == null) return;
2425
ContextMenu.IsEnabled = true;
2526
ContextMenu.PlacementTarget = (sender as Button);
2627
ContextMenu.Placement = PlacementMode.Bottom;

0 commit comments

Comments
 (0)