Example #1
0
        public override void Execute()
        {
            if (_window == null)
                Initialise();

            if (PageExists("TextEditor", "SQL"))
                _showLineNumbers = ReadProperty<bool>("TextEditor", "SQL", "ShowLineNumbers", false);
            else
                _showLineNumbers = ReadProperty<bool>("TextEditor", "AllLanguages", "ShowLineNumbers", false);

            _listBox.Items.Clear();
            _listBox.Items.AddRange(GetItems().ToArray());
            _listBox.Height = Math.Min(300, Math.Max(150, _listBox.Items.Count * 20));

            _editor = _window.FindWindow();
            var point = _editor.GetScreenPoint(_window);
            var cursor = AddIn.VirtualCursor;

            int lineNumberWidth = _showLineNumbers ? LineNumber_Width : 25;
            point.X += lineNumberWidth + Border_Width + (int)(cursor.Column * Math.Ceiling(_fontSize.Width));
            point.Y += Border_Width + (int)(cursor.Row * Math.Ceiling(_fontSize.Height));

            _listBox.Location = new Point(point.X, point.Y);
            InternalExecute();
        }
Example #2
0
 public Point GetScreenPoint( Window parent )
 {
     var result = new Point();
     var window = Handle;
     do
     {
         var location = GetLocation( window );
         result = new Point() { X = result.X + location.Left, Y = result.Y + location.Top };
         window = GetParent( window );
     }
     while ( window != parent.Handle );
     return result;
 }
Example #3
0
        private void Initialise()
        {
            string fontFamily = ReadProperty<string>( "FontsAndColors", "TextEditor", "FontFamily", "Courier New" );
            short fontSize = ReadProperty<short>( "FontsAndColors", "TextEditor", "FontSize", 10 );

            _font = new Font( fontFamily, ( float )fontSize );

            _listBox = new Form.ListBox();
            _listBox.DrawMode = Form.DrawMode.OwnerDrawVariable;
            _listBox.Width = 340;
            _listBox.Height = 200;
            _listBox.DrawItem += ListBoxDrawItem;
            _listBox.MeasureItem += ListBoxMeasureItem;
            _listBox.KeyDown += ListBoxKeyDown;
            _listBox.DoubleClick += ListBoxDoubleClick;
            _listBox.LostFocus += ListBoxLostFocus;
            _listBox.Hide();

            _window = new Window( (IntPtr) AddIn.TextDocument.DTE.MainWindow.HWnd );

            _fontSize = TextRenderer.MeasureText( "W", _font );
            _fontSize.Width = TextRenderer.MeasureText( "WW", _font ).Width - _fontSize.Width;
            _fontSize.Height -= 1;

            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListMembers", false );
            //WriteProperty<bool>( "TextEditor", "SQL", "AutoListParams", true );
            _window.SetParent( _listBox.Handle );
        }
Example #4
0
 private void Output( Window window, int indent )
 {
     int index = 0;
     foreach ( var win in FindAllChildWindows() )
     {
         Trace.WriteLine(
             String.Format(
                 "{0}[{1}] - {2}",
                 new string( ' ', indent * 4 ),
                 index++,
                 win.ClassName
             )
         );
         foreach ( var child in win.FindAllChildWindows() )
             Output( child, indent + 1 );
     }
 }
Example #5
0
 private Window[] FindChildWindows( Func<Window, bool> filter )
 {
     List<Window> windows = new List<Window>();
     EnumChildWindows(
         Handle,
         ( hwnd, lParam ) =>
         {
             Window window = new Window( hwnd );
             if ( filter( window ) )
                 windows.Add( window );
             return 1;
         },
         new IntPtr( 0 )
     );
     return windows.ToArray();
 }