VS2013 图片背景·全透明背景图(转)

摘要:
注意:1.xaml编辑器和单独的编辑器都在VS的子窗口中,所以背景仍然是黑色的。然后你会看到角落里的背景图片3.修改肤色匹配1.关闭实验VS,转到官方网站下载并安装Visual Studio 2013ColorThemeEditorhttps://visualstudiogallery.msdn.microsoft.com/9e08e5d3-6eb4-4e73-a045-6ea2a5cbdabe2.安装成功后,重新启动VS,调试并启动实验VS3。此时,在实验VS中搜索并根据ColorTheme4重新启动。重新启动后,输入“工具-˃自定义颜色”。单击“CustomizeColors”中的“ImportTheme”。4.编辑器是透明的。1.到目前为止,打开文件后,编辑器的背景仍然是黑色的。
Note
1.xaml编辑器和个别的编辑器(如HTML的)因为是承载在VS的一个子窗口上,所以背景依然是黑色的。
2.该背景必须在VS实验环境下使用。
效果图:
VS2013 图片背景·全透明背景图(转)第1张
1.准备工作

1.先准备Visual Studio 2013 SDK
http://download.microsoft.com/download/9/1/0/910EE61D-A231-4DAB-BD56-DCE7092687D5/vssdk_full.exe

2.可直接套用的VSTheme
http://pan.baidu.com/s/1kTFt3gz

 

 

2.新建Package项目

1.安装好SDK后,进入VS。先新建一个Project,在“其它项目类型”那里找到“Visual Studio Package”

2.接下来的对话框里,选“C#”,然后基本是下一步。在最后一步把那两个复选框取消,因为那个在这里没什么用处。最后就成功新建了个VS扩展的Project

3.对Project添加WPF的程序集为引用,有四个,分别为“PresentationCore”、“PresentationFramework”、“System.Xaml”、“WindowsBase”。

4.然后打开“XXXPackage.cs”(XXX一般为这个Project的名字)文件,
代码如下:
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 Microsoft.SoheeBackground//命名空间自己修改回自己用的

{

   [PackageRegistration(UseManagedResourcesOnly = true)]

   [InstalledProductRegistration("#110", "#112","1.0", IconResourceID = 400)]

 

//此处删除了一条代码段,原因不明,对后续影响不明

 

   [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;

 

            //加载图片  E:FileDownloadExplorere30870a304e251ff3c5926fa786c9177f3e537f.jpg

            var rImageSource = BitmapFrame.Create(new Uri(@"E:FileDownloadExplorer241f95cad1c8a786d814d6eb6709c93d70cf501c.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);

        }

    }

}

5.代码修改后,调试,这时就会编译扩展,然后启动实验用VS。(如果这是第一次启动实验用VS,可能要像刚安装完VS那样设置一下)接着你会看到角落处显现出那张背景图

3.修改皮肤配色

1.关闭实验用VS,前往官网下载并安装Visual Studio 2013 Color Theme Editor
https://visualstudiogallery.msdn.microsoft.com/9e08e5d3-6eb4-4e73-a045-6ea2a5cbdabe

2.安装成功后,重启VS,并调试启动实验用VS

3.此时在实验用VS中搜索并按照Color Theme

VS2013 图片背景·全透明背景图(转)第2张

 

4.重启,重启后,进入“工具->CustomizeColors”。在“Customize Colors”那里点“Import Theme”即可(文件在一开始百度云下载的打包文件中)

 

4.编辑器透明化

1.到目前为止,打开文件后,编辑器的背景还是黑的。接下来就是把这层黑的去掉。先打开“source.extension.vsixmanifest”文件,进入“Assets”选项卡,单击“New”按钮。在弹出的对话框里,“Type”选“Microsoft.VisualStudio.MefComponent”,“Source”选“Aproject in current solution”,“Project”选当前的Project,目前应该就一个选项的。最后OK
 
2.添加引用 System.ComponentModel.Composition、Microsoft.VisualStudio.CoreUtility、Microsoft.VisualStudio.Text.UI、Microsoft.VisualStudio.Text.UI.Wpf
 
3.新建一个文件,这里就叫“EditorBackground.cs”
代码如下:
  1. 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 Microsoft.SoheeBackground
    {
    
       [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("IndicatorMargin");
    
                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;
    
            }
    
        }
    
    }

4.再启动调试用VS,选择之前Import 的 Theme即可。
 
5.以后可以直接在 开始-VisualStudio2013-Microsoft VisualStudio SDK-Tools-Start Experimental Instance 开启调试用VS

 PS:参考

1.http://startalkers.lofter.com/post/1cb119b5_5be5e5a

2.http://doc.okbase.net/u012915516/archive/124296.html

来自为知笔记(Wiz)


免责声明:文章转载自《VS2013 图片背景·全透明背景图(转)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇FFMPEG编译参数《Linux内核精髓:精通Linux内核必会的75个绝技》目录下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

VSCode——自定义VSCode背景图片

本文转载自https://blog.csdn.net/yukinoai/article/details/845649491.以管理员身份运行VS Code,安装background插件2.打开setting,在搜索框中输入background,选择扩展中的plugin background,选择在setting.json中编辑3.在用户设置中输入以下代码,...

css多栏自适应布局

css多栏自适应布局还是需要总结一下的,都是基本功。 一般使用position属性布局,或者用float属性布局,也可以使用display属性。 看资料说position适合首页布局,因为首页内容往往可以完全控制。float适合模板布局,模板中填充的内容无法控制。 一、左侧尺寸固定右侧自适应 1、浮动实现 在css浮动一文已介绍过。 .left{...

CSS美化自己的完美网页

CSS美化自己的完美网页 CSS概述 css样式: css是英文Cascading Style Sheets的缩写,称为层叠样式表,用于对页面进行美化,CSS的可以使页面更加的美观。基本上所有的html页面都或多或少的使用css。 CSS 指层叠样式表 (CascadingStyleSheets) 样式定义如何显示HTML 元素 样式通常存储在样式表...

关于android中EditText边框的问题 下划线

方法1   将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为@null 接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。 如果可以了就采纳吧。不行的话...

CSS伪元素before和after

今天发现很多国外的网站和框架设计都用到了before和after,之前使用的比较少,今天试了下觉得还是很有意思的~ 说明 1. :before 和 :after将在内容元素的前后插入额外的元素;:before将会在内容之前“添加”一个元素而:after将会在内容后“添加”一个元素。在它们之中添加内容我们可以使用content属性。 2. :before 和...

vue移动端横向滚动计算滚动距离,从而移动背景图滚动条 vant库

  <template>   <div class="page-body">     <div class="page-title flex">       <div class="title-txt">         title随便title       </div>       <d...