git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorBellai Ádám <USER\adam.bellai>
Wed, 4 Oct 2017 08:51:32 +0000 (08:51 +0000)
committerBellai Ádám <USER\adam.bellai>
Wed, 4 Oct 2017 08:51:32 +0000 (08:51 +0000)
client/Maestro/MaestroForm.Source.cs
client/Maestro/MaestroForm.Target.cs
client/Maestro/Sources/FileSystemSource.cs
client/PlanAIRClient/TrafficAPI.cs
client/PlanAIRClient/TrafficIDSelector.cs

index fcdf2146e2c116d84c92d60a8f5321465a1d0b95..80ff6e434a69be9b027cdf40548f26a6770e69d7 100644 (file)
@@ -12,11 +12,13 @@ using System.Windows.Forms;
 using System.Text;\r
 \r
 namespace Maestro {\r
+\r
+    delegate void SetTextCallback();\r
     public partial class MaestroForm {\r
         private ISource source;\r
         private SourceInfo selectedSource;\r
         private string startingName;\r
-        private List<String> selectedSources = new List<string>();\r
+        private List<DataGridViewRow> selectedRows = new List<DataGridViewRow>();\r
 \r
         public IDTypes IDType { get; set; }\r
 \r
@@ -132,10 +134,10 @@ namespace Maestro {
                 else\r
                     checkBoxCell.Value = (checkBoxCell.Value == null || checkBoxCell.Value.Equals(false)) ? true : false;\r
                 if (checkBoxCell.Value.Equals(false))\r
-                    selectedSources.Remove(name);\r
+                    this.selectedRows.Remove(actualRow);\r
                 else {\r
-                    if (!selectedSources.Contains(name))\r
-                        selectedSources.Add(name);\r
+                    if (!this.selectedRows.Contains(actualRow))\r
+                        this.selectedRows.Add(actualRow);\r
                 }\r
                 SetTextSelectedSourceTextFromCheckBoxes();\r
                 SetMetadataButtonEnabled((bool)checkBoxCell.Value);\r
@@ -156,19 +158,19 @@ namespace Maestro {
 \r
         private void SetMetadataButtonEnabled(bool checkBox) {\r
             SetStartingName(checkBox);\r
-            if (selectedSources == null || selectedSources.Count == 0) {\r
+            if (selectedRows == null || selectedRows.Count == 0) {\r
                 buttonMetadata.Enabled = false;\r
                 IsSelectedFileAnID();\r
                 return;\r
             }\r
-            if (selectedSources.Count == 1) {\r
+            if (selectedRows.Count == 1) {\r
                 buttonMetadata.Enabled = true;\r
                 IsSelectedFileAnID();\r
                 return;\r
             }\r
 \r
-            for (int i = 1; i < selectedSources.Count; i++) {\r
-                string name = selectedSources[i];\r
+            foreach (DataGridViewRow actual in selectedRows) {\r
+                string name = actual.Cells[1].Value as string;\r
                 if (!name.StartsWith(String.Format("{0}-", startingName)) &&\r
                     !name.StartsWith(String.Format("{0}_", startingName)) &&\r
                     !name.StartsWith(String.Format("{0}.", startingName))) {\r
@@ -182,11 +184,11 @@ namespace Maestro {
 \r
         private void SetStartingName(bool checkBox) {\r
             if (!checkBox)\r
-                if (selectedSources == null || selectedSources.Count == 0) {\r
+                if (selectedRows == null || selectedRows.Count == 0) {\r
                     startingName = null;\r
                     return;\r
                 }\r
-            string query = selectedSources[0];\r
+            string query = selectedRows[0].Cells[1].Value as string;\r
             int separatorPosition = query.IndexOf("-") < 0 ? query.IndexOf("_") : query.IndexOf("-");\r
             int dotPosition = query.IndexOf(".");\r
             if (separatorPosition > 0) {\r
@@ -201,20 +203,21 @@ namespace Maestro {
 \r
         private void SetTextSelectedSourceTextFromCheckBoxes() {\r
             String selectedNames = "";\r
-            foreach (String actual in selectedSources)\r
-                selectedNames += actual + " ";\r
+            foreach (DataGridViewRow actual in selectedRows)\r
+                selectedNames += actual.Cells[1].Value + " ";\r
             SelectedSource = new SourceInfo() {\r
                 Name = selectedNames\r
             };\r
             SetSelectedSourceFileInfo(SelectedSource);\r
-            ApplyProcessorButtonsLogic();\r
+            ApplyProcessorButtonsLogicWithoutArchiveMetadataButton();\r
         }\r
 \r
         private void SetSelectedSourceFileInfo(SourceInfo selectedSource) {\r
             if (Configuration.Source.GetType() == typeof(NEXIOSource))\r
                 selectedSource.FileInfo = null;\r
-            else if (selectedSources.Count == 1) {\r
-                Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, selectedSources[0]));\r
+            else if (selectedRows.Count == 1) {\r
+                string name = selectedRows[0].Cells[1].Value as string;\r
+                Uri inputUri = new Uri(String.Format("{0}/{1}", Configuration.Source.Local.Address.LocalPath, name));\r
                 selectedSource.FileInfo = new System.IO.FileInfo(inputUri.LocalPath);\r
             }\r
         }\r
@@ -229,9 +232,8 @@ namespace Maestro {
             if (item.IsHighlighted) {\r
                 row.DefaultCellStyle.BackColor = Color.DarkGreen;\r
                 row.DefaultCellStyle.ForeColor = Color.White;\r
-            } else {\r
+            } else\r
                 row.DefaultCellStyle = null;\r
-            }\r
         }\r
 \r
         private void dataGridSource_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {\r
@@ -240,5 +242,25 @@ namespace Maestro {
             var selectedRows = dataGridSource.SelectedRows;\r
             SetSourceFromCheckBoxAction(selectedRows);\r
         }\r
+\r
+        public void SourceDeleted(String fileName) {\r
+            foreach (DataGridViewRow actual in selectedRows) {\r
+                String actualName = actual.Cells[1].Value as string;\r
+                if (fileName.Equals(actualName)) {\r
+                    selectedRows.Remove(actual);\r
+                    if (textSelectedSource.InvokeRequired) {\r
+                        SetTextCallback d = new SetTextCallback(SetTextSelectedSourceAndMetadataButtonEnabled);\r
+                        Invoke(d);\r
+                    } else\r
+                        SetTextSelectedSourceAndMetadataButtonEnabled();\r
+                    return;\r
+                }\r
+            }\r
+        }\r
+\r
+        private void SetTextSelectedSourceAndMetadataButtonEnabled() {\r
+            SetTextSelectedSourceTextFromCheckBoxes();\r
+            SetMetadataButtonEnabled(selectedRows.Count > 0);\r
+        }\r
     }\r
 }\r
index fb4c29646202f40be4764b990bd9f4af7d5d2752..cfb0243ea69be5c96f017c0f5153b9f4ad87fe90 100644 (file)
@@ -40,15 +40,25 @@ namespace Maestro {
             checkBox.CheckStateChanged += (s, e) => {\r
                 if (checkBox.Checked) {\r
                     List<ITargetProcessor> processors = new List<ITargetProcessor>();\r
-                    foreach (String actual in selectedSources) {\r
+                    foreach (DataGridViewRow actualRow in selectedRows) {\r
+                        string fileName = actualRow.Cells[1].Value as string;\r
                         string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor);\r
                         Type type = Type.GetType(typeName);\r
-                        ISourceItem selectedFile = GetSourceItemFromBindingSource(actual);//bindingSource.Current as ISourceItem;\r
+                        ISourceItem selectedFile = GetSourceItemFromBindingSource(fileName);//bindingSource.Current as ISourceItem;\r
                         string id = selectedMetadata.ID;\r
                         object[] parameters = new object[] { this, Configuration.Source, target, selectedFile.Name, id, segments, mediaCubeApi, model };\r
                         ITargetProcessor processor = (ITargetProcessor)Activator.CreateInstance(type, parameters);\r
                         processors.Add(processor);\r
                     }\r
+                    //foreach (String actual in selectedSources) {\r
+                    //    string typeName = string.Format("{0}.{1}", typeof(ITargetProcessor).Namespace, target.Processor);\r
+                    //    Type type = Type.GetType(typeName);\r
+                    //    ISourceItem selectedFile = GetSourceItemFromBindingSource(actual);//bindingSource.Current as ISourceItem;\r
+                    //    string id = selectedMetadata.ID;\r
+                    //    object[] parameters = new object[] { this, Configuration.Source, target, selectedFile.Name, id, segments, mediaCubeApi, model };\r
+                    //    ITargetProcessor processor = (ITargetProcessor)Activator.CreateInstance(type, parameters);\r
+                    //    processors.Add(processor);\r
+                    //}\r
                     currentProcessors.Add(checkBox, processors);\r
                 } else\r
                     currentProcessors.Remove(checkBox);\r
@@ -75,17 +85,19 @@ namespace Maestro {
         }\r
 \r
         private void ApplyMetaDataButtonLogic() {\r
-            if (selectedSources.Count <= 0) {\r
+            if (selectedRows.Count <= 0) {\r
                 buttonMetadata.Enabled = false;\r
                 return;\r
             }\r
-            if (selectedSources.Count == 1)\r
+            if (selectedRows.Count == 1)\r
                 buttonMetadata.Enabled = true;\r
             else {\r
-                String calculatedHouseID = selectedSources[0];\r
-                foreach (String actual in selectedSources)\r
-                    if (!actual.StartsWith(startingName))\r
+                String calculatedHouseID = selectedRows[0].Cells[1].Value as String;\r
+                foreach (DataGridViewRow actual in selectedRows) {\r
+                    string actualName = actual.Cells[1].Value as string;\r
+                    if (!actualName.StartsWith(startingName))\r
                         buttonMetadata.Enabled = false;\r
+                }\r
             }\r
         }\r
 \r
@@ -106,7 +118,6 @@ namespace Maestro {
 \r
             if (Configuration.Player != null)\r
                 ctxiDefineSegments.Enabled = SelectedSource?.FileInfo != null && Configuration.Player.SegmentEditor && MetadataType.Traffic.Equals(SelectedMetadata?.Kind);\r
-            //todo\r
             IsSelectedFileAnID();\r
             EnableArchiveMetadataButtonAndCreateMetadataModel();\r
         }\r
@@ -218,5 +229,17 @@ namespace Maestro {
                 CreateJobsQueueWorker();\r
         }\r
 \r
+        private void ApplyProcessorButtonsLogicWithoutArchiveMetadataButton() {\r
+            ClearSelectedProcessors();\r
+            if (!String.IsNullOrEmpty(textSelectedMetadata.Text) && !String.IsNullOrEmpty(textSelectedMetadata.Text)) {\r
+                ChangeProcessButtonsState(true);\r
+            } else {\r
+                ChangeProcessButtonsState(false);\r
+            }\r
+\r
+            if (Configuration.Player != null)\r
+                ctxiDefineSegments.Enabled = SelectedSource?.FileInfo != null && Configuration.Player.SegmentEditor && MetadataType.Traffic.Equals(SelectedMetadata?.Kind);\r
+        }\r
+\r
     }\r
 }\r
index 709264e681fe1a602df0ff72a2f8489755f9218e..7a9f26b048a99b86edb472ba392853e14ad373bb 100644 (file)
@@ -157,6 +157,8 @@ namespace Maestro.Sources {
                     Source = parent\r
                 });\r
             });\r
+            MaestroForm form = (MaestroForm)parent;\r
+            form.SourceDeleted(e.Name);\r
         }\r
 \r
         public void ApplySort(ListSortDescriptionCollection sorts) {\r
index 14061b97fb4806abcd76c1e17e3e927101ad5a00..7af30395620840779dea334a20c6efaa090be21f 100644 (file)
@@ -147,7 +147,6 @@ namespace TrafficClient {
             }\r
         }\r
 \r
-        //todo visszatérés, hogy sikeres volt-e a törlés?\r
         public void DeleteSegment(int itemID, int segmentID) {\r
             try {\r
                 TryConnect();\r
index 7108731b2b46786f9f383932cb015ae3dfb8724d..b8d39babd423749bef3e8c7a484f8a0fb9b32872 100644 (file)
@@ -97,7 +97,7 @@ namespace TrafficClient {
                 return;\r
             }\r
             List<MamResultWrapper> list = new List<MamResultWrapper>();\r
-            foreach (MamResultWrapper actual in result) \r
+            foreach (MamResultWrapper actual in result)\r
                 list.Add(actual);\r
             if (CanSort(list))\r
                 list.Sort((x, y) => DateTime.Compare(x.NextBroadcastDate.Value, y.NextBroadcastDate.Value));\r
@@ -105,10 +105,9 @@ namespace TrafficClient {
         }\r
 \r
         private bool CanSort(List<MamResultWrapper> list) {\r
-            foreach (MamResultWrapper actual in list) {\r
+            foreach (MamResultWrapper actual in list)\r
                 if (!actual.NextBroadcastDate.HasValue)\r
                     return false;\r
-            }\r
             return true;\r
         }\r
 \r