提交 dee8b077 编写于 作者: I Ivan Basov

intellisense control

上级 3e00101e
......@@ -40,7 +40,7 @@
<ColumnDefinition Width="400" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="{Binding ElementName=dialog, Path=TypeNameLabel}" />
<Border Grid.Row="0" Grid.Column="1" BorderThickness="1" Margin="6,0,0,0"> <ContentControl x:Name="TypeNameContentControl" Width="300" Focusable="True" /> </Border>
<Border Grid.Row="0" Grid.Column="1" BorderThickness="1" Margin="6,0,0,0"> <ContentControl x:Name="TypeNameContentControl" Width="300" Focusable="True" PreviewKeyDown="TypeNameContentControl_PreviewKeyDown" /> </Border>
<Label Grid.Row="1" Grid.Column="0" Content="{Binding ElementName=dialog, Path=ParameterNameLabel}" />
<TextBox Grid.Row="1" Grid.Column="1" Width="200" Text="{Binding ParameterName}" />
<Label Grid.Row="2" Grid.Column="0" Content="{Binding ElementName=dialog, Path=CallsiteValueLabel}" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Windows;
using System.Windows.Input;
using System.Windows.Interop;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
......@@ -62,5 +64,48 @@ private void Cancel_Click(object sender, RoutedEventArgs e)
{
DialogResult = false;
}
private void TypeNameContentControl_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
if (elementWithFocus is IWpfTextView)
{
IntellisenseTextBox typeNameTextBox = elementWithFocus.GetParentOfType<IntellisenseTextBox>();
if (typeNameTextBox != null)
{
if (e.Key == Key.Escape && !typeNameTextBox.HasActiveIntellisenseSession)
{
e.Handled = true;
}
else if (e.Key == Key.Enter && !typeNameTextBox.HasActiveIntellisenseSession)
{
// Do nothing. This case is handled in parent control KeyDown events.
}
else if (e.Key == Key.Tab && !typeNameTextBox.HasActiveIntellisenseSession)
{
// Do nothing. This case is handled in parent control KeyDown events.
}
else
{
// Let the editor control handle the keystrokes
System.Windows.Interop.MSG msg = ComponentDispatcher.CurrentKeyboardMessage;
var oleInteropMsg = new OLE.Interop.MSG();
oleInteropMsg.hwnd = msg.hwnd;
oleInteropMsg.message = (uint)msg.message;
oleInteropMsg.wParam = msg.wParam;
oleInteropMsg.lParam = msg.lParam;
oleInteropMsg.pt.x = msg.pt_x;
oleInteropMsg.pt.y = msg.pt_y;
e.Handled = typeNameTextBox.HandleKeyDown(oleInteropMsg);
}
}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册