Exemple #1
0
        void CodeEditorMenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            var menuItem = sender as OleMenuCommand;

            if (menuItem != null)
            {
                if (!package.DisableConverterInContextMenu)
                {
                    menuItem.Visible = !CodeConversion.GetCSSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.IsEmpty ?? false;
                }
                else
                {
                    menuItem.Visible = false;
                }
            }
        }
Exemple #2
0
        void ProjectItemMenuItem_BeforeQueryStatus(object sender, EventArgs e)
        {
            var menuItem = sender as OleMenuCommand;

            if (menuItem != null)
            {
                menuItem.Visible = false;
                menuItem.Enabled = false;

                string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
                var    fileInfo = new FileInfo(itemPath);
                if (!CodeConversion.IsCSFileName(fileInfo.Name))
                {
                    return;
                }

                menuItem.Visible = true;
                menuItem.Enabled = true;
            }
        }
        async void ProjectItemMenuItemCallback(object sender, EventArgs e)
        {
            string itemPath = VisualStudioInteraction.GetSingleSelectedItemPath();
            var    fileInfo = new FileInfo(itemPath);

            if (!CodeConversion.IsVBFileName(fileInfo.Name))
            {
                return;
            }

            try {
                using (StreamReader reader = new StreamReader(itemPath)) {
                    string csCode = await reader.ReadToEndAsync();

                    CodeConversion.PerformVBToCSConversion(ServiceProvider, csCode);
                }
            } catch (Exception ex) {
                VisualStudioInteraction.ShowException(ServiceProvider, CodeConversion.VBToCSConversionTitle, ex);
            }
        }
Exemple #4
0
        void CodeEditorMenuItemCallback(object sender, EventArgs e)
        {
            string selectedText = CodeConversion.GetCSSelectionInCurrentView(ServiceProvider)?.StreamSelectionSpan.GetText();

            CodeConversion.PerformCSToVBConversion(ServiceProvider, selectedText);
        }