This commit is contained in:
2024-02-23 07:03:56 -05:00
commit 4a3813687a
937 changed files with 113251 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
namespace Xceed.Wpf.Toolkit
{
public interface IRichTextBoxFormatBar
{
/// <summary>
/// Represents the RichTextBox that will be the target for all text manipulations in the format bar.
/// </summary>
System.Windows.Controls.RichTextBox Target
{
get;
set;
}
/// <summary>
/// Represents the property that will be used to know if the formatBar should fade when mouse goes away.
/// </summary>
bool PreventDisplayFadeOut
{
get;
}
/// <summary>
/// Represents the Method that will be used to update the format bar values based on the Selection.
/// </summary>
void Update();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

View File

@@ -0,0 +1,447 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using Xceed.Wpf.Toolkit.Core.Utilities;
using System.Windows.Media;
using System.Windows.Documents;
using System.Windows.Controls.Primitives;
using Xceed.Wpf.Toolkit.Core;
namespace Xceed.Wpf.Toolkit
{
public class RichTextBoxFormatBar : Control, IRichTextBoxFormatBar
{
#region Members
private ComboBox _cmbFontFamilies;
private ComboBox _cmbFontSizes;
private ColorPicker _cmbFontBackgroundColor;
private ColorPicker _cmbFontColor;
private ToggleButton _btnNumbers;
private ToggleButton _btnBullets;
private ToggleButton _btnBold;
private ToggleButton _btnItalic;
private ToggleButton _btnUnderline;
private ToggleButton _btnAlignLeft;
private ToggleButton _btnAlignCenter;
private ToggleButton _btnAlignRight;
private Thumb _dragWidget;
private bool _waitingForMouseOver;
#endregion
#region Properties
public static double[] FontSizes
{
get
{
return new double[] {
3.0, 4.0, 5.0, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5,
10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 15.0,
16.0, 17.0, 18.0, 19.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0,
32.0, 34.0, 36.0, 38.0, 40.0, 44.0, 48.0, 52.0, 56.0, 60.0, 64.0, 68.0, 72.0, 76.0,
80.0, 88.0, 96.0, 104.0, 112.0, 120.0, 128.0, 136.0, 144.0
};
}
}
#endregion
#region Constructors
static RichTextBoxFormatBar()
{
DefaultStyleKeyProperty.OverrideMetadata( typeof( RichTextBoxFormatBar ), new FrameworkPropertyMetadata( typeof( RichTextBoxFormatBar ) ) );
}
#endregion //Constructors
#region Event Hanlders
private void FontFamily_SelectionChanged( object sender, SelectionChangedEventArgs e )
{
if( e.AddedItems.Count == 0 )
return;
FontFamily editValue = ( FontFamily )e.AddedItems[ 0 ];
ApplyPropertyValueToSelectedText( TextElement.FontFamilyProperty, editValue );
_waitingForMouseOver = true;
}
private void FontSize_SelectionChanged( object sender, SelectionChangedEventArgs e )
{
if( e.AddedItems.Count == 0 )
return;
ApplyPropertyValueToSelectedText( TextElement.FontSizeProperty, e.AddedItems[ 0 ] );
_waitingForMouseOver = true;
}
void FontColor_SelectedColorChanged( object sender, RoutedPropertyChangedEventArgs<Color?> e )
{
Color? selectedColor = ( Color? )e.NewValue;
ApplyPropertyValueToSelectedText( TextElement.ForegroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null );
_waitingForMouseOver = true;
}
private void FontBackgroundColor_SelectedColorChanged( object sender, RoutedPropertyChangedEventArgs<Color?> e )
{
Color? selectedColor = ( Color? )e.NewValue;
ApplyPropertyValueToSelectedText( TextElement.BackgroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null );
_waitingForMouseOver = true;
}
private void Bullets_Clicked( object sender, RoutedEventArgs e )
{
if( BothSelectionListsAreChecked() )
{
_btnNumbers.IsChecked = false;
}
}
private void Numbers_Clicked( object sender, RoutedEventArgs e )
{
if( BothSelectionListsAreChecked() )
{
_btnBullets.IsChecked = false;
}
}
private void DragWidget_DragDelta( object sender, DragDeltaEventArgs e )
{
ProcessMove( e );
}
protected override void OnMouseEnter( System.Windows.Input.MouseEventArgs e )
{
base.OnMouseEnter( e );
_waitingForMouseOver = false;
}
#endregion //Event Hanlders
#region Methods
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
if( _dragWidget != null )
{
_dragWidget.DragDelta -= new DragDeltaEventHandler( DragWidget_DragDelta );
}
if( _cmbFontFamilies != null )
{
_cmbFontFamilies.SelectionChanged -= new SelectionChangedEventHandler( FontFamily_SelectionChanged );
}
if( _cmbFontSizes != null )
{
_cmbFontSizes.SelectionChanged -= new SelectionChangedEventHandler( FontSize_SelectionChanged );
}
if( _btnBullets != null )
{
_btnBullets.Click -= new RoutedEventHandler( Bullets_Clicked );
}
if( _btnNumbers != null )
{
_btnNumbers.Click -= new RoutedEventHandler( Numbers_Clicked );
}
if( _cmbFontBackgroundColor != null )
{
_cmbFontBackgroundColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler<Color?>( FontBackgroundColor_SelectedColorChanged );
}
if( _cmbFontColor != null )
{
_cmbFontColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler<Color?>( FontColor_SelectedColorChanged );
}
this.GetTemplateComponent( ref _cmbFontFamilies, "_cmbFontFamilies" );
this.GetTemplateComponent( ref _cmbFontSizes, "_cmbFontSizes" );
this.GetTemplateComponent( ref _cmbFontBackgroundColor, "_cmbFontBackgroundColor" );
this.GetTemplateComponent( ref _cmbFontColor, "_cmbFontColor" );
this.GetTemplateComponent( ref _btnNumbers, "_btnNumbers" );
this.GetTemplateComponent( ref _btnBullets, "_btnBullets" );
this.GetTemplateComponent( ref _btnBold, "_btnBold" );
this.GetTemplateComponent( ref _btnItalic, "_btnItalic" );
this.GetTemplateComponent( ref _btnUnderline, "_btnUnderline" );
this.GetTemplateComponent( ref _btnAlignLeft, "_btnAlignLeft" );
this.GetTemplateComponent( ref _btnAlignCenter, "_btnAlignCenter" );
this.GetTemplateComponent( ref _btnAlignRight, "_btnAlignRight" );
this.GetTemplateComponent( ref _dragWidget, "_dragWidget" );
if( _dragWidget != null )
{
_dragWidget.DragDelta += new DragDeltaEventHandler( DragWidget_DragDelta );
}
if( _cmbFontFamilies != null )
{
_cmbFontFamilies.ItemsSource = FontUtilities.Families.OrderBy( fontFamily => fontFamily.Source );
_cmbFontFamilies.SelectionChanged += new SelectionChangedEventHandler( FontFamily_SelectionChanged );
}
if( _cmbFontSizes != null )
{
_cmbFontSizes.ItemsSource = FontSizes;
_cmbFontSizes.SelectionChanged += new SelectionChangedEventHandler( FontSize_SelectionChanged );
}
if( _btnBullets != null )
{
_btnBullets.Click += new RoutedEventHandler( Bullets_Clicked );
}
if( _btnNumbers != null )
{
_btnNumbers.Click += new RoutedEventHandler( Numbers_Clicked );
}
if( _cmbFontBackgroundColor != null )
{
_cmbFontBackgroundColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler<Color?>( FontBackgroundColor_SelectedColorChanged );
}
if( _cmbFontColor != null )
{
_cmbFontColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler<Color?>( FontColor_SelectedColorChanged );
}
// Update the ComboBoxes when changing themes.
this.Update();
}
private void GetTemplateComponent<T>( ref T partMember, string partName ) where T : class
{
partMember = ( this.Template != null )
? this.Template.FindName( partName, this ) as T
: null;
}
private void UpdateToggleButtonState()
{
UpdateItemCheckedState( _btnBold, TextElement.FontWeightProperty, FontWeights.Bold );
UpdateItemCheckedState( _btnItalic, TextElement.FontStyleProperty, FontStyles.Italic );
UpdateItemCheckedState( _btnUnderline, Inline.TextDecorationsProperty, TextDecorations.Underline );
UpdateItemCheckedState( _btnAlignLeft, Paragraph.TextAlignmentProperty, TextAlignment.Left );
UpdateItemCheckedState( _btnAlignCenter, Paragraph.TextAlignmentProperty, TextAlignment.Center );
UpdateItemCheckedState( _btnAlignRight, Paragraph.TextAlignmentProperty, TextAlignment.Right );
}
void UpdateItemCheckedState( ToggleButton button, DependencyProperty formattingProperty, object expectedValue )
{
object currentValue = DependencyProperty.UnsetValue;
if( ( Target != null ) && ( Target.Selection != null ) )
{
currentValue = Target.Selection.GetPropertyValue( formattingProperty );
}
if( currentValue == DependencyProperty.UnsetValue )
return;
button.IsChecked = ( currentValue == null )
? false
: currentValue != null && currentValue.Equals( expectedValue );
}
private void UpdateSelectedFontFamily()
{
object value = DependencyProperty.UnsetValue;
if( ( Target != null ) && ( Target.Selection != null ) )
{
value = Target.Selection.GetPropertyValue( TextElement.FontFamilyProperty );
}
if( value == DependencyProperty.UnsetValue )
return;
FontFamily currentFontFamily = ( FontFamily )value;
if( currentFontFamily != null )
{
_cmbFontFamilies.SelectedItem = currentFontFamily;
}
}
private void UpdateSelectedFontSize()
{
object value = DependencyProperty.UnsetValue;
if( ( Target != null ) && ( Target.Selection != null ) )
{
value = Target.Selection.GetPropertyValue( TextElement.FontSizeProperty );
}
if( value == DependencyProperty.UnsetValue )
return;
_cmbFontSizes.SelectedValue = value;
}
private void UpdateFontColor()
{
object value = DependencyProperty.UnsetValue;
if( ( Target != null ) && ( Target.Selection != null ) )
{
value = Target.Selection.GetPropertyValue( TextElement.ForegroundProperty );
}
if( value == DependencyProperty.UnsetValue )
return;
Color? currentColor = ( ( value == null )
? null
: ( Color? )( ( SolidColorBrush )value ).Color );
_cmbFontColor.SelectedColor = currentColor;
}
private void UpdateFontBackgroundColor()
{
object value = DependencyProperty.UnsetValue;
if( ( Target != null ) && ( Target.Selection != null ) )
{
value = Target.Selection.GetPropertyValue( TextElement.BackgroundProperty );
}
if( value == DependencyProperty.UnsetValue )
return;
Color? currentColor = ( ( value == null )
? null
: ( Color? )( ( SolidColorBrush )value ).Color );
_cmbFontBackgroundColor.SelectedColor = currentColor;
}
/// <summary>
/// Updates the visual state of the List styles, such as Numbers and Bullets.
/// </summary>
private void UpdateSelectionListType()
{
//uncheck both
_btnBullets.IsChecked = false;
_btnNumbers.IsChecked = false;
Paragraph startParagraph = ( ( Target != null ) && ( Target.Selection != null ) )
? Target.Selection.Start.Paragraph
: null;
Paragraph endParagraph = ( ( Target != null ) && ( Target.Selection != null ) )
? Target.Selection.End.Paragraph
: null;
if( startParagraph != null && endParagraph != null && ( startParagraph.Parent is ListItem ) && ( endParagraph.Parent is ListItem ) && object.ReferenceEquals( ( ( ListItem )startParagraph.Parent ).List, ( ( ListItem )endParagraph.Parent ).List ) )
{
TextMarkerStyle markerStyle = ( ( ListItem )startParagraph.Parent ).List.MarkerStyle;
if( markerStyle == TextMarkerStyle.Disc ) //bullets
{
_btnBullets.IsChecked = true;
}
else if( markerStyle == TextMarkerStyle.Decimal ) //numbers
{
_btnNumbers.IsChecked = true;
}
}
}
/// <summary>
/// Checks to see if both selection lists are checked. (Bullets and Numbers)
/// </summary>
/// <returns></returns>
private bool BothSelectionListsAreChecked()
{
return _btnBullets.IsChecked == true && _btnNumbers.IsChecked == true;
}
void ApplyPropertyValueToSelectedText( DependencyProperty formattingProperty, object value )
{
if( ( Target == null ) || ( Target.Selection == null ) )
return;
SolidColorBrush solidColorBrush = value as SolidColorBrush;
if( ( solidColorBrush != null ) && solidColorBrush.Color.Equals( Colors.Transparent ) )
{
Target.Selection.ApplyPropertyValue( formattingProperty, null );
}
else
{
Target.Selection.ApplyPropertyValue( formattingProperty, value );
}
}
private void ProcessMove( DragDeltaEventArgs e )
{
AdornerLayer layer = AdornerLayer.GetAdornerLayer( Target );
UIElementAdorner<Control> adorner = layer.GetAdorners( Target ).OfType<UIElementAdorner<Control>>().First();
adorner.SetOffsets( adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange );
}
#endregion //Methods
#region IRichTextBoxFormatBar Interface
#region Target
public static readonly DependencyProperty TargetProperty = DependencyProperty.Register( "Target", typeof( global::System.Windows.Controls.RichTextBox ), typeof( RichTextBoxFormatBar ), new PropertyMetadata( null, OnRichTextBoxPropertyChanged ) );
public global::System.Windows.Controls.RichTextBox Target
{
get
{
return ( global::System.Windows.Controls.RichTextBox )GetValue( TargetProperty );
}
set
{
SetValue( TargetProperty, value );
}
}
private static void OnRichTextBoxPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
RichTextBoxFormatBar formatBar = d as RichTextBoxFormatBar;
}
#endregion //Target
public bool PreventDisplayFadeOut
{
get
{
return ( _cmbFontFamilies.IsDropDownOpen || _cmbFontSizes.IsDropDownOpen ||
_cmbFontBackgroundColor.IsOpen || _cmbFontColor.IsOpen || _waitingForMouseOver );
}
}
public void Update()
{
UpdateToggleButtonState();
UpdateSelectedFontFamily();
UpdateSelectedFontSize();
UpdateFontColor();
UpdateFontBackgroundColor();
UpdateSelectionListType();
}
#endregion
}
}

View File

@@ -0,0 +1,260 @@
/*************************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
***********************************************************************************/
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using Xceed.Wpf.Toolkit.Core;
using Xceed.Wpf.Toolkit.Core.Utilities;
namespace Xceed.Wpf.Toolkit
{
public class RichTextBoxFormatBarManager : DependencyObject
{
#region Members
private global::System.Windows.Controls.RichTextBox _richTextBox;
private UIElementAdorner<Control> _adorner;
private IRichTextBoxFormatBar _toolbar;
private Window _parentWindow;
private const double _hideAdornerDistance = 150d;
#endregion //Members
#region Properties
#region FormatBar
public static readonly DependencyProperty FormatBarProperty = DependencyProperty.RegisterAttached( "FormatBar", typeof( IRichTextBoxFormatBar ), typeof( RichTextBox ), new PropertyMetadata( null, OnFormatBarPropertyChanged ) );
public static void SetFormatBar( UIElement element, IRichTextBoxFormatBar value )
{
element.SetValue( FormatBarProperty, value );
}
public static IRichTextBoxFormatBar GetFormatBar( UIElement element )
{
return ( IRichTextBoxFormatBar )element.GetValue( FormatBarProperty );
}
private static void OnFormatBarPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e )
{
global::System.Windows.Controls.RichTextBox rtb = d as global::System.Windows.Controls.RichTextBox;
if( rtb == null )
throw new Exception( "A FormatBar can only be applied to a RichTextBox." );
RichTextBoxFormatBarManager manager = new RichTextBoxFormatBarManager();
manager.AttachFormatBarToRichtextBox( rtb, e.NewValue as IRichTextBoxFormatBar );
}
#endregion //FormatBar
public bool IsAdornerVisible
{
get
{
return _adorner.Visibility == Visibility.Visible;
}
}
#endregion //Properties
#region Event Handlers
void RichTextBox_MouseButtonUp( object sender, MouseButtonEventArgs e )
{
if( e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released )
{
if( !_richTextBox.IsReadOnly )
{
TextRange selectedText = new TextRange( _richTextBox.Selection.Start, _richTextBox.Selection.End );
#if !VS2008
if( selectedText.Text.Length > 0 && !String.IsNullOrWhiteSpace( selectedText.Text ) )
ShowAdorner();
#else
if( selectedText.Text.Length > 0 && !String.IsNullOrEmpty( selectedText.Text ) )
ShowAdorner();
#endif
else
HideAdorner();
e.Handled = true;
}
}
else
HideAdorner();
}
private void OnPreviewMouseMoveParentWindow( object sender, MouseEventArgs e )
{
Point p = e.GetPosition( _adorner );
double maxDist = 0d;
bool preventDisplayFadeOut = ( ( _adorner.Child != null ) && ( _adorner.Child is IRichTextBoxFormatBar ) ) ?
( ( IRichTextBoxFormatBar )_adorner.Child ).PreventDisplayFadeOut :
false;
//Mouse is inside FormatBar: Nothing to do.
if( preventDisplayFadeOut ||
( p.X >= 0 ) && ( p.X <= _adorner.ActualWidth ) && ( p.Y >= 0 ) && ( p.Y <= _adorner.ActualHeight ) )
{
return;
}
//Mouse is too much outside FormatBar: Close it.
else if( ( p.X < -_hideAdornerDistance ) || ( p.X > _adorner.ActualWidth + _hideAdornerDistance ) || ( p.Y < -_hideAdornerDistance ) || ( p.Y > _adorner.ActualHeight + _hideAdornerDistance ) )
{
HideAdorner();
}
//Mouse is just outside FormatBar: Vary its opacity.
else
{
if( p.X < 0 )
maxDist = -p.X;
else if( p.X > _adorner.ActualWidth )
maxDist = p.X - _adorner.ActualWidth;
if( p.Y < 0 )
maxDist = Math.Max( maxDist, -p.Y );
else if( p.Y > _adorner.ActualHeight )
maxDist = Math.Max( maxDist, p.Y - _adorner.ActualHeight );
_adorner.Opacity = 1d - ( Math.Min( maxDist, 100d ) / 100d );
}
}
void RichTextBox_TextChanged( object sender, TextChangedEventArgs e )
{
//This fixes the bug when applying text transformations the text would lose it's highlight. That was because the RichTextBox was losing focus,
//so we just give it focus again and it seems to do the trick of re-highlighting it.
if( !_richTextBox.IsFocused && !_richTextBox.Selection.IsEmpty )
_richTextBox.Focus();
}
#endregion //Event Handlers
#region Methods
/// <summary>
/// Attaches a FormatBar to a RichtextBox
/// </summary>
/// <param name="richTextBox">The RichtextBox to attach to.</param>
/// <param name="formatBar">The Formatbar to attach.</param>
private void AttachFormatBarToRichtextBox( global::System.Windows.Controls.RichTextBox richTextBox, IRichTextBoxFormatBar formatBar )
{
_richTextBox = richTextBox;
//we cannot use the PreviewMouseLeftButtonUp event because of selection bugs.
//we cannot use the MouseLeftButtonUp event because it is handled by the RichTextBox and does not bubble up to here, so we must
//add a hander to the MouseUpEvent using the Addhandler syntax, and specify to listen for handled events too.
_richTextBox.AddHandler( Mouse.MouseUpEvent, new MouseButtonEventHandler( RichTextBox_MouseButtonUp ), true );
_richTextBox.TextChanged += RichTextBox_TextChanged;
_adorner = new UIElementAdorner<Control>( _richTextBox );
formatBar.Target = _richTextBox;
_toolbar = formatBar;
}
/// <summary>
/// Shows the FormatBar
/// </summary>
void ShowAdorner()
{
if( _adorner.Visibility == Visibility.Visible )
return;
VerifyAdornerLayer();
Control adorningEditor = _toolbar as Control;
if( _adorner.Child == null )
_adorner.Child = adorningEditor;
adorningEditor.ApplyTemplate();
_toolbar.Update();
_adorner.Visibility = Visibility.Visible;
PositionFormatBar( adorningEditor );
_parentWindow = TreeHelper.FindParent<Window>( _adorner );
if( _parentWindow != null )
{
Mouse.AddMouseMoveHandler( _parentWindow, OnPreviewMouseMoveParentWindow );
}
}
/// <summary>
/// Positions the FormatBar so that is does not go outside the bounds of the RichTextBox or covers the selected text
/// </summary>
/// <param name="adorningEditor"></param>
private void PositionFormatBar( Control adorningEditor )
{
Point mousePosition = Mouse.GetPosition( _richTextBox );
double left = mousePosition.X;
double top = ( mousePosition.Y - 15 ) - adorningEditor.ActualHeight;
//top
if( top < 0 )
{
top = mousePosition.Y + 10;
}
//right boundary
if( left + adorningEditor.ActualWidth > _richTextBox.ActualWidth - 20 )
{
left = left - ( adorningEditor.ActualWidth - ( _richTextBox.ActualWidth - left ) );
}
_adorner.SetOffsets( left, top );
}
/// <summary>
/// Ensures that the IRichTextFormatBar is in the adorner layer.
/// </summary>
/// <returns>True if the IRichTextFormatBar is in the adorner layer, else false.</returns>
bool VerifyAdornerLayer()
{
if( _adorner.Parent != null )
return true;
AdornerLayer layer = AdornerLayer.GetAdornerLayer( _richTextBox );
if( layer == null )
return false;
layer.Add( _adorner );
return true;
}
/// <summary>
/// Hides the IRichTextFormatBar that is in the adornor layer.
/// </summary>
void HideAdorner()
{
if( IsAdornerVisible )
{
_adorner.Visibility = Visibility.Collapsed;
//_adorner.Child = null;
if( _parentWindow != null )
{
Mouse.RemoveMouseMoveHandler( _parentWindow, OnPreviewMouseMoveParentWindow );
}
}
}
#endregion //Methods
}
}

View File

@@ -0,0 +1,729 @@
<!--***********************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
**********************************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Themes/Aero2/Glyphs.xaml" />
</ResourceDictionary.MergedDictionaries>
<conv:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
<ControlTemplate x:Key="ThumbControlTemplate"
TargetType="{x:Type Thumb}">
<Border Background="Transparent"
Cursor="Hand"
ToolTip="Click to Drag">
<StackPanel VerticalAlignment="Center"
Width="75">
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
</StackPanel>
</Border>
</ControlTemplate>
<SolidColorBrush x:Key="MouseOverBorderBrush"
Color="#FFFFB700" />
<LinearGradientBrush x:Key="MouseOverBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFFEFBF4" />
<GradientStop Offset="0.19"
Color="#FFFDE7CE" />
<GradientStop Offset="0.39"
Color="#FFFDDEB8" />
<GradientStop Offset="0.39"
Color="#FFFFCE6B" />
<GradientStop Offset="0.79"
Color="#FFFFDE9A" />
<GradientStop Offset="1"
Color="#FFFFEBAA" />
</LinearGradientBrush>
<SolidColorBrush x:Key="CheckedBorderBrush"
Color="#FFC29B29" />
<LinearGradientBrush x:Key="CheckedBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFFFDCA0" />
<GradientStop Offset="0.18"
Color="#FFFFD692" />
<GradientStop Offset="0.39"
Color="#FFFFC45D" />
<GradientStop Offset="1"
Color="#FFFFD178" />
</LinearGradientBrush>
<SolidColorBrush x:Key="PressedBorderBrush"
Color="#FFC29B29" />
<LinearGradientBrush x:Key="PressedBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFE3C085" />
<GradientStop Offset="0.19"
Color="#FFF4CC89" />
<GradientStop Offset="0.36"
Color="#FFF5C777" />
<GradientStop Offset="0.36"
Color="#FFF5BB56" />
<GradientStop Offset="0.79"
Color="#FFF4CE9A" />
<GradientStop Offset="1"
Color="#FFF3E28D" />
</LinearGradientBrush>
<Style x:Key="FormatBarToggleButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
CornerRadius="0" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0"
Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content"
Content="{TemplateBinding Content}"
Margin="1"
RenderOptions.BitmapScalingMode="NearestNeighbor"
VerticalAlignment="Center"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Opacity"
TargetName="Content"
Value="0.5" />
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="FontColorButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0"
Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Image Source="../Images/FontColorPicker16.png"
Width="16"
Height="16" />
<Rectangle Grid.Row="1"
Height="4"
Margin="0,12,0,0"
Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Grid>
<Path Grid.Column="1"
Width="9"
Height="5"
Data="{StaticResource DownArrowGeometry}"
Fill="#FF000000"
Margin="0,1,0,0"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="FontBackgrounColorButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="White" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="0"
Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Image Source="../Images/TextHighlightColorPicker16.png"
Width="16"
Height="16" />
<Rectangle Grid.Row="1"
Height="4"
Margin="0,12,0,0"
Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Grid>
<Path Grid.Column="1"
Width="9"
Height="5"
Data="{StaticResource DownArrowGeometry}"
Fill="#FF000000"
Margin="0,1,0,0"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- =================================================================== -->
<!-- Template -->
<!-- =================================================================== -->
<ControlTemplate x:Key="richTextBoxFormatBarTemplate"
TargetType="{x:Type local:RichTextBoxFormatBar}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type Separator}"
BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
</ControlTemplate.Resources>
<Border CornerRadius="0"
BorderThickness="1"
BorderBrush="#FFADC7DE"
Background="#FFDAE8F9">
<Grid Margin="5,0,5,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Thumb x:Name="_dragWidget"
Height="10"
Template="{StaticResource ThumbControlTemplate}" />
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="_cmbFontFamilies"
IsEditable="True"
Width="100"
ToolTip="Font Family" />
<ComboBox x:Name="_cmbFontSizes"
IsEditable="True"
Width="43"
ToolTip="Font Size"/>
<Separator />
<ToggleButton x:Name="_btnBullets"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleBullets"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Bullets">
<Image Source="../Images/Bullets16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnNumbers"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleNumbering"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Numbering">
<Image Source="../Images/Numbering16.png" />
</ToggleButton>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,3,0,0">
<ToggleButton x:Name="_btnBold"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleBold"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Bold">
<Image Source="../Images/Bold16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnItalic"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleItalic}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Italic">
<Image Source="../Images/Italic16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnUnderline"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleUnderline}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Underline">
<Image Source="../Images/Underline16.png" />
</ToggleButton>
<Separator />
<RadioButton x:Name="_btnAlignLeft"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignLeft}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Left">
<Image Source="../Images/LeftAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignCenter"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignCenter}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Center">
<Image Source="../Images/CenterAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignRight"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignRight}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Right">
<Image Source="../Images/RightAlign16.png" />
</RadioButton>
<Separator />
<local:ColorPicker x:Name="_cmbFontBackgroundColor"
BorderThickness="0"
ButtonStyle="{StaticResource FontBackgrounColorButtonStyle}"
ToolTip="Text Highlight Color" />
<local:ColorPicker x:Name="_cmbFontColor"
BorderThickness="0"
ButtonStyle="{StaticResource FontColorButtonStyle}"
ToolTip="Font Color" />
</StackPanel>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
<!-- =================================================================== -->
<!-- Style -->
<!-- =================================================================== -->
<Style TargetType="{x:Type local:RichTextBoxFormatBar}">
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template" Value="{StaticResource richTextBoxFormatBarTemplate}" />
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="5" Opacity=".25" />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,732 @@
<!--***********************************************************************************
Extended WPF Toolkit
Copyright (C) 2007-2013 Xceed Software Inc.
This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
For more features, controls, and fast professional support,
pick up the Plus Edition at http://xceed.com/wpf_toolkit
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
**********************************************************************************-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters" >
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\..\Themes\Generic\Glyphs.xaml" />
</ResourceDictionary.MergedDictionaries>
<conv:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
<ControlTemplate x:Key="ThumbControlTemplate"
TargetType="{x:Type Thumb}">
<Border Background="Transparent"
Cursor="Hand"
ToolTip="Click to Drag">
<StackPanel VerticalAlignment="Center"
Width="75">
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
</StackPanel>
</Border>
</ControlTemplate>
<SolidColorBrush x:Key="MouseOverBorderBrush"
Color="#FFFFB700" />
<LinearGradientBrush x:Key="MouseOverBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFFEFBF4" />
<GradientStop Offset="0.19"
Color="#FFFDE7CE" />
<GradientStop Offset="0.39"
Color="#FFFDDEB8" />
<GradientStop Offset="0.39"
Color="#FFFFCE6B" />
<GradientStop Offset="0.79"
Color="#FFFFDE9A" />
<GradientStop Offset="1"
Color="#FFFFEBAA" />
</LinearGradientBrush>
<SolidColorBrush x:Key="CheckedBorderBrush"
Color="#FFC29B29" />
<LinearGradientBrush x:Key="CheckedBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFFFDCA0" />
<GradientStop Offset="0.18"
Color="#FFFFD692" />
<GradientStop Offset="0.39"
Color="#FFFFC45D" />
<GradientStop Offset="1"
Color="#FFFFD178" />
</LinearGradientBrush>
<SolidColorBrush x:Key="PressedBorderBrush"
Color="#FFC29B29" />
<LinearGradientBrush x:Key="PressedBackgroundBrush"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Offset="0"
Color="#FFE3C085" />
<GradientStop Offset="0.19"
Color="#FFF4CC89" />
<GradientStop Offset="0.36"
Color="#FFF5C777" />
<GradientStop Offset="0.36"
Color="#FFF5BB56" />
<GradientStop Offset="0.79"
Color="#FFF4CE9A" />
<GradientStop Offset="1"
Color="#FFF3E28D" />
</LinearGradientBrush>
<Style x:Key="FormatBarToggleButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
CornerRadius="2" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2"
Padding="{TemplateBinding Padding}">
<StackPanel x:Name="StackPanel"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
<ContentPresenter x:Name="Content"
Content="{TemplateBinding Content}"
Margin="1"
RenderOptions.BitmapScalingMode="NearestNeighbor"
VerticalAlignment="Center"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</StackPanel>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Opacity"
TargetName="Content"
Value="0.5" />
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="FontColorButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="2" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2"
Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Image Source="../Images/FontColorPicker16.png"
Width="16"
Height="16" />
<Rectangle Grid.Row="1"
Height="4"
Margin="0,12,0,0"
Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Grid>
<Path Grid.Column="1"
Width="9"
Height="5"
Data="{StaticResource DownArrowGeometry}"
Fill="#FF000000"
Margin="0,1,0,0"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="FontBackgrounColorButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Background"
Value="White" />
<Setter Property="BorderBrush"
Value="Transparent" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="FocusVisualStyle"
Value="{x:Null}" />
<Setter Property="Height"
Value="22" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="ToolTipService.InitialShowDelay"
Value="900" />
<Setter Property="ToolTipService.ShowDuration"
Value="20000" />
<Setter Property="ToolTipService.BetweenShowDelay"
Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="OuterBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="2" />
<Border x:Name="MiddleBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2">
<Border x:Name="InnerBorder"
BorderBrush="Transparent"
BorderThickness="{TemplateBinding BorderThickness}"
Background="Transparent"
CornerRadius="2"
Padding="{TemplateBinding Padding}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid>
<Image Source="../Images/TextHighlightColorPicker16.png"
Width="16"
Height="16" />
<Rectangle Grid.Row="1"
Height="4"
Margin="0,12,0,0"
Fill="{Binding SelectedColor, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ColorPicker}, Converter={StaticResource ColorToSolidColorBrushConverter}}" />
</Grid>
<Path Grid.Column="1"
Width="9"
Height="5"
Data="{StaticResource DownArrowGeometry}"
Fill="#FF000000"
Margin="0,1,0,0"/>
</Grid>
</Border>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource MouseOverBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="#80FFFFFF" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="TextElement.Foreground"
TargetName="OuterBorder"
Value="#FF9E9E9E" />
</Trigger>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource CheckedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource CheckedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#FFE7CBAD"
Offset="0" />
<GradientStop Color="#FFF7D7B5"
Offset="0.1" />
<GradientStop Color="#FFFFD38C"
Offset="0.36" />
<GradientStop Color="#FFFFC75A"
Offset="0.36" />
<GradientStop Color="#FFFFEFA5"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Background"
TargetName="OuterBorder"
Value="{StaticResource PressedBackgroundBrush}" />
<Setter Property="BorderBrush"
TargetName="OuterBorder"
Value="{StaticResource PressedBorderBrush}" />
<Setter Property="BorderBrush"
TargetName="InnerBorder"
Value="Transparent" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsChecked"
Value="True" />
<Condition Property="IsMouseOver"
Value="True" />
</MultiTrigger.Conditions>
<Setter Property="Background"
TargetName="MiddleBorder">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1"
StartPoint="0,0">
<GradientStop Color="#40FFFEFE"
Offset="0" />
<GradientStop Color="#40FFFEFE"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.39" />
<GradientStop Color="#20FFCE68"
Offset="0.69" />
<GradientStop Color="#10FFFFFF"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- =================================================================== -->
<!-- Template -->
<!-- =================================================================== -->
<ControlTemplate x:Key="richTextBoxFormatBarTemplate"
TargetType="{x:Type local:RichTextBoxFormatBar}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type Separator}"
BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
</ControlTemplate.Resources>
<Border CornerRadius="3"
BorderThickness="1"
BorderBrush="Gray"
Background="WhiteSmoke">
<Grid Margin="5,0,5,5">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Thumb x:Name="_dragWidget"
Height="10"
Template="{StaticResource ThumbControlTemplate}" />
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="_cmbFontFamilies"
IsEditable="True"
Width="100"
ToolTip="Font Family" />
<ComboBox x:Name="_cmbFontSizes"
IsEditable="True"
Width="43"
ToolTip="Font Size"/>
<Separator />
<ToggleButton x:Name="_btnBullets"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleBullets"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Bullets">
<Image Source="../Images/Bullets16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnNumbers"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleNumbering"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Numbering">
<Image Source="../Images/Numbering16.png" />
</ToggleButton>
</StackPanel>
<StackPanel Orientation="Horizontal"
Margin="0,3,0,0">
<ToggleButton x:Name="_btnBold"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleBold"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Bold">
<Image Source="../Images/Bold16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnItalic"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleItalic}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Italic">
<Image Source="../Images/Italic16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnUnderline"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleUnderline}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Underline">
<Image Source="../Images/Underline16.png" />
</ToggleButton>
<Separator />
<RadioButton x:Name="_btnAlignLeft"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignLeft}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Left">
<Image Source="../Images/LeftAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignCenter"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignCenter}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Center">
<Image Source="../Images/CenterAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignRight"
Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignRight}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Target}"
ToolTip="Align Right">
<Image Source="../Images/RightAlign16.png" />
</RadioButton>
<Separator />
<local:ColorPicker x:Name="_cmbFontBackgroundColor"
BorderThickness="0"
ButtonStyle="{StaticResource FontBackgrounColorButtonStyle}"
ToolTip="Text Highlight Color" />
<local:ColorPicker x:Name="_cmbFontColor"
BorderThickness="0"
ButtonStyle="{StaticResource FontColorButtonStyle}"
ToolTip="Font Color" />
</StackPanel>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
<!-- =================================================================== -->
<!-- Style -->
<!-- =================================================================== -->
<Style TargetType="{x:Type local:RichTextBoxFormatBar}">
<Setter Property="Template"
Value="{StaticResource richTextBoxFormatBarTemplate}" />
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="5"
Opacity=".25" />
</Setter.Value>
</Setter>
<Setter Property="Background"
Value="Transparent" />
<Setter Property="IsTabStop"
Value="false" />
</Style>
</ResourceDictionary>