Visual Studio开发环境加载项 VSE2017的下载、安装和使用

本加载项主要用于Visual Studio 2017 / 2019,专业版、企业版、社区版都可使用。

下载链接在本帖底部。

下载以后按照如下步骤进行安装:

  1. 完全退出Visual Studio
  2. 把VSE2017.zip下载到D:的根目录
  3. 直接解压到D:的根目录下,在D:\VSE2017\文件夹下看到3个文件夹和1个VSE2017.vsix文件
  4. 双击vsix文件,按照提示安装
  5. 重启Visual Studio

 

 

 上面3个文件夹的作用,后面讲解。

重要提示:如果你的电脑没有D:盘,则换到C:盘上操作。如果没有C:盘,就不要用本软件。因为放到其他位置不能正常工作

安装过程中的画面1:

 

 安装画面2: 

 重启Visual Studio 2017

首先看一下功能【1】:点击菜单中的按钮,可以向当前编辑文档插入代码。

 再看一下功能【2】:代码宝库

点击菜单“视图”、“其他窗口”,点击“代码宝库”。

底部多出来一个“代码宝库”窗格。鼠标选择左侧列表中的条目,右侧文本框有对应的内容。

用鼠标拖曳文本框中的内容,拖到上面文档的编辑区域,即可把代码快速复制过去。 

最后看一下功能【3】

在解决方案资源管理器的某个文件上,点击右键。右键菜单最上面的两个功能可以试一下。很好用

 

软件的禁用和卸载

如果想临时屏蔽该插件,或者完全卸载插件。请点击菜单“工具”、“扩展和更新”

 

 

 

最后说一下自定义代码的管理。本插件的界面采用XML语言定制,无法根据文件夹和文件动态生成菜单。因此自定义代码的路径和文件个数只能是固定的。

打开“D:\VSA\C#”文件夹,可以看到12个文本文件。这些是构成主菜单的来源。注意:用户不可修改12个文件的文件名称,但是可以在记事本中修改文件中的代码。

 同理,对于 D:\VSA\VB.NET文件夹,也是如此,可以修改文件内容,不可修改文件名。

提示:当你的当前项目是VB.NET语言的,那么点击菜单命令,会自动插入VB.NET文件夹中的代码。

D:\VSA\CodeLibrary文件夹的原理更为简单,该文件夹为“代码宝库”窗格提供数据源。用户可以任意增删里面的文本文件数量,也可以任意修改文件名和文件内容。

下次启动Visual Studio会重新读取。

附:Visual Studio 2019中的安装和使用

选择想要安装的版本,勾选其中一个就行。 对话框右侧有许可协议“License”

 

安装无论成功失败,可以点击左下角的“View Install Log”查看原因和细节。

 

 

 在使用方面,VSA主菜单直接看不见,需要点击“扩展”菜单,在下面可以找到。

 

 其他功能与VS2017中完全一样。

插件的禁用和卸载

需要点击菜单“扩展”、“管理扩展”,弹出对话框。

 备注:本产品不能用于 Visual Studio 2015及其以下版本。   

*重大更新

2021/9/29 软件名称更改为 VSE2017

在代码窗口的右键菜单中增加 “转换代码语言”的功能。用户选中一部分代码,点击该命令,可以在C#和VB.NET之间转换。

 

假设原先的VB.NET代码是:

复制代码
Imports System.Net
Imports System.Text.RegularExpressions
Public Class Bing
    Private WC As WebClient
    Private ig As String
    Private token As String
    Private key As String
    Private auth As String
    Private dic As Dictionary(Of String, String)
    Private ResponseText As String
    Private Reg As Regex
    Private MC As MatchCollection
    Private M As Match
    Public Sub New()
        MyBase.New()
        GetToken()
        GetAuth()
    End Sub
    Private Sub GetToken()
        Dim value As String
        WC = New WebClient
        ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
        With WC
            .Encoding = System.Text.Encoding.UTF8
            .Headers.Add(header:=HttpRequestHeader.UserAgent, value:="Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36")
            ResponseText = .DownloadString(address:="https://cn.bing.com/search?q=translate&FORM=BESBTB")
        End With
        Reg = New Regex(pattern:=Replace("'ig':'(.+?)'.+?var\s*params_RichTranslateHelper\s*=\s*\[(.+?),\s*'(.+?)'", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        M = Reg.Match(input:=ResponseText)
        ig = M.Groups(1).Value
        key = M.Groups(2).Value
        token = M.Groups(3).Value
        Reg = New Regex(pattern:=Replace("case'([^']+?)':t='([^']+?)';i='([^']+?)';r='([^']+?)';break;", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        MC = Reg.Matches(input:=ResponseText)
        dic = New Dictionary(Of String, String)
        For Each M In MC
            value = String.Format("<speak version='1.0' xml:lang='{2}'><voice xml:lang='{2}' xml:gender='{3}' name='{4}'><prosody rate='-20.00%'>[text]</prosody></voice></speak>", M.Groups(0).Value, M.Groups(1).Value, M.Groups(2).Value, M.Groups(3).Value, M.Groups(4).Value)
            dic.Add(key:=M.Groups(1).Value, value:=value)
        Next
    End Sub

    Private Sub GetAuth()
        WC = New WebClient
        With WC
            .Encoding = System.Text.Encoding.UTF8
            .Headers.Add(header:=HttpRequestHeader.ContentType, value:="application/x-www-form-urlencoded")
            ResponseText = .UploadString(address:=String.Format("http://cn.bing.com/tfetspktok?isVertical=1&&IG={0}&IID=translator.5022.1 HTTP/1.1&token={1}&key={2}", ig, token, key), method:="POST", data:="")
        End With
        Reg = New Regex(pattern:=Replace("'token':'([^']+?)'", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        M = Reg.Match(input:=ResponseText)
        auth = M.Groups(1).Value
    End Sub
    Public Function LanguageNameList() As String()
        Return dic.Keys.ToArray
    End Function

    Public Function Translate(ByVal from As String, ByVal too As String, ByVal text As String) As String
        text = System.Web.HttpUtility.UrlEncode(str:=text, e:=System.Text.Encoding.UTF8)
        WC = New WebClient
        With WC
            .Encoding = System.Text.Encoding.UTF8
            .Headers.Add(header:=HttpRequestHeader.ContentType, value:="application/x-www-form-urlencoded")
            .Headers.Add(header:=HttpRequestHeader.UserAgent, value:="Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36")
            ResponseText = .UploadString(address:=String.Format("https://cn.bing.com/ttranslatev3?&IG={0}&IID=SERP.5537.18", ig), data:=String.Format("&fromLang={0}&to={1}&text={2}&token={3}&key={4}", from, too, text, token, key), method:="POST")
        End With
        Reg = New Regex(pattern:=Replace("'translations':\[\{'text':'([^']+?)'", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        M = Reg.Match(input:=ResponseText)
        Return M.Groups(1).Value
    End Function

    Public Function Tlookup(ByVal from As String, ByVal too As String, ByVal text As String) As String()
        Dim L As List(Of String)
        text = System.Web.HttpUtility.UrlEncode(str:=text, e:=System.Text.Encoding.UTF8)
        WC = New WebClient
        With WC
            .Encoding = System.Text.Encoding.UTF8
            .Headers.Add(header:=HttpRequestHeader.ContentType, value:="application/x-www-form-urlencoded")
            ResponseText = .UploadString(address:=String.Format("https://cn.bing.com/tlookupv3?&IG={0}&IID=SERP.5537.3", ig), data:=String.Format("&from={0}&to={1}&text={2}&token={3}&key={4}", from, too, text, token, key), method:="POST")
        End With
        Reg = New Regex(pattern:=Replace("'normalizedTarget':'([^']+?)'", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        MC = Reg.Matches(input:=ResponseText)
        L = New List(Of String)
        For Each M In MC
            ResponseText = M.Groups(1).Value
            L.Add(ResponseText)
        Next M
        Return L.ToArray
    End Function

    Public Sub Text2MP3(lang As String, text As String, filename As String, Optional url As String = "https://southeastasia.tts.speech.microsoft.com/cognitiveservices/v1?")
        Dim b As Byte()
        Dim data As String
        If dic.ContainsKey(lang) Then
            data = Replace(dic.Item(lang), "[text]", text)
            b = System.Text.Encoding.UTF8.GetBytes(data)
            WC = New WebClient
            ServicePointManager.SecurityProtocol = CType(3072, SecurityProtocolType)
            '这句用于解决 “请求被终止,未能创建未能创建 SSL/TLS 安全通道”
            With WC
                .Encoding = System.Text.Encoding.UTF8
                .Headers.Add(HttpRequestHeader.ContentType, "application/ssml+xml")
                .Headers.Add(HttpRequestHeader.Authorization, "Bearer " & auth)
                .Headers.Add("x-microsoft-outputformat", "audio-16khz-32kbitrate-mono-mp3")
                .Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36")
                b = .UploadData(address:=url, data:=b)
            End With
            If My.Computer.FileSystem.FileExists(filename) Then
                My.Computer.FileSystem.DeleteFile(filename)
            End If
            My.Computer.FileSystem.WriteAllBytes(file:=filename, data:=b, append:=False)
        Else
            MsgBox("Invalid Parameter.", vbCritical)
        End If
    End Sub

    Public Function English2Chinese(ByVal text As String) As String()
        Dim L As List(Of String)
        WC = New WebClient
        With WC
            .Headers.Add(header:=HttpRequestHeader.ContentType, value:="text/html; charset=utf-8")
            .Headers.Add(header:=HttpRequestHeader.UserAgent, value:="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36")
            ResponseText = .DownloadString(address:="https://cn.bing.com/dict/SerpHoverTrans?q=" & text)
        End With
        Reg = New Regex(pattern:=Replace("<span class='ht_pos'>(.+?)</span><span class='ht_trs'>(.+?)</span>", Chr(39), Chr(34)), options:=RegexOptions.IgnoreCase)
        MC = Reg.Matches(input:=ResponseText)
        L = New List(Of String)
        For Each M In MC
            L.Add(M.Groups(1).Value & "|" & M.Groups(2).Value)
        Next
        Return L.ToArray()
    End Function
End Class
复制代码

 

 

转换后的代码为:

 

复制代码
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.Net;
using System.Text.RegularExpressions;

public class Bing
{
    private WebClient WC;
    private string ig;
    private string token;
    private string key;
    private string auth;
    private Dictionary<string, string> dic;
    private string ResponseText;
    private Regex Reg;
    private MatchCollection MC;
    private Match M;
    public Bing() : base()
    {
        GetToken();
        GetAuth();
    }
    private void GetToken()
    {
        string value;
        WC = new WebClient();
        ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
        {
            var withBlock = WC;
            withBlock.Encoding = System.Text.Encoding.UTF8;
            withBlock.Headers.Add(header: HttpRequestHeader.UserAgent, value: "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36");
            ResponseText = withBlock.DownloadString(address: "https://cn.bing.com/search?q=translate&FORM=BESBTB");
        }
        Reg = new Regex(pattern: Replace(@"'ig':'(.+?)'.+?var\s*params_RichTranslateHelper\s*=\s*\[(.+?),\s*'(.+?)'", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        M = Reg.Match(input: ResponseText);
        ig = M.Groups(1).Value;
        key = M.Groups(2).Value;
        token = M.Groups(3).Value;
        Reg = new Regex(pattern: Replace("case'([^']+?)':t='([^']+?)';i='([^']+?)';r='([^']+?)';break;", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        MC = Reg.Matches(input: ResponseText);
        dic = new Dictionary<string, string>();
        foreach (var M in MC)
        {
            value = string.Format("<speak version='1.0' xml:lang='{2}'><voice xml:lang='{2}' xml:gender='{3}' name='{4}'><prosody rate='-20.00%'>[text]</prosody></voice></speak>", M.Groups(0).Value, M.Groups(1).Value, M.Groups(2).Value, M.Groups(3).Value, M.Groups(4).Value);
            dic.Add(key: M.Groups(1).Value, value: value);
        }
    }

    private void GetAuth()
    {
        WC = new WebClient();
        {
            var withBlock = WC;
            withBlock.Encoding = System.Text.Encoding.UTF8;
            withBlock.Headers.Add(header: HttpRequestHeader.ContentType, value: "application/x-www-form-urlencoded");
            ResponseText = withBlock.UploadString(address: string.Format("http://cn.bing.com/tfetspktok?isVertical=1&&IG={0}&IID=translator.5022.1 HTTP/1.1&token={1}&key={2}", ig, token, key), method: "POST", data: "");
        }
        Reg = new Regex(pattern: Replace("'token':'([^']+?)'", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        M = Reg.Match(input: ResponseText);
        auth = M.Groups(1).Value;
    }
    public string[] LanguageNameList()
    {
        return dic.Keys.ToArray;
    }

    public string Translate(string from, string too, string text)
    {
        text = System.Web.HttpUtility.UrlEncode(str: text, e: System.Text.Encoding.UTF8);
        WC = new WebClient();
        {
            var withBlock = WC;
            withBlock.Encoding = System.Text.Encoding.UTF8;
            withBlock.Headers.Add(header: HttpRequestHeader.ContentType, value: "application/x-www-form-urlencoded");
            withBlock.Headers.Add(header: HttpRequestHeader.UserAgent, value: "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36");
            ResponseText = withBlock.UploadString(address: string.Format("https://cn.bing.com/ttranslatev3?&IG={0}&IID=SERP.5537.18", ig), data: string.Format("&fromLang={0}&to={1}&text={2}&token={3}&key={4}", from, too, text, token, key), method: "POST");
        }
        Reg = new Regex(pattern: Replace(@"'translations':\[\{'text':'([^']+?)'", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        M = Reg.Match(input: ResponseText);
        return M.Groups(1).Value;
    }

    public string[] Tlookup(string from, string too, string text)
    {
        List<string> L;
        text = System.Web.HttpUtility.UrlEncode(str: text, e: System.Text.Encoding.UTF8);
        WC = new WebClient();
        {
            var withBlock = WC;
            withBlock.Encoding = System.Text.Encoding.UTF8;
            withBlock.Headers.Add(header: HttpRequestHeader.ContentType, value: "application/x-www-form-urlencoded");
            ResponseText = withBlock.UploadString(address: string.Format("https://cn.bing.com/tlookupv3?&IG={0}&IID=SERP.5537.3", ig), data: string.Format("&from={0}&to={1}&text={2}&token={3}&key={4}", from, too, text, token, key), method: "POST");
        }
        Reg = new Regex(pattern: Replace("'normalizedTarget':'([^']+?)'", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        MC = Reg.Matches(input: ResponseText);
        L = new List<string>();
        foreach (var M in MC)
        {
            ResponseText = M.Groups(1).Value;
            L.Add(ResponseText);
        }
        return L.ToArray();
    }

    public void Text2MP3(string lang, string text, string filename, string url = "https://southeastasia.tts.speech.microsoft.com/cognitiveservices/v1?")
    {
        byte[] b;
        string data;
        if (dic.ContainsKey(lang))
        {
            data = Replace(dic.Item[lang], "[text]", text);
            b = System.Text.Encoding.UTF8.GetBytes(data);
            WC = new WebClient();
            ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
            // 这句用于解决 “请求被终止,未能创建未能创建 SSL/TLS 安全通道”
            {
                var withBlock = WC;
                withBlock.Encoding = System.Text.Encoding.UTF8;
                withBlock.Headers.Add(HttpRequestHeader.ContentType, "application/ssml+xml");
                withBlock.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + auth);
                withBlock.Headers.Add("x-microsoft-outputformat", "audio-16khz-32kbitrate-mono-mp3");
                withBlock.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36");
                b = withBlock.UploadData(address: url, data: b);
            }
            if (My.Computer.FileSystem.FileExists(filename))
                My.Computer.FileSystem.DeleteFile(filename);
            My.Computer.FileSystem.WriteAllBytes(file: filename, data: b, append: false);
        }
        else
            MsgBox("Invalid Parameter.", Constants.vbCritical);
    }

    public string[] English2Chinese(string text)
    {
        List<string> L;
        WC = new WebClient();
        {
            var withBlock = WC;
            withBlock.Headers.Add(header: HttpRequestHeader.ContentType, value: "text/html; charset=utf-8");
            withBlock.Headers.Add(header: HttpRequestHeader.UserAgent, value: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36");
            ResponseText = withBlock.DownloadString(address: "https://cn.bing.com/dict/SerpHoverTrans?q=" + text);
        }
        Reg = new Regex(pattern: Replace("<span class='ht_pos'>(.+?)</span><span class='ht_trs'>(.+?)</span>", Strings.Chr(39), Strings.Chr(34)), options: RegexOptions.IgnoreCase);
        MC = Reg.Matches(input: ResponseText);
        L = new List<string>();
        foreach (var M in MC)
            L.Add(M.Groups(1).Value + "|" + M.Groups(2).Value);
        return L.ToArray();
    }
}
复制代码

 

 

 

 

下载地址:

VSE2017.zip 

posted @   ryueifu  阅读(3433)  评论(1编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示