From d6c88a215e88c82aed3c0b2cd2ae33576e37ea6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bellai=20=C3=81d=C3=A1m?= Date: Tue, 3 Oct 2017 12:41:27 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30515 --- client/Maestro/MaestroForm.Source.cs | 65 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index c944991c..fcdf2146 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -92,17 +92,18 @@ namespace Maestro { } private void sourceGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { - var selectedItem = bindingSource.Current; - if (selectedItem == null) { + var selectedrows = dataGridSource.SelectedRows; + var selectedItems = bindingSource.Current; + if (selectedrows == null) { return; } if (e.ColumnIndex == 0) { - SetSourceFromCheckBoxAction(sender, selectedItem); + SetSourceFromCheckBoxAction(selectedrows); return; } if (e.ColumnIndex != 3) return; - FileSourceItem fileSourceItem = selectedItem as FileSourceItem; + FileSourceItem fileSourceItem = selectedItems as FileSourceItem; if (fileSourceItem == null) return; Cursor = Cursors.WaitCursor; @@ -115,26 +116,42 @@ namespace Maestro { })); } - private void SetSourceFromCheckBoxAction(object sender, object selectedItem) { + private void SetSourceFromCheckBoxAction(DataGridViewSelectedRowCollection selectedRows) { String name; - NexioSourceItem n = selectedItem as NexioSourceItem; - if (n == null) { - FileSourceItem f = selectedItem as FileSourceItem; - name = f.Name; - } else name = n.Name; + bool valueOfCheckBoxes = GetValueOfCheckBoxes(selectedRows); + foreach (DataGridViewRow actualRow in selectedRows) { + var cells = actualRow.Cells; + if (cells.Count <= 0) + return; + name = cells[1].Value as string; + if (String.IsNullOrEmpty(name)) + return; + DataGridViewCheckBoxCell checkBoxCell = cells[0] as DataGridViewCheckBoxCell; + if (selectedRows.Count > 1) + checkBoxCell.Value = valueOfCheckBoxes; + else + checkBoxCell.Value = (checkBoxCell.Value == null || checkBoxCell.Value.Equals(false)) ? true : false; + if (checkBoxCell.Value.Equals(false)) + selectedSources.Remove(name); + else { + if (!selectedSources.Contains(name)) + selectedSources.Add(name); + } + SetTextSelectedSourceTextFromCheckBoxes(); + SetMetadataButtonEnabled((bool)checkBoxCell.Value); + } + } - DataGridView gridView = sender as DataGridView; - var cells = gridView.SelectedCells; - if (cells.Count <= 0) - return; - DataGridViewCheckBoxCell checkBoxCell = cells[0] as DataGridViewCheckBoxCell; - checkBoxCell.Value = (checkBoxCell.Value == null || checkBoxCell.Value.Equals(false)) ? true : false; - if (checkBoxCell.Value.Equals(false)) - selectedSources.Remove(name); - else - selectedSources.Add(name); - SetTextSelectedSourceTextFromCheckBoxes(); - SetMetadataButtonEnabled((bool)checkBoxCell.Value); + private bool GetValueOfCheckBoxes(DataGridViewSelectedRowCollection selectedRows) { + bool result = true; + foreach (DataGridViewRow actualRow in selectedRows) { + var cells = actualRow.Cells; + DataGridViewCheckBoxCell checkBoxCell = cells[0] as DataGridViewCheckBoxCell; + if (checkBoxCell.Value != null && checkBoxCell.Value.Equals(true)) + result = false; + else { result = true; return result; } + } + return result; } private void SetMetadataButtonEnabled(bool checkBox) { @@ -220,8 +237,8 @@ namespace Maestro { private void dataGridSource_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex < 0) return; - var selectedItem = bindingSource.Current; - SetSourceFromCheckBoxAction(sender, selectedItem); + var selectedRows = dataGridSource.SelectedRows; + SetSourceFromCheckBoxAction(selectedRows); } } } -- 2.54.0