(这篇教程发出去以后,各位大佬们问题反馈还是挺多的,没办法,我看到底下网友提出来一种比较简单的方法,今天又重新做了一次,各位大佬可以参考一下。)
速成教程的链接地址:https://blog.csdn.net/bin_ge_love/article/details/80742226
这算是第一次写关于软件配置方面的博客,或者说教程吧,所以写的尽量详细一点。
为了更换vs2013的背景,在网上查资料,然后自己试着弄,折腾了好久才弄好的,为了让大家少走弯路,少费点时间,所以我写一篇博客,帮助真正需要的小伙伴们。前一段时间刚配置好的vs2013主题背景,发出来先让大家看看呗(背景图片可以自己更换哦)
本片博客主要解决win10用户上安装Visual Studio 2013 Color Theme Editor的问题
废话不多说,下来进入正题:
1.安装需要的插件
1> Visual Studio 2013 SDK(可以在vs2013--->工具---->扩展和扩展-->联机 里边搜索下载)
下载的地址: http://www.microsoft.com/en-au/download/details.aspx?id=40758
2> Visual Studio 2013Color Theme Editor(win7用户可以在vs2013--->工具---->扩展和扩展-->联机 里边搜索下载。。。
如果不会或者嫌搜索麻烦,博客后边有更加详细的教程,往下看哦!)
下载地址:https://visualstudiogallery.msdn.microsoft.com/9e08e5d3-6eb4-4e73-a045-6ea2a5cbdabe(可以在网上搜这个名字,下载一个就ok)
win10的系统貌似可以下载并安装 上面的 第一个插件,第二个插件安装的时候会报错,或者两个安装时都报错(win7的可以直接按上述方法试下,看报不报错)
如果报错的话,就不要在vs2013里面下载安装了,直接在网上搜索下载并安装
关于win10,用“工具-->扩展和更新”安装会提示NET.xxx的错误或警告(估计是版本不符)
解决方案:
打开”工具”下的”扩展和更新”选择”联机”右上角搜索”Visual Studio 2013 Color Theme Editor”(注意空格,没有空格貌似会搜不到)
单机“Visual Studio 2013 Color Theme Editor”右边的”详细信息”,我们从网站上单独下载这个扩展包
将修改好的文件重新放回” ColorThemeEditor”文件内.关掉压缩工具,点击安装.
安装成功后,打开C:\Users\13081\AppData\Local\Microsoft\VisualStudio目录(红色字体是主机账户名,你的跟我肯定不一样,所以你自己修改一下),可以看到这个目录下有两个文件夹,如图
一个有Exp后缀,一个没有.没有的这个就是成功安装“Visual Studio 2013 Color Theme Editor”的,而Exp(就是我们改了背景的VS)并没有安装,那么,我们将没有后缀文件夹内的” Extensions”文件复制到Exp后缀文件夹下,再次启动VS2013个性版.
打开“工具”→”扩展和更新”在已安装内找到“Visual Studio 2013 Color Theme Editor”启动它→重启VS2013个性版。重启后可以看到”工具”栏选项下多了
” Change color Theme ”和” Customize Colors ”
” Change color Theme ”,下拥有更多可以选择的主题.
打开” Customize Colors ”
至此,Visual Studio 2013 Color Theme Editor安装成功,以后要用的话,就在你的工具里边。
2、按照上述方法安装好两个插件后,打开vs2013
a、 点击“文件-->新建-->项目-->在“已安装”内选择“C#”找到里面的“扩展性”选择“Visual Studio Package”→”确定”建立一个VSPackage(自定名称,如果在接下来的操作中出现问题,试试用纯字母名称建立试试?噢,对了,在”其他项目类型”里的”扩展性”也能找到“Visual Studio Package”)(安装正确的话肯定能找到)
b、建立好项目后,打开解决方案资源管理器,右击“引用” -->“添加引用” 添加以下引用(一个一个添加)
“PresentationCore”
“PresentationFramework”
“System.Xaml”
“WindowsBase”
“System.ComponentModel.Composition”
“Microsoft.VisualStudio.CoreUtility”
“Microsoft.VisualStudio.Text.UI”
“Microsoft.VisualStudio.Text.UI.Wpf”
可以在上面 “搜索程序集”里面(右上角箭头)搜索你要添加的名称
c、添加完成后,打开“xxxPackage.cs”(xxx就是你刚才建项目时的名字,我这里是VSPackagePackage.cs),把你原来的代码删除,将下面代码粘贴到你的文件里边
<pre name="code" class="csharp">using Microsoft.VisualStudio;
using Company.VSPackage;////注意改掉此句中的VSPackage ,改成你的项目名称,如若找不到
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace Moen.IDEBackground
{
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(GuidList.guidVSPackagePkgString)]//注意改掉此句中的VSPackage ,改成你的项目名称,如若找不到,可在Guids.cs寻找变量名替换,头文件也需改变
[ProvideAutoLoad(UIContextGuids.NoSolution)]
[ProvideAutoLoad(UIContextGuids.SolutionExists)]
public sealed class IDEBackgroundPackage : Package
{
protected override void Initialize()
{
base.Initialize();
Application.Current.MainWindow.Loaded += MainWindow_Loaded;
}
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
var rWindow = (Window)sender;
var rImageSource = BitmapFrame.Create(new Uri(@"C:\vs 背景\11.jpg"/*图片路径*/), BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
rImageSource.Freeze();
var rImageControl = new Image()
{
Source = rImageSource,
Stretch = Stretch.UniformToFill,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetRowSpan(rImageControl, 4);
var rRootGrid = (Grid)rWindow.Template.FindName("RootGrid", rWindow);
rRootGrid.Children.Insert(0, rImageControl);
}
}
}
要注意上面的注释那块要改成创建项目时的名称 ★★★ 上面图片后面的路径改成你自己图片的路径
编译运行即可得到一个新vs2013实验实例。
现在,可能你什么还看不见,或者说只能看到一些边框有图片,不要着急,马上就能看到了。
下来,我们导入一个透明的主题,这个透明的主题,我会在博客后边上传成一个文件,你到时直接下载,然后导入到你的vs里边去,就是用上面的Visual Studio 2013 Color Theme Editor导入。Import Theme按钮导入(下图)
当然,如果你嫌麻烦,我会再上传一个我自己的主题,就是你上面看到的那个背景。
导入之后,下边就会出现你导入的主题,点击主题上边的“编辑”按钮,进入如下页面(下图)
在此页面找到如下选项,并将其设置为0,
“Environment →EnvironmentBackgroundGradientXXX”
"Environment → MainWindowActiveCaption”
“Environment →MainWindowInactiveCaption”
“Environment → CommandShelfBackgroundGradientXXX”
“Environment →CommandShelfHighlightGradientXXX”
“Environment → CommandBarGradientXXX”
“Environment → CommandBarToolBarBorder”
其中如Environment →EnvironmentBackgroundGradientXXX,指Environment →EnvironmentBackgroundGradient开头的全部选项接下来就可以看到,除了编辑器,其他地方的图片都可以显示出来。
关闭vs2013实验实例,打开原版vs2013,在刚才的文档里找到“source.extension.vsixmanifest”
进入“Assets”选项卡,单击“New”按钮。在弹出的对话框里,“Type”选“Microsoft.VisualStudio.MefComponent”,“Source”选“Aproject in current solution”,“Project”选当前的Project,目前应该就一个选项的。最后OK
接下来在项目中新建一个文件,叫“EditorBackground.cs”,代码如下
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Utilities;
using System;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace Moen.IDEBackground
{
[Export(typeof(IWpfTextViewCreationListener))]
[ContentType("Text")]
[ContentType("BuildOutput")]
[TextViewRole(PredefinedTextViewRoles.Document)]
class Listener : IWpfTextViewCreationListener
{
[Import]
IEditorFormatMapService EditorFormatMapService = null;
public void TextViewCreated(IWpfTextView rpTextView)
{
new EditorBackground(rpTextView);
//去掉断点边栏的背景
var rProperties = EditorFormatMapService.GetEditorFormatMap(rpTextView).GetProperties("Indicator Margin");
rProperties["BackgroundColor"] = Colors.Transparent;
rProperties["Background"] = Brushes.Transparent;
}
}
class EditorBackground
{
IWpfTextView r_TextView;
ContentControl r_Control;
Grid r_ParentGrid;
Canvas r_ViewStack;
public EditorBackground(IWpfTextView rpTextView)
{
r_TextView = rpTextView;
r_Control = (ContentControl)r_TextView;
r_TextView.Background = Brushes.Transparent;
r_TextView.BackgroundBrushChanged += TextView_BackgroundBrushChanged;
r_TextView.Closed += TextView_Closed;
r_Control.Loaded += TextView_Loaded;
}
void MakeBackgroundTransparent()
{
r_TextView.Background = Brushes.Transparent;
r_ViewStack.Background = Brushes.Transparent;
r_ParentGrid.ClearValue(Grid.BackgroundProperty);
}
void TextView_Loaded(object sender, RoutedEventArgs e)
{
if (r_ParentGrid == null)
r_ParentGrid = (Grid)r_Control.Parent;
if (r_ViewStack == null)
r_ViewStack = (Canvas)r_Control.Content;
MakeBackgroundTransparent();
}
void TextView_BackgroundBrushChanged(object sender, BackgroundBrushChangedEventArgs e)
{
r_Control.Dispatcher.BeginInvoke(new Action(() =>
{
while (r_ParentGrid.Background != null)
MakeBackgroundTransparent();
}), DispatcherPriority.Render);
}
void TextView_Closed(object sender, EventArgs e)
{
//清除委托,以防内存泄露
r_TextView.Closed -= TextView_Closed;
r_TextView.BackgroundBrushChanged -= TextView_BackgroundBrushChanged;
}
}
}
调试,进入调试即可进入实验用例VS,进入配色表,找到“Environment →EnvironmentBackground”,设为透明。再找到“Environment → Window”设置为透明,"TreeView → Background",透明度设为0。
至此,大功就告成了。。。。。。。。。
下次直接在“开始菜单->Microsoft Visual Studio 2013->Microsoft Visual Studio SDK->Tools->Start Experimental Instance of Visual Studio2013”打开编译器。或者,你也可以将打开的实验实例锁定在电脑的边侧栏
vs2013的原版还是原版,如需使用皮肤,必须使用vs2013实验实例,可在上路径找出。其他版本的vs应该都可以按照这个方法,更换主题或者背景。
主题背景链接:http://pan.baidu.com/s/1mhC9SWK 美女背景图主题
http://pan.baidu.com/s/1pLeofmr 全透明主题