From f074cfd8a3763e5776d9380313b16db49c28e521 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bellai=20=C3=81d=C3=A1m?= Date: Tue, 10 Oct 2017 09:39:50 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30573 --- .../Configuration/ConfigurationInfo.cs | 2 +- client/Maestro/MaestroForm.Source.cs | 2 +- .../Maestro/Resources/configuration-unc.json | 2 +- client/Maestro/Sources/FileSystemSource.cs | 33 ++++++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/client/Maestro/Configuration/ConfigurationInfo.cs b/client/Maestro/Configuration/ConfigurationInfo.cs index acb4ec99..a3328520 100644 --- a/client/Maestro/Configuration/ConfigurationInfo.cs +++ b/client/Maestro/Configuration/ConfigurationInfo.cs @@ -30,7 +30,6 @@ namespace Maestro.Configuration { public bool EnableCustomMetadataId { get; set; } public MetadataProvider[] Metadatas { get; set; } public Target[] Targets { get; set; } - public String Filter { get; set; } } public class Player { @@ -63,6 +62,7 @@ namespace Maestro.Configuration { public class Source { public Connection Local { get; set; } public Connection Remote { get; set; } + public String Filter { get; set; } } public class UNCSource : Source { diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 88cac0c9..7a1af3bc 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -37,7 +37,7 @@ namespace Maestro { if (Configuration?.Source is UNCSource) { logger.Debug("UNC source initialization"); - source = new FileSystemSource(this, MessageBus, Configuration.Filter); + source = new FileSystemSource(this, MessageBus, Configuration.Source.Filter); logger.Debug("UNC source created"); } if (Configuration?.Source is NEXIOSource) { diff --git a/client/Maestro/Resources/configuration-unc.json b/client/Maestro/Resources/configuration-unc.json index 12f1a435..2d40e582 100644 --- a/client/Maestro/Resources/configuration-unc.json +++ b/client/Maestro/Resources/configuration-unc.json @@ -4,7 +4,6 @@ "startInTray": false, "enableNameOverride": false, "enableCustomMetadataId": true, - "filter": "avi,wav", "player": { "enabled": true, "autoStart": false, @@ -12,6 +11,7 @@ }, "source": { "$type": "UNCSource", + "filter": "avi,wav,mxf", "local": { "address": "file://10.10.1.100/BRAAVOS/_TEST_/_ECHO/hirado/test" }, diff --git a/client/Maestro/Sources/FileSystemSource.cs b/client/Maestro/Sources/FileSystemSource.cs index 4dc44d9f..3b24042c 100644 --- a/client/Maestro/Sources/FileSystemSource.cs +++ b/client/Maestro/Sources/FileSystemSource.cs @@ -22,6 +22,8 @@ namespace Maestro.Sources { private string fileExtensionFilter; private List acceptableExtensions = new List(); private List cache = new List(); + private BackgroundWorker pathWatcherWorker = new BackgroundWorker(); + private string path; public DataGridViewColumn[] Columns { get { @@ -69,6 +71,21 @@ namespace Maestro.Sources { this.messageBus = messageBus; this.fileExtensionFilter = fileExtensionFilter; SetAcceptableExtensions(); + pathWatcherWorker.DoWork += pathWatcherWorker_watchPath; + pathWatcherWorker.ProgressChanged += pathWatcherWorker_progressChanged; + pathWatcherWorker.WorkerReportsProgress = true; + } + + private void pathWatcherWorker_progressChanged(object sender, ProgressChangedEventArgs e) { + InnerStartUp(); + } + + private void pathWatcherWorker_watchPath(object sender, DoWorkEventArgs e) { + while (!(Directory.Exists(path))) { + + } + pathWatcherWorker.ReportProgress(0); + } private void SetAcceptableExtensions() { @@ -78,10 +95,19 @@ namespace Maestro.Sources { public void Startup(Uri address) { string path = address.LocalPath; + this.path = path; + if (Directory.Exists(path)) { + InnerStartUp(); + } else pathWatcherWorker.RunWorkerAsync(); + } + + private void InnerStartUp() { createWatch(path); Task.Run(() => initializeList(path)); } + + //private void AddItem(FileInfo fi, bool highlight) { // FileSourceItem item = CreateItem(fi, highlight); // Add(item); @@ -111,10 +137,15 @@ namespace Maestro.Sources { watcher.Created += new FileSystemEventHandler(OnCreated); watcher.Deleted += new FileSystemEventHandler(OnDeleted); watcher.Renamed += new RenamedEventHandler(OnRenamed); + //watcher.Disposed += new EventHandler(OnDispose); watcher.EnableRaisingEvents = true; } - public void OnRenamed(object sender, RenamedEventArgs e) { + public void OnDispose(object sender, RenamedEventArgs e) { + + } + + public void OnRenamed(object sender, RenamedEventArgs e) { logger.Debug("{0} {1} {2}", e.ChangeType, e.OldName, e.Name); var item = this.Where(x => x.Name == e.OldName).SingleOrDefault(); if (item == null) -- 2.54.0