/// <summary> /// Restores the removed rows /// </summary> public override List <DataGridViewRow> RestoreRemovedRows() { ClearSelection(); previouslySelectedRow = null; List <DataGridViewRow> list = base.RestoreRemovedRows(); if (!string.IsNullOrEmpty(ContextColumnName) && Columns.Contains(ContextColumnName) && list != null) { foreach (DataGridViewKeyValueRow <CodeStringResultItem> row in list) { if (row.Index == -1) { continue; } DataGridViewDynamicWrapCell c = (DataGridViewDynamicWrapCell)row.Cells[ContextColumnName]; c.SetWrapContents(false); } } // perform sorting if (SortedColumn != null) { Sort(SortedColumn, SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } return(list); }
/// <summary> /// Sets content of the grid /// </summary> public override void SetData(List <CodeStringResultItem> value) { if (value == null) { throw new ArgumentNullException("value"); } try { base.SetData(value); this.Rows.Clear(); destinationItemsCache.Clear(); resxItemsCache.Clear(); loadedItems.Clear(); CheckedRowsCount = 0; SuspendLayout(); // set "context" column visibility according to settings if (Columns.Contains(ContextColumnName)) { Columns[ContextColumnName].Visible = SettingsObject.Instance.ShowContextColumn; } foreach (CodeStringResultItem item in value) { DataGridViewKeyValueRow <CodeStringResultItem> row = new DataGridViewKeyValueRow <CodeStringResultItem>(); row.DataSourceItem = item; DataGridViewCheckBoxCell checkCell = new DataGridViewCheckBoxCell(); checkCell.Value = false; row.Cells.Add(checkCell); DataGridViewTextBoxCell locProbCell = new DataGridViewTextBoxCell(); row.Cells.Add(locProbCell); DataGridViewTextBoxCell lineCell = new DataGridViewTextBoxCell(); lineCell.Value = item.ReplaceSpan.iStartLine + 1; row.Cells.Add(lineCell); DataGridViewComboBoxCell keyCell = new DataGridViewComboBoxCell(); // add key name suggestions foreach (string key in item.GetKeyNameSuggestions()) { keyCell.Items.Add(key); if (keyCell.Value == null) // add first suggestion as default value { keyCell.Value = key; } } if (SettingsObject.Instance.SelectedKeyIndex >= 0 && SettingsObject.Instance.SelectedKeyIndex < keyCell.Items.Count) { keyCell.Value = keyCell.Items[SettingsObject.Instance.SelectedKeyIndex]; } row.Cells.Add(keyCell); DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell(); valueCell.Value = item.Value; row.Cells.Add(valueCell); DataGridViewTextBoxCell sourceCell = new DataGridViewTextBoxCell(); sourceCell.Value = item.SourceItem.Name; row.Cells.Add(sourceCell); DataGridViewComboBoxCell destinationCell = new DataGridViewComboBoxCell(); // add possible ResX files as destinations destinationCell.Items.AddRange(CreateDestinationOptions(destinationCell, item.SourceItem)); if (destinationCell.Items.Count > 0) { destinationCell.Value = destinationCell.Items[0].ToString(); } row.Cells.Add(destinationCell); DataGridViewDynamicWrapCell contextCell = new DataGridViewDynamicWrapCell(); contextCell.Value = item.Context; contextCell.RelativeLine = item.ContextRelativeLine; contextCell.FullText = item.Context; contextCell.SetWrapContents(false); row.Cells.Add(contextCell); DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); row.Cells.Add(cell); Rows.Add(row); locProbCell.ReadOnly = true; valueCell.ReadOnly = false; sourceCell.ReadOnly = true; lineCell.ReadOnly = true; contextCell.ReadOnly = true; var x = row.Cells[ContextColumnName]; Validate(row); keyCell.Tag = keyCell.Value; } this.ClearSelection(); this.ResumeLayout(); this.OnResize(null); parentToolPanel.ResetFilterSettings(); // reset filter according to settings UpdateCheckHeader(); // perform sorting if (SortedColumn != null) { Sort(SortedColumn, SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } } finally { SetDataFinished = true; } }
/// <summary> /// Sets grid content /// </summary> public override void SetData(List <CodeReferenceResultItem> value) { if (value == null) { throw new ArgumentNullException("value"); } try { Rows.Clear(); errorRows.Clear(); this.SuspendLayout(); // adjust "context" column visibility according to the settings if (Columns.Contains(ContextColumnName)) { Columns[ContextColumnName].Visible = SettingsObject.Instance.ShowContextColumn; } // create new row for each result item foreach (var item in value) { DataGridViewCheckedRow <CodeReferenceResultItem> row = new DataGridViewCheckedRow <CodeReferenceResultItem>(); row.DataSourceItem = item; DataGridViewCheckBoxCell checkCell = new DataGridViewCheckBoxCell(); checkCell.Value = item.MoveThisItem; row.Cells.Add(checkCell); DataGridViewTextBoxCell lineCell = new DataGridViewTextBoxCell(); lineCell.Value = item.ReplaceSpan.iStartLine + 1; row.Cells.Add(lineCell); DataGridViewTextBoxCell referenceCell = new DataGridViewTextBoxCell(); referenceCell.Value = item.FullReferenceText; row.Cells.Add(referenceCell); DataGridViewTextBoxCell valueCell = new DataGridViewTextBoxCell(); valueCell.Value = item.Value; row.Cells.Add(valueCell); DataGridViewTextBoxCell sourceCell = new DataGridViewTextBoxCell(); sourceCell.Value = item.SourceItem.Name; row.Cells.Add(sourceCell); DataGridViewTextBoxCell destinationCell = new DataGridViewTextBoxCell(); destinationCell.Value = item.DestinationItem.ToString(); if (LockFiles) { VLDocumentViewsManager.SetFileReadonly(item.DestinationItem.InternalProjectItem.GetFullPath(), true); // lock selected destination file } row.Cells.Add(destinationCell); DataGridViewDynamicWrapCell contextCell = new DataGridViewDynamicWrapCell(); contextCell.Value = item.Context; contextCell.RelativeLine = item.ContextRelativeLine; contextCell.FullText = item.Context; contextCell.SetWrapContents(false); row.Cells.Add(contextCell); DataGridViewTextBoxCell cell = new DataGridViewTextBoxCell(); row.Cells.Add(cell); Rows.Add(row); referenceCell.ReadOnly = true; valueCell.ReadOnly = true; sourceCell.ReadOnly = true; destinationCell.ReadOnly = true; lineCell.ReadOnly = true; contextCell.ReadOnly = true; } CheckedRowsCount = Rows.Count; CheckHeader.Checked = true; this.ClearSelection(); this.ResumeLayout(true); this.OnResize(null); NotifyErrorRowsChanged(); // perform sorting if (SortedColumn != null) { Sort(SortedColumn, SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending); } } finally { SetDataFinished = true; } }