none
Visual Studio2015のクイック検索の窓を大きくしたい RRS feed

  • 質問

  •  Visual Studioのソースの編集の時にクイック検索をよく使うのですが、字が小さくて不便を感じています。変更方法をお教えください。
    2016年1月20日 6:02

回答

  • 標準機能ではクイック検索の窓だけを大きくすることはできないみたいです。
    テキストエディタ上でCtrlキーを押しながらマウスホイールを回してやると、エディタごと拡大縮小はできますが。

    それ以外の方法だと拡張機能で無理やり拡大してみるとか

    using System.ComponentModel.Composition;
    using Microsoft.VisualStudio.Text.Editor;
    using Microsoft.VisualStudio.Utilities;
    using System;
    using System.Windows;
    using System.Windows.Media;
    namespace Gekka.VisualStudio.Extention
    {
        [Export(typeof(IWpfTextViewCreationListener))]
        [ContentType("text")]
        [TextViewRole(PredefinedTextViewRoles.Document)]
        internal sealed class QuiceSearchZoomListener : IWpfTextViewCreationListener
        {
            public QuiceSearchZoomListener()
            {
            }
            private static EnvDTE.DTE _dte;
            private static EnvDTE.CommandEvents _commandEvents;
            private static string guidFind;
            private static int idFind;
            private IWpfTextView _view;
    
            [Import]
            internal Microsoft.VisualStudio.Shell.SVsServiceProvider ServiceProvider = null;
    
            public void TextViewCreated(IWpfTextView textView)
            {
                _view = textView;
    
                if (_dte == null)
                {
                    _dte=ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
                    if (_dte != null)
                    {
                        _commandEvents = _dte.Events.CommandEvents;
                        _commandEvents.AfterExecute += _commandEvents_AfterExecute;
    
                        EnvDTE.Command cmd = _dte.Commands.Item("Edit.Find");
                        guidFind = cmd.Guid;
                        idFind=cmd.ID;
                    }
                }          
            }
    
            void _commandEvents_AfterExecute(string Guid, int ID, object CustomIn, object CustomOut)
            {
                if (Guid == guidFind && ID == idFind)
                {
                   var findUI= FindFindUI(_view.VisualElement,0) as FrameworkElement;
                   if (findUI != null)
                   {
                       if(findUI.RenderTransform ==null || findUI.RenderTransform== ScaleTransform.Identity)
                       {
                           findUI.RenderTransform = new ScaleTransform(1, 1);
                           findUI.RenderTransformOrigin=new Point(1,0);
                           findUI.MouseWheel += findUI_MouseWheel;
                       }
                   }
                }
            }
    
            void findUI_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
            {
                FrameworkElement fe = (FrameworkElement)sender;
                ScaleTransform st = fe.RenderTransform as ScaleTransform;
                if (st != null)
                {
                    double d;
                  
                    if (e.Delta > 0)
                    {
                        d = st.ScaleX * 1.25;
                    }
                    else
                    {
                        d = st.ScaleX / 1.25;
                    }
                    if (0.1 <= d && d <= 100)
                    {
                        st.ScaleX = d;
                        st.ScaleY = d;
                    }
                    e.Handled = true;
                }
            }
    
            private System.Windows.DependencyObject FindFindUI(System.Windows.DependencyObject d, int deep)
            {
    
                deep += 1;
                string s = string.Empty.PadLeft(deep, '-');
                int count = 0;
                if (d is Visual)
                {
                    count = VisualTreeHelper.GetChildrenCount(d);
                    for (int i = 0; i < count; i++)
                    {
                        DependencyObject dChild = VisualTreeHelper.GetChild(d, i);
                        System.Windows.Controls.Control c = dChild as System.Windows.Controls.Control;
                        if (c != null)
                        {
                            System.Diagnostics.Debug.WriteLine(s + dChild.GetType().Name.ToString() + "\t" + c.Name);
    
                            if (c.Name == "FindControl")
                            {
                                return c;
                            }
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine(s + dChild.GetType().Name.ToString());
                        }
                        var ret=FindFindUI(dChild, deep);
                        if (ret != null)
                        {
                            return ret;
                        }
    
                    }
                }
                if (count == 0)
                {
                    var logicalChildren=LogicalTreeHelper.GetChildren(d);
                    if (logicalChildren != null)
                    {
                        foreach (object o in logicalChildren)
                        {
                            var dlogical = o as DependencyObject;
                            if (dlogical != null)
                            {
                               var ret= FindFindUI(dlogical, deep);
                               if (ret != null)
                               {
                                   return ret;
                               }
                            }
                        }
                    }
                }
                return null;
            }
        }
    }
    
    github ZIP

    個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)

    2016年1月20日 14:42

すべての返信

  • 標準機能ではクイック検索の窓だけを大きくすることはできないみたいです。
    テキストエディタ上でCtrlキーを押しながらマウスホイールを回してやると、エディタごと拡大縮小はできますが。

    それ以外の方法だと拡張機能で無理やり拡大してみるとか

    using System.ComponentModel.Composition;
    using Microsoft.VisualStudio.Text.Editor;
    using Microsoft.VisualStudio.Utilities;
    using System;
    using System.Windows;
    using System.Windows.Media;
    namespace Gekka.VisualStudio.Extention
    {
        [Export(typeof(IWpfTextViewCreationListener))]
        [ContentType("text")]
        [TextViewRole(PredefinedTextViewRoles.Document)]
        internal sealed class QuiceSearchZoomListener : IWpfTextViewCreationListener
        {
            public QuiceSearchZoomListener()
            {
            }
            private static EnvDTE.DTE _dte;
            private static EnvDTE.CommandEvents _commandEvents;
            private static string guidFind;
            private static int idFind;
            private IWpfTextView _view;
    
            [Import]
            internal Microsoft.VisualStudio.Shell.SVsServiceProvider ServiceProvider = null;
    
            public void TextViewCreated(IWpfTextView textView)
            {
                _view = textView;
    
                if (_dte == null)
                {
                    _dte=ServiceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
                    if (_dte != null)
                    {
                        _commandEvents = _dte.Events.CommandEvents;
                        _commandEvents.AfterExecute += _commandEvents_AfterExecute;
    
                        EnvDTE.Command cmd = _dte.Commands.Item("Edit.Find");
                        guidFind = cmd.Guid;
                        idFind=cmd.ID;
                    }
                }          
            }
    
            void _commandEvents_AfterExecute(string Guid, int ID, object CustomIn, object CustomOut)
            {
                if (Guid == guidFind && ID == idFind)
                {
                   var findUI= FindFindUI(_view.VisualElement,0) as FrameworkElement;
                   if (findUI != null)
                   {
                       if(findUI.RenderTransform ==null || findUI.RenderTransform== ScaleTransform.Identity)
                       {
                           findUI.RenderTransform = new ScaleTransform(1, 1);
                           findUI.RenderTransformOrigin=new Point(1,0);
                           findUI.MouseWheel += findUI_MouseWheel;
                       }
                   }
                }
            }
    
            void findUI_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
            {
                FrameworkElement fe = (FrameworkElement)sender;
                ScaleTransform st = fe.RenderTransform as ScaleTransform;
                if (st != null)
                {
                    double d;
                  
                    if (e.Delta > 0)
                    {
                        d = st.ScaleX * 1.25;
                    }
                    else
                    {
                        d = st.ScaleX / 1.25;
                    }
                    if (0.1 <= d && d <= 100)
                    {
                        st.ScaleX = d;
                        st.ScaleY = d;
                    }
                    e.Handled = true;
                }
            }
    
            private System.Windows.DependencyObject FindFindUI(System.Windows.DependencyObject d, int deep)
            {
    
                deep += 1;
                string s = string.Empty.PadLeft(deep, '-');
                int count = 0;
                if (d is Visual)
                {
                    count = VisualTreeHelper.GetChildrenCount(d);
                    for (int i = 0; i < count; i++)
                    {
                        DependencyObject dChild = VisualTreeHelper.GetChild(d, i);
                        System.Windows.Controls.Control c = dChild as System.Windows.Controls.Control;
                        if (c != null)
                        {
                            System.Diagnostics.Debug.WriteLine(s + dChild.GetType().Name.ToString() + "\t" + c.Name);
    
                            if (c.Name == "FindControl")
                            {
                                return c;
                            }
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine(s + dChild.GetType().Name.ToString());
                        }
                        var ret=FindFindUI(dChild, deep);
                        if (ret != null)
                        {
                            return ret;
                        }
    
                    }
                }
                if (count == 0)
                {
                    var logicalChildren=LogicalTreeHelper.GetChildren(d);
                    if (logicalChildren != null)
                    {
                        foreach (object o in logicalChildren)
                        {
                            var dlogical = o as DependencyObject;
                            if (dlogical != null)
                            {
                               var ret= FindFindUI(dlogical, deep);
                               if (ret != null)
                               {
                                   return ret;
                               }
                            }
                        }
                    }
                }
                return null;
            }
        }
    }
    
    github ZIP

    個別に明示されていない限りgekkaがフォーラムに投稿したコードにはフォーラム使用条件に基づき「MICROSOFT LIMITED PUBLIC LICENSE」が適用されます。(かなり自由に使ってOK!)

    2016年1月20日 14:42
  • gekka様

    ご回答ありがとうございます。

    拡張機能を早速導入しました。

    検索窓が自由に拡大でき編集作業が楽に

    できるようになり非常に助かりました。

    ありがとうございました。

    2016年1月23日 13:17