diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Properties/AssemblyInfo.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Properties/AssemblyInfo.cs index 0b939ab2..01a5795a 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Properties/AssemblyInfo.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Properties/AssemblyInfo.cs @@ -31,7 +31,7 @@ using System; [assembly: AssemblyCompany( "Xceed Software Inc." )] [assembly: AssemblyProduct( "Xceed Toolkit for WPF - AvalonDock" )] -[assembly: AssemblyCopyright( "Copyright (C) Xceed Software Inc. 2007-2025" )] +[assembly: AssemblyCopyright( "Copyright (C) Xceed Software Inc. 2007-2026" )] diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Theme.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Theme.xaml index b8f64b4f..64d522ec 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Theme.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock.Themes.Aero/Theme.xaml @@ -47,6 +47,97 @@ + + + + + + + - diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControlDialog.xaml.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControlDialog.xaml.cs index f2afe8dc..d7d89cc6 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControlDialog.xaml.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/CollectionControl/Implementation/CollectionControlDialog.xaml.cs @@ -232,9 +232,7 @@ namespace Xceed.Wpf.Toolkit Debug.Assert( result != null ); if( result != null ) { - PropertyInfo[] propertyInfos = typeof( ICollection ).IsAssignableFrom( sourceType ) - ? sourceType.GetProperties( BindingFlags.Instance | BindingFlags.Public ) - : sourceType.GetProperties( BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly ); + PropertyInfo[] propertyInfos = sourceType.GetProperties( BindingFlags.Instance | BindingFlags.Public ); foreach( var propertyInfo in propertyInfos ) { diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Implementation/ColorPicker.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Implementation/ColorPicker.cs index 5940f037..1536a71f 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Implementation/ColorPicker.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Implementation/ColorPicker.cs @@ -657,6 +657,35 @@ namespace Xceed.Wpf.Toolkit #endregion //UsingAlphaChannel + #region CornerRadius + + public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof( CornerRadius ), typeof( CornerRadius ), typeof( ColorPicker ), new FrameworkPropertyMetadata( new CornerRadius(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback( OnCornerRadiusPropertyChanged ) ) ); + public CornerRadius CornerRadius + { + get + { + return ( CornerRadius )GetValue( CornerRadiusProperty ); + } + set + { + SetValue( CornerRadiusProperty, value ); + } + } + + private static void OnCornerRadiusPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) + { + ColorPicker colorPicker = ( ColorPicker )d; + if( colorPicker != null ) + colorPicker.OnCornerRadiusChanged(); + } + + protected virtual void OnCornerRadiusChanged() + { + } + + #endregion //CornerRadius + + #endregion //Properties #region Constructors diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Aero2.NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Aero2.NormalColor.xaml index 5fda4800..737bd595 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Aero2.NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Aero2.NormalColor.xaml @@ -19,6 +19,7 @@ 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" + xmlns:core="clr-namespace:Xceed.Wpf.Toolkit.Core" xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes"> @@ -133,8 +134,10 @@ - @@ -147,7 +150,7 @@ + + + + VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" /> @@ -296,15 +305,17 @@ + Value="AliceBlue" /> + Value="{StaticResource PanelBackgroundBrush}" /> + + Value="#FFF0F0F0" /> @@ -320,7 +331,8 @@ Padding="{TemplateBinding Padding}" IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" - Style="{TemplateBinding ButtonStyle}"> + Style="{TemplateBinding ButtonStyle}" + core:AppearanceProperties.OuterCornerRadius="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}"> diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Generic.xaml index c709428d..a72cb9ec 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/ColorPicker/Themes/Generic.xaml @@ -18,6 +18,7 @@ @@ -173,8 +174,10 @@ - @@ -187,7 +190,7 @@ + + + + + StartPoint="0.5,0"> + Style="{TemplateBinding ButtonStyle}" + core:AppearanceProperties.OuterCornerRadius="{Binding CornerRadius, RelativeSource={RelativeSource TemplatedParent}}"> @@ -379,7 +391,7 @@ BorderThickness="1" BorderBrush="#FFC9CACA" /> + VerticalAlignment="Center"> @@ -441,12 +453,12 @@ Background="{TemplateBinding HeaderBackground}" Foreground="{TemplateBinding HeaderForeground}" Padding="2" - Margin="0,0,0,1" > + Margin="0,0,0,1"> + Style="{StaticResource ColorListStyle}"> @@ -463,12 +475,12 @@ Background="{TemplateBinding HeaderBackground}" Foreground="{TemplateBinding HeaderForeground}" Padding="2" - Margin="0,1,0,1" > + Margin="0,1,0,1"> + Style="{StaticResource ColorListStyle}"> @@ -486,12 +498,12 @@ Background="{TemplateBinding HeaderBackground}" Foreground="{TemplateBinding HeaderForeground}" Padding="2" - Margin="0,1,0,1" > + Margin="0,1,0,1"> + Style="{StaticResource ColorListStyle}"> diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/AppearanceProperties.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/AppearanceProperties.cs new file mode 100644 index 00000000..1d1c32f3 --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/AppearanceProperties.cs @@ -0,0 +1,113 @@ +/************************************************************************************* + + Toolkit for WPF + + Copyright (C) 2007-2025 Xceed Software Inc. + + This program is provided to you under the terms of the XCEED SOFTWARE, INC. + COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at + https://github.com/xceedsoftware/wpftoolkit/blob/master/license.md + + For more features, controls, and fast professional support, + pick up the Plus Edition at https://xceed.com/xceed-toolkit-plus-for-wpf/ + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System.Windows.Media; +using System.Windows; + +namespace Xceed.Wpf.Toolkit.Core +{ + public class AppearanceProperties + { + #region OuterCornerRadiusProperty + + public static CornerRadius GetOuterCornerRadius( DependencyObject obj ) + { + return ( CornerRadius )obj.GetValue( OuterCornerRadiusProperty ); + } + + public static void SetOuterCornerRadius( DependencyObject obj, CornerRadius value ) + { + obj.SetValue( OuterCornerRadiusProperty, value ); + } + + public static readonly DependencyProperty OuterCornerRadiusProperty = + DependencyProperty.RegisterAttached( + "OuterCornerRadius", + typeof( CornerRadius ), + typeof( AppearanceProperties ), + new FrameworkPropertyMetadata( new CornerRadius( 0.0 ) ) ); + + #endregion OuterCornerRadiusProperty + + + #region ContentMarginProperty + + public static Thickness GetContentMargin( DependencyObject obj ) + { + return ( Thickness )obj.GetValue( ContentMarginProperty ); + } + + public static void SetContentMargin( DependencyObject obj, Thickness value ) + { + obj.SetValue( ContentMarginProperty, value ); + } + + public static readonly DependencyProperty ContentMarginProperty = + DependencyProperty.RegisterAttached( + "ContentMargin", + typeof( Thickness ), + typeof( AppearanceProperties ), + new FrameworkPropertyMetadata( new Thickness( 0.0 ) ) ); + + #endregion InnerBorderThicknessProperty + + + #region HeaderForegroundProperty + + public static Brush GetHeaderForeground( DependencyObject obj ) + { + return ( Brush )obj.GetValue( HeaderForegroundProperty ); + } + + public static void SetHeaderForeground( DependencyObject obj, Brush value ) + { + obj.SetValue( HeaderForegroundProperty, value ); + } + + public static readonly DependencyProperty HeaderForegroundProperty = + DependencyProperty.RegisterAttached( + "HeaderForeground", + typeof( Brush ), + typeof( AppearanceProperties ), + new FrameworkPropertyMetadata( ( Brush )( new SolidColorBrush( Colors.Black ).GetAsFrozen() ) ) ); + + #endregion HeaderForegroundProperty + + + #region HeaderFontWeightProperty + + public static FontWeight GetHeaderFontWeight( DependencyObject obj ) + { + return ( FontWeight )obj.GetValue( HeaderFontWeightProperty ); + } + + public static void SetHeaderFontWeight( DependencyObject obj, FontWeight value ) + { + obj.SetValue( HeaderFontWeightProperty, value ); + } + + public static readonly DependencyProperty HeaderFontWeightProperty = + DependencyProperty.RegisterAttached( + "HeaderFontWeight", + typeof( FontWeight ), + typeof( AppearanceProperties ), + new FrameworkPropertyMetadata( FontWeights.Normal ) ); + + #endregion HeaderFontWeightProperty + } + +} diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/Converters/CornerRadiusReplacementConverter.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/Converters/CornerRadiusReplacementConverter.cs new file mode 100644 index 00000000..c967419e --- /dev/null +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Core/Converters/CornerRadiusReplacementConverter.cs @@ -0,0 +1,151 @@ +/************************************************************************************* + + Toolkit for WPF + + Copyright (C) 2007-2025 Xceed Software Inc. + + This program is provided to you under the terms of the XCEED SOFTWARE, INC. + COMMUNITY LICENSE AGREEMENT (for non-commercial use) as published at + https://github.com/xceedsoftware/wpftoolkit/blob/master/license.md + + For more features, controls, and fast professional support, + pick up the Plus Edition at https://xceed.com/xceed-toolkit-plus-for-wpf/ + + Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids + + ***********************************************************************************/ + +using System.Globalization; +using System.Windows.Data; +using System.Windows.Markup; +using System.Windows; +using System; + +namespace Xceed.Wpf.Toolkit.Core.Converters +{ + public class CornerRadiusReplacementConverter : MarkupExtension, IValueConverter + { + + public const string Auto = "Auto"; + + #region Constructors + + public CornerRadiusReplacementConverter() + { + } + + public CornerRadiusReplacementConverter( + object topLeft, + object topRight, + object bottomRight, + object bottomLeft ) + { + this.TopLeft = topLeft; + this.TopRight = topRight; + this.BottomRight = bottomRight; + this.BottomLeft = bottomLeft; + } + + #endregion Constructors + + #region Properties + + public object TopLeft { get; set; } = Auto; + + public object TopRight { get; set; } = Auto; + + public object BottomRight { get; set; } = Auto; + + public object BottomLeft { get; set; } = Auto; + + #endregion Properties + + #region Implement IValueConverter + + public object Convert( object value, Type targetType, object parameter, CultureInfo culture ) + { + if( value is CornerRadius ) + { + CornerRadius source = ( CornerRadius )value; + + return new CornerRadius( + GetValue( this.TopLeft, source, source.TopLeft ), + GetValue( this.TopRight, source, source.TopRight ), + GetValue( this.BottomRight, source, source.BottomRight ), + GetValue( this.BottomLeft, source, source.BottomLeft ) ); + } + else if( value is double || value is int ) + { + CornerRadius source = new CornerRadius( System.Convert.ToDouble( value ) ); + + return new CornerRadius( + this.GetValue( this.TopLeft, source, source.TopLeft ), + this.GetValue( this.TopRight, source, source.TopRight ), + this.GetValue( this.BottomRight, source, source.BottomRight ), + this.GetValue( this.BottomLeft, source, source.BottomLeft ) ); + } + + return new CornerRadius( 0 ); + } + + public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture ) + { + throw new NotImplementedException(); + } + + #endregion Implement IValueConverter + + #region Implement MarkupExtension + + public override object ProvideValue( IServiceProvider serviceProvider ) + { + return this; + } + + #endregion Implement MarkupExtension + + #region Methods (Private) + + private double GetValue( object operand, CornerRadius sourceCornerRadius, double autoValue ) + { + var stringVal = operand as string; + if( stringVal != null ) + { + if( Auto.Equals( stringVal, StringComparison.Ordinal ) ) + { + return autoValue; + } + else if( "TopLeft".Equals( stringVal, StringComparison.Ordinal ) ) + { + return sourceCornerRadius.TopLeft; + } + else if( "TopRight".Equals( stringVal, StringComparison.Ordinal ) ) + { + return sourceCornerRadius.TopRight; + } + else if( "BottomRight".Equals( stringVal, StringComparison.Ordinal ) ) + { + return sourceCornerRadius.BottomRight; + } + else if( "BottomLeft".Equals( stringVal, StringComparison.Ordinal ) ) + { + return sourceCornerRadius.BottomLeft; + } + else if( double.TryParse( stringVal, out var doubleValue ) ) + { + return doubleValue; + } + } + else if( operand is double || operand is int ) + { + return ( double )System.Convert.ToDouble( operand ); + } + + throw new ArgumentException( "Value '" + operand + "' not recognized. Supported values are Auto, Left, Top, Right, Bottom or a double value." ); + } + + #endregion Methods (Private) + + } + +} diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Implementation/DateTimePicker.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Implementation/DateTimePicker.cs index 2abb3511..feafd790 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Implementation/DateTimePicker.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Implementation/DateTimePicker.cs @@ -51,6 +51,23 @@ namespace Xceed.Wpf.Toolkit #region Properties + #region AutoCloseCalendarOnTodayButton + + public static readonly DependencyProperty AutoCloseCalendarOnTodayButtonProperty = DependencyProperty.Register( nameof( AutoCloseCalendarOnTodayButton ), typeof( bool ), typeof( DateTimePicker ), new UIPropertyMetadata( false ) ); + public bool AutoCloseCalendarOnTodayButton + { + get + { + return ( bool )GetValue( AutoCloseCalendarOnTodayButtonProperty ); + } + set + { + SetValue( AutoCloseCalendarOnTodayButtonProperty, value ); + } + } + + #endregion //AutoCloseCalendarOnToDayButton + #region AutoCloseCalendar public static readonly DependencyProperty AutoCloseCalendarProperty = DependencyProperty.Register( "AutoCloseCalendar", typeof( bool ), typeof( DateTimePicker ), new UIPropertyMetadata( false ) ); diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Themes/Aero2.NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Themes/Aero2.NormalColor.xaml index a757e612..dddd7197 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Themes/Aero2.NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimePicker/Themes/Aero2.NormalColor.xaml @@ -21,6 +21,7 @@ xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes" xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes" xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters" + xmlns:core="clr-namespace:Xceed.Wpf.Toolkit.Core" xmlns:dateConv="clr-namespace:Xceed.Wpf.Toolkit.Converters" xmlns:sys="clr-namespace:System;assembly=mscorlib"> @@ -47,7 +48,7 @@ + + ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius, Converter={conv:CornerRadiusReplacementConverter Auto, 0, 0, Auto}}"> + + + @@ -72,7 +73,7 @@ + + ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius, Converter={conv:CornerRadiusReplacementConverter Auto, 0, 0, Auto}}"> + + + x.Value ).ToArray() ); var time = string.Join( cultureInfo.DateTimeFormat.TimeSeparator, timeParts ); + while( millisecondsPart.Length < 3 ) + { + millisecondsPart = "0" + millisecondsPart; + } time += "." + millisecondsPart; return String.Format( "{0} {1} {2}", date, time, designator ); diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Themes/Aero2.NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Themes/Aero2.NormalColor.xaml index 2ff6b4e6..91c4446a 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Themes/Aero2.NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/DateTimeUpDown/Themes/Aero2.NormalColor.xaml @@ -18,120 +18,148 @@ - - - + + + - - - + + + - + - + BorderThickness="0" + Background="Transparent" + CaretBrush="{Binding CaretBrush, RelativeSource={RelativeSource TemplatedParent}}" + ContextMenu="{TemplateBinding ContextMenu}" + FontFamily="{TemplateBinding FontFamily}" + FontSize="{TemplateBinding FontSize}" + FontStretch="{TemplateBinding FontStretch}" + FontStyle="{TemplateBinding FontStyle}" + FontWeight="{TemplateBinding FontWeight}" + Foreground="{TemplateBinding Foreground}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + IsUndoEnabled="{Binding IsUndoEnabled, RelativeSource={RelativeSource TemplatedParent}}" + IsTabStop="True" + AutoSelectBehavior="OnFocus" + MinWidth="20" + AcceptsReturn="False" + Padding="{TemplateBinding Padding}" + TextAlignment="{TemplateBinding TextAlignment}" + TextWrapping="NoWrap" + TabIndex="{TemplateBinding TabIndex}" + Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" + Watermark="{TemplateBinding Watermark}" + WatermarkTemplate="{TemplateBinding WatermarkTemplate}" /> + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/Generic.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/Generic.xaml index 69204262..c6c9776d 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/Generic.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/Generic.xaml @@ -17,47 +17,59 @@ - - - - - - - + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/HighContrast.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/HighContrast.xaml index 69204262..c6c9776d 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/HighContrast.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/MaskedTextBox/Themes/HighContrast.xaml @@ -17,47 +17,59 @@ - - - - - - - + + + + + + + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Themes/Aero2.NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Themes/Aero2.NormalColor.xaml index 97b65651..e75add8d 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Themes/Aero2.NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/NumericUpDown/Themes/Aero2.NormalColor.xaml @@ -20,6 +20,7 @@ xmlns:local="clr-namespace:Xceed.Wpf.Toolkit" xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes" xmlns:prim="clr-namespace:Xceed.Wpf.Toolkit.Primitives" + xmlns:core="clr-namespace:Xceed.Wpf.Toolkit.Core" xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters"> @@ -54,6 +55,8 @@ Value="Right" /> + @@ -73,8 +76,8 @@ SpinnerUpContentTemplate="{Binding ButtonSpinnerUpContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource IncreaseGlyphNormalKey}}" SpinnerDownContentTemplate="{Binding ButtonSpinnerDownContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphNormalKey}}" SpinnerUpDisabledContentTemplate="{Binding ButtonSpinnerUpDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource IncreaseGlyphDisabledKey}}" - SpinnerDownDisabledContentTemplate="{Binding ButtonSpinnerDownDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphDisabledKey}}"> - + SpinnerDownDisabledContentTemplate="{Binding ButtonSpinnerDownDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphDisabledKey}}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius}"> @@ -54,6 +55,8 @@ Value="Right" /> + @@ -73,11 +76,12 @@ SpinnerUpContentTemplate="{Binding ButtonSpinnerUpContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource IncreaseGlyphNormalKey}}" SpinnerDownContentTemplate="{Binding ButtonSpinnerDownContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphNormalKey}}" SpinnerUpDisabledContentTemplate="{Binding ButtonSpinnerUpDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource IncreaseGlyphDisabledKey}}" - SpinnerDownDisabledContentTemplate="{Binding ButtonSpinnerDownDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphDisabledKey}}"> + SpinnerDownDisabledContentTemplate="{Binding ButtonSpinnerDownDisabledContentTemplate, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DecreaseGlyphDisabledKey}}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius}"> ", OnMaskPropertyChanged ) ); - public string Mask - { - get - { - return ( string )GetValue( MaskProperty ); - } - set - { - SetValue( MaskProperty, value ); - } - } - - private static void OnMaskPropertyChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) - { - MaskedTextBox maskedTextBox = o as MaskedTextBox; - if( maskedTextBox != null ) - maskedTextBox.OnMaskChanged( ( string )e.OldValue, ( string )e.NewValue ); - } - - protected virtual void OnMaskChanged( string oldValue, string newValue ) - { - UpdateMaskProvider( newValue ); - UpdateText( 0 ); - } - - #endregion //Mask - - #region PromptChar - - public static readonly DependencyProperty PromptCharProperty = DependencyProperty.Register( "PromptChar", typeof( char ), typeof( MaskedTextBox ), new UIPropertyMetadata( '_', OnPromptCharChanged ) ); - public char PromptChar - { - get - { - return ( char )GetValue( PromptCharProperty ); - } - set - { - SetValue( PromptCharProperty, value ); - } - } - - private static void OnPromptCharChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) - { - MaskedTextBox maskedTextBox = o as MaskedTextBox; - if( maskedTextBox != null ) - maskedTextBox.OnPromptCharChanged( ( char )e.OldValue, ( char )e.NewValue ); - } - - protected virtual void OnPromptCharChanged( char oldValue, char newValue ) - { - UpdateMaskProvider( Mask ); - } - - #endregion //PromptChar - - #region SelectAllOnGotFocus - - public static readonly DependencyProperty SelectAllOnGotFocusProperty = DependencyProperty.Register( "SelectAllOnGotFocus", typeof( bool ), typeof( MaskedTextBox ), new PropertyMetadata( false ) ); - public bool SelectAllOnGotFocus - { - get - { - return ( bool )GetValue( SelectAllOnGotFocusProperty ); - } - set - { - SetValue( SelectAllOnGotFocusProperty, value ); - } - } - - #endregion //SelectAllOnGotFocus - - #region Text - - private static void OnTextChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) - { - MaskedTextBox inputBase = o as MaskedTextBox; - if( inputBase != null ) - inputBase.OnTextChanged( ( string )e.OldValue, ( string )e.NewValue ); - } - - protected virtual void OnTextChanged( string oldValue, string newValue ) - { - if( _isInitialized ) - SyncTextAndValueProperties( MaskedTextBox.TextProperty, newValue ); - } - - #endregion //Text - - #region Value - - public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( "Value", typeof( object ), typeof( MaskedTextBox ), new FrameworkPropertyMetadata( null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged ) ); - public object Value - { - get - { - return ( object )GetValue( ValueProperty ); - } - set - { - SetValue( ValueProperty, value ); - } - } - - private static void OnValueChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) - { - MaskedTextBox maskedTextBox = o as MaskedTextBox; - if( maskedTextBox != null ) - maskedTextBox.OnValueChanged( ( object )e.OldValue, ( object )e.NewValue ); - } - - protected virtual void OnValueChanged( object oldValue, object newValue ) - { - if( _isInitialized ) - SyncTextAndValueProperties( MaskedTextBox.ValueProperty, newValue ); - - RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs( oldValue, newValue ); - args.RoutedEvent = MaskedTextBox.ValueChangedEvent; - RaiseEvent( args ); - } - - #endregion //Value - - #region ValueType - - public static readonly DependencyProperty ValueTypeProperty = DependencyProperty.Register( "ValueType", typeof( Type ), typeof( MaskedTextBox ), new UIPropertyMetadata( typeof( String ), OnValueTypeChanged ) ); - public Type ValueType - { - get - { - return ( Type )GetValue( ValueTypeProperty ); - } - set - { - SetValue( ValueTypeProperty, value ); - } - } - - private static void OnValueTypeChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) - { - MaskedTextBox maskedTextBox = o as MaskedTextBox; - if( maskedTextBox != null ) - maskedTextBox.OnValueTypeChanged( ( Type )e.OldValue, ( Type )e.NewValue ); - } - - protected virtual void OnValueTypeChanged( Type oldValue, Type newValue ) - { - if( _isInitialized ) - SyncTextAndValueProperties( MaskedTextBox.TextProperty, Text ); - } - - #endregion //ValueType - - #endregion //Properties - - #region Constructors - - static MaskedTextBox() - { - TextProperty.OverrideMetadata( typeof( MaskedTextBox ), new FrameworkPropertyMetadata( OnTextChanged ) ); - } - - public MaskedTextBox() - { - CommandBindings.Add( new CommandBinding( ApplicationCommands.Paste, Paste ) ); //handle paste - CommandBindings.Add( new CommandBinding( ApplicationCommands.Cut, null, CanCut ) ); //surpress cut - } - - #endregion //Constructors - - #region Base Class Overrides - - public override void OnApplyTemplate() - { - base.OnApplyTemplate(); - - UpdateMaskProvider( Mask ); - UpdateText( 0 ); - } - - protected override void OnInitialized( EventArgs e ) - { - base.OnInitialized( e ); - - if( !_isInitialized ) - { - _isInitialized = true; - SyncTextAndValueProperties( ValueProperty, Value ); - } - } - - protected override void OnGotKeyboardFocus( KeyboardFocusChangedEventArgs e ) - { - if( SelectAllOnGotFocus ) - { - SelectAll(); - } - - base.OnGotKeyboardFocus( e ); - } - - protected override void OnPreviewKeyDown( KeyEventArgs e ) - { - if( !e.Handled ) - { - HandlePreviewKeyDown( e ); - } - - base.OnPreviewKeyDown( e ); - } - - protected override void OnPreviewTextInput( TextCompositionEventArgs e ) - { - if( !e.Handled ) - { - HandlePreviewTextInput( e ); - } - - base.OnPreviewTextInput( e ); - } - - #endregion //Base Class Overrides - - #region Events - - public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent( "ValueChanged", RoutingStrategy.Bubble, typeof( RoutedPropertyChangedEventHandler ), typeof( MaskedTextBox ) ); - public event RoutedPropertyChangedEventHandler ValueChanged - { - add - { - AddHandler( ValueChangedEvent, value ); - } - remove - { - RemoveHandler( ValueChangedEvent, value ); - } - } - - #endregion //Events - - #region Methods - - #region Private - - private void UpdateText() - { - UpdateText( SelectionStart ); - } - - private void UpdateText( int position ) - { - MaskedTextProvider provider = MaskProvider; - if( provider == null ) - throw new InvalidOperationException(); - - Text = provider.ToDisplayString(); - SelectionLength = 0; - SelectionStart = position; - } - - private int GetNextCharacterPosition( int startPosition ) - { - int position = MaskProvider.FindEditPositionFrom( startPosition, true ); - return position == -1 ? startPosition : position; - } - - private void UpdateMaskProvider( string mask ) - { - //do not create a mask provider if the Mask is empty, which can occur if the IncludePrompt and IncludeLiterals properties - //are set prior to the Mask. - if( String.IsNullOrEmpty( mask ) ) - return; - - MaskProvider = new MaskedTextProvider( mask ) - { - IncludePrompt = this.IncludePrompt, - IncludeLiterals = this.IncludeLiterals, - PromptChar = this.PromptChar, - ResetOnSpace = false //should make this a property - }; - } - - private object ConvertTextToValue( string text ) - { - object convertedValue = null; - - Type dataType = ValueType; - - string valueToConvert = MaskProvider.ToString().Trim(); - - try - { - if( valueToConvert.GetType() == dataType || dataType.IsInstanceOfType( valueToConvert ) ) - { - convertedValue = valueToConvert; - } -#if !VS2008 - else if( String.IsNullOrWhiteSpace( valueToConvert ) ) - { - convertedValue = Activator.CreateInstance( dataType ); - } -#else - else if ( String.IsNullOrEmpty( valueToConvert ) ) - { - convertedValue = Activator.CreateInstance( dataType ); - } -#endif - else if( null == convertedValue && valueToConvert is IConvertible ) - { - convertedValue = Convert.ChangeType( valueToConvert, dataType ); - } - } - catch - { - //if an excpetion occurs revert back to original value - _convertExceptionOccurred = true; - return Value; - } - - return convertedValue; - } - - private string ConvertValueToText( object value ) - { - if( value == null ) - value = string.Empty; - - if( _convertExceptionOccurred ) - { - value = Value; - _convertExceptionOccurred = false; - } - - //I have only seen this occur while in Blend, but we need it here so the Blend designer doesn't crash. - if( MaskProvider == null ) - return value.ToString(); - - MaskProvider.Set( value.ToString() ); - return MaskProvider.ToDisplayString(); - } - - private void SyncTextAndValueProperties( DependencyProperty p, object newValue ) - { - //prevents recursive syncing properties - if( _isSyncingTextAndValueProperties ) - return; - - _isSyncingTextAndValueProperties = true; - - //this only occures when the user typed in the value - if( MaskedTextBox.TextProperty == p ) - { - if( newValue != null ) - SetValue( MaskedTextBox.ValueProperty, ConvertTextToValue( newValue.ToString() ) ); - } - - SetValue( MaskedTextBox.TextProperty, ConvertValueToText( newValue ) ); - - _isSyncingTextAndValueProperties = false; - } - - private void HandlePreviewTextInput( TextCompositionEventArgs e ) - { - if( !IsReadOnly ) - { - this.InsertText( e.Text ); - } - - e.Handled = true; - } - - private void HandlePreviewKeyDown( KeyEventArgs e ) - { - if( e.Key == Key.Delete ) - { - e.Handled = IsReadOnly - || HandleKeyDownDelete(); - } - else if( e.Key == Key.Back ) - { - e.Handled = IsReadOnly - || HandleKeyDownBack(); - } - else if( e.Key == Key.Space ) - { - if( !IsReadOnly ) - { - InsertText( " " ); - } - - e.Handled = true; - } - else if( e.Key == Key.Return || e.Key == Key.Enter ) - { - if( !IsReadOnly && AcceptsReturn ) - { - this.InsertText( "\r" ); - } - - // We don't want the OnPreviewTextInput to be triggered for the Return/Enter key - // when it is not accepted. - e.Handled = true; - } - else if( e.Key == Key.Escape ) - { - // We don't want the OnPreviewTextInput to be triggered at all for the Escape key. - e.Handled = true; - } - else if( e.Key == Key.Tab ) - { - if( AcceptsTab ) - { - if( !IsReadOnly ) - { - this.InsertText( "\t" ); - } - - e.Handled = true; - } - } - } - - private bool HandleKeyDownDelete() - { - ModifierKeys modifiers = Keyboard.Modifiers; - bool handled = true; - - if( modifiers == ModifierKeys.None ) - { - if( !RemoveSelectedText() ) - { - int position = SelectionStart; - - if( position < Text.Length ) - { - RemoveText( position, 1 ); - UpdateText( position ); - } - } - else - { - UpdateText(); - } - } - else if( modifiers == ModifierKeys.Control ) - { - if( !RemoveSelectedText() ) - { - int position = SelectionStart; - - RemoveTextToEnd( position ); - UpdateText( position ); - } - else - { - UpdateText(); - } - } - else if( modifiers == ModifierKeys.Shift ) - { - if( RemoveSelectedText() ) - { - UpdateText(); - } - else - { - handled = false; - } - } - else - { - handled = false; - } - - return handled; - } - - private bool HandleKeyDownBack() - { - ModifierKeys modifiers = Keyboard.Modifiers; - bool handled = true; - - if( modifiers == ModifierKeys.None || modifiers == ModifierKeys.Shift ) - { - if( !RemoveSelectedText() ) - { - int position = SelectionStart; - - if( position > 0 ) - { - int newPosition = position - 1; - - RemoveText( newPosition, 1 ); - UpdateText( newPosition ); - } - } - else - { - UpdateText(); - } - } - else if( modifiers == ModifierKeys.Control ) - { - if( !RemoveSelectedText() ) - { - RemoveTextFromStart( SelectionStart ); - UpdateText( 0 ); - } - else - { - UpdateText(); - } - } - else - { - handled = false; - } - - return handled; - } - - private void InsertText( string text ) - { - int position = SelectionStart; - MaskedTextProvider provider = MaskProvider; - - bool textRemoved = this.RemoveSelectedText(); - - position = GetNextCharacterPosition( position ); - - if( !textRemoved && Keyboard.IsKeyToggled( Key.Insert ) ) - { - if( provider.Replace( text, position ) ) - { - position += text.Length; - } - } - else - { - if( provider.InsertAt( text, position ) ) - { - position += text.Length; - } - } - - position = GetNextCharacterPosition( position ); - - this.UpdateText( position ); - } - - private void RemoveTextFromStart( int endPosition ) - { - RemoveText( 0, endPosition ); - } - - private void RemoveTextToEnd( int startPosition ) - { - RemoveText( startPosition, Text.Length - startPosition ); - } - - private void RemoveText( int position, int length ) - { - if( length == 0 ) - return; - - MaskProvider.RemoveAt( position, position + length - 1 ); - } - - private bool RemoveSelectedText() - { - int length = SelectionLength; - - if( length == 0 ) - return false; - - int position = SelectionStart; - - return MaskProvider.RemoveAt( position, position + length - 1 ); - } - - #endregion //Private - - #endregion //Methods - - #region Commands - - private void Paste( object sender, RoutedEventArgs e ) - { - if( IsReadOnly ) - return; - - object data = Clipboard.GetData( DataFormats.Text ); - if( data != null ) - { - string text = data.ToString().Trim(); - if( text.Length > 0 ) - { - int position = SelectionStart; - - MaskProvider.Set( text ); - - UpdateText( position ); - } - } - } - - private void CanCut( object sender, CanExecuteRoutedEventArgs e ) - { - e.CanExecute = false; - e.Handled = true; - } - - #endregion //Commands - } -} diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/InputBase.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/InputBase.cs index 76342a96..c65fe8d3 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/InputBase.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/InputBase.cs @@ -27,6 +27,35 @@ namespace Xceed.Wpf.Toolkit.Primitives { #region Properties + #region CornerRadius + + public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register( nameof(CornerRadius), typeof( CornerRadius ), typeof( InputBase ), new UIPropertyMetadata( new CornerRadius(), OnCornerRadiusPropertyChanged ) ); + public CornerRadius CornerRadius + { + get + { + return ( CornerRadius )GetValue( CornerRadiusProperty ); + } + set + { + SetValue( CornerRadiusProperty, value ); + } + } + + private static void OnCornerRadiusPropertyChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) + { + InputBase inputBase = o as InputBase; + if( inputBase != null ) + inputBase.OnCornerRadiusChanged( ( CornerRadius )e.OldValue, ( CornerRadius )e.NewValue ); + } + + protected virtual void OnCornerRadiusChanged( CornerRadius oldValue, CornerRadius newValue ) + { + } + + #endregion //CornerRadius + + #region AllowTextInput public static readonly DependencyProperty AllowTextInputProperty = DependencyProperty.Register( "AllowTextInput", typeof( bool ), typeof( InputBase ), new UIPropertyMetadata( true, OnAllowTextInputChanged ) ); diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/SelectAllSelector.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/SelectAllSelector.cs index 2c72e871..2853a756 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/SelectAllSelector.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/SelectAllSelector.cs @@ -15,10 +15,13 @@ ***********************************************************************************/ +using System.Collections; +using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Windows; +using System.Windows.Data; namespace Xceed.Wpf.Toolkit.Primitives { @@ -126,6 +129,21 @@ namespace Xceed.Wpf.Toolkit.Primitives #endregion //IsSelectAllActive + + + + + + + + + + + + + + + #region SelectAllContent public static readonly DependencyProperty SelectAllContentProperty = DependencyProperty.Register( "SelectAllContent", typeof( object ), typeof( SelectAllSelector ), new UIPropertyMetadata( "Select All" ) ); @@ -237,6 +255,22 @@ namespace Xceed.Wpf.Toolkit.Primitives } } + + + + + + + + + + #endregion + + #region Protected Methods + protected override void OnItemsSourceChanged( IEnumerable oldValue, IEnumerable newValue ) + { + base.OnItemsSourceChanged( oldValue, newValue ); + } #endregion } } diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Selector.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Selector.cs index f5df285a..2ba61384 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Selector.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Selector.cs @@ -911,6 +911,7 @@ namespace Xceed.Wpf.Toolkit.Primitives private void RemoveUnavailableSelectedItems() { + _ignoreSelectedItemsCollectionChanged++; HashSet hash = new HashSet( ItemsCollection.Cast() ); diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Themes/Aero2/WindowControl.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Themes/Aero2/WindowControl.xaml index 66b9ba60..b2dbd144 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Themes/Aero2/WindowControl.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Primitives/Themes/Aero2/WindowControl.xaml @@ -82,8 +82,8 @@ Grid.Column="1" VerticalAlignment="Center" Source="{TemplateBinding CaptionIcon}" - MaxWidth="15" - MaxHeight="15" + MaxWidth="17" + MaxHeight="17" Margin="5,2,0,2"> e ) { Color? selectedColor = ( Color? )e.NewValue; - ApplyPropertyValueToSelectedText( TextElement.ForegroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null ); - _waitingForMouseOver = true; + this.ApplyPropertyValueToSelectedText( TextElement.ForegroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null ); + m_waitingForMouseOver = true; } private void FontBackgroundColor_SelectedColorChanged( object sender, RoutedPropertyChangedEventArgs e ) { Color? selectedColor = ( Color? )e.NewValue; - ApplyPropertyValueToSelectedText( TextElement.BackgroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null ); - _waitingForMouseOver = true; + this.ApplyPropertyValueToSelectedText( TextElement.BackgroundProperty, selectedColor.HasValue ? new SolidColorBrush( selectedColor.Value ) : null ); + m_waitingForMouseOver = true; } private void Bullets_Clicked( object sender, RoutedEventArgs e ) { - if( BothSelectionListsAreChecked() && ( _btnNumbers != null ) ) + if( this.BothSelectionListsAreChecked() && ( m_btnNumbers != null ) ) { - _btnNumbers.IsChecked = false; + m_btnNumbers.IsChecked = false; } } private void Numbers_Clicked( object sender, RoutedEventArgs e ) { - if( BothSelectionListsAreChecked() && ( _btnBullets != null ) ) + if( this.BothSelectionListsAreChecked() && ( m_btnBullets != null ) ) { - _btnBullets.IsChecked = false; + m_btnBullets.IsChecked = false; } } private void DragWidget_DragDelta( object sender, DragDeltaEventArgs e ) { - ProcessMove( e ); + this.ProcessMove( e ); } protected override void OnMouseEnter( System.Windows.Input.MouseEventArgs e ) { base.OnMouseEnter( e ); - _waitingForMouseOver = false; + m_waitingForMouseOver = false; } - #endregion //Event Hanlders + #endregion //Event Handlers #region Methods @@ -157,93 +170,92 @@ namespace Xceed.Wpf.Toolkit { base.OnApplyTemplate(); - if( _dragWidget != null ) + if( m_dragWidget != null ) { - _dragWidget.DragDelta -= new DragDeltaEventHandler( DragWidget_DragDelta ); + m_dragWidget.DragDelta -= new DragDeltaEventHandler( this.DragWidget_DragDelta ); } - if( _cmbFontFamilies != null ) + if( m_cmbFontFamilies != null ) { - _cmbFontFamilies.SelectionChanged -= new SelectionChangedEventHandler( FontFamily_SelectionChanged ); + m_cmbFontFamilies.SelectionChanged -= new SelectionChangedEventHandler( this.FontFamily_SelectionChanged ); } - if( _cmbFontSizes != null ) + if( m_cmbFontSizes != null ) { - _cmbFontSizes.SelectionChanged -= new SelectionChangedEventHandler( FontSize_SelectionChanged ); + m_cmbFontSizes.SelectionChanged -= new SelectionChangedEventHandler( this.FontSize_SelectionChanged ); } - if( _btnBullets != null ) + if( m_btnBullets != null ) { - _btnBullets.Click -= new RoutedEventHandler( Bullets_Clicked ); + m_btnBullets.Click -= new RoutedEventHandler( this.Bullets_Clicked ); } - if( _btnNumbers != null ) + if( m_btnNumbers != null ) { - _btnNumbers.Click -= new RoutedEventHandler( Numbers_Clicked ); + m_btnNumbers.Click -= new RoutedEventHandler( this.Numbers_Clicked ); } - if( _cmbFontBackgroundColor != null ) + if( m_cmbFontBackgroundColor != null ) { - _cmbFontBackgroundColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler( FontBackgroundColor_SelectedColorChanged ); + m_cmbFontBackgroundColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler( this.FontBackgroundColor_SelectedColorChanged ); } - if( _cmbFontColor != null ) + if( m_cmbFontColor != null ) { - _cmbFontColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler( FontColor_SelectedColorChanged ); + m_cmbFontColor.SelectedColorChanged -= new RoutedPropertyChangedEventHandler( this.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 ) + this.GetTemplateComponent( ref m_cmbFontFamilies, "_cmbFontFamilies" ); + this.GetTemplateComponent( ref m_cmbFontSizes, "_cmbFontSizes" ); + this.GetTemplateComponent( ref m_cmbFontBackgroundColor, "_cmbFontBackgroundColor" ); + this.GetTemplateComponent( ref m_cmbFontColor, "_cmbFontColor" ); + this.GetTemplateComponent( ref m_btnNumbers, "_btnNumbers" ); + this.GetTemplateComponent( ref m_btnBullets, "_btnBullets" ); + this.GetTemplateComponent( ref m_btnBold, "_btnBold" ); + this.GetTemplateComponent( ref m_btnItalic, "_btnItalic" ); + this.GetTemplateComponent( ref m_btnUnderline, "_btnUnderline" ); + this.GetTemplateComponent( ref m_btnAlignLeft, "_btnAlignLeft" ); + this.GetTemplateComponent( ref m_btnAlignCenter, "_btnAlignCenter" ); + this.GetTemplateComponent( ref m_btnAlignRight, "_btnAlignRight" ); + this.GetTemplateComponent( ref m_dragWidget, "_dragWidget" ); + + if( m_dragWidget != null ) { - _dragWidget.DragDelta += new DragDeltaEventHandler( DragWidget_DragDelta ); + m_dragWidget.DragDelta += new DragDeltaEventHandler( DragWidget_DragDelta ); } - if( _cmbFontFamilies != null ) + if( m_cmbFontFamilies != null ) { - _cmbFontFamilies.ItemsSource = FontUtilities.Families.OrderBy( fontFamily => FontUtilities.GetFontFamilyName( fontFamily ) ).Select( fontFamily => FontUtilities.GetFontFamilyName( fontFamily ) ); - _cmbFontFamilies.SelectionChanged += new SelectionChangedEventHandler( FontFamily_SelectionChanged ); + m_cmbFontFamilies.ItemsSource = FontUtilities.Families.OrderBy( fontFamily => FontUtilities.GetFontFamilyName( fontFamily ) ).Select( fontFamily => FontUtilities.GetFontFamilyName( fontFamily ) ); + m_cmbFontFamilies.SelectionChanged += new SelectionChangedEventHandler( this.FontFamily_SelectionChanged ); } - if( _cmbFontSizes != null ) + if( m_cmbFontSizes != null ) { - _cmbFontSizes.ItemsSource = FontSizes; - _cmbFontSizes.SelectionChanged += new SelectionChangedEventHandler( FontSize_SelectionChanged ); + m_cmbFontSizes.ItemsSource = FontSizes; + m_cmbFontSizes.SelectionChanged += new SelectionChangedEventHandler( this.FontSize_SelectionChanged ); } - if( _btnBullets != null ) + if( m_btnBullets != null ) { - _btnBullets.Click += new RoutedEventHandler( Bullets_Clicked ); + m_btnBullets.Click += new RoutedEventHandler( this.Bullets_Clicked ); } - if( _btnNumbers != null ) + if( m_btnNumbers != null ) { - _btnNumbers.Click += new RoutedEventHandler( Numbers_Clicked ); + m_btnNumbers.Click += new RoutedEventHandler( this.Numbers_Clicked ); } - if( _cmbFontBackgroundColor != null ) + if( m_cmbFontBackgroundColor != null ) { - _cmbFontBackgroundColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler( FontBackgroundColor_SelectedColorChanged ); + m_cmbFontBackgroundColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler( this.FontBackgroundColor_SelectedColorChanged ); } - if( _cmbFontColor != null ) + if( m_cmbFontColor != null ) { - _cmbFontColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler( FontColor_SelectedColorChanged ); + m_cmbFontColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler( FontColor_SelectedColorChanged ); } - // Update the ComboBoxes when changing themes. this.Update(); } @@ -256,21 +268,21 @@ namespace Xceed.Wpf.Toolkit private void UpdateToggleButtonState() { - UpdateItemCheckedState( _btnBold, TextElement.FontWeightProperty, FontWeights.Bold ); - UpdateItemCheckedState( _btnItalic, TextElement.FontStyleProperty, FontStyles.Italic ); - UpdateItemCheckedState( _btnUnderline, Inline.TextDecorationsProperty, TextDecorations.Underline ); + this.UpdateItemCheckedState( m_btnBold, TextElement.FontWeightProperty, FontWeights.Bold ); + this.UpdateItemCheckedState( m_btnItalic, TextElement.FontStyleProperty, FontStyles.Italic ); + this.UpdateItemCheckedState( m_btnUnderline, Inline.TextDecorationsProperty, TextDecorations.Underline ); - UpdateItemCheckedState( _btnAlignLeft, Paragraph.TextAlignmentProperty, TextAlignment.Left ); - UpdateItemCheckedState( _btnAlignCenter, Paragraph.TextAlignmentProperty, TextAlignment.Center ); - UpdateItemCheckedState( _btnAlignRight, Paragraph.TextAlignmentProperty, TextAlignment.Right ); + this.UpdateItemCheckedState( m_btnAlignLeft, Paragraph.TextAlignmentProperty, TextAlignment.Left ); + this.UpdateItemCheckedState( m_btnAlignCenter, Paragraph.TextAlignmentProperty, TextAlignment.Center ); + this.UpdateItemCheckedState( m_btnAlignRight, Paragraph.TextAlignmentProperty, TextAlignment.Right ); } void UpdateItemCheckedState( ToggleButton button, DependencyProperty formattingProperty, object expectedValue ) { object currentValue = DependencyProperty.UnsetValue; - if( ( Target != null ) && ( Target.Selection != null ) ) + if( ( this.Target != null ) && ( this.Target.Selection != null ) ) { - currentValue = Target.Selection.GetPropertyValue( formattingProperty ); + currentValue = this.Target.Selection.GetPropertyValue( formattingProperty ); } if( currentValue == DependencyProperty.UnsetValue ) @@ -287,44 +299,44 @@ namespace Xceed.Wpf.Toolkit private void UpdateSelectedFontFamily() { object value = DependencyProperty.UnsetValue; - if( ( Target != null ) && ( Target.Selection != null ) ) + if( ( this.Target != null ) && ( this.Target.Selection != null ) ) { - value = Target.Selection.GetPropertyValue( TextElement.FontFamilyProperty ); + value = this.Target.Selection.GetPropertyValue( TextElement.FontFamilyProperty ); } if( value == DependencyProperty.UnsetValue ) return; FontFamily currentFontFamily = ( FontFamily )value; - if( ( currentFontFamily != null ) && ( _cmbFontFamilies != null ) ) + if( ( currentFontFamily != null ) && ( m_cmbFontFamilies != null ) ) { - _cmbFontFamilies.SelectedItem = FontUtilities.GetFontFamilyName( currentFontFamily ); + m_cmbFontFamilies.SelectedItem = FontUtilities.GetFontFamilyName( currentFontFamily ); } } private void UpdateSelectedFontSize() { object value = DependencyProperty.UnsetValue; - if( ( Target != null ) && ( Target.Selection != null ) ) + if( ( this.Target != null ) && ( this.Target.Selection != null ) ) { - value = Target.Selection.GetPropertyValue( TextElement.FontSizeProperty ); + value = this.Target.Selection.GetPropertyValue( TextElement.FontSizeProperty ); } if( value == DependencyProperty.UnsetValue ) return; - if( _cmbFontSizes != null ) + if( m_cmbFontSizes != null ) { - _cmbFontSizes.SelectedValue = value; + m_cmbFontSizes.SelectedValue = value; } } private void UpdateFontColor() { object value = DependencyProperty.UnsetValue; - if( ( Target != null ) && ( Target.Selection != null ) ) + if( ( this.Target != null ) && ( this.Target.Selection != null ) ) { - value = Target.Selection.GetPropertyValue( TextElement.ForegroundProperty ); + value = this.Target.Selection.GetPropertyValue( TextElement.ForegroundProperty ); } if( value == DependencyProperty.UnsetValue ) @@ -333,18 +345,18 @@ namespace Xceed.Wpf.Toolkit Color? currentColor = ( ( value == null ) ? null : ( Color? )( ( SolidColorBrush )value ).Color ); - if( _cmbFontColor != null ) + if( m_cmbFontColor != null ) { - _cmbFontColor.SelectedColor = currentColor; + m_cmbFontColor.SelectedColor = currentColor; } } private void UpdateFontBackgroundColor() { object value = DependencyProperty.UnsetValue; - if( ( Target != null ) && ( Target.Selection != null ) ) + if( ( this.Target != null ) && ( this.Target.Selection != null ) ) { - value = Target.Selection.GetPropertyValue( TextElement.BackgroundProperty ); + value = this.Target.Selection.GetPropertyValue( TextElement.BackgroundProperty ); } if( value == DependencyProperty.UnsetValue ) @@ -353,67 +365,67 @@ namespace Xceed.Wpf.Toolkit Color? currentColor = ( ( value == null ) ? null : ( Color? )( ( SolidColorBrush )value ).Color ); - if( _cmbFontBackgroundColor != null ) + if( m_cmbFontBackgroundColor != null ) { - _cmbFontBackgroundColor.SelectedColor = currentColor; + m_cmbFontBackgroundColor.SelectedColor = currentColor; } } private void UpdateSelectionListType() { - if( ( _btnNumbers == null ) || ( _btnBullets == null ) ) + if( ( m_btnNumbers == null ) || ( m_btnBullets == null ) ) return; //uncheck both - _btnBullets.IsChecked = false; - _btnNumbers.IsChecked = false; + m_btnBullets.IsChecked = false; + m_btnNumbers.IsChecked = false; - Paragraph startParagraph = ( ( Target != null ) && ( Target.Selection != null ) ) - ? Target.Selection.Start.Paragraph + Paragraph startParagraph = ( ( this.Target != null ) && ( this.Target.Selection != null ) ) + ? this.Target.Selection.Start.Paragraph : null; - Paragraph endParagraph = ( ( Target != null ) && ( Target.Selection != null ) ) - ? Target.Selection.End.Paragraph + Paragraph endParagraph = ( ( this.Target != null ) && ( this.Target.Selection != null ) ) + ? this.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 + if( markerStyle == TextMarkerStyle.Disc ) { - _btnBullets.IsChecked = true; + m_btnBullets.IsChecked = true; } - else if( markerStyle == TextMarkerStyle.Decimal ) //numbers + else if( markerStyle == TextMarkerStyle.Decimal ) { - _btnNumbers.IsChecked = true; + m_btnNumbers.IsChecked = true; } } } private bool BothSelectionListsAreChecked() { - return ( ( _btnBullets != null ) && ( _btnBullets.IsChecked == true ) ) - && ( ( _btnNumbers != null ) && ( _btnNumbers.IsChecked == true ) ); + return ( ( m_btnBullets != null ) && ( m_btnBullets.IsChecked == true ) ) + && ( ( m_btnNumbers != null ) && ( m_btnNumbers.IsChecked == true ) ); } void ApplyPropertyValueToSelectedText( DependencyProperty formattingProperty, object value ) { - if( ( Target == null ) || ( Target.Selection == null ) ) + if( ( this.Target == null ) || ( this.Target.Selection == null ) ) return; SolidColorBrush solidColorBrush = value as SolidColorBrush; if( ( solidColorBrush != null ) && solidColorBrush.Color.Equals( Colors.Transparent ) ) { - Target.Selection.ApplyPropertyValue( formattingProperty, null ); + this.Target.Selection.ApplyPropertyValue( formattingProperty, null ); } else { - Target.Selection.ApplyPropertyValue( formattingProperty, value ); + this.Target.Selection.ApplyPropertyValue( formattingProperty, value ); } } private void ProcessMove( DragDeltaEventArgs e ) { - AdornerLayer layer = AdornerLayer.GetAdornerLayer( Target ); - UIElementAdorner adorner = layer.GetAdorners( Target ).OfType>().First(); + AdornerLayer layer = AdornerLayer.GetAdornerLayer( this.Target ); + UIElementAdorner adorner = layer.GetAdorners( this.Target ).OfType>().First(); adorner.SetOffsets( adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange ); } @@ -423,17 +435,11 @@ namespace Xceed.Wpf.Toolkit #region Target - public static readonly DependencyProperty TargetProperty = DependencyProperty.Register( "Target", typeof( global::System.Windows.Controls.RichTextBox ), typeof( RichTextBoxFormatBar ), new PropertyMetadata( null, OnRichTextBoxPropertyChanged ) ); + public static readonly DependencyProperty TargetProperty = DependencyProperty.Register( nameof( 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 ); - } + get { return ( global::System.Windows.Controls.RichTextBox )GetValue( TargetProperty ); } + set { SetValue( TargetProperty, value ); } } private static void OnRichTextBoxPropertyChanged( DependencyObject d, DependencyPropertyChangedEventArgs e ) @@ -447,22 +453,22 @@ namespace Xceed.Wpf.Toolkit { get { - return ( ( ( _cmbFontFamilies != null ) && _cmbFontFamilies.IsDropDownOpen ) - || ( ( _cmbFontSizes != null ) && _cmbFontSizes.IsDropDownOpen ) - || ( ( _cmbFontBackgroundColor != null ) && _cmbFontBackgroundColor.IsOpen ) - || ( ( _cmbFontColor != null ) && _cmbFontColor.IsOpen ) - || _waitingForMouseOver ); + return ( ( ( m_cmbFontFamilies != null ) && m_cmbFontFamilies.IsDropDownOpen ) + || ( ( m_cmbFontSizes != null ) && m_cmbFontSizes.IsDropDownOpen ) + || ( ( m_cmbFontBackgroundColor != null ) && m_cmbFontBackgroundColor.IsOpen ) + || ( ( m_cmbFontColor != null ) && m_cmbFontColor.IsOpen ) + || m_waitingForMouseOver ); } } public void Update() { - UpdateToggleButtonState(); - UpdateSelectedFontFamily(); - UpdateSelectedFontSize(); - UpdateFontColor(); - UpdateFontBackgroundColor(); - UpdateSelectionListType(); + this.UpdateToggleButtonState(); + this.UpdateSelectedFontFamily(); + this.UpdateSelectedFontSize(); + this.UpdateFontColor(); + this.UpdateFontBackgroundColor(); + this.UpdateSelectionListType(); } #endregion diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs index 7f7c9822..a66ef285 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs @@ -29,12 +29,11 @@ namespace Xceed.Wpf.Toolkit { #region Members - private global::System.Windows.Controls.RichTextBox _richTextBox; - private UIElementAdorner _adorner; - private IRichTextBoxFormatBar _toolbar; - private Window _parentWindow; - - private const double _hideAdornerDistance = 150d; + private global::System.Windows.Controls.RichTextBox m_richTextBox; + private UIElementAdorner m_adorner; + private IRichTextBoxFormatBar m_toolbar; + private Window m_parentWindow; + private const double m_hideAdornerDistance = 150d; #endregion //Members @@ -68,11 +67,12 @@ namespace Xceed.Wpf.Toolkit { get { - return _adorner.Visibility == Visibility.Visible; + return m_adorner.Visibility == Visibility.Visible; } } - #endregion //Properties + +#endregion //Properties #region Event Handlers @@ -80,59 +80,66 @@ namespace Xceed.Wpf.Toolkit { if( e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released ) { - if( !_richTextBox.IsReadOnly ) + if( !m_richTextBox.IsReadOnly ) { - TextRange selectedText = new TextRange( _richTextBox.Selection.Start, _richTextBox.Selection.End ); + TextRange selectedText = new TextRange( m_richTextBox.Selection.Start, m_richTextBox.Selection.End ); #if !VS2008 if( selectedText.Text.Length > 0 && !String.IsNullOrWhiteSpace( selectedText.Text ) ) - ShowAdorner(); + { + this.ShowAdorner(); + } #else - if( selectedText.Text.Length > 0 && !String.IsNullOrEmpty( selectedText.Text ) ) - ShowAdorner(); + if (selectedText.Text.Length > 0 && !String.IsNullOrEmpty(selectedText.Text)) + { + this.ShowAdorner(); + } #endif else - HideAdorner(); - + { + { + this.HideAdorner(); + } + } e.Handled = true; } } - else - HideAdorner(); } private void OnPreviewMouseMoveParentWindow( object sender, MouseEventArgs e ) { - Point p = e.GetPosition( _adorner ); + + Point p = e.GetPosition( m_adorner ); double maxDist = 0d; - bool preventDisplayFadeOut = ( ( _adorner.Child != null ) && ( _adorner.Child is IRichTextBoxFormatBar ) ) ? - ( ( IRichTextBoxFormatBar )_adorner.Child ).PreventDisplayFadeOut : - false; + bool preventDisplayFadeOut = ( ( m_adorner.Child != null ) && ( m_adorner.Child is IRichTextBoxFormatBar ) ) + ? ( ( IRichTextBoxFormatBar )m_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 ) ) + ( p.X >= 0 ) && ( p.X <= m_adorner.ActualWidth ) && ( p.Y >= 0 ) && ( p.Y <= m_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 ) ) + else if( ( p.X < -m_hideAdornerDistance ) || ( p.X > m_adorner.ActualWidth + m_hideAdornerDistance ) || ( p.Y < -m_hideAdornerDistance ) || ( p.Y > m_adorner.ActualHeight + m_hideAdornerDistance ) ) { - HideAdorner(); + this.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; + else if( p.X > m_adorner.ActualWidth ) + maxDist = p.X - m_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 ); + else if( p.Y > m_adorner.ActualHeight ) + maxDist = Math.Max( maxDist, p.Y - m_adorner.ActualHeight ); - _adorner.Opacity = 1d - ( Math.Min( maxDist, 100d ) / 100d ); + m_adorner.Opacity = 1d - ( Math.Min( maxDist, 100d ) / 100d ); } } @@ -140,60 +147,102 @@ namespace Xceed.Wpf.Toolkit { //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(); + if( !m_richTextBox.IsFocused && !m_richTextBox.Selection.IsEmpty ) + m_richTextBox.Focus(); + } + + void RichTextBox_Loaded( object sender, RoutedEventArgs e ) + { + } + + void RichTextBox_GotFocus( object sender, RoutedEventArgs e ) + { } - #endregion //Event Handlers + +#endregion //Event Handlers #region Methods + private bool IsCursorInsideWord() + { + if( m_richTextBox?.Selection?.Start == null ) + return false; + + TextPointer caretPosition = m_richTextBox.Selection.Start; + + string charBefore = caretPosition.GetTextInRun( LogicalDirection.Backward ); + string charAfter = caretPosition.GetTextInRun( LogicalDirection.Forward ); + + bool hasWordCharBefore = !string.IsNullOrEmpty( charBefore ) && + charBefore.Length > 0 && + char.IsLetterOrDigit( charBefore[ charBefore.Length - 1 ] ); + + bool hasWordCharAfter = !string.IsNullOrEmpty( charAfter ) && + charAfter.Length > 0 && + char.IsLetterOrDigit( charAfter[ 0 ] ); + + return hasWordCharBefore || hasWordCharAfter; + } + + private void AttachFormatBarToRichtextBox( global::System.Windows.Controls.RichTextBox richTextBox, IRichTextBoxFormatBar formatBar ) { - _richTextBox = richTextBox; + m_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; + m_richTextBox.AddHandler( Mouse.MouseUpEvent, new MouseButtonEventHandler( this.RichTextBox_MouseButtonUp ), true ); + m_richTextBox.TextChanged += this.RichTextBox_TextChanged; + m_richTextBox.Loaded += this.RichTextBox_Loaded; + m_richTextBox.GotFocus += this.RichTextBox_GotFocus; + m_adorner = new UIElementAdorner( m_richTextBox ); - _adorner = new UIElementAdorner( _richTextBox ); + formatBar.Target = m_richTextBox; + m_toolbar = formatBar; - formatBar.Target = _richTextBox; - _toolbar = formatBar; + { + this.HideAdorner(); + } } - void ShowAdorner() + + private void ShowAdorner() { - if( _adorner.Visibility == Visibility.Visible ) + if( m_adorner.Visibility == Visibility.Visible ) { - HideAdorner(); + this.HideAdorner(); } - VerifyAdornerLayer(); + this.VerifyAdornerLayer(); - Control adorningEditor = _toolbar as Control; + Control adorningEditor = m_toolbar as Control; - if( _adorner.Child == null ) - _adorner.Child = adorningEditor; + if( m_adorner.Child == null ) + { + m_adorner.Child = adorningEditor; + } adorningEditor.ApplyTemplate(); - _toolbar.Update(); + m_toolbar.Update(); - _adorner.Visibility = Visibility.Visible; + m_adorner.Visibility = Visibility.Visible; - PositionFormatBar( adorningEditor ); + { + this.MousePositionFormatBar( adorningEditor ); + } - _parentWindow = TreeHelper.FindParent( _adorner ); - if( _parentWindow != null ) + m_parentWindow = TreeHelper.FindParent( m_adorner ); + if( m_parentWindow != null + ) { - Mouse.AddMouseMoveHandler( _parentWindow, OnPreviewMouseMoveParentWindow ); + Mouse.AddMouseMoveHandler( m_parentWindow, this.OnPreviewMouseMoveParentWindow ); } } - private void PositionFormatBar( Control adorningEditor ) + private void MousePositionFormatBar( Control adorningEditor ) { - Point mousePosition = Mouse.GetPosition( _richTextBox ); + Point mousePosition = Mouse.GetPosition( m_richTextBox ); var left = mousePosition.X; var top = mousePosition.Y; @@ -211,42 +260,64 @@ namespace Xceed.Wpf.Toolkit } // Right boundary - if( left + adorningEditor.ActualWidth > _richTextBox.ActualWidth - 10d ) + if( left + adorningEditor.ActualWidth > m_richTextBox.ActualWidth - 10d ) { - left = _richTextBox.ActualWidth - adorningEditor.ActualWidth - 10d; + left = m_richTextBox.ActualWidth - adorningEditor.ActualWidth - 10d; } // Bottom boundary - if( top + adorningEditor.ActualHeight > _richTextBox.ActualHeight - 10d ) + if( top + adorningEditor.ActualHeight > m_richTextBox.ActualHeight - 10d ) { - top = _richTextBox.ActualHeight - adorningEditor.ActualHeight - 10d; + top = m_richTextBox.ActualHeight - adorningEditor.ActualHeight - 10d; } - _adorner.SetOffsets( left, top ); + m_adorner.SetOffsets( left, top ); } - bool VerifyAdornerLayer() + + + + + + + + + + + + + + + + + + + private bool VerifyAdornerLayer() { - if( _adorner.Parent != null ) + if( m_adorner.Parent != null ) + { return true; + } - AdornerLayer layer = AdornerLayer.GetAdornerLayer( _richTextBox ); + AdornerLayer layer = AdornerLayer.GetAdornerLayer( m_richTextBox ); if( layer == null ) + { return false; + } - layer.Add( _adorner ); + layer.Add( m_adorner ); return true; } - void HideAdorner() + private void HideAdorner() { - if( IsAdornerVisible ) + + if( this.IsAdornerVisible ) { - _adorner.Visibility = Visibility.Collapsed; - //_adorner.Child = null; - if( _parentWindow != null ) + m_adorner.Visibility = Visibility.Collapsed; + if( m_parentWindow != null ) { - Mouse.RemoveMouseMoveHandler( _parentWindow, OnPreviewMouseMoveParentWindow ); + Mouse.RemoveMouseMoveHandler( m_parentWindow, this.OnPreviewMouseMoveParentWindow ); } } } diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero/Buttons_NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero/Buttons_NormalColor.xaml index de7ba1b2..02e41f9f 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero/Buttons_NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero/Buttons_NormalColor.xaml @@ -18,35 +18,40 @@ - + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero2/Buttons.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero2/Buttons.xaml index 6f21955a..7a72c117 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero2/Buttons.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Aero2/Buttons.xaml @@ -18,35 +18,40 @@ - + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Generic/Buttons.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Generic/Buttons.xaml index 02c03987..8e846630 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Generic/Buttons.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/Themes/Generic/Buttons.xaml @@ -18,33 +18,36 @@ - + diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/TimePicker/Themes/Aero2.NormalColor.xaml b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/TimePicker/Themes/Aero2.NormalColor.xaml index 640c9f63..31186c35 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/TimePicker/Themes/Aero2.NormalColor.xaml +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.Toolkit/TimePicker/Themes/Aero2.NormalColor.xaml @@ -20,6 +20,7 @@ xmlns:local="clr-namespace:Xceed.Wpf.Toolkit" xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes" xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes" + xmlns:core="clr-namespace:Xceed.Wpf.Toolkit.Core" xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters" xmlns:sys="clr-namespace:System;assembly=mscorlib"> @@ -46,7 +47,7 @@ + + ShowSpinner="{TemplateBinding ShowButtonSpinner}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius, Converter={conv:CornerRadiusReplacementConverter Auto, 0, 0, Auto}}"> + + + @@ -74,7 +75,7 @@ + + ShowSpinner="{TemplateBinding ShowButtonSpinner}" + CornerRadius="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=CornerRadius, Converter={conv:CornerRadiusReplacementConverter Auto, 0, 0, Auto}}"> + + + - - - + + + - - - + + + - + - + BorderThickness="0" + Background="Transparent" + CaretBrush="{Binding CaretBrush, RelativeSource={RelativeSource TemplatedParent}}" + ContextMenu="{TemplateBinding ContextMenu}" + FontFamily="{TemplateBinding FontFamily}" + FontSize="{TemplateBinding FontSize}" + FontStretch="{TemplateBinding FontStretch}" + FontStyle="{TemplateBinding FontStyle}" + FontWeight="{TemplateBinding FontWeight}" + Foreground="{TemplateBinding Foreground}" + HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" + VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" + IsUndoEnabled="{Binding IsUndoEnabled, RelativeSource={RelativeSource TemplatedParent}}" + IsTabStop="True" + MinWidth="20" + AcceptsReturn="False" + Padding="{TemplateBinding Padding}" + TextAlignment="{TemplateBinding TextAlignment}" + TextWrapping="NoWrap" + TabIndex="{TemplateBinding TabIndex}" + Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" + Watermark="{TemplateBinding Watermark}" + WatermarkTemplate="{TemplateBinding WatermarkTemplate}" /> + + + + + + + + + + + + + + + + + + + + + + + -