/// <summary> /// "Run" button clicked /// </summary> private void RunClick(object sender, EventArgs e) { int checkedRows = panel.CheckedRowsCount; int rowCount = panel.Rows.Count; int rowErrors = 0; try { VLDocumentViewsManager.ReleaseLocks(); // unlock locked documents MenuManager.OperationInProgress = false; // permit other operations BatchInliner inliner = new BatchInliner(); inliner.Inline(panel.GetData(), false, ref rowErrors); // run inliner } catch (Exception ex) { VLOutputWindow.VisualLocalizerPane.WriteException(ex); MessageBox.ShowException(ex); } finally { if (this.Frame != null) ((IVsWindowFrame)this.Frame).CloseFrame((uint)__FRAMECLOSE.FRAMECLOSE_NoSave); // close the toolwindow panel.Clear(); VLOutputWindow.VisualLocalizerPane.Activate(); VLOutputWindow.VisualLocalizerPane.WriteLine("Batch Inline command completed - selected {0} rows of {1}, {2} rows processed successfully", checkedRows, rowCount, checkedRows - rowErrors); } }
/// <summary> /// Called from editor when Inline operation is requested /// </summary> /// <param name="kind">Bitmask of INLINEKIND parameters</param> private void EditorControl_InlineRequested(INLINEKIND kind) { bool readonlyExists = false; foreach (ResXStringGridRow row in SelectedRows) { if (row.IsNewRow) { continue; } readonlyExists = readonlyExists || row.CodeReferenceContainsReadonly; if (readonlyExists) { break; } } if (readonlyExists) { VisualLocalizer.Library.Components.MessageBox.ShowError("This operation cannot be executed, because some of the references are located in readonly files."); return; } // show confirmation DialogResult result = VisualLocalizer.Library.Components.MessageBox.Show("This operation is irreversible, cannot be undone globally, only using undo managers in open files. Do you want to proceed?", null, OLEMSGBUTTON.OLEMSGBUTTON_YESNO, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, OLEMSGICON.OLEMSGICON_WARNING); if (result == DialogResult.Yes) { try { editorControl.ReferenceCounterThreadSuspended = true; // suspend reference lookuper thread if ((kind & INLINEKIND.INLINE) == INLINEKIND.INLINE) { editorControl.UpdateReferencesCount((IEnumerable)SelectedRows); // update references for specified rows manually List <CodeReferenceResultItem> totalList = new List <CodeReferenceResultItem>(); foreach (ResXStringGridRow row in SelectedRows) { if (!row.IsNewRow) { totalList.AddRange(row.CodeReferences); } } BatchInliner inliner = new BatchInliner(); // run inliner int errors = 0; inliner.Inline(totalList, false, ref errors); VLOutputWindow.VisualLocalizerPane.WriteLine("Inlining of selected rows finished - found {0} references, {1} finished successfuly", totalList.Count, totalList.Count - errors); } if ((kind & INLINEKIND.REMOVE) == INLINEKIND.REMOVE) { // remove the rows if requested RemoveStringsUndoUnit removeUnit = null; EditorControl_RemoveRequested(REMOVEKIND.REMOVE, false, out removeUnit); } StringInlinedUndoItem undoItem = new StringInlinedUndoItem(SelectedRows.Count); editorControl.Editor.AddUndoUnit(undoItem); } catch (Exception ex) { VLOutputWindow.VisualLocalizerPane.WriteException(ex); VisualLocalizer.Library.Components.MessageBox.ShowException(ex); } finally { editorControl.ReferenceCounterThreadSuspended = false; } } }