Browse Source

renamed IRichTextBoxFormatBar property from RichTextBox to Target. This describes the purpose of the property better when creating your own custom format bar.

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
1763c930b6
  1. 5
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/IRichTextBoxFormatBar.cs
  2. 12
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml
  3. 26
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml.cs
  4. 2
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs

5
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/IRichTextBoxFormatBar.cs

@ -4,6 +4,9 @@ namespace Microsoft.Windows.Controls
{
public interface IRichTextBoxFormatBar
{
global::System.Windows.Controls.RichTextBox RichTextBox { get; set; }
/// <summary>
/// Represents the RichTextBox that will be the target for all text manipulations in the format bar.
/// </summary>
global::System.Windows.Controls.RichTextBox Target { get; set; }
}
}

12
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml

@ -168,30 +168,30 @@
<StackPanel Orientation="Horizontal" Margin="0,3,0,0">
<ToggleButton x:Name="_btnBold" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}">
Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=_window, Path=Target}">
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Bold16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnItalic" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleItalic}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}">
Command="{x:Static EditingCommands.ToggleItalic}" CommandTarget="{Binding ElementName=_window, Path=Target}">
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Italic16.png" />
</ToggleButton>
<ToggleButton x:Name="_btnUnderline" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.ToggleUnderline}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}">
Command="{x:Static EditingCommands.ToggleUnderline}" CommandTarget="{Binding ElementName=_window, Path=Target}">
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Underline16.png" />
</ToggleButton>
<Separator />
<RadioButton x:Name="_btnAlignLeft" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignLeft}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" >
Command="{x:Static EditingCommands.AlignLeft}" CommandTarget="{Binding ElementName=_window, Path=Target}" >
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/LeftAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignCenter" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignCenter}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" >
Command="{x:Static EditingCommands.AlignCenter}" CommandTarget="{Binding ElementName=_window, Path=Target}" >
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/CenterAlign16.png" />
</RadioButton>
<RadioButton x:Name="_btnAlignRight" Style="{StaticResource FormatBarToggleButtonStyle}"
Command="{x:Static EditingCommands.AlignRight}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" >
Command="{x:Static EditingCommands.AlignRight}" CommandTarget="{Binding ElementName=_window, Path=Target}" >
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/RightAlign16.png" />
</RadioButton>

26
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml.cs

@ -17,11 +17,11 @@ namespace Microsoft.Windows.Controls
#region RichTextBox
public static readonly DependencyProperty RichTextBoxProperty = DependencyProperty.Register("RichTextBox", typeof(global::System.Windows.Controls.RichTextBox), typeof(RichTextBoxFormatBar), new PropertyMetadata(null, new PropertyChangedCallback(OnRichTextBoxPropertyChanged)));
public global::System.Windows.Controls.RichTextBox RichTextBox
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(RichTextBoxProperty); }
set { SetValue(RichTextBoxProperty, value); }
get { return (global::System.Windows.Controls.RichTextBox)GetValue(TargetProperty); }
set { SetValue(TargetProperty, value); }
}
private static void OnRichTextBoxPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
@ -32,12 +32,12 @@ namespace Microsoft.Windows.Controls
private void HookupRichTextBoxEvents()
{
RichTextBox.SelectionChanged += RichTextBox_SelectionChanged;
Target.SelectionChanged += RichTextBox_SelectionChanged;
}
#endregion //RichTextBox
public double[] FontSizes
public static double[] FontSizes
{
get
{
@ -67,7 +67,7 @@ namespace Microsoft.Windows.Controls
void FormatToolbar_Loaded(object sender, RoutedEventArgs e)
{
_cmbFontFamilies.ItemsSource = System.Windows.Media.Fonts.SystemFontFamilies;
_cmbFontFamilies.ItemsSource = Fonts.SystemFontFamilies;
_cmbFontSizes.ItemsSource = FontSizes;
}
@ -122,13 +122,13 @@ namespace Microsoft.Windows.Controls
void UpdateItemCheckedState(ToggleButton button, DependencyProperty formattingProperty, object expectedValue)
{
object currentValue = RichTextBox.Selection.GetPropertyValue(formattingProperty);
object currentValue = Target.Selection.GetPropertyValue(formattingProperty);
button.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != null && currentValue.Equals(expectedValue);
}
private void UpdateSelectedFontFamily()
{
object value = RichTextBox.Selection.GetPropertyValue(TextElement.FontFamilyProperty);
object value = Target.Selection.GetPropertyValue(TextElement.FontFamilyProperty);
FontFamily currentFontFamily = (FontFamily)((value == DependencyProperty.UnsetValue) ? null : value);
if (currentFontFamily != null)
{
@ -138,7 +138,7 @@ namespace Microsoft.Windows.Controls
private void UpdateSelectedFontSize()
{
object value = RichTextBox.Selection.GetPropertyValue(TextElement.FontSizeProperty);
object value = Target.Selection.GetPropertyValue(TextElement.FontSizeProperty);
_cmbFontSizes.SelectedValue = (value == DependencyProperty.UnsetValue) ? null : value;
}
@ -147,13 +147,13 @@ namespace Microsoft.Windows.Controls
if (value == null)
return;
RichTextBox.Selection.ApplyPropertyValue(formattingProperty, value);
Target.Selection.ApplyPropertyValue(formattingProperty, value);
}
private void ProcessMove(DragDeltaEventArgs e)
{
AdornerLayer layer = AdornerLayer.GetAdornerLayer(RichTextBox);
UIElementAdorner<Control> adorner = layer.GetAdorners(RichTextBox)[0] as UIElementAdorner<Control>;
AdornerLayer layer = AdornerLayer.GetAdornerLayer(Target);
UIElementAdorner<Control> adorner = layer.GetAdorners(Target)[0] as UIElementAdorner<Control>;
adorner.SetOffsets(adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange);
}

2
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs

@ -92,7 +92,7 @@ namespace Microsoft.Windows.Controls
_adorner = new UIElementAdorner<Control>(_richTextBox);
formatBar.RichTextBox = _richTextBox;
formatBar.Target = _richTextBox;
_toolbar = formatBar;
}

Loading…
Cancel
Save