├── .gitattributes
├── .gitignore
├── README.md
├── TeslaTags.Gui
├── App.config
├── App.xaml
├── App.xaml.cs
├── Icons
│ ├── AllSizes.ico
│ ├── Artboard 1128.png
│ ├── Artboard 116.png
│ ├── Artboard 124.png
│ ├── Artboard 132.png
│ ├── Artboard 148.png
│ ├── Artboard 164.png
│ ├── noun_464493_cc.ai
│ └── noun_464493_cc.svg
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ └── AssemblyInfo.cs
├── Services
│ ├── IConfigurationService.cs
│ ├── IDialogService.cs
│ ├── ILiveConfigurationService.cs
│ └── WindowService.cs
├── TeslaTags.Gui.csproj
├── ViewModel
│ ├── BaseViewModel.cs
│ ├── DesignTeslaTagService.cs
│ ├── DirectoryViewModel.Properties.cs
│ ├── DirectoryViewModel.cs
│ ├── GenreRulesViewModel.cs
│ ├── MainViewModel.Properties.cs
│ ├── MainViewModel.cs
│ └── ViewModelLocator.cs
├── Views
│ └── DataGridBehavior.AutoScroll.cs
├── app.manifest
└── packages.config
├── TeslaTags.QuickFix
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── TeslaTags.QuickFix.csproj
└── packages.config
├── TeslaTags.Tests
├── DiscTrackNumberTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── TeslaTags.Tests.csproj
└── packages.config
├── TeslaTags.sln
├── TeslaTags
├── App.config
├── Extensions.cs
├── Files
│ ├── FlacLoadedFile.cs
│ ├── GenericId3LoadedFile.cs
│ ├── LoadedFile.cs
│ ├── Mp4LoadedFile.cs
│ ├── MpegLoadedFile.cs
│ ├── OggLoadedFile.cs
│ ├── RiffLoadedFile.cs
│ └── TagLibLoadedFile.cs
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Services
│ ├── IDirectoryPredicate.cs
│ ├── ITeslaTagService.cs
│ ├── Pocos
│ │ ├── DirectoryResult.cs
│ │ ├── Message.cs
│ │ └── MessageExtensions.cs
│ ├── RealTeslaTagService.cs
│ ├── RealTeslaTagUtilityService.cs
│ └── TeslaTagService
│ │ ├── DiscAndTrackNumberHelper.cs
│ │ ├── GenreRules.cs
│ │ ├── RecoveryTag.cs
│ │ ├── Retagger.cs
│ │ ├── RetaggingOptions.cs
│ │ ├── TagExtensions.cs
│ │ ├── TagWriter.cs
│ │ └── TeslaTagFolderProcessor.cs
├── TagExperiments.cs
├── TeslaTags.csproj
├── Values.cs
└── packages.config
└── packages-other
└── ShellFileDialogs
├── ShellFileDialogs.dll
└── ShellFileDialogs.pdb
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | project.fragment.lock.json
46 | artifacts/
47 |
48 | *_i.c
49 | *_p.c
50 | *_i.h
51 | *.ilk
52 | *.meta
53 | *.obj
54 | *.pch
55 | *.pdb
56 | *.pgc
57 | *.pgd
58 | *.rsp
59 | *.sbr
60 | *.tlb
61 | *.tli
62 | *.tlh
63 | *.tmp
64 | *.tmp_proj
65 | *.log
66 | *.vspscc
67 | *.vssscc
68 | .builds
69 | *.pidb
70 | *.svclog
71 | *.scc
72 |
73 | # Chutzpah Test files
74 | _Chutzpah*
75 |
76 | # Visual C++ cache files
77 | ipch/
78 | *.aps
79 | *.ncb
80 | *.opendb
81 | *.opensdf
82 | *.sdf
83 | *.cachefile
84 | *.VC.db
85 | *.VC.VC.opendb
86 |
87 | # Visual Studio profiler
88 | *.psess
89 | *.vsp
90 | *.vspx
91 | *.sap
92 |
93 | # TFS 2012 Local Workspace
94 | $tf/
95 |
96 | # Guidance Automation Toolkit
97 | *.gpState
98 |
99 | # ReSharper is a .NET coding add-in
100 | _ReSharper*/
101 | *.[Rr]e[Ss]harper
102 | *.DotSettings.user
103 |
104 | # JustCode is a .NET coding add-in
105 | .JustCode
106 |
107 | # TeamCity is a build add-in
108 | _TeamCity*
109 |
110 | # DotCover is a Code Coverage Tool
111 | *.dotCover
112 |
113 | # NCrunch
114 | _NCrunch_*
115 | .*crunch*.local.xml
116 | nCrunchTemp_*
117 |
118 | # MightyMoose
119 | *.mm.*
120 | AutoTest.Net/
121 |
122 | # Web workbench (sass)
123 | .sass-cache/
124 |
125 | # Installshield output folder
126 | [Ee]xpress/
127 |
128 | # DocProject is a documentation generator add-in
129 | DocProject/buildhelp/
130 | DocProject/Help/*.HxT
131 | DocProject/Help/*.HxC
132 | DocProject/Help/*.hhc
133 | DocProject/Help/*.hhk
134 | DocProject/Help/*.hhp
135 | DocProject/Help/Html2
136 | DocProject/Help/html
137 |
138 | # Click-Once directory
139 | publish/
140 |
141 | # Publish Web Output
142 | *.[Pp]ublish.xml
143 | *.azurePubxml
144 | # TODO: Comment the next line if you want to checkin your web deploy settings
145 | # but database connection strings (with potential passwords) will be unencrypted
146 | #*.pubxml
147 | *.publishproj
148 |
149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
150 | # checkin your Azure Web App publish settings, but sensitive information contained
151 | # in these scripts will be unencrypted
152 | PublishScripts/
153 |
154 | # NuGet Packages
155 | *.nupkg
156 | # The packages folder can be ignored because of Package Restore
157 | **/packages/*
158 | # except build/, which is used as an MSBuild target.
159 | !**/packages/build/
160 | # Uncomment if necessary however generally it will be regenerated when needed
161 | #!**/packages/repositories.config
162 | # NuGet v3's project.json files produces more ignoreable files
163 | *.nuget.props
164 | *.nuget.targets
165 |
166 | # Microsoft Azure Build Output
167 | csx/
168 | *.build.csdef
169 |
170 | # Microsoft Azure Emulator
171 | ecf/
172 | rcf/
173 |
174 | # Windows Store app package directories and files
175 | AppPackages/
176 | BundleArtifacts/
177 | Package.StoreAssociation.xml
178 | _pkginfo.txt
179 |
180 | # Visual Studio cache files
181 | # files ending in .cache can be ignored
182 | *.[Cc]ache
183 | # but keep track of directories ending in .cache
184 | !*.[Cc]ache/
185 |
186 | # Others
187 | ClientBin/
188 | ~$*
189 | *~
190 | *.dbmdl
191 | *.dbproj.schemaview
192 | *.jfm
193 | *.pfx
194 | *.publishsettings
195 | node_modules/
196 | orleans.codegen.cs
197 |
198 | # Since there are multiple workflows, uncomment next line to ignore bower_components
199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200 | #bower_components/
201 |
202 | # RIA/Silverlight projects
203 | Generated_Code/
204 |
205 | # Backup & report files from converting an old project file
206 | # to a newer Visual Studio version. Backup files are not needed,
207 | # because we have git ;-)
208 | _UpgradeReport_Files/
209 | Backup*/
210 | UpgradeLog*.XML
211 | UpgradeLog*.htm
212 |
213 | # SQL Server files
214 | *.mdf
215 | *.ldf
216 |
217 | # Business Intelligence projects
218 | *.rdl.data
219 | *.bim.layout
220 | *.bim_*.settings
221 |
222 | # Microsoft Fakes
223 | FakesAssemblies/
224 |
225 | # GhostDoc plugin setting file
226 | *.GhostDoc.xml
227 |
228 | # Node.js Tools for Visual Studio
229 | .ntvs_analysis.dat
230 |
231 | # Visual Studio 6 build log
232 | *.plg
233 |
234 | # Visual Studio 6 workspace options file
235 | *.opt
236 |
237 | # Visual Studio LightSwitch build output
238 | **/*.HTMLClient/GeneratedArtifacts
239 | **/*.DesktopClient/GeneratedArtifacts
240 | **/*.DesktopClient/ModelManifest.xml
241 | **/*.Server/GeneratedArtifacts
242 | **/*.Server/ModelManifest.xml
243 | _Pvt_Extensions
244 |
245 | # Paket dependency manager
246 | .paket/paket.exe
247 | paket-files/
248 |
249 | # FAKE - F# Make
250 | .fake/
251 |
252 | # JetBrains Rider
253 | .idea/
254 | *.sln.iml
255 |
256 | # CodeRush
257 | .cr/
258 |
259 | # Python Tools for Visual Studio (PTVS)
260 | __pycache__/
261 | *.pyc
--------------------------------------------------------------------------------
/TeslaTags.Gui/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/App.xaml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Text;
4 | using System.Windows;
5 |
6 | using CommonServiceLocator;
7 |
8 | using GalaSoft.MvvmLight;
9 | using GalaSoft.MvvmLight.Ioc;
10 |
11 | namespace TeslaTags.Gui
12 | {
13 | public static class Program
14 | {
15 | // This is the exact same code that the PresentationBuildTasks compiler builds.
16 | // Except with async before starting the application object, to prevent issues caused by running async code in synchronous "OnFoo" event-handlers (i.e. `OnStartup`).
17 | // It also sets-up IoC before any WPF code starts too.
18 | [STAThread]
19 | //public static async Task Main()
20 | public static Int32 Main(String[] args)
21 | {
22 | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
23 |
24 | // https://stackoverflow.com/questions/50901586/how-do-i-resume-on-the-entry-thread-in-an-async-main?noredirect=1#comment88808169_50901586
25 |
26 | #region Attempts at running async code before WPF:
27 | #if NEVER
28 |
29 | //AsyncContext.Run( XmlDocumentConfigurationService.Instance.LoadConfigAsync );
30 |
31 | //System.Threading.SynchronizationContext.SetSynchronizationContext( )
32 |
33 | Int32 th0 = Thread.CurrentThread.ManagedThreadId;
34 | SynchronizationContext th0Context = SynchronizationContext.Current;
35 |
36 | Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
37 | DispatcherSynchronizationContext context = new DispatcherSynchronizationContext( dispatcher );
38 | SynchronizationContext.SetSynchronizationContext( context );
39 |
40 | SynchronizationContext th1Context = SynchronizationContext.Current;
41 |
42 | await XmlDocumentConfigurationService.Instance.LoadConfigAsync();
43 |
44 | Int32 th2 = Thread.CurrentThread.ManagedThreadId;
45 | SynchronizationContext th2Context = SynchronizationContext.Current;
46 |
47 | #endif
48 | #endregion
49 |
50 | XmlDocumentConfigurationService.Instance.LoadConfig();
51 |
52 | ////////////////////
53 |
54 | RegisterDependencies( SimpleIoc.Default );
55 |
56 | ////////////////////
57 |
58 | // Then call into WPF's PresentationBuildTasks-generated Main:
59 | TeslaTagsApplication.Main();
60 |
61 | return 0;
62 | }
63 |
64 | private static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
65 | {
66 | StringBuilder sb = new StringBuilder();
67 | sb.AppendLine( "AppDomain Unhandled exception:" );
68 |
69 | Exception ex = e.ExceptionObject as Exception;
70 | while( ex != null )
71 | {
72 | sb.AppendLine( ex.Message );
73 | sb.AppendLine( ex.GetType().FullName );
74 | sb.AppendLine( ex.StackTrace );
75 | sb.AppendLine();
76 |
77 | ex = ex.InnerException;
78 | }
79 |
80 | String message = sb.ToString();
81 |
82 | try
83 | {
84 | using( EventLog eventLog = new EventLog( "Application" ) )
85 | {
86 | eventLog.Source = "Application";
87 | eventLog.WriteEntry( message, EventLogEntryType.Error, eventID: 101, category: 1 );
88 | }
89 | }
90 | catch
91 | {
92 | // er...?
93 | }
94 | }
95 |
96 | private static void RegisterDependencies(SimpleIoc ioc)
97 | {
98 | ServiceLocator.SetLocatorProvider( () => ioc );
99 |
100 | ioc.Register( () => XmlDocumentConfigurationService.Instance );
101 |
102 | IConfigurationService configService = ioc.GetInstance();
103 |
104 | if( ViewModelBase.IsInDesignModeStatic || configService.Config.DesignMode )
105 | {
106 | // https://olitee.com/2015/01/mvvmlight-simpleioc-design-time-error/
107 | if( !ioc.IsRegistered() )
108 | {
109 | ioc.Register();
110 | }
111 | }
112 | else
113 | {
114 | // Create run time view services and models
115 | ioc.Register();
116 | }
117 |
118 | ioc.Register();
119 |
120 | ioc.Register();
121 |
122 | ioc.Register();
123 | }
124 | }
125 |
126 | public partial class TeslaTagsApplication : Application
127 | {
128 | static TeslaTagsApplication()
129 | {
130 | GalaSoft.MvvmLight.Threading.DispatcherHelper.Initialize();
131 | }
132 |
133 | /*
134 | protected override async void OnStartup(StartupEventArgs e)
135 | {
136 | RegisterDependencies();
137 |
138 | // https://stackoverflow.com/questions/49701102/wpf-app-run-async-task-before-opening-window
139 |
140 | IConfigurationService configService = SimpleIoc.Default.GetInstance();
141 | await configService.LoadConfigAsync();
142 |
143 | base.OnStartup( e );
144 | }*/
145 |
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/AllSizes.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/AllSizes.ico
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 1128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 1128.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 116.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 116.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 124.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 124.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 132.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 132.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 148.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 148.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/Artboard 164.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/Artboard 164.png
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/noun_464493_cc.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/daiplusplus/TeslaTags/f1a835f25ef7ad7907743a5132ca217f5a62f138/TeslaTags.Gui/Icons/noun_464493_cc.ai
--------------------------------------------------------------------------------
/TeslaTags.Gui/Icons/noun_464493_cc.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Windows;
5 | using System.Windows.Controls.Primitives;
6 | using System.Windows.Data;
7 | using System.Windows.Interop;
8 | using System.Windows.Navigation;
9 |
10 | using GalaSoft.MvvmLight.Ioc;
11 |
12 | namespace TeslaTags.Gui
13 | {
14 | public partial class MainWindow : Window
15 | {
16 | private MainViewModel ViewModel => (MainViewModel)this.DataContext;
17 |
18 | public MainWindow()
19 | {
20 | this.InitializeComponent();
21 |
22 | this.browseButton.Click += this.BrowseButton_Click;
23 |
24 | this.Loaded += this.MainWindow_Loaded;
25 | this.Closing += this.MainWindow_Closing;
26 |
27 | // Nudge the popup targets: // https://stackoverflow.com/questions/1600218/how-can-i-move-a-wpf-popup-when-its-anchor-element-moves
28 | // The main fix in that QA is for Popups inside a UserControl - as they're in a Window we can access events directly:
29 | this.LocationChanged += this.WindowRectangleChange;
30 | this.SizeChanged += this.WindowRectangleChange;
31 |
32 | //this.DataContextChanged += this.MainWindow_DataContextChanged;
33 | }
34 |
35 | private void WindowRectangleChange( Object sender, EventArgs e )
36 | {
37 | Double offset = this.excludePopup.HorizontalOffset;
38 | this.excludePopup.HorizontalOffset = offset + 1; // Trigger reflow
39 | this.excludePopup.HorizontalOffset = offset; // ...but don't make it a visual change.
40 |
41 | offset = this.genrePopup.HorizontalOffset;
42 | this.genrePopup.HorizontalOffset = offset + 1;
43 | this.genrePopup.HorizontalOffset = offset;
44 | }
45 |
46 | #region Window Events
47 |
48 | // HACK: Using events to avoid taking a dependency on the Blend SDK, as it's a simple application:
49 | private void MainWindow_Loaded(Object sender, RoutedEventArgs e)
50 | {
51 | this.cvs = (CollectionViewSource)this.FindResource( "directoriesProgressCvs" );
52 |
53 | this.ViewModel.WindowLoadedCommand.Execute( parameter: null );
54 | }
55 |
56 | private void MainWindow_Closing(Object sender, System.ComponentModel.CancelEventArgs e)
57 | {
58 | this.ViewModel.WindowClosingCommand.Execute( parameter: null );
59 | }
60 |
61 | #endregion
62 |
63 | private void BrowseButton_Click(Object sender, RoutedEventArgs e)
64 | {
65 | WindowInteropHelper helper = new WindowInteropHelper( this );
66 | IntPtr hWnd = helper.Handle;
67 |
68 | String path = SimpleIoc.Default.GetInstance().ShowFolderBrowseDialog( hWnd, "Browse for root of Tesla music collection directory structure." );
69 |
70 | if( Directory.Exists( path ) )
71 | {
72 | this.ViewModel.DirectoryPath = path;
73 | }
74 | }
75 |
76 | private void Hyperlink_RequestNavigate(Object sender, RequestNavigateEventArgs e)
77 | {
78 | if( e.Uri != null )
79 | {
80 | try
81 | {
82 | Process p = Process.Start( e.Uri.ToString() );
83 | if( p != null ) p.Dispose();
84 | }
85 | catch
86 | {
87 | }
88 | }
89 | }
90 |
91 | private void AlbumArtBrowseButton_Click(Object sender, RoutedEventArgs e)
92 | {
93 | DirectoryViewModel dvm = this.ViewModel.SelectedDirectory;
94 |
95 | WindowInteropHelper helper = new WindowInteropHelper( this );
96 | IntPtr hWnd = helper.Handle;
97 |
98 | String path = SimpleIoc.Default.GetInstance().ShowFileOpenDialogForImages( hWnd, "Browse for new album art image.", dvm.FullDirectoryPath );
99 |
100 | if( Directory.Exists( path ) )
101 | {
102 | if( path.StartsWith( dvm.FullDirectoryPath, StringComparison.OrdinalIgnoreCase ) )
103 | {
104 | path = path.Substring( dvm.FullDirectoryPath.Length );
105 | }
106 |
107 | this.ViewModel.SelectedDirectory.SelectedImageFileName = path;
108 | }
109 | }
110 |
111 | private CollectionViewSource cvs;
112 |
113 | // Remember, WPF has separate `Checked` and `Unchecked` events, not just a single `CheckedChanged` event like WinForms.
114 | // BTW - this still causes incorrect DataGrid scrollbar calculations resulting in a scrollbar thumb that changes height as you drag it
115 | // The only *trivial* solution is to switch to pixel-based scrolling instead of row-item-based scrolling: http://wpfthoughts.blogspot.com/2014/05/datagrid-vertical-scrolling-issues.html
116 | // ...but is there a way to get both - so it does item height calculations for scrolling based on pixels but the scroll-stops are snapped to each row-item? (i.e. support for variable-height rows)? TODO.
117 | private void DirectoryFilterCheckedChanged( Object sender, RoutedEventArgs e )
118 | {
119 | if( this.cvs == null ) return;
120 |
121 | this.cvs.View.Refresh();
122 | }
123 |
124 | // This method can be set as `this.csv.View.Filter = DataGridFilter` but it's unclear what the *best* way to do that is given `this.csv.View` could be recreated... I think?
125 | private Boolean DataGridFilter( Object item )
126 | {
127 | DirectoryViewModel dvm = (DirectoryViewModel)item;
128 |
129 | Boolean isChecked = this.boringFilterCheckbox.IsChecked ?? false;
130 | if( isChecked )
131 | {
132 | // TODO: Consider moving this logic into DirectoryViewModel directly.
133 | Boolean isBoring =
134 | ( dvm.FolderType == FolderType.Empty )
135 | ||
136 | ( dvm.FilesModifiedProposed == 0 && dvm.InfoCount == 0 && dvm.WarnCount == 0 && dvm.ErrorCount == 0 );
137 |
138 | return !isBoring;
139 | }
140 | else
141 | {
142 | return true; // Include all rows.
143 | }
144 | }
145 |
146 | // ...alternatively, this alternate approach is provided:
147 | private void CollectionViewSource_Filter( Object sender, FilterEventArgs e )
148 | {
149 | e.Accepted = this.DataGridFilter( e.Item );
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle( "TeslaTags.Gui" )]
11 | [assembly: AssemblyDescription( "" )]
12 | [assembly: AssemblyConfiguration( "" )]
13 | [assembly: AssemblyCompany( "" )]
14 | [assembly: AssemblyProduct( "TeslaTags.Gui" )]
15 | [assembly: AssemblyCopyright( "Copyright © 2018" )]
16 | [assembly: AssemblyTrademark( "" )]
17 | [assembly: AssemblyCulture( "" )]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible( false )]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion( "1.0.*" )]
55 | //[assembly: AssemblyFileVersion( "1.0.0.0" )]
56 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Services/IConfigurationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Xml.Linq;
7 |
8 | namespace TeslaTags.Gui
9 | {
10 | public interface IConfigurationService
11 | {
12 | //Task LoadConfigAsync();
13 | void LoadConfig();
14 |
15 | Config Config { get; }
16 |
17 | //Task SaveConfigAsync(Config config);
18 | void SaveConfig(Config config);
19 | }
20 |
21 | public class Config
22 | {
23 | public Boolean DesignMode { get; set; }
24 |
25 | public String RootDirectory { get; set; }
26 |
27 | public String[] ExcludeList { get; set; }
28 | public String[] FileExtensions { get; set; }
29 |
30 | public Boolean HideEmptyDirectories { get; set; }
31 |
32 | public GenreRules GenreRules { get; set; }
33 |
34 | public (Int32 X, Int32 Y, Int32 Width, Int32 Height) RestoredWindowPosition { get; set; }
35 |
36 | public Boolean IsMaximized { get; set; }
37 | }
38 |
39 | public class XmlDocumentConfigurationService : IConfigurationService
40 | {
41 | private XmlDocumentConfigurationService()
42 | {
43 | }
44 |
45 | public static XmlDocumentConfigurationService Instance { get; } = new XmlDocumentConfigurationService();
46 |
47 | private static readonly Char[] _directoryListSeparators = new Char[] { ';' };
48 |
49 | private Config config;
50 | public Config Config
51 | {
52 | get
53 | {
54 | if( this.config == null ) throw new InvalidOperationException( "Configuration hasn't been loaded." );
55 | return this.config;
56 | }
57 | }
58 |
59 | public void LoadConfig()
60 | {
61 | Config config = new Config();
62 |
63 | // Set defaults:
64 | config.ExcludeList = FileSystemPredicate.DefaultExcludeFolders.ToArray();
65 | config.FileExtensions = FileSystemPredicate.DefaultAudioFileExtensions.ToArray();
66 |
67 | XDocument doc = OpenAppConfig();
68 | if( doc != null )
69 | {
70 | PopulateConfig( config, doc );
71 | }
72 |
73 | this.config = config;
74 | }
75 |
76 | private static void PopulateConfig(Config config, XDocument doc)
77 | {
78 | Boolean E(String key, String name) => String.Equals( key, name, StringComparison.OrdinalIgnoreCase );
79 |
80 | var appSettings = doc
81 | .Elements( "configuration" ) // `Elements(XName)` is immediate children, unlike `Descendants(XName)` which does a deep search.
82 | .Elements( "appSettings" )
83 | .Elements( "add" )
84 | .Select( el => (key: el.Attribute("key")?.Value, value: el.Attribute("value")?.Value ) )
85 | .Where( t => !String.IsNullOrWhiteSpace( t.key ) );
86 |
87 | config.GenreRules = new GenreRules();
88 |
89 | foreach( (String key, String value) in appSettings )
90 | {
91 | if( E( key, nameof(TeslaTags.Gui.Config.DesignMode) ) )
92 | {
93 | if( Boolean.TryParse( value, out Boolean designModeValue ) ) config.DesignMode = designModeValue;
94 | }
95 | else if( E( key, nameof(TeslaTags.Gui.Config.HideEmptyDirectories) ) )
96 | {
97 | if( Boolean.TryParse( value, out Boolean hideEmptyDirectoriesValue ) ) config.HideEmptyDirectories = hideEmptyDirectoriesValue;
98 | }
99 | else if( E( key, nameof(TeslaTags.Gui.Config.RestoredWindowPosition) ) )
100 | {
101 | IList values = value
102 | .Split( _directoryListSeparators, StringSplitOptions.RemoveEmptyEntries )
103 | .Select( s => Int32.TryParse( s, NumberStyles.Integer, CultureInfo.InvariantCulture, out Int32 v ) ? (Int32?)v : null )
104 | .Where( v => v != null )
105 | .Select( v => v.Value )
106 | .ToList();
107 |
108 | if( values.Count == 4 ) config.RestoredWindowPosition = ( X: values[0], Y: values[1], Width: values[2], Height: values[3] );
109 | }
110 | else if( E( key, nameof(TeslaTags.Gui.Config.IsMaximized) ) )
111 | {
112 | if( Boolean.TryParse( value, out Boolean isMaximizedValue ) ) config.IsMaximized = isMaximizedValue;
113 | }
114 | else if( E( key, nameof(TeslaTags.Gui.Config.ExcludeList) ) )
115 | {
116 | String[] excludeList = value?.Split( _directoryListSeparators, StringSplitOptions.RemoveEmptyEntries ) ?? null;
117 | if( excludeList != null && excludeList.Length > 0 ) config.ExcludeList = excludeList;
118 | }
119 | else if( E( key, nameof(TeslaTags.Gui.Config.FileExtensions) ) )
120 | {
121 | String[] extensionList = value?.Split( _directoryListSeparators, StringSplitOptions.RemoveEmptyEntries ) ?? null;
122 | if( extensionList != null && extensionList.Length > 0 ) config.FileExtensions = extensionList;
123 | }
124 | else if( E( key, nameof(TeslaTags.Gui.Config.RootDirectory) ) )
125 | {
126 | config.RootDirectory = value;
127 | }
128 |
129 | // Genre rules:
130 |
131 | else if( E( key, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.AssortedFilesAction) ) ) // "_2" because the config schema is different than how it was prior to Release 7.
132 | {
133 | if( Enum.TryParse( value, out AssortedFilesGenreAction genreActionValue ) ) config.GenreRules.AssortedFilesAction = genreActionValue;
134 | }
135 | else if( E( key, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAlbumWithGuestArtistsAction) ) )
136 | {
137 | if( Enum.TryParse( value, out GenreAction genreActionValue ) ) config.GenreRules.ArtistAlbumWithGuestArtistsAction = genreActionValue;
138 | }
139 | else if( E( key, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAssortedAction) ) )
140 | {
141 | if( Enum.TryParse( value, out GenreAction genreActionValue ) ) config.GenreRules.ArtistAssortedAction = genreActionValue;
142 | }
143 | else if( E( key, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAlbumAction) ) )
144 | {
145 | if( Enum.TryParse( value, out GenreAction genreActionValue ) ) config.GenreRules.ArtistAlbumAction = genreActionValue;
146 | }
147 | else if( E( key, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.CompilationAlbumAction) ) )
148 | {
149 | if( Enum.TryParse( value, out GenreAction genreActionValue ) ) config.GenreRules.CompilationAlbumAction = genreActionValue;
150 | }
151 | }
152 |
153 | if( config.ExcludeList == null ) config.ExcludeList = new String[0];
154 | }
155 |
156 | private static String AppConfigFileName => AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
157 |
158 | private static XDocument OpenAppConfig()
159 | {
160 | if( !File.Exists( AppConfigFileName ) ) return null;
161 |
162 | XDocument doc = XDocument.Load( AppConfigFileName, LoadOptions.PreserveWhitespace );
163 | return doc;
164 | }
165 |
166 | public void SaveConfig(Config config)
167 | {
168 | XDocument doc = OpenAppConfig();
169 | if( doc == null ) doc = new XDocument();
170 |
171 | XElement appSettingsElement = doc
172 | .Elements( "configuration" ) // `Elements(XName)` is immediate children, unlike `Descendants(XName)` which does a deep search.
173 | .Elements( "appSettings" )
174 | .SingleOrDefault();
175 |
176 | if( appSettingsElement == null )
177 | {
178 | XElement configurationElement = doc.Elements("configuration").SingleOrDefault();
179 | if( configurationElement == null )
180 | {
181 | configurationElement = new XElement("configuration");
182 | doc.AddFirst( configurationElement );
183 | }
184 |
185 | appSettingsElement = new XElement( "appSettings" );
186 | configurationElement.Add( appSettingsElement );
187 | }
188 |
189 | Dictionary appSettingsDict = appSettingsElement
190 | .Elements( "add" )
191 | .Select( el => ( key: el.Attribute("key")?.Value, element: el ) )
192 | .Where( t => !String.IsNullOrWhiteSpace( t.key ) )
193 | .ToDictionary( t => t.key, t => t.element, StringComparer.OrdinalIgnoreCase );
194 |
195 | ////////////////////////
196 |
197 | String restoredWindowPositionValue = String.Format(
198 | CultureInfo.InvariantCulture,
199 | "{0};{1};{2};{3}",
200 | config.RestoredWindowPosition.X,
201 | config.RestoredWindowPosition.Y,
202 | config.RestoredWindowPosition.Width,
203 | config.RestoredWindowPosition.Height
204 | );
205 |
206 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.DesignMode) , config.DesignMode.ToString() );
207 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.HideEmptyDirectories) , config.HideEmptyDirectories.ToString() );
208 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.RestoredWindowPosition), restoredWindowPositionValue );
209 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.IsMaximized) , config.IsMaximized.ToString() );
210 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.ExcludeList) , String.Join( ";", config.ExcludeList .Where( s => !String.IsNullOrWhiteSpace(s) ).OrderBy( s => s ) ) );
211 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.FileExtensions) , String.Join( ";", config.FileExtensions.Where( s => !String.IsNullOrWhiteSpace(s) ).OrderBy( s => s ) ) );
212 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.RootDirectory) , config.RootDirectory );
213 |
214 | // Genre rules, version 2 (Release 7+)
215 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.AssortedFilesAction ), config.GenreRules.AssortedFilesAction .ToString() );
216 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAlbumWithGuestArtistsAction), config.GenreRules.ArtistAlbumWithGuestArtistsAction.ToString() );
217 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAssortedAction ), config.GenreRules.ArtistAssortedAction .ToString() );
218 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.ArtistAlbumAction ), config.GenreRules.ArtistAlbumAction .ToString() );
219 | SetAppSetting( appSettingsElement, appSettingsDict, nameof(TeslaTags.Gui.Config.GenreRules) + "_2" + nameof(TeslaTags.Gui.Config.GenreRules.CompilationAlbumAction ), config.GenreRules.CompilationAlbumAction .ToString() );
220 |
221 | ////////////////////////
222 |
223 | doc.Save( AppConfigFileName );
224 |
225 | // https://stackoverflow.com/questions/18500419/how-to-change-number-of-characters-used-for-indentation-when-writing-xml-with-xd
226 | // - this doesn't seem to work well?
227 | /*XmlWriterSettings settings = new XmlWriterSettings();
228 | settings.Indent = true;
229 | settings.IndentChars = "\t";
230 |
231 | using( XmlWriter writer = XmlWriter.Create( AppConfigFileName + ".xml", settings ) )
232 | {
233 | doc.Save( writer );
234 | }*/
235 | }
236 |
237 | private static void SetAppSetting(XElement appSettingsElement, Dictionary appSettingsDict, String key, String value)
238 | {
239 | XElement appConfigElement = GetAppConfigKeyValueElement( appSettingsDict, key, appSettingsElement );
240 |
241 | appConfigElement.SetAttributeValue( "value", value );
242 | }
243 |
244 | private static XElement GetAppConfigKeyValueElement(Dictionary dict, String key, XElement appSettingsElement)
245 | {
246 | if( dict.TryGetValue( key, out XElement value ) )
247 | {
248 | return value;
249 | }
250 | else
251 | {
252 | value = new XElement("add");
253 | value.SetAttributeValue( "key", key );
254 | dict.Add( key, value );
255 |
256 | appSettingsElement.Add( new XText( "\r\n\t\t" ) );
257 | appSettingsElement.Add( value );
258 |
259 | return value;
260 | }
261 | }
262 | }
263 | }
264 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Services/IDialogService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using ShellFileDialogs;
4 |
5 | namespace TeslaTags.Gui
6 | {
7 | public interface IFileDialogService
8 | {
9 | String ShowFolderBrowseDialog(IntPtr hWnd, String title);
10 |
11 | String ShowFileOpenDialogForImages(IntPtr hWnd, String title, String initialDirectory);
12 | }
13 |
14 | public class ComFileDialogService : IFileDialogService
15 | {
16 | public String ShowFolderBrowseDialog(IntPtr hWnd, String title)
17 | {
18 | String path = FolderBrowserDialog.ShowDialog( hWnd, title, null );
19 | return path;
20 | }
21 |
22 | private static readonly Filter[] _imagesFilters = new Filter[]
23 | {
24 | new Filter( "Images", "jpg", "jpeg", "png", "bmp", "gif" ),
25 | new Filter( "All files", "*" ),
26 | };
27 |
28 | public String ShowFileOpenDialogForImages(IntPtr hWnd, String title, String initialDirectory)
29 | {
30 | String path = FileOpenDialog.ShowSingleSelectDialog( hWnd, title, initialDirectory, defaultFileName: null, filters: _imagesFilters, selectedFilterIndex: -1 );
31 | return path;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Services/ILiveConfigurationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace TeslaTags.Gui
8 | {
9 | /// Gets "live" configuration values directly from the UI, even if they aren't saved yet.
10 | public interface ILiveConfigurationService
11 | {
12 | FileSystemPredicate CreateFileSystemPredicate();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/Services/WindowService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows;
4 |
5 | namespace TeslaTags.Gui
6 | {
7 | public interface IWindowService
8 | {
9 | Window GetWindowByDataContext(Object dataContext);
10 |
11 | void ShowMessageBoxWarningDialog(Object dataContext, String title, String message);
12 |
13 | void ShowMessageBoxErrorDialog(Object dataContext, String title, String message);
14 | }
15 |
16 | public class WindowService : IWindowService
17 | {
18 | public Window GetWindowByDataContext(Object dataContext)
19 | {
20 | return Application.Current.Windows
21 | .Cast()
22 | .SingleOrDefault( w => w.DataContext == dataContext );
23 | }
24 |
25 | public void ShowMessageBoxWarningDialog(Object dataContext, String title, String message)
26 | {
27 | Window window = this.GetWindowByDataContext( dataContext );
28 |
29 | MessageBox.Show(
30 | owner : window,
31 | messageBoxText: message,
32 | caption : title,
33 | button : MessageBoxButton.OK,
34 | icon : MessageBoxImage.Warning,
35 | defaultResult : MessageBoxResult.OK,
36 | options : MessageBoxOptions.None
37 | );
38 | }
39 |
40 | public void ShowMessageBoxErrorDialog(Object dataContext, String title, String message)
41 | {
42 | Window window = this.GetWindowByDataContext( dataContext );
43 |
44 | MessageBox.Show(
45 | owner : window,
46 | messageBoxText: message,
47 | caption : title,
48 | button : MessageBoxButton.OK,
49 | icon : MessageBoxImage.Error,
50 | defaultResult : MessageBoxResult.OK,
51 | options : MessageBoxOptions.None
52 | );
53 | }
54 |
55 | // This function was intended for binding to the WPF Window size+position+state, but it's easier to do it directly without binding.
56 | /*
57 | private static void CreateBinding( INotifyPropertyChanged source, String sourcePropertyPath, DependencyObject target, DependencyProperty targetProperty, BindingMode mode = BindingMode.TwoWay )
58 | {
59 | Binding binding = new Binding();
60 | binding.Source = source;
61 | binding.Path = new PropertyPath( sourcePropertyPath );
62 | binding.Mode = mode;
63 | binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
64 |
65 | BindingOperations.SetBinding( target, targetProperty, binding );
66 | }*/
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/TeslaTags.Gui.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {624055F2-0408-49EA-A6C3-F59EE7DBA1CF}
8 | WinExe
9 | TeslaTags.Gui
10 | TeslaTags.Gui
11 | v4.7.1
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 | 7.3
27 | false
28 | AllRules.ruleset
29 |
30 |
31 | AnyCPU
32 | pdbonly
33 | true
34 | bin\Release\
35 | TRACE
36 | prompt
37 | 4
38 |
39 |
40 | Icons\AllSizes.ico
41 |
42 |
43 | TeslaTags.Gui.Program
44 |
45 |
46 | app.manifest
47 |
48 |
49 |
50 | ..\packages\CommonServiceLocator.2.0.3\lib\net47\CommonServiceLocator.dll
51 |
52 |
53 | ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.dll
54 |
55 |
56 | ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Extras.dll
57 |
58 |
59 | ..\packages\MvvmLightLibs.5.4.1\lib\net45\GalaSoft.MvvmLight.Platform.dll
60 |
61 |
62 | ..\packages-other\ShellFileDialogs\ShellFileDialogs.dll
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | 4.0
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | MSBuild:Compile
80 | Designer
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | MSBuild:Compile
97 | Designer
98 |
99 |
100 | App.xaml
101 | Code
102 |
103 |
104 | MainWindow.xaml
105 | Code
106 |
107 |
108 |
109 |
110 | Code
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 | {831fe5d4-250f-4f55-9934-5072f2b7cbee}
121 | TeslaTags
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/ViewModel/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.ComponentModel;
5 | using System.Linq;
6 | using System.Reflection;
7 | using GalaSoft.MvvmLight;
8 | using GalaSoft.MvvmLight.CommandWpf;
9 |
10 | namespace TeslaTags.Gui
11 | {
12 | public abstract class BaseViewModel : ViewModelBase
13 | {
14 | /* TODO: I don't understand why this doesn't work.
15 | protected RelayCommand CreateBusyCommand( Action action, Func additionalCanExecute, Boolean enabledWhenBusy = false )
16 | {
17 | RelayCommand cmd;
18 | if( enabledWhenBusy )
19 | {
20 | cmd = new RelayCommand( action, canExecute: () => this.CanExecuteWhenBusy() && additionalCanExecute() );
21 | }
22 | else
23 | {
24 | cmd = new RelayCommand( action, canExecute: () => this.CanExecuteWhenNotBusy() && additionalCanExecute() );
25 | }
26 | this.busyCommands.Add( cmd );
27 | return cmd;
28 | }*/
29 |
30 | protected RelayCommand CreateBusyCommand( Action action, Boolean enabledWhenBusy = false )
31 | {
32 | RelayCommand cmd;
33 | if( enabledWhenBusy )
34 | {
35 | cmd = new RelayCommand( action, canExecute: this.CanExecuteWhenBusy );
36 | }
37 | else
38 | {
39 | cmd = new RelayCommand( action, canExecute: this.CanExecuteWhenNotBusy );
40 | }
41 | this.busyCommands.Add( cmd );
42 | return cmd;
43 | }
44 |
45 | private readonly List busyCommands = new List();
46 |
47 | private Boolean isBusy;
48 | public Boolean IsBusy
49 | {
50 | get { return this.isBusy; }
51 | set
52 | {
53 | if( this.Set( nameof(this.IsBusy), ref this.isBusy, value ) )
54 | {
55 | this.RaisePropertyChanged( nameof(this.IsNotBusy) );
56 | foreach( RelayCommand cmd in this.busyCommands )
57 | {
58 | cmd.RaiseCanExecuteChanged();
59 | }
60 | }
61 | }
62 | }
63 | public Boolean IsNotBusy => !this.IsBusy;
64 |
65 | protected Boolean CanExecuteWhenNotBusy()
66 | {
67 | //System.Diagnostics.Debug.WriteLine( nameof(this.CanExecuteWhenNotBusy) + " == " + ( !this.IsBusy ) );
68 | return !this.IsBusy;
69 | }
70 |
71 | protected Boolean CanExecuteWhenBusy()
72 | {
73 | //System.Diagnostics.Debug.WriteLine( nameof(this.CanExecuteWhenBusy) + " == " + ( this.IsBusy ) );
74 | return this.IsBusy;
75 | }
76 |
77 | protected static ObservableCollection> CreateOptions()
78 | where TEnum : System.Enum /* make sure you're using the C# 7.3 compiler for this: https://github.com/dotnet/csharplang/issues/104 */
79 | {
80 | //TEnum[] values = (TEnum[])Enum.GetValues( typeof(TEnum) );
81 |
82 | Type type = typeof(TEnum);
83 | var options = type
84 | .GetFields( BindingFlags.Static | BindingFlags.Public )
85 | .Select( fi => {
86 | String description = fi.GetCustomAttribute()?.Description;
87 | TEnum value = (TEnum)fi.GetValue( null );
88 |
89 | return new ValueOption( value, description ?? value.ToString() );
90 | } );
91 |
92 | ObservableCollection> ret = new ObservableCollection>();
93 | foreach( ValueOption opt in options ) ret.Add( opt );
94 |
95 | return ret;
96 | }
97 | }
98 |
99 | public class ValueOption
100 | {
101 | public ValueOption( T value, String text )
102 | {
103 | this.Value = value;
104 | this.Text = text;
105 | }
106 |
107 | public T Value { get; }
108 | public String Text { get; }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/TeslaTags.Gui/ViewModel/DesignTeslaTagService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using System.Windows.Threading;
8 |
9 | namespace TeslaTags.Gui
10 | {
11 | public class DesignTeslaTagService : ITeslaTagsService
12 | {
13 | private String rootDirectory;
14 |
15 | private readonly DispatcherTimer timer;
16 |
17 | private static readonly List _directories = new List()
18 | {
19 | @"Foobar",
20 | @"Foobar\Artist1",
21 | @"Foobar\Artist1\Album",
22 | @"Foobar\ArtistB\Singles",
23 | @"Foobar\Foo",
24 | };
25 |
26 | private List directories;
27 |
28 | public DesignTeslaTagService()
29 | {
30 | this.timer = new DispatcherTimer();
31 | this.timer.Interval = new TimeSpan( hours: 0, minutes: 0, seconds: 1 );
32 | this.timer.Tick += this.Timer_Tick;
33 | }
34 |
35 | private Int32 processState = 0; // 0 = Start, 1 = Getting directories, 2 = Got directories/Processing files, 3 = Done.
36 | private DateTime stateStart = DateTime.MinValue;
37 | private Int32 directoryIdx = 0;
38 |
39 | private TaskCompletionSource