5 changed files with 170 additions and 1 deletions
@ -0,0 +1,35 @@ |
|||||||
|
<UserControl x:Class="ICSharpCode.AvalonEdit.AddIn.FocusHighlight" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||||
|
<Grid HorizontalAlignment="Left" VerticalAlignment="Top"> |
||||||
|
<Border |
||||||
|
Name="el" |
||||||
|
CornerRadius="2" |
||||||
|
BorderThickness="1" |
||||||
|
BorderBrush="Black"> |
||||||
|
<Border.Triggers> |
||||||
|
<EventTrigger RoutedEvent="Border.Loaded"> |
||||||
|
<BeginStoryboard> |
||||||
|
<Storyboard> |
||||||
|
<DoubleAnimation |
||||||
|
Storyboard.TargetName="el" |
||||||
|
Storyboard.TargetProperty="Width" |
||||||
|
From="2" To="12" Duration="0:0:0.4" |
||||||
|
AutoReverse="True" RepeatBehavior="1x" /> |
||||||
|
<DoubleAnimation |
||||||
|
Storyboard.TargetName="el" |
||||||
|
Storyboard.TargetProperty="Height" |
||||||
|
From="17" To="27" Duration="0:0:0.4" |
||||||
|
AutoReverse="True" RepeatBehavior="1x" /> |
||||||
|
<DoubleAnimation |
||||||
|
Storyboard.TargetName="el" |
||||||
|
Storyboard.TargetProperty="Opacity" |
||||||
|
From="1" To="0" Duration="0:0:0.2" BeginTime="0:0:0.6" |
||||||
|
RepeatBehavior="1x" /> |
||||||
|
</Storyboard> |
||||||
|
</BeginStoryboard> |
||||||
|
</EventTrigger> |
||||||
|
</Border.Triggers> |
||||||
|
</Border> |
||||||
|
</Grid> |
||||||
|
</UserControl> |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
|
||||||
|
namespace ICSharpCode.AvalonEdit.AddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for FocusHighlight.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class FocusHighlight : UserControl |
||||||
|
{ |
||||||
|
public FocusHighlight() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,85 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Windows.Media.Animation; |
||||||
|
using System.Windows.Threading; |
||||||
|
|
||||||
|
namespace ICSharpCode.AvalonEdit.AddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of FocusHighlightAdorner.
|
||||||
|
/// </summary>
|
||||||
|
public class FocusHighlightAdorner : Adorner |
||||||
|
{ |
||||||
|
FocusHighlight highlight; |
||||||
|
|
||||||
|
public FocusHighlightAdorner(UIElement adornedElement, Point origin) |
||||||
|
: base(adornedElement) |
||||||
|
{ |
||||||
|
this.Highlight = new FocusHighlight() { |
||||||
|
RenderTransform = new TranslateTransform(origin.X, origin.Y), |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/sets the visual child.
|
||||||
|
/// </summary>
|
||||||
|
protected FocusHighlight Highlight { |
||||||
|
get { return highlight; } |
||||||
|
set { |
||||||
|
RemoveVisualChild(highlight); |
||||||
|
highlight = value; |
||||||
|
AddVisualChild(highlight); |
||||||
|
InvalidateMeasure(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the visual child.
|
||||||
|
/// </summary>
|
||||||
|
protected override Visual GetVisualChild(int index) |
||||||
|
{ |
||||||
|
if (index == 0 && highlight != null) |
||||||
|
return highlight; |
||||||
|
else |
||||||
|
throw new ArgumentOutOfRangeException("index"); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the number of visual children.
|
||||||
|
/// </summary>
|
||||||
|
protected override int VisualChildrenCount { |
||||||
|
get { return highlight != null ? 1 : 0; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Measure the visual child.
|
||||||
|
/// </summary>
|
||||||
|
protected override Size MeasureOverride(Size availableSize) |
||||||
|
{ |
||||||
|
if (highlight != null) { |
||||||
|
highlight.Measure(availableSize); |
||||||
|
return availableSize; |
||||||
|
} else { |
||||||
|
return base.MeasureOverride(availableSize); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Arrange the visual child.
|
||||||
|
/// </summary>
|
||||||
|
protected override Size ArrangeOverride(Size finalSize) |
||||||
|
{ |
||||||
|
if (highlight != null) { |
||||||
|
highlight.Arrange(new Rect(new Point(0, 0), finalSize)); |
||||||
|
return finalSize; |
||||||
|
} else { |
||||||
|
return base.ArrangeOverride(finalSize); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue