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