private async Task ConvertDocumentAsync(string documentPath, Span selected) { if (documentPath == null || !CodeConversion.IsVBFileName(documentPath)) { return; } try { await _codeConversion.PerformDocumentConversionAsync <VBToCSConversion>(documentPath, selected); } catch (Exception ex) { await VisualStudioInteraction.ShowExceptionAsync(ServiceProvider, CodeConversion.ConverterTitle, ex); } }
private async Task ProjectItemMenuItem_BeforeQueryStatusAsync(object sender, EventArgs e) { if (sender is OleMenuCommand menuItem) { menuItem.Visible = false; menuItem.Enabled = false; string itemPath = (await VisualStudioInteraction.GetSingleSelectedItemOrDefaultAsync())?.ItemPath; if (itemPath == null || !CodeConversion.IsVBFileName(itemPath)) { return; } menuItem.Visible = true; menuItem.Enabled = true; } }
void ProjectItemMenuItem_BeforeQueryStatus(object sender, EventArgs e) { var menuItem = sender as OleMenuCommand; if (menuItem != null) { menuItem.Visible = false; menuItem.Enabled = false; string itemPath = VisualStudioInteraction.GetSingleSelectedItemOrDefault()?.ItemPath; if (itemPath == null || !CodeConversion.IsVBFileName(itemPath)) { return; } menuItem.Visible = true; menuItem.Enabled = true; } }