Siegfried Pammer 14 years ago
parent
commit
74ff5b60f4
  1. 22
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.cs
  2. 16
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.xaml

22
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Utils;
@ -28,6 +29,12 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -28,6 +29,12 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
{
this.CloseAutomatically = true;
AttachEvents();
Rect caret = this.TextArea.Caret.CalculateCaretRectangle();
Rect workingArea = System.Windows.Forms.Screen.FromPoint(caret.Location.ToSystemDrawing()).WorkingArea.ToWpf();
MaxHeight = workingArea.Height;
MaxWidth = Math.Min(workingArea.Width, Math.Max(1000, workingArea.Width * 0.6));
}
/// <summary>
@ -63,4 +70,19 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion @@ -63,4 +70,19 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion
}
}
}
/// <summary>
/// TemplateSelector for InsightWindow to replace plain string content by a TextBlock with TextWrapping.
/// </summary>
internal sealed class InsightWindowTemplateSelector : DataTemplateSelector
{
/// <inheritdoc/>
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is string)
return (DataTemplate)((FrameworkElement)container).FindResource("TextBlockTemplate");
return null;
}
}
}

16
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/InsightWindow.xaml

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cc="clr-namespace:ICSharpCode.AvalonEdit.CodeCompletion"
>
<cc:InsightWindowTemplateSelector x:Key="templateSelector" />
<!-- Template for InsightWindow. Based on the template for ToolTip. -->
<Style TargetType="{x:Type cc:InsightWindow}">
<Setter Property="SizeToContent" Value="WidthAndHeight" />
@ -100,10 +102,16 @@ @@ -100,10 +102,16 @@
<Path Stroke="Black" Fill="Black" Data="M 0,0 L 1,0 L 0.5,0.866 Z" Stretch="UniformToFill" />
</Button>
</StackPanel>
<ContentControl Grid.Row="0" Grid.Column="1"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentHeader}"/>
<ContentControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentContent}"/>
<ContentPresenter Grid.Row="0" Grid.Column="1"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentHeader}"/>
<ContentPresenter Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ContentTemplateSelector="{StaticResource templateSelector}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Provider.CurrentContent}">
<ContentPresenter.Resources>
<DataTemplate x:Key="TextBlockTemplate">
<TextBlock TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" />
</DataTemplate>
</ContentPresenter.Resources>
</ContentPresenter>
</Grid>
</ControlTemplate>
</Setter.Value>

Loading…
Cancel
Save