private void btnMoveRowUp_Click(object sender, EventArgs e) { if (dgBuildList.SelectedRows.Count > 0) { int i = 0; var rows = new int[dgBuildList.SelectedRows.Count]; foreach (DataGridViewRow row in dgBuildList.SelectedRows) { rows[i++] = row.Index; } Array.Sort(rows); int top = 1; foreach (int row in rows) { if (row > 0) { TranslationSourceInfo ti = _sourceFiles[row]; int idx = Math.Max(row - 1, top); _sourceFiles.RemoveAt(row); _sourceFiles.Insert(idx, ti); dgBuildList.Rows[row].Selected = false; dgBuildList.Rows[idx].Selected = true; if (idx == top) { top += 1; } } } //_bindingSource.ResetBindings(false); dgBuildList.Update(); SetButtonStates(); dgBuildList.Refresh(); ColorBuildGrid(); } }
private void DgBuildListOnCellMouseUp(object sender, DataGridViewCellMouseEventArgs dataGridViewCellMouseEventArgs) { bool segmented = chkSegmentedSource.Checked; int ridx = dataGridViewCellMouseEventArgs.RowIndex; int cidx = dataGridViewCellMouseEventArgs.ColumnIndex; if (cidx == 0) { foreach (DataGridViewRow dataGridViewRow in dgBuildList.Rows) { dataGridViewRow.Cells[0].Value = null; dataGridViewRow.DefaultCellStyle.BackColor = segmented ? Color.White : Color.WhiteSmoke; dataGridViewRow.DefaultCellStyle.ForeColor = segmented ? Color.Black : Color.DarkGray; dgBuildList.InvalidateRow(dataGridViewRow.Index); _sourceFiles[dataGridViewRow.Index].Primary = false; } TranslationSourceInfo ti = _sourceFiles[ridx]; ti.Primary = true; _sourceFiles.Remove(ti); _sourceFiles.Insert(0, ti); _bindingSource.ResetBindings(false); ColorBuildGrid(); foreach (DataGridViewRow dataGridViewRow in dgBuildList.Rows) { dataGridViewRow.Selected = dataGridViewRow.Index == 0; } SetButtonStates(); } }
/** * Called when a file has been added to the Navigator. * We look to see if is a Translator source file and * is source code file. If it is we will automatically * add it to the build list. */ private void NavigatorOnFileAdded(FileInfo fi) { try { if (IsFileInSourceFolder(fi)) { var property = cmbSourceTypes.SelectedValue as string; if (property == null) { throw new Exception("No Selected Source Item"); } var sourceFileExtensions = ATMLContext.GetProperty(property) as string; if (sourceFileExtensions == null) { throw new Exception(string.Format("Failed to find property [{0}]", property)); } if (sourceFileExtensions.Contains(fi.Extension)) { if (!HasFileInBuildList(fi)) { var si = new TranslationSourceInfo(fi.Name); _sourceFiles.Add(si); //SaveProjectInfo(); SetButtonStates(); _bindingSource.ResetBindings(false); } } } } catch (Exception err) { LogManager.SourceError(ATMLTranslator.SOURCE, err); } }
private void dgBuildList_DragDrop(object sender, DragEventArgs e) { FileInfo fileInfo = _navigator.GetSelectedFile(); if (fileInfo != null) { var tsi = new TranslationSourceInfo(fileInfo.Name); if (Ok2AddFileToBuildList(fileInfo)) { _sourceFiles.Add(tsi); _bindingSource.ResetBindings(false); SetButtonStates(); } } }
private void btnAddSource_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); if (DialogResult.OK == ofd.ShowDialog()) { foreach (string fileName in ofd.FileNames) { var fi = new FileInfo(fileName); if (fi.Exists) { var tsi = new TranslationSourceInfo(fi.Name); if (Ok2AddFileToBuildList(fi)) { _sourceFiles.Add(tsi); _bindingSource.ResetBindings(false); SetButtonStates(); } } } } }
private void btnMoveRowDown_Click(object sender, EventArgs e) { if (dgBuildList.SelectedRows.Count > 0) { int i = 0; var rows = new int[dgBuildList.SelectedRows.Count]; foreach (DataGridViewRow row in dgBuildList.SelectedRows) { rows[i++] = row.Index; } Array.Sort(rows); i = dgBuildList.SelectedRows.Count; int bottom = _sourceFiles.Count; for (int x = i - 1; x >= 0; x--) { int row = rows[x]; if (row > 0) { TranslationSourceInfo ti = _sourceFiles[row]; int idx = Math.Min(row + 1, bottom - 1); _sourceFiles.RemoveAt(row); _sourceFiles.Insert(idx, ti); dgBuildList.Rows[row].Selected = false; dgBuildList.Rows[idx].Selected = true; if (idx == (bottom - 1)) { bottom -= 1; } } } //_bindingSource.ResetBindings(false); dgBuildList.Update(); SetButtonStates(); dgBuildList.Refresh(); ColorBuildGrid(); } }