From: Bellai Ádám Date: Mon, 16 Oct 2017 13:35:14 +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=d55041bdcccc3df2c350ac8ac762483743088b83;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30626 --- diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 6b86b104..43cc83c0 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -9,7 +9,7 @@ using System.Collections.ObjectModel; using System.Drawing; using System.Linq; using System.Windows.Forms; -using System.Text; +using System.Linq; namespace Maestro { @@ -113,14 +113,16 @@ namespace Maestro { private void SetSourceFromCheckBoxAction(DataGridViewSelectedRowCollection selectedRows) { String name; bool valueOfCheckBoxes = GetValueOfCheckBoxes(selectedRows); + int nameIndex = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; + int checkBoxIndex = dataGridSource.Columns.Cast().Where(x => x.GetType() == typeof(DataGridViewCheckBoxColumn)).SingleOrDefault().Index; foreach (DataGridViewRow actualRow in selectedRows) { var cells = actualRow.Cells; if (cells.Count <= 0) return; - name = cells[1].Value as string; + name = cells[nameIndex].Value as string; if (String.IsNullOrEmpty(name)) return; - DataGridViewCheckBoxCell checkBoxCell = cells[0] as DataGridViewCheckBoxCell; + DataGridViewCheckBoxCell checkBoxCell = cells[checkBoxIndex] as DataGridViewCheckBoxCell; if (selectedRows.Count > 1) checkBoxCell.Value = valueOfCheckBoxes; else @@ -138,9 +140,10 @@ namespace Maestro { private bool GetValueOfCheckBoxes(DataGridViewSelectedRowCollection selectedRows) { bool result = true; + int index = dataGridSource.Columns.Cast().Where(x => x.GetType() == typeof(DataGridViewCheckBoxColumn)).SingleOrDefault().Index; foreach (DataGridViewRow actualRow in selectedRows) { var cells = actualRow.Cells; - DataGridViewCheckBoxCell checkBoxCell = cells[0] as DataGridViewCheckBoxCell; + DataGridViewCheckBoxCell checkBoxCell = cells[index] as DataGridViewCheckBoxCell; if (checkBoxCell.Value != null && checkBoxCell.Value.Equals(true)) result = false; else { result = true; return result; } @@ -160,9 +163,9 @@ namespace Maestro { IsSelectedFileAnID(); return; } - + int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; foreach (DataGridViewRow actual in selectedRows) { - string name = actual.Cells[1].Value as string; + string name = actual.Cells[index].Value as string; if (!name.StartsWith(String.Format("{0}-", startingName)) && !name.StartsWith(String.Format("{0}_", startingName)) && !name.StartsWith(String.Format("{0}.", startingName))) { @@ -180,8 +183,9 @@ namespace Maestro { startingName = null; return; } - string query = selectedRows[0].Cells[1].Value as string; - int separatorPosition = query.IndexOf("-");//< 0 ? query.IndexOf("_") : query.IndexOf("-"); + int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; + string query = selectedRows[0].Cells[index].Value as string; + int separatorPosition = query.IndexOf("-"); int separatorPosition2 = query.IndexOf("_"); int realseparatorPosition = 0; if (separatorPosition < 0) @@ -203,8 +207,9 @@ namespace Maestro { private void SetTextSelectedSourceTextFromCheckBoxes() { String selectedNames = ""; - foreach (DataGridViewRow actual in selectedRows) - selectedNames += actual.Cells[1].Value + " "; + int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; + foreach (DataGridViewRow actual in selectedRows) + selectedNames += actual.Cells[index].Value + " "; SelectedSource = new SourceInfo() { Name = selectedNames }; @@ -216,7 +221,8 @@ namespace Maestro { if (Configuration.Source.GetType() == typeof(NEXIOSource)) selectedSource.FileInfo = null; else if (selectedRows.Count == 1) { - string name = selectedRows[0].Cells[1].Value as string; + int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; + string name = selectedRows[0].Cells[index].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); } @@ -244,8 +250,9 @@ namespace Maestro { } public void SourceDeleted(String fileName) { + int index = dataGridSource.Columns.Cast().Where(x => x.HeaderText == StringResources.NEV).SingleOrDefault().Index; foreach (DataGridViewRow actual in selectedRows) { - String actualName = actual.Cells[1].Value as string; + String actualName = actual.Cells[index].Value as string; if (fileName.Equals(actualName)) { selectedRows.Remove(actual); if (textSelectedSource.InvokeRequired) {