@ -0,0 +1,142 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- BusyIndicator --> |
|||
<!-- =============================================================================== --> |
|||
<Style TargetType="{x:Type local:BusyIndicator}"> |
|||
<Setter Property="BusyContent" Value="Please wait..."/> |
|||
<Setter Property="IsTabStop" Value="False"/> |
|||
<Setter Property="OverlayStyle"> |
|||
<Setter.Value> |
|||
<Style TargetType="Rectangle"> |
|||
<Setter Property="Fill" Value="White"/> |
|||
<Setter Property="Opacity" Value="0.5"/> |
|||
</Style> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="ProgressBarStyle"> |
|||
<Setter.Value> |
|||
<Style TargetType="ProgressBar"> |
|||
<Setter Property="IsIndeterminate" Value="True"/> |
|||
<Setter Property="Height" Value="15"/> |
|||
<Setter Property="Margin" Value="8,0,8,8"/> |
|||
</Style> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="DisplayAfter" Value="00:00:00.1"/> |
|||
<Setter Property="HorizontalAlignment" Value="Stretch"/> |
|||
<Setter Property="VerticalAlignment" Value="Stretch"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Stretch"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:BusyIndicator}"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="VisibilityStates"> |
|||
<VisualState x:Name="Hidden"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="busycontent" Storyboard.TargetProperty="(UIElement.Visibility)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Collapsed</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="overlay" Storyboard.TargetProperty="(UIElement.Visibility)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Collapsed</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Visible"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="busycontent" Storyboard.TargetProperty="(UIElement.Visibility)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="overlay" Storyboard.TargetProperty="(UIElement.Visibility)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
<VisualStateGroup x:Name="BusyStatusStates"> |
|||
<VisualState x:Name="Idle"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="content" Storyboard.TargetProperty="(Control.IsEnabled)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<sys:Boolean>True</sys:Boolean> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Busy"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.001" Storyboard.TargetName="content" Storyboard.TargetProperty="(Control.IsEnabled)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<sys:Boolean>False</sys:Boolean> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<ContentControl x:Name="content" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> |
|||
<Rectangle x:Name="overlay" Style="{TemplateBinding OverlayStyle}"/> |
|||
<ContentPresenter x:Name="busycontent"> |
|||
<ContentPresenter.Content> |
|||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center"> |
|||
<Border Background="White" BorderThickness="1" CornerRadius="2"> |
|||
<Border.BorderBrush> |
|||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
</Border.BorderBrush> |
|||
<Border CornerRadius="1.5" Margin="1"> |
|||
<Border.Background> |
|||
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> |
|||
<GradientStop Color="#FFF6F8F9" Offset="0.02"/> |
|||
<GradientStop Color="#FFB8B8B8" Offset="0.996"/> |
|||
</LinearGradientBrush> |
|||
</Border.Background> |
|||
<Grid MinWidth="150"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="Auto"/> |
|||
</Grid.RowDefinitions> |
|||
<ContentPresenter Content="{TemplateBinding BusyContent}" ContentTemplate="{TemplateBinding BusyContentTemplate}" Margin="8"/> |
|||
<ProgressBar Grid.Row="1" Style="{TemplateBinding ProgressBarStyle}"/> |
|||
</Grid> |
|||
</Border> |
|||
</Border> |
|||
</Grid> |
|||
</ContentPresenter.Content> |
|||
</ContentPresenter> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public delegate void CheckListBoxCheckedChangedEventHandler(object sender, CheckListBoxCheckedChangedEventArgs e); |
|||
public class CheckListBoxCheckedChangedEventArgs : RoutedEventArgs |
|||
{ |
|||
public object Item { get; private set; } |
|||
|
|||
public CheckListBoxCheckedChangedEventArgs(RoutedEvent routedEvent, object source, object item) |
|||
: base(routedEvent, source) |
|||
{ |
|||
Item = item; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Navigation; |
|||
using System.Windows.Shapes; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public class CheckListBoxItem : ContentControl |
|||
{ |
|||
static CheckListBoxItem() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckListBoxItem), new FrameworkPropertyMetadata(typeof(CheckListBoxItem))); |
|||
} |
|||
|
|||
public CheckListBoxItem() |
|||
{ |
|||
AddHandler(Mouse.MouseDownEvent, new MouseButtonEventHandler(CheckListBoxItem_MouseDown)); |
|||
} |
|||
|
|||
#region Properties
|
|||
|
|||
public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register("IsChecked", typeof(bool), typeof(CheckListBoxItem), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsSelectedChanged)); |
|||
public bool IsChecked |
|||
{ |
|||
get { return (bool)GetValue(IsCheckedProperty); } |
|||
set { SetValue(IsCheckedProperty, value); } |
|||
} |
|||
|
|||
private static void OnIsSelectedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
CheckListBoxItem checkListBoxItem = o as CheckListBoxItem; |
|||
if (checkListBoxItem != null) |
|||
checkListBoxItem.OnIsSelectedChanged((bool)e.OldValue, (bool)e.NewValue); |
|||
} |
|||
|
|||
protected virtual void OnIsSelectedChanged(bool oldValue, bool newValue) |
|||
{ |
|||
if (newValue) |
|||
RaiseSelectionChangedEvent(new RoutedEventArgs(CheckListBox.CheckedEvent, this)); |
|||
else |
|||
RaiseSelectionChangedEvent(new RoutedEventArgs(CheckListBox.UncheckedEvent, this)); |
|||
} |
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Events
|
|||
|
|||
public static readonly RoutedEvent SelectedEvent = CheckListBox.CheckedEvent.AddOwner(typeof(CheckListBoxItem)); |
|||
public static readonly RoutedEvent UnselectedEvent = CheckListBox.UncheckedEvent.AddOwner(typeof(CheckListBoxItem)); |
|||
|
|||
#endregion
|
|||
|
|||
#region Event Hanlders
|
|||
|
|||
void CheckListBoxItem_MouseDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
IsChecked = !IsChecked; |
|||
} |
|||
|
|||
#endregion //Event Hanlders
|
|||
|
|||
#region Methods
|
|||
|
|||
private void RaiseSelectionChangedEvent(RoutedEventArgs e) |
|||
{ |
|||
base.RaiseEvent(e); |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,196 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- ChildWindow --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<SolidColorBrush x:Key="ChildWindowMainBrushColor" Color="#FF3C688D"/> |
|||
<LinearGradientBrush x:Key="BorderBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#7FFFFFFF" Offset="0.05"/> |
|||
<GradientStop Color="#B2FFFFFF" Offset="0.07"/> |
|||
<GradientStop Color="#00FFFFFF" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowDarkBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowBackgroundBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFffffff"/> |
|||
<GradientStop Offset="0.479" Color="#FFf4f5f6"/> |
|||
<GradientStop Offset="1" Color="#FFd0d6db"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowButtonHoverBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFb5bdc8"/> |
|||
<GradientStop Offset="0.370" Color="#FF8399a9"/> |
|||
<GradientStop Offset="0.370" Color="#FF718597"/> |
|||
<GradientStop Offset="0.906" Color="#FFb9c1ca"/> |
|||
<GradientStop Offset="1" Color="#FFb9c1ca"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="ChildWindowButtonPressedBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FF6b7c8d"/> |
|||
<GradientStop Offset="0.370" Color="#FF4d606f"/> |
|||
<GradientStop Offset="0.370" Color="#FF465460"/> |
|||
<GradientStop Offset="0.906" Color="#FF262d33"/> |
|||
<GradientStop Offset="1" Color="#FF262d33"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<Style x:Key="ChildWindowCloseButtonStyle" TargetType="Button"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="3"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ChildWindowButtonHoverBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Pressed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource ChildWindowButtonPressedBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<Border x:Name="Background" CornerRadius="0,0,2,0" Background="{StaticResource ChildWindowDarkBrush}"> |
|||
<Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/> |
|||
</Border> |
|||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
|||
<Path x:Name="path" |
|||
Height="6" |
|||
Width="7" |
|||
Stretch="Fill" |
|||
Opacity="1" |
|||
Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z" |
|||
Fill="White" Margin="0,0,0,1" Visibility="Collapsed" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style TargetType="{x:Type local:ChildWindow}"> |
|||
<Setter Property="Background" Value="#FFFFFFFF"/> |
|||
<Setter Property="BorderBrush" Value="{StaticResource ChildWindowDarkBrush}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="CaptionForeground" Value="#FF000000" /> |
|||
<Setter Property="CloseButtonStyle" Value="{StaticResource ChildWindowCloseButtonStyle}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
<Setter Property="IsEnabled" Value="true" /> |
|||
<Setter Property="OverlayBrush" Value="#7F000000" /> |
|||
<Setter Property="OverlayOpacity" Value="1" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Top" /> |
|||
<Setter Property="WindowBorderBrush" Value="{StaticResource ChildWindowDarkBrush}" /> |
|||
<Setter Property="WindowBackground" Value="{StaticResource ChildWindowBackgroundBrush}" /> |
|||
<Setter Property="WindowOpacity" Value="1.0" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:ChildWindow}"> |
|||
<Grid x:Name="Root"> |
|||
<Grid.Resources> |
|||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> |
|||
</Grid.Resources> |
|||
<Grid x:Name="PART_Overlay" HorizontalAlignment="Stretch" VerticalAlignment="Top" Margin="0" RenderTransformOrigin="0.5,0.5" |
|||
Background="{TemplateBinding OverlayBrush}" |
|||
Opacity="{TemplateBinding OverlayOpacity}" |
|||
Visibility="{TemplateBinding IsModal, Converter={StaticResource BooleanToVisibilityConverter}}"/> |
|||
<Grid x:Name="PART_WindowRoot" HorizontalAlignment="Left" VerticalAlignment="Top"> |
|||
<Grid.RenderTransform> |
|||
<TransformGroup> |
|||
<ScaleTransform /> |
|||
<SkewTransform /> |
|||
<RotateTransform /> |
|||
<TranslateTransform /> |
|||
</TransformGroup> |
|||
</Grid.RenderTransform> |
|||
|
|||
<!-- Borders --> |
|||
<Grid x:Name="WindowGrid"> |
|||
<Border BorderBrush="{TemplateBinding WindowBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5,5,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Grid Margin="0" Background="{x:Null}"> |
|||
<Border x:Name="WindowBorder" Margin="1,1,1,1" Background="{TemplateBinding WindowBackground}" CornerRadius="4,4,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Border BorderBrush="White" BorderThickness="1" CornerRadius="4,4,0,0" Margin="1" Opacity="0.7"/> |
|||
</Grid> |
|||
</Grid> |
|||
|
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto" MinHeight="26"/> |
|||
<RowDefinition /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<!-- Content Border --> |
|||
<Grid Margin="6,0,6,6" x:Name="ContentGrid" Grid.Row="1"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
<Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1"/> |
|||
<Border Margin="1" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0.1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"> |
|||
|
|||
<ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" /> |
|||
</Border> |
|||
</Grid> |
|||
|
|||
<!-- Header --> |
|||
<Border x:Name="PART_DragWidget" Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0"> |
|||
<Grid> |
|||
<Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center"> |
|||
<!-- Caption --> |
|||
<ContentControl x:Name="Caption" Margin="5,0,0,0" IsTabStop="False" HorizontalAlignment="Stretch" |
|||
Content="{TemplateBinding Caption}" |
|||
Foreground="{TemplateBinding CaptionForeground}"/> |
|||
|
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
|
|||
<!-- Buttons --> |
|||
<Border BorderBrush="#A5FFFFFF" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3" VerticalAlignment="Top" Margin="0,1,7,0" HorizontalAlignment="Right"> |
|||
<Button x:Name="PART_CloseButton" Style="{TemplateBinding CloseButtonStyle}" Visibility="{TemplateBinding CloseButtonVisibility}" Height="17" Width="43" IsTabStop="False"> |
|||
<Path Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Width="12" Fill="#E4FFFFFF" Stretch="Fill" Stroke="#FF535666" |
|||
Data="M0.5,0.5 L4.5178828,0.5 L6.0620003,3.125 L7.4936447,0.5 L11.5,0.5 L11.5,1.5476431 L8.7425003,6.1201854 L11.5,10.359666 L11.5,11.5 L7.4941902,11.5 L6.0620003,8.8740005 L4.5172949,11.5 L0.5,11.5 L0.5,10.43379 L3.3059995,6.1201582 L0.5,1.4676378 L0.5,0.5 z"/> |
|||
</Button> |
|||
</Border> |
|||
</Grid> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static partial class VisualStates |
|||
{ |
|||
/// <summary>
|
|||
/// Window State group name.
|
|||
/// </summary>
|
|||
public const string WindowStatesGroup = "WindowStatesGroup"; |
|||
|
|||
/// <summary>
|
|||
/// Open state name for ChildWindow.
|
|||
/// </summary>
|
|||
public const string Open = "Open"; |
|||
|
|||
/// <summary>
|
|||
/// Closed state name for ChildWindow.
|
|||
/// </summary>
|
|||
public const string Closed = "Closed"; |
|||
} |
|||
} |
|||
@ -0,0 +1,367 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- ColorPicker --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<LinearGradientBrush x:Key="ColorPickerDarkBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<DrawingBrush x:Key="CheckerBrush" Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile"> |
|||
<DrawingBrush.Drawing> |
|||
<DrawingGroup> |
|||
<GeometryDrawing Brush="White"> |
|||
<GeometryDrawing.Geometry> |
|||
<RectangleGeometry Rect="0,0 100,100" /> |
|||
</GeometryDrawing.Geometry> |
|||
</GeometryDrawing> |
|||
<GeometryDrawing Brush="LightGray"> |
|||
<GeometryDrawing.Geometry> |
|||
<GeometryGroup> |
|||
<RectangleGeometry Rect="0,0 50,50" /> |
|||
<RectangleGeometry Rect="50,50 50,50" /> |
|||
</GeometryGroup> |
|||
</GeometryDrawing.Geometry> |
|||
</GeometryDrawing> |
|||
</DrawingGroup> |
|||
</DrawingBrush.Drawing> |
|||
</DrawingBrush> |
|||
|
|||
<Style x:Key="SliderRepeatButtonStyle" |
|||
TargetType="{x:Type RepeatButton}"> |
|||
<Setter Property="OverridesDefaultStyle" Value="true"/> |
|||
<Setter Property="IsTabStop" Value="false"/> |
|||
<Setter Property="Focusable" Value="false"/> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type RepeatButton}"> |
|||
<Border Background="{TemplateBinding Background}"/> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style x:Key="VerticalSlideThumbStyle" TargetType="{x:Type Thumb}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Thumb}"> |
|||
<Canvas x:Name="selector" Height="8" Background="Transparent" IsHitTestVisible="True" > |
|||
<Path Width="5" Height="8" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FF000000" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z " /> |
|||
<Path Width="5" Height="8" Canvas.Top="8" Canvas.Left="20" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FF000000" Data="F1 M 276.761,316L 262.619,307.835L 262.619,324.165L 276.761,316 Z "> |
|||
<Path.RenderTransform> |
|||
<RotateTransform Angle="180"/> |
|||
</Path.RenderTransform> |
|||
</Path> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsDragging" Value="True"> |
|||
<Setter Property="Foreground" |
|||
Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/> |
|||
</Trigger> |
|||
<Trigger Property="IsEnabled" Value="False"> |
|||
<Setter Property="Foreground" |
|||
Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style x:Key="OpacitySliderStyle" TargetType="{x:Type Slider}"> |
|||
<Setter Property="Orientation" Value="Vertical"/> |
|||
<Setter Property="Minimum" Value="0" /> |
|||
<Setter Property="Maximum" Value="1" /> |
|||
<Setter Property="TickFrequency" Value="0.01" /> |
|||
<Setter Property="SmallChange" Value="0.01" /> |
|||
<Setter Property="LargeChange" Value="0.02" /> |
|||
<Setter Property="IsDirectionReversed" Value="False" /> |
|||
<Setter Property="IsMoveToPointEnabled" Value="True" /> |
|||
<Setter Property="Background"> |
|||
<Setter.Value> |
|||
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5"> |
|||
<LinearGradientBrush.RelativeTransform> |
|||
<TransformGroup> |
|||
<ScaleTransform CenterY="0.5" CenterX="0.5"/> |
|||
<SkewTransform CenterY="0.5" CenterX="0.5"/> |
|||
<RotateTransform Angle="90" CenterY="0.5" CenterX="0.5"/> |
|||
<TranslateTransform/> |
|||
</TransformGroup> |
|||
</LinearGradientBrush.RelativeTransform> |
|||
<GradientStop Color="White" /> |
|||
<GradientStop Color="Transparent" Offset="1" /> |
|||
</LinearGradientBrush> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Slider}"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto" /> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="*"/> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Border x:Name="PART_TrackBackground" Background="{TemplateBinding Background}" Grid.Column="1" Width="20" /> |
|||
|
|||
<Track Grid.Column="1" Name="PART_Track"> |
|||
<Track.DecreaseRepeatButton> |
|||
<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.DecreaseLarge"/> |
|||
</Track.DecreaseRepeatButton> |
|||
<Track.IncreaseRepeatButton> |
|||
<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.IncreaseLarge"/> |
|||
</Track.IncreaseRepeatButton> |
|||
|
|||
<Track.Thumb> |
|||
<Thumb Style="{StaticResource VerticalSlideThumbStyle}" /> |
|||
</Track.Thumb> |
|||
</Track> |
|||
|
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style x:Key="ColorPickerToggleButton" TargetType="ToggleButton"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="5"/> |
|||
<Setter Property="BorderThickness" Value="1,0,0,0"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="ToggleButton"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="_backgroundHighlight" Storyboard.TargetProperty="Opacity"> |
|||
<SplineDoubleKeyFrame KeyTime="0" Value="1"/> |
|||
</DoubleAnimationUsingKeyFrames> |
|||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="_backgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)"> |
|||
<SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/> |
|||
</ColorAnimationUsingKeyFrames> |
|||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="_backgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)"> |
|||
<SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/> |
|||
</ColorAnimationUsingKeyFrames> |
|||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="_backgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)"> |
|||
<SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/> |
|||
</ColorAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
|
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*"/> |
|||
<ColumnDefinition Width="1"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<Border x:Name="Background" Background="White" BorderThickness="0" Grid.ColumnSpan="3" Cursor="Hand"> |
|||
<Grid Margin="1" Background="#FF1F3B53"> |
|||
<Border x:Name="_backgroundHighlight" Opacity="0" Background="#FF448DCA"/> |
|||
<Rectangle x:Name="_backgroundGradient"> |
|||
<Rectangle.Fill> |
|||
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
|||
<GradientStop Color="#F3F3F3" Offset="0"/> |
|||
<GradientStop Color="#EBEBEB" Offset="0.5"/> |
|||
<GradientStop Color="#DDDDDD" Offset="0.5"/> |
|||
<GradientStop Color="#CDCDCD" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Border Margin="5" BorderBrush="{StaticResource ColorPickerDarkBorderBrush}" BorderThickness="1" CornerRadius="3"> |
|||
<Rectangle Fill="{TemplateBinding Background}" /> |
|||
</Border> |
|||
|
|||
<Border Grid.Column="1" Background="#FFC9CACA" BorderBrush="White" BorderThickness="1,0,0,0" Margin="0,2"/> |
|||
|
|||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Grid.Column="2"/> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style TargetType="{x:Type local:ColorPicker}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:ColorPicker}"> |
|||
<Grid> |
|||
<Border BorderBrush="{StaticResource ColorPickerDarkBorderBrush}" BorderThickness="1" CornerRadius="1"> |
|||
<Grid> |
|||
<ToggleButton x:Name="PART_ColorPickerToggleButton" Style="{StaticResource ColorPickerToggleButton}" Height="25"> |
|||
<ToggleButton.Background> |
|||
<SolidColorBrush Color="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}"/> |
|||
</ToggleButton.Background> |
|||
<ToggleButton.Content> |
|||
<Grid x:Name="arrowGlyph" IsHitTestVisible="False"> |
|||
<Path Height="3" Width="5" Stretch="Fill" Fill="#FFFFFFFF" Margin="0,1,0,0" |
|||
Data="M 0,0 C0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,3 2,3 2,3 3,3 3,3 3,3 3,2 3,2 3,2 4,2 4,2 4,2 4,1 4,1 4,1 5,1 5,1 5,1 5,0 5,0 5,0 0,0 0,0 z" /> |
|||
<Path Height="3" Width="5" Stretch="Fill" Fill="{StaticResource ColorPickerDarkBorderBrush}" |
|||
Data="M 0,0 C0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,3 2,3 2,3 3,3 3,3 3,3 3,2 3,2 3,2 4,2 4,2 4,2 4,1 4,1 4,1 5,1 5,1 5,1 5,0 5,0 5,0 0,0 0,0 z" /> |
|||
</Grid> |
|||
</ToggleButton.Content> |
|||
</ToggleButton> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Popup x:Name="PART_ColorPickerCanvasPopup" VerticalAlignment="Bottom" IsOpen="False" > |
|||
<Border BorderThickness="1" Background="White" BorderBrush="{StaticResource ColorPickerDarkBorderBrush}" Padding="3"> |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition /> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
<Grid Margin="2"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions > |
|||
<ColumnDefinition Width="200"></ColumnDefinition> |
|||
<ColumnDefinition Width="5"></ColumnDefinition> |
|||
<ColumnDefinition Width="22"></ColumnDefinition> |
|||
<ColumnDefinition Width="5"></ColumnDefinition> |
|||
<ColumnDefinition Width="22"></ColumnDefinition> |
|||
</Grid.ColumnDefinitions> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto" /> |
|||
<RowDefinition Height="20"/> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Border BorderThickness="1" BorderBrush="DarkGray" ClipToBounds="True" Background="{StaticResource CheckerBrush}"> |
|||
<Canvas x:Name="PART_ColorShadingCanvas" Width="200" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top"> |
|||
<Rectangle x:Name="ColorShadingRectangle" Height="{Binding ElementName=PART_ColorShadingCanvas,Path=Height}" Width="{Binding ElementName=PART_ColorShadingCanvas,Path=Width}" > |
|||
<Rectangle.Fill> |
|||
<SolidColorBrush Color="{Binding ElementName=PART_SpectrumSlider, Path=SelectedColor}" /> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<Rectangle x:Name="WhiteGradient" Width="{Binding ElementName=PART_ColorShadingCanvas,Path=Width}" Height="{Binding ElementName=PART_ColorShadingCanvas,Path=Height}" > |
|||
<Rectangle.Fill> |
|||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> |
|||
<GradientStop Offset="0" Color="#ffffffff"/> |
|||
<GradientStop Offset="1" Color="Transparent"/> |
|||
</LinearGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<Rectangle x:Name="BlackGradient" Width="{Binding ElementName=PART_ColorShadingCanvas,Path=Width}" Height="{Binding ElementName=PART_ColorShadingCanvas,Path=Height}" > |
|||
<Rectangle.Fill> |
|||
<LinearGradientBrush StartPoint="0,1" EndPoint="0, 0"> |
|||
<GradientStop Offset="0" Color="#ff000000"/> |
|||
<GradientStop Offset="1" Color="#00000000"/> |
|||
</LinearGradientBrush> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
<Canvas x:Name="PART_ColorShadeSelector" Width="10" Height="10" IsHitTestVisible="False"> |
|||
<Ellipse Width="10" Height="10" StrokeThickness="3" Stroke="#FFFFFFFF" IsHitTestVisible="False" /> |
|||
<Ellipse Width="10" Height="10" StrokeThickness="1" Stroke="#FF000000" IsHitTestVisible="False" /> |
|||
</Canvas> |
|||
</Canvas> |
|||
</Border> |
|||
|
|||
<Border BorderThickness="0,1,0,0" Grid.Row="1"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Grid Background="{StaticResource CheckerBrush}"> |
|||
<Rectangle x:Name="SelectedColor"> |
|||
<Rectangle.Fill> |
|||
<SolidColorBrush Color="{Binding SelectedColor, RelativeSource={RelativeSource TemplatedParent}}"/> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
</Grid> |
|||
<Grid Grid.Column="1" Background="{StaticResource CheckerBrush}"> |
|||
<Rectangle x:Name="CurrentColor"> |
|||
<Rectangle.Fill> |
|||
<SolidColorBrush Color="{Binding CurrentColor, RelativeSource={RelativeSource TemplatedParent}}"/> |
|||
</Rectangle.Fill> |
|||
</Rectangle> |
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Border BorderThickness="1" BorderBrush="DarkGray" Grid.Column="2" Grid.RowSpan="2" ClipToBounds="True"> |
|||
<local:ColorSpectrumSlider x:Name="PART_SpectrumSlider" Width="20" /> |
|||
</Border> |
|||
|
|||
|
|||
<Border Grid.Column="4" Grid.RowSpan="2" BorderThickness="1" BorderBrush="DarkGray" Background="{StaticResource CheckerBrush}" ClipToBounds="True"> |
|||
<Slider x:Name="PART_OpacitySlider" |
|||
Style="{StaticResource OpacitySliderStyle}" |
|||
Value="{Binding Path=ScA, RelativeSource={RelativeSource TemplatedParent}}"/> |
|||
</Border> |
|||
</Grid> |
|||
</Grid> |
|||
<Button x:Name="PART_OkButton" Grid.Row="1" HorizontalAlignment="Right" MinWidth="50" Cursor="Hand" Content="OK" /> |
|||
</Grid> |
|||
</Border> |
|||
</Popup> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style TargetType="{x:Type local:ColorSpectrumSlider}"> |
|||
<Setter Property="Orientation" Value="Vertical"/> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/> |
|||
<Setter Property="Minimum" Value="1"/> |
|||
<Setter Property="Maximum" Value="360"/> |
|||
<Setter Property="TickFrequency" Value="0.001" /> |
|||
<Setter Property="IsSnapToTickEnabled" Value="True" /> |
|||
<Setter Property="IsDirectionReversed" Value="False" /> |
|||
<Setter Property="IsMoveToPointEnabled" Value="True" /> |
|||
<Setter Property="Value" Value="1" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:ColorSpectrumSlider}"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto" /> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="*"/> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Border x:Name="PART_TrackBackground" Grid.Column="1" Width="20"> |
|||
<Rectangle x:Name="PART_SpectrumDisplay" Stretch="Fill" VerticalAlignment="Stretch" /> |
|||
</Border> |
|||
|
|||
<Track Grid.Column="1" Name="PART_Track"> |
|||
<Track.DecreaseRepeatButton> |
|||
<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.DecreaseLarge"/> |
|||
</Track.DecreaseRepeatButton> |
|||
<Track.IncreaseRepeatButton> |
|||
<RepeatButton Style="{StaticResource SliderRepeatButtonStyle}" Command="Slider.IncreaseLarge"/> |
|||
</Track.IncreaseRepeatButton> |
|||
|
|||
<Track.Thumb> |
|||
<Thumb Style="{StaticResource VerticalSlideThumbStyle}" /> |
|||
</Track.Thumb> |
|||
</Track> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,85 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Media; |
|||
using System.Windows.Shapes; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal class ColorSpectrumSlider : Slider |
|||
{ |
|||
#region Private Members
|
|||
|
|||
private Rectangle _spectrumDisplay; |
|||
private LinearGradientBrush _pickerBrush; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static ColorSpectrumSlider() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorSpectrumSlider), new FrameworkPropertyMetadata(typeof(ColorSpectrumSlider))); |
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorSpectrumSlider), new PropertyMetadata(System.Windows.Media.Colors.Transparent)); |
|||
public Color SelectedColor |
|||
{ |
|||
get { return (Color)GetValue(SelectedColorProperty); } |
|||
set { SetValue(SelectedColorProperty, value); } |
|||
} |
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
_spectrumDisplay = (Rectangle)GetTemplateChild("PART_SpectrumDisplay"); |
|||
CreateSpectrum(); |
|||
OnValueChanged(Double.NaN, Value); |
|||
} |
|||
|
|||
protected override void OnValueChanged(double oldValue, double newValue) |
|||
{ |
|||
base.OnValueChanged(oldValue, newValue); |
|||
|
|||
Color color = ColorUtilities.ConvertHsvToRgb(360 - newValue, 1, 1); |
|||
SelectedColor = color; |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Methods
|
|||
|
|||
private void CreateSpectrum() |
|||
{ |
|||
_pickerBrush = new LinearGradientBrush(); |
|||
_pickerBrush.StartPoint = new Point(0.5, 0); |
|||
_pickerBrush.EndPoint = new Point(0.5, 1); |
|||
_pickerBrush.ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation; |
|||
|
|||
List<Color> colorsList = ColorUtilities.GenerateHsvSpectrum(); |
|||
|
|||
double stopIncrement = (double)1 / colorsList.Count; |
|||
|
|||
int i; |
|||
for (i = 0; i < colorsList.Count; i++) |
|||
{ |
|||
_pickerBrush.GradientStops.Add(new GradientStop(colorsList[i], i * stopIncrement)); |
|||
} |
|||
|
|||
_pickerBrush.GradientStops[i - 1].Offset = 1.0; |
|||
_spectrumDisplay.Fill = _pickerBrush; |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal struct HsvColor |
|||
{ |
|||
public double H; |
|||
public double S; |
|||
public double V; |
|||
|
|||
public HsvColor(double h, double s, double v) |
|||
{ |
|||
H = h; |
|||
S = s; |
|||
V = v; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:chrome="clr-namespace:Microsoft.Windows.Controls.Chromes" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls" |
|||
xmlns:coreConverters="clr-namespace:Microsoft.Windows.Controls.Core.Converters"> |
|||
|
|||
<coreConverters:InverseBoolConverter x:Key="InverseBoolConverter" /> |
|||
|
|||
<DataTemplate x:Key="DefaultWatermarkTemplate"> |
|||
<ContentControl Content="{Binding}" Foreground="Gray" Focusable="False" /> |
|||
</DataTemplate> |
|||
|
|||
<LinearGradientBrush x:Key="TextBoxBorder" EndPoint="0,20" MappingMode="Absolute" StartPoint="0,0"> |
|||
<GradientStop Color="#ABADB3" Offset="0.05"/> |
|||
<GradientStop Color="#E2E3EA" Offset="0.07"/> |
|||
<GradientStop Color="#E3E9EF" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- MaskedTextBox --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<Style TargetType="{x:Type local:MaskedTextBox}"> |
|||
<Setter Property="Background" Value="White"/> |
|||
<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="WatermarkTemplate" Value="{StaticResource DefaultWatermarkTemplate}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:MaskedTextBox}"> |
|||
<local:WatermarkTextBox x:Name="TextBox" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontSize="{TemplateBinding FontSize}" |
|||
FontStretch="{TemplateBinding FontStretch}" |
|||
FontStyle="{TemplateBinding FontStyle}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
IsReadOnly="{Binding IsEditable, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}" |
|||
MinWidth="20" AcceptsReturn="False" TextWrapping="NoWrap" |
|||
TabIndex="{TemplateBinding TabIndex}" |
|||
Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" |
|||
Watermark="{TemplateBinding Watermark}" |
|||
WatermarkTemplate="{TemplateBinding WatermarkTemplate}"/> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,286 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- MessageBox --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxDarkBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxWindowBackgroundBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFffffff"/> |
|||
<GradientStop Offset="0.479" Color="#FFf4f5f6"/> |
|||
<GradientStop Offset="1" Color="#FFd0d6db"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxWindowButtonHoverBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFb5bdc8"/> |
|||
<GradientStop Offset="0.370" Color="#FF8399a9"/> |
|||
<GradientStop Offset="0.370" Color="#FF718597"/> |
|||
<GradientStop Offset="0.906" Color="#FFb9c1ca"/> |
|||
<GradientStop Offset="1" Color="#FFb9c1ca"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="MessageBoxWindowButtonPressedBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FF6b7c8d"/> |
|||
<GradientStop Offset="0.370" Color="#FF4d606f"/> |
|||
<GradientStop Offset="0.370" Color="#FF465460"/> |
|||
<GradientStop Offset="0.906" Color="#FF262d33"/> |
|||
<GradientStop Offset="1" Color="#FF262d33"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<Style x:Key="MessageBoxCloseButtonStyle" TargetType="Button"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="3"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MessageBoxWindowButtonHoverBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Pressed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MessageBoxWindowButtonPressedBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<Border x:Name="Background" CornerRadius="0,0,2,0" Background="{StaticResource MessageBoxDarkBrush}"> |
|||
<Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/> |
|||
</Border> |
|||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
|||
<Path x:Name="path" |
|||
Height="6" |
|||
Width="7" |
|||
Stretch="Fill" |
|||
Opacity="1" |
|||
Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z" |
|||
Fill="White" Margin="0,0,0,1" Visibility="Collapsed" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<ControlTemplate x:Key="MessageBoxDragWidgetTemplate" TargetType="{x:Type Thumb}"> |
|||
<Border Background="Transparent"> |
|||
</Border> |
|||
</ControlTemplate> |
|||
|
|||
<Style TargetType="{x:Type local:MessageBox}"> |
|||
<Setter Property="Background" Value="#FFFFFFFF"/> |
|||
<Setter Property="BorderBrush" Value="{StaticResource MessageBoxDarkBrush}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="CaptionForeground" Value="#FF000000" /> |
|||
<Setter Property="CloseButtonStyle" Value="{StaticResource MessageBoxCloseButtonStyle}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Left" /> |
|||
<Setter Property="IsEnabled" Value="true" /> |
|||
<Setter Property="MinWidth" Value="350" /> |
|||
<Setter Property="MinHeight" Value="50" /> |
|||
<Setter Property="VerticalAlignment" Value="Top" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Top" /> |
|||
<Setter Property="WindowBorderBrush" Value="{StaticResource MessageBoxDarkBrush}" /> |
|||
<Setter Property="WindowBackground" Value="{StaticResource MessageBoxWindowBackgroundBrush}" /> |
|||
<Setter Property="WindowOpacity" Value="1.0" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:MessageBox}"> |
|||
<Grid x:Name="Root"> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="group1"> |
|||
<VisualState x:Name="OK"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OkGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="OKCancel"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="OkCancelGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="YesNo"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="YesNoGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
|
|||
<VisualState x:Name="YesNoCancel"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="YesNoCancelGrid" Storyboard.TargetProperty="Visibility"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
|
|||
<!-- Borders --> |
|||
<Grid x:Name="MessageBoxWindowGrid"> |
|||
<Border BorderBrush="{TemplateBinding WindowBorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="5,5,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Grid Margin="0" Background="{x:Null}"> |
|||
<Border x:Name="MessageBoxWindow" Margin="1,1,1,1" Background="{TemplateBinding WindowBackground}" CornerRadius="4,4,0,0" Opacity="{TemplateBinding WindowOpacity}"/> |
|||
<Border BorderBrush="White" BorderThickness="1" CornerRadius="4,4,0,0" Margin="1" Opacity="0.7"/> |
|||
</Grid> |
|||
</Grid> |
|||
|
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="Auto" MinHeight="26"/> |
|||
<RowDefinition /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<!-- Content Border --> |
|||
<Grid Margin="6,0,6,6" x:Name="ContentGrid" Grid.Row="1"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
<Border BorderBrush="#FFFFFFFF" BorderThickness="1" CornerRadius="1"/> |
|||
<Border Margin="1" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0.1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"> |
|||
|
|||
<Grid MinWidth="350"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition /> |
|||
<RowDefinition Height="Auto" /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Grid Margin="24,16,24,22"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="*"/> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<!-- Message Image --> |
|||
<Image x:Name="MessageBoxImage" VerticalAlignment="Top" SnapsToDevicePixels="True" Stretch="None" Margin="-6,-1,10,-4" Source="{TemplateBinding ImageSource}"></Image> |
|||
|
|||
<!-- Message Text --> |
|||
<TextBlock x:Name="MessageText" Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Center" MaxWidth="450" |
|||
Text="{TemplateBinding Text}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontSize="{TemplateBinding FontSize}" |
|||
FontStyle="{TemplateBinding FontStyle}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
Foreground="{TemplateBinding Foreground}"/> |
|||
|
|||
</Grid> |
|||
|
|||
<!-- Buttons --> |
|||
<Grid Grid.Row="1" HorizontalAlignment="Right" Margin="12,0,12,12"> |
|||
<Grid x:Name="OkGrid" Visibility="Collapsed"> |
|||
<Button x:Name="PART_OkButton" MinWidth="65" Margin="6,0,0,0">OK</Button> |
|||
</Grid> |
|||
<Grid x:Name="OkCancelGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_OkButton1" MinWidth="65" Margin="6,0,0,0">OK</Button> |
|||
<Button Grid.Column="1" x:Name="PART_CancelButton" MinWidth="65" Margin="6,0,0,0">Cancel</Button> |
|||
</Grid> |
|||
<Grid x:Name="YesNoGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_YesButton" MinWidth="65" Margin="6,0,0,0">Yes</Button> |
|||
<Button Grid.Column="1" x:Name="PART_NoButton" MinWidth="65" Margin="6,0,0,0">No</Button> |
|||
</Grid> |
|||
<Grid x:Name="YesNoCancelGrid" Visibility="Collapsed"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="Auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<Button x:Name="PART_YesButton1" MinWidth="65" Margin="6,0,0,0">Yes</Button> |
|||
<Button Grid.Column="1" x:Name="PART_NoButton1" MinWidth="65" Margin="6,0,0,0">No</Button> |
|||
<Button Grid.Column="2" x:Name="PART_CancelButton1" MinWidth="65" Margin="6,0,0,0">Cancel</Button> |
|||
</Grid> |
|||
</Grid> |
|||
</Grid> |
|||
</Border> |
|||
</Grid> |
|||
|
|||
<!-- Header --> |
|||
<Border x:Name="HeaderArea" Background="Transparent" Grid.Column="1" CornerRadius="5,5,0,0" Margin="1,1,1,0"> |
|||
<Grid> |
|||
<Grid x:Name="CaptionHeader" Margin="1,1,105,0" VerticalAlignment="Center"> |
|||
<!-- Caption --> |
|||
<ContentControl x:Name="Caption" Margin="5,0,0,0" IsTabStop="False" HorizontalAlignment="Stretch" |
|||
Content="{TemplateBinding Caption}" |
|||
Foreground="{TemplateBinding CaptionForeground}"/> |
|||
|
|||
</Grid> |
|||
<Thumb x:Name="PART_DragWidget" Template="{StaticResource MessageBoxDragWidgetTemplate}"/> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
</Grid> |
|||
|
|||
<Border x:Name="Resize" BorderThickness="7" BorderBrush="Transparent" /> |
|||
|
|||
<!-- Close Button --> |
|||
<Border BorderBrush="#A5FFFFFF" BorderThickness="1,0,1,1" CornerRadius="0,0,3,3" VerticalAlignment="Top" Margin="0,1,7,0" HorizontalAlignment="Right"> |
|||
<Button x:Name="PART_CloseButton" Style="{TemplateBinding CloseButtonStyle}" Height="17" Width="43" IsTabStop="False"> |
|||
<Path Height="10" HorizontalAlignment="Center" VerticalAlignment="Center" Width="12" Fill="#E4FFFFFF" Stretch="Fill" Stroke="#FF535666" |
|||
Data="M0.5,0.5 L4.5178828,0.5 L6.0620003,3.125 L7.4936447,0.5 L11.5,0.5 L11.5,1.5476431 L8.7425003,6.1201854 L11.5,10.359666 L11.5,11.5 L7.4941902,11.5 L6.0620003,8.8740005 L4.5172949,11.5 L0.5,11.5 L0.5,10.43379 L3.3059995,6.1201582 L0.5,1.4676378 L0.5,0.5 z"/> |
|||
</Button> |
|||
</Border> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,63 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
// Runtime Version:4.0.30319.261
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Xceed.Wpf.Toolkit.Properties { |
|||
using System; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
|||
/// </summary>
|
|||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
|||
// class via a tool like ResGen or Visual Studio.
|
|||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
|||
// with the /str option, or rebuild your VS project.
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
|||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
internal class Resources { |
|||
|
|||
private static global::System.Resources.ResourceManager resourceMan; |
|||
|
|||
private static global::System.Globalization.CultureInfo resourceCulture; |
|||
|
|||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
|||
internal Resources() { |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns the cached ResourceManager instance used by this class.
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Resources.ResourceManager ResourceManager { |
|||
get { |
|||
if (object.ReferenceEquals(resourceMan, null)) { |
|||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Xceed.Wpf.Toolkit.Properties.Resources", typeof(Resources).Assembly); |
|||
resourceMan = temp; |
|||
} |
|||
return resourceMan; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Overrides the current thread's CurrentUICulture property for all
|
|||
/// resource lookups using this strongly typed resource class.
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Globalization.CultureInfo Culture { |
|||
get { |
|||
return resourceCulture; |
|||
} |
|||
set { |
|||
resourceCulture = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
|||
@ -0,0 +1,26 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
// Runtime Version:4.0.30319.261
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Xceed.Wpf.Toolkit.Properties { |
|||
|
|||
|
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] |
|||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
|||
|
|||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
|||
|
|||
public static Settings Default { |
|||
get { |
|||
return defaultInstance; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<?xml version='1.0' encoding='utf-8'?> |
|||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
|||
<Profiles> |
|||
<Profile Name="(Default)" /> |
|||
</Profiles> |
|||
<Settings /> |
|||
</SettingsFile> |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Attributes |
|||
{ |
|||
public class TypeEditorAttribute : Attribute |
|||
{ |
|||
public Type Type { get; set; } |
|||
|
|||
public TypeEditorAttribute(Type type) |
|||
{ |
|||
var valueSourceInterface = type.GetInterface("Microsoft.Windows.Controls.PropertyGrid.Editors.ITypeEditor"); |
|||
if (valueSourceInterface == null) |
|||
throw new ArgumentException("Type must implement the ITypeEditor interface.", "type"); |
|||
|
|||
Type = type; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
public class CheckBoxEditorProvider : ITypeEditorProvider |
|||
{ |
|||
CheckBox _checkbox; |
|||
|
|||
public CheckBoxEditorProvider() |
|||
{ |
|||
_checkbox = new CheckBox(); |
|||
_checkbox.Margin = new Thickness(2, 0, 0, 0); |
|||
} |
|||
|
|||
public void Initialize(PropertyItem propertyItem) |
|||
{ |
|||
ResolveBinding(propertyItem); |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return _checkbox; |
|||
} |
|||
|
|||
private void ResolveBinding(PropertyItem property) |
|||
{ |
|||
var binding = new Binding(property.Name); |
|||
binding.Source = property.Instance; |
|||
binding.ValidatesOnExceptions = true; |
|||
binding.ValidatesOnDataErrors = true; |
|||
|
|||
if (property.IsWriteable) |
|||
binding.Mode = BindingMode.TwoWay; |
|||
else |
|||
binding.Mode = BindingMode.OneWay; |
|||
|
|||
BindingOperations.SetBinding(_checkbox, CheckBox.IsCheckedProperty, binding); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Windows.Controls; |
|||
using System.Windows; |
|||
using System.Windows.Data; |
|||
using System.Reflection; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
public class EnumComboBoxEditorProvider : ITypeEditorProvider |
|||
{ |
|||
ComboBox _comboBox; |
|||
|
|||
public EnumComboBoxEditorProvider() |
|||
{ |
|||
_comboBox = new ComboBox(); |
|||
} |
|||
|
|||
public void Initialize(PropertyItem propertyItem) |
|||
{ |
|||
ResolveBinding(propertyItem); |
|||
SetItemsSource(propertyItem); |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return _comboBox; |
|||
} |
|||
|
|||
private void ResolveBinding(PropertyItem property) |
|||
{ |
|||
var binding = new Binding(property.Name); |
|||
binding.Source = property.Instance; |
|||
binding.ValidatesOnExceptions = true; |
|||
binding.ValidatesOnDataErrors = true; |
|||
|
|||
if (property.IsWriteable) |
|||
binding.Mode = BindingMode.TwoWay; |
|||
else |
|||
binding.Mode = BindingMode.OneWay; |
|||
|
|||
BindingOperations.SetBinding(_comboBox, ComboBox.SelectedItemProperty, binding); |
|||
} |
|||
|
|||
private void SetItemsSource(PropertyItem property) |
|||
{ |
|||
_comboBox.ItemsSource = GetValues(property.PropertyType); |
|||
} |
|||
|
|||
public static object[] GetValues(Type enumType) |
|||
{ |
|||
List<object> values = new List<object>(); |
|||
|
|||
var fields = from field in enumType.GetFields() |
|||
where field.IsLiteral |
|||
select field; |
|||
|
|||
foreach (FieldInfo field in fields) |
|||
{ |
|||
values.Add(field.GetValue(enumType)); |
|||
} |
|||
|
|||
return values.ToArray(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,110 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows.Controls; |
|||
using System.Windows; |
|||
using System.Windows.Data; |
|||
using System.Windows.Media; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
public class FontComboBoxEditorProvider : ITypeEditorProvider |
|||
{ |
|||
ComboBox _comboBox; |
|||
|
|||
public FontComboBoxEditorProvider() |
|||
{ |
|||
_comboBox = new ComboBox(); |
|||
} |
|||
|
|||
public void Initialize(PropertyItem propertyItem) |
|||
{ |
|||
ResolveBinding(propertyItem); |
|||
SetItemsSource(propertyItem); |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return _comboBox; |
|||
} |
|||
|
|||
private void ResolveBinding(PropertyItem property) |
|||
{ |
|||
var binding = new Binding(property.Name); |
|||
binding.Source = property.Instance; |
|||
binding.ValidatesOnExceptions = true; |
|||
binding.ValidatesOnDataErrors = true; |
|||
|
|||
if (property.IsWriteable) |
|||
binding.Mode = BindingMode.TwoWay; |
|||
else |
|||
binding.Mode = BindingMode.OneWay; |
|||
|
|||
BindingOperations.SetBinding(_comboBox, ComboBox.SelectedItemProperty, binding); |
|||
} |
|||
|
|||
private void SetItemsSource(PropertyItem property) |
|||
{ |
|||
if (property.PropertyType == typeof(FontFamily)) |
|||
{ |
|||
List<FontFamily> fonts = new List<FontFamily>(); |
|||
fonts.Add(new FontFamily("Arial")); |
|||
fonts.Add(new FontFamily("Courier New")); |
|||
fonts.Add(new FontFamily("Times New Roman")); |
|||
fonts.Add(new FontFamily("Batang")); |
|||
fonts.Add(new FontFamily("BatangChe")); |
|||
fonts.Add(new FontFamily("DFKai-SB")); |
|||
fonts.Add(new FontFamily("Dotum")); |
|||
fonts.Add(new FontFamily("DutumChe")); |
|||
fonts.Add(new FontFamily("FangSong")); |
|||
fonts.Add(new FontFamily("GulimChe")); |
|||
fonts.Add(new FontFamily("Gungsuh")); |
|||
fonts.Add(new FontFamily("GungsuhChe")); |
|||
fonts.Add(new FontFamily("KaiTi")); |
|||
fonts.Add(new FontFamily("Malgun Gothic")); |
|||
fonts.Add(new FontFamily("Meiryo")); |
|||
fonts.Add(new FontFamily("Microsoft JhengHei")); |
|||
fonts.Add(new FontFamily("Microsoft YaHei")); |
|||
fonts.Add(new FontFamily("MingLiU")); |
|||
fonts.Add(new FontFamily("MingLiu_HKSCS")); |
|||
fonts.Add(new FontFamily("MingLiu_HKSCS-ExtB")); |
|||
fonts.Add(new FontFamily("MingLiu-ExtB")); |
|||
_comboBox.ItemsSource = fonts; |
|||
} |
|||
else if (property.PropertyType == typeof(FontWeight)) |
|||
{ |
|||
List<FontWeight> list = new List<FontWeight>() |
|||
{ |
|||
FontWeights.Black, FontWeights.Bold, FontWeights.ExtraBlack, FontWeights.ExtraBold, |
|||
FontWeights.ExtraLight, FontWeights.Light, FontWeights.Medium, FontWeights.Normal, FontWeights.SemiBold, |
|||
FontWeights.Thin |
|||
}; |
|||
_comboBox.ItemsSource = list; |
|||
} |
|||
else if (property.PropertyType == typeof(FontStyle)) |
|||
{ |
|||
List<FontStyle> list = new List<FontStyle>() |
|||
{ |
|||
FontStyles.Italic, |
|||
FontStyles.Normal |
|||
}; |
|||
_comboBox.ItemsSource = list; |
|||
} |
|||
else if (property.PropertyType == typeof(FontStretch)) |
|||
{ |
|||
List<FontStretch> list = new List<FontStretch>() |
|||
{ |
|||
FontStretches.Condensed, |
|||
FontStretches.Expanded, |
|||
FontStretches.ExtraCondensed, |
|||
FontStretches.ExtraExpanded, |
|||
FontStretches.Normal, |
|||
FontStretches.SemiCondensed, |
|||
FontStretches.SemiExpanded, |
|||
FontStretches.UltraCondensed, |
|||
FontStretches.UltraExpanded |
|||
}; |
|||
_comboBox.ItemsSource = list; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
interface ITypeEditorProvider |
|||
{ |
|||
void Initialize(PropertyItem propertyItem); |
|||
FrameworkElement ResolveEditor(); |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
using System; |
|||
using System.Windows.Data; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
public class NumericUpDownEditorProvider : ITypeEditorProvider |
|||
{ |
|||
NumericUpDown _numericUpDown; |
|||
|
|||
public NumericUpDownEditorProvider() |
|||
{ |
|||
_numericUpDown = new NumericUpDown(); |
|||
} |
|||
|
|||
public void Initialize(PropertyItem propertyItem) |
|||
{ |
|||
ResolveBinding(propertyItem); |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return _numericUpDown; |
|||
} |
|||
|
|||
private void ResolveBinding(PropertyItem property) |
|||
{ |
|||
var binding = new Binding(property.Name); |
|||
binding.Source = property.Instance; |
|||
binding.ValidatesOnExceptions = true; |
|||
binding.ValidatesOnDataErrors = true; |
|||
|
|||
if (property.IsWriteable) |
|||
binding.Mode = BindingMode.TwoWay; |
|||
else |
|||
binding.Mode = BindingMode.OneWay; |
|||
|
|||
BindingOperations.SetBinding(_numericUpDown, NumericUpDown.ValueProperty, binding); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using System; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Implementation.EditorProviders |
|||
{ |
|||
public class TextBoxEditorProvider : ITypeEditorProvider |
|||
{ |
|||
FrameworkElement _editor; |
|||
|
|||
public TextBoxEditorProvider() |
|||
{ |
|||
_editor = new TextBox(); |
|||
} |
|||
|
|||
public void Initialize(PropertyItem propertyItem) |
|||
{ |
|||
ResolveBinding(propertyItem); |
|||
} |
|||
|
|||
public FrameworkElement ResolveEditor() |
|||
{ |
|||
return _editor; |
|||
} |
|||
|
|||
private void ResolveBinding(PropertyItem property) |
|||
{ |
|||
var binding = new Binding(property.Name); |
|||
binding.Source = property.Instance; |
|||
binding.ValidatesOnExceptions = true; |
|||
binding.ValidatesOnDataErrors = true; |
|||
|
|||
if (property.IsWriteable) |
|||
binding.Mode = BindingMode.TwoWay; |
|||
else |
|||
binding.Mode = BindingMode.OneWay; |
|||
|
|||
BindingOperations.SetBinding(_editor, TextBox.TextProperty, binding); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
|||
{ |
|||
public class DateTimeUpDownEditor : TypeEditor<DateTimeUpDown> |
|||
{ |
|||
protected override void SetControlProperties() |
|||
{ |
|||
Editor.BorderThickness = new System.Windows.Thickness( 0 ); |
|||
} |
|||
protected override void SetValueDependencyProperty() |
|||
{ |
|||
ValueProperty = DateTimeUpDown.ValueProperty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
|||
{ |
|||
public class DecimalUpDownEditor : TypeEditor<DecimalUpDown> |
|||
{ |
|||
protected override void SetControlProperties() |
|||
{ |
|||
Editor.BorderThickness = new System.Windows.Thickness( 0 ); |
|||
} |
|||
|
|||
protected override void SetValueDependencyProperty() |
|||
{ |
|||
ValueProperty = DecimalUpDown.ValueProperty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
|||
{ |
|||
public class DoubleUpDownEditor : TypeEditor<DoubleUpDown> |
|||
{ |
|||
protected override void SetControlProperties() |
|||
{ |
|||
Editor.BorderThickness = new System.Windows.Thickness( 0 ); |
|||
} |
|||
|
|||
protected override void SetValueDependencyProperty() |
|||
{ |
|||
ValueProperty = DoubleUpDown.ValueProperty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
namespace Xceed.Wpf.Toolkit.PropertyGrid.Editors |
|||
{ |
|||
public class IntegerUpDownEditor : TypeEditor<IntegerUpDown> |
|||
{ |
|||
protected override void SetControlProperties() |
|||
{ |
|||
Editor.BorderThickness = new System.Windows.Thickness( 0 ); |
|||
} |
|||
protected override void SetValueDependencyProperty() |
|||
{ |
|||
ValueProperty = IntegerUpDown.ValueProperty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid.Editors |
|||
{ |
|||
public class NumericUpDownEditor : TypeEditor<NumericUpDown> |
|||
{ |
|||
protected override void SetValueDependencyProperty() |
|||
{ |
|||
ValueProperty = NumericUpDown.ValueProperty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid |
|||
{ |
|||
public interface IEditorDefinition |
|||
{ |
|||
DataTemplate EditorTemplate { get; set; } |
|||
PropertyDefinitionCollection PropertiesDefinitions { get; set; } |
|||
Type TargetType { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows.Controls; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.PropertyGrid |
|||
{ |
|||
public class PropertyCategoryItem : Control |
|||
{ |
|||
public static readonly DependencyProperty CategoryProperty = DependencyProperty.Register("Category", typeof(string), typeof(PropertyCategoryItem), new UIPropertyMetadata(String.Empty, new PropertyChangedCallback(OnCategoryChanged), new CoerceValueCallback(OnCoerceCategory))); |
|||
|
|||
private static object OnCoerceCategory(DependencyObject o, object value) |
|||
{ |
|||
PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; |
|||
if (propertyCategoryItem != null) |
|||
return propertyCategoryItem.OnCoerceCategory((string)value); |
|||
else |
|||
return value; |
|||
} |
|||
|
|||
private static void OnCategoryChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; |
|||
if (propertyCategoryItem != null) |
|||
propertyCategoryItem.OnCategoryChanged((string)e.OldValue, (string)e.NewValue); |
|||
} |
|||
|
|||
protected virtual string OnCoerceCategory(string value) |
|||
{ |
|||
// TODO: Keep the proposed value within the desired range.
|
|||
return value; |
|||
} |
|||
|
|||
protected virtual void OnCategoryChanged(string oldValue, string newValue) |
|||
{ |
|||
// TODO: Add your property changed side-effects. Descendants can override as well.
|
|||
} |
|||
|
|||
public string Category |
|||
{ |
|||
// IMPORTANT: To maintain parity between setting a property in XAML and procedural code, do not touch the getter and setter inside this dependency property!
|
|||
get |
|||
{ |
|||
return (string)GetValue(CategoryProperty); |
|||
} |
|||
set |
|||
{ |
|||
SetValue(CategoryProperty, value); |
|||
} |
|||
} |
|||
|
|||
|
|||
private List<PropertyItem> _Properties = new List<PropertyItem>(); |
|||
public List<PropertyItem> Properties |
|||
{ |
|||
get |
|||
{ |
|||
return _Properties; |
|||
} |
|||
set |
|||
{ |
|||
_Properties = value; |
|||
} |
|||
} |
|||
|
|||
|
|||
static PropertyCategoryItem() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyCategoryItem), new FrameworkPropertyMetadata(typeof(PropertyCategoryItem))); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,186 @@ |
|||
<UserControl x:Class="Microsoft.Windows.Controls.Formatting.FormatToolbar" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Background="Transparent" |
|||
IsTabStop="False" |
|||
x:Name="_window"> |
|||
<UserControl.Effect> |
|||
<DropShadowEffect BlurRadius="5" Opacity=".25" /> |
|||
</UserControl.Effect> |
|||
|
|||
<UserControl.Resources> |
|||
|
|||
<ControlTemplate x:Key="ThumbControlTemplate" TargetType="{x:Type Thumb}"> |
|||
<Border Background="Transparent" Cursor="Hand" ToolTip="Click to Drag"> |
|||
</Border> |
|||
</ControlTemplate> |
|||
|
|||
<Style TargetType="{x:Type Separator}" BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"/> |
|||
|
|||
<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> |
|||
|
|||
</UserControl.Resources> |
|||
|
|||
<Border CornerRadius="3" BorderThickness="1" BorderBrush="Gray" Background="WhiteSmoke"> |
|||
<Grid Margin="5,0,5,5"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition /> |
|||
<RowDefinition /> |
|||
</Grid.RowDefinitions> |
|||
|
|||
<Thumb x:Name="_dragWidget" Height="10" |
|||
Template="{StaticResource ThumbControlTemplate}" |
|||
DragDelta="DragWidget_DragDelta"/> |
|||
|
|||
<StackPanel Grid.Row="1"> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<ComboBox x:Name="_cmbFontFamilies" IsEditable="True" Width="110" |
|||
SelectionChanged="FontFamily_SelectionChanged"/> |
|||
<ComboBox x:Name="_cmbFontSizes" IsEditable="True" Width="45" |
|||
SelectionChanged="FontSize_SelectionChanged"/> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Horizontal" Margin="0,3,0,0"> |
|||
<ToggleButton x:Name="_btnBold" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}"> |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/Bold16.png" /> |
|||
</ToggleButton> |
|||
<ToggleButton x:Name="_btnItalic" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="{x:Static EditingCommands.ToggleItalic}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}"> |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/Italic16.png" /> |
|||
</ToggleButton> |
|||
<ToggleButton x:Name="_btnUnderline" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="{x:Static EditingCommands.ToggleUnderline}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}"> |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/Underline16.png" /> |
|||
</ToggleButton> |
|||
|
|||
<Separator /> |
|||
|
|||
<RadioButton x:Name="_btnAlignLeft" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="{x:Static EditingCommands.AlignLeft}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" > |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/LeftAlign16.png" /> |
|||
</RadioButton> |
|||
<RadioButton x:Name="_btnAlignCenter" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="{x:Static EditingCommands.AlignCenter}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" > |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/CenterAlign16.png" /> |
|||
</RadioButton> |
|||
<RadioButton x:Name="_btnAlignRight" Style="{StaticResource FormatBarToggleButtonStyle}" |
|||
Command="{x:Static EditingCommands.AlignRight}" CommandTarget="{Binding ElementName=_window, Path=RichTextBox}" > |
|||
<Image Source="/WPFToolkit.Extended;component/RichTextBox/FormatToolbar/Images/RightAlign16.png" /> |
|||
</RadioButton> |
|||
|
|||
</StackPanel> |
|||
|
|||
</StackPanel> |
|||
</Grid> |
|||
</Border> |
|||
</UserControl> |
|||
@ -0,0 +1,148 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls.Formatting |
|||
{ |
|||
/// <summary>
|
|||
/// Interaction logic for FormatToolbar.xaml
|
|||
/// </summary>
|
|||
public partial class FormatToolbar : UserControl |
|||
{ |
|||
#region Properties
|
|||
|
|||
public static readonly DependencyProperty RichTextBoxProperty = DependencyProperty.Register("RichTextBox", typeof(RichTextBox), typeof(FormatToolbar)); |
|||
public RichTextBox RichTextBox |
|||
{ |
|||
get { return (RichTextBox)GetValue(RichTextBoxProperty); } |
|||
set { SetValue(RichTextBoxProperty, value); } |
|||
} |
|||
|
|||
public 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
|
|||
|
|||
public FormatToolbar(RichTextBox richTextBox) |
|||
{ |
|||
InitializeComponent(); |
|||
Loaded += FormatToolbar_Loaded; |
|||
RichTextBox = richTextBox; |
|||
RichTextBox.SelectionChanged += RichTextBox_SelectionChanged; |
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Event Hanlders
|
|||
|
|||
void FormatToolbar_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
_cmbFontFamilies.ItemsSource = System.Windows.Media.Fonts.SystemFontFamilies; |
|||
_cmbFontSizes.ItemsSource = FontSizes; |
|||
} |
|||
|
|||
private void FontFamily_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|||
{ |
|||
if (e.AddedItems.Count == 0) |
|||
return; |
|||
|
|||
FontFamily editValue = (FontFamily)e.AddedItems[0]; |
|||
ApplyPropertyValueToSelectedText(TextElement.FontFamilyProperty, editValue); |
|||
} |
|||
|
|||
private void FontSize_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|||
{ |
|||
if (e.AddedItems.Count == 0) |
|||
return; |
|||
|
|||
ApplyPropertyValueToSelectedText(TextElement.FontSizeProperty, e.AddedItems[0]); |
|||
} |
|||
|
|||
void RichTextBox_SelectionChanged(object sender, RoutedEventArgs e) |
|||
{ |
|||
UpdateVisualState(); |
|||
} |
|||
|
|||
private void DragWidget_DragDelta(object sender, DragDeltaEventArgs e) |
|||
{ |
|||
ProcessMove(e); |
|||
} |
|||
|
|||
#endregion //Event Hanlders
|
|||
|
|||
#region Methods
|
|||
|
|||
private void UpdateVisualState() |
|||
{ |
|||
UpdateToggleButtonState(); |
|||
UpdateSelectedFontFamily(); |
|||
UpdateSelectedFontSize(); |
|||
} |
|||
|
|||
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 = RichTextBox.Selection.GetPropertyValue(formattingProperty); |
|||
button.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != null && currentValue.Equals(expectedValue); |
|||
} |
|||
|
|||
private void UpdateSelectedFontFamily() |
|||
{ |
|||
object value = RichTextBox.Selection.GetPropertyValue(TextElement.FontFamilyProperty); |
|||
FontFamily currentFontFamily = (FontFamily)((value == DependencyProperty.UnsetValue) ? null : value); |
|||
if (currentFontFamily != null) |
|||
{ |
|||
_cmbFontFamilies.SelectedItem = currentFontFamily; |
|||
} |
|||
} |
|||
|
|||
private void UpdateSelectedFontSize() |
|||
{ |
|||
object value = RichTextBox.Selection.GetPropertyValue(TextElement.FontSizeProperty); |
|||
_cmbFontSizes.SelectedValue = (value == DependencyProperty.UnsetValue) ? null : value; |
|||
} |
|||
|
|||
void ApplyPropertyValueToSelectedText(DependencyProperty formattingProperty, object value) |
|||
{ |
|||
if (value == null) |
|||
return; |
|||
|
|||
RichTextBox.Selection.ApplyPropertyValue(formattingProperty, value); |
|||
} |
|||
|
|||
private void ProcessMove(DragDeltaEventArgs e) |
|||
{ |
|||
AdornerLayer layer = AdornerLayer.GetAdornerLayer(RichTextBox); |
|||
UIElementAdorner<Control> adorner = layer.GetAdorners(RichTextBox)[0] as UIElementAdorner<Control>; |
|||
adorner.SetOffsets(adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange); |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,107 @@ |
|||
using System; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Documents; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls.Formatting |
|||
{ |
|||
internal class FormatToolbarManager |
|||
{ |
|||
RichTextBox _richTextBox; |
|||
readonly UIElementAdorner<Control> _adorner; |
|||
FormatToolbar toolbar; |
|||
|
|||
bool AdornerIsVisible |
|||
{ |
|||
get { return _adorner.Visibility == Visibility.Visible; } |
|||
} |
|||
|
|||
public FormatToolbarManager(RichTextBox richTextBox) |
|||
{ |
|||
_richTextBox = richTextBox; |
|||
_adorner = new UIElementAdorner<Control>(richTextBox); |
|||
toolbar = new FormatToolbar(richTextBox); |
|||
AttachToRichtextBox(); |
|||
} |
|||
|
|||
private void AttachToRichtextBox() |
|||
{ |
|||
_richTextBox.Selection.Changed += Selection_Changed; |
|||
} |
|||
|
|||
void Selection_Changed(object sender, EventArgs e) |
|||
{ |
|||
TextRange selectedText = new TextRange(_richTextBox.Selection.Start, _richTextBox.Selection.End); |
|||
if (selectedText.Text.Length > 0) |
|||
{ |
|||
VerifyAdorner(); |
|||
} |
|||
else |
|||
{ |
|||
HideAdorner(); |
|||
} |
|||
} |
|||
|
|||
//TODO: refactor
|
|||
void VerifyAdorner() |
|||
{ |
|||
VerifyAdornerLayer(); |
|||
|
|||
Control adorningEditor = toolbar; |
|||
_adorner.Child = adorningEditor; |
|||
_adorner.Visibility = Visibility.Visible; |
|||
|
|||
Rect wordBoundary = _richTextBox.Selection.End.GetPositionAtOffset(0, LogicalDirection.Backward).GetCharacterRect(LogicalDirection.Backward); |
|||
|
|||
double left = wordBoundary.X; |
|||
double top = (wordBoundary.Y + wordBoundary.Height) - toolbar.ActualHeight; |
|||
|
|||
//top boundary
|
|||
if (top < 0) |
|||
{ |
|||
top = wordBoundary.Y + wordBoundary.Height; |
|||
} |
|||
|
|||
//right boundary
|
|||
if (left + toolbar.ActualWidth > _richTextBox.ActualWidth - 20) |
|||
{ |
|||
left = left - toolbar.ActualWidth; |
|||
top = wordBoundary.Y + wordBoundary.Height + 5; |
|||
} |
|||
|
|||
//bottom boundary
|
|||
if (top + toolbar.ActualHeight > _richTextBox.ActualHeight - 20) |
|||
{ |
|||
top = wordBoundary.Y - (toolbar.ActualHeight + wordBoundary.Height); |
|||
} |
|||
|
|||
_adorner.SetOffsets(left, top); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Ensures that the adorner is in the adorner layer.
|
|||
/// </summary>
|
|||
/// <returns>True if the adorner 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; |
|||
} |
|||
|
|||
void HideAdorner() |
|||
{ |
|||
if (this.AdornerIsVisible) |
|||
{ |
|||
_adorner.Visibility = Visibility.Collapsed; |
|||
_adorner.Child = null; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
Before Width: | Height: | Size: 175 B After Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
|
Before Width: | Height: | Size: 169 B After Width: | Height: | Size: 169 B |
|
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
|
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 197 B After Width: | Height: | Size: 197 B |
@ -0,0 +1,60 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
|
|||
<ResourceDictionary.MergedDictionaries> |
|||
<ResourceDictionary Source="Brushes.xaml" /> |
|||
</ResourceDictionary.MergedDictionaries> |
|||
|
|||
<DataTemplate x:Key="IncreaseGlyphKey"> |
|||
<Path |
|||
Width="7" |
|||
Height="4" |
|||
Data="M 0,3 C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 3,3 4,3 4,3 4,3 4,4 4,4 4,4 7,4 7,4 7,4 7,3 7,3 7,3 6,3 6,3 6,3 6,2 6,2 6,2 5,2 5,2 5,2 5,1 5,1 5,1 4,1 4,1 4,1 4,0 4,0 4,0 3,0 3,0 3,0 3,1 3,1 3,1 2,1 2,1 2,1 2,2 2,2 2,2 1,2 1,2 1,2 1,3 1,3 1,3 0,3 0,3 z" |
|||
Fill="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}" |
|||
SnapsToDevicePixels="True" |
|||
HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" /> |
|||
</DataTemplate> |
|||
|
|||
<DataTemplate x:Key="DecreaseGlyphKey"> |
|||
<Path |
|||
Width="7" |
|||
Height="4" |
|||
Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" |
|||
Fill="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}" |
|||
SnapsToDevicePixels="True" |
|||
HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" /> |
|||
</DataTemplate> |
|||
|
|||
<Style x:Key="SpinnerButtonStyle" TargetType="RepeatButton"> |
|||
<Setter Property="Background" Value="Transparent"/> |
|||
<Setter Property="BorderBrush" Value="Transparent"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Foreground" Value="{StaticResource DropdownBtnGlyphNormalForegroundFillKey}"/> |
|||
<Setter Property="Padding" Value="4,2"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="RepeatButton"> |
|||
<Border x:Name="Bd" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" CornerRadius="{StaticResource SpinButtonCornerRadiusKey}" > |
|||
<Grid> |
|||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/> |
|||
</Grid> |
|||
</Border> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsMouseOver" Value="True"> |
|||
<Setter Property="Background" TargetName="Bd" Value="{StaticResource DropdownBtnHottrackCenterFillKey}"/> |
|||
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource DropdownBtnHottrackOuterBorderFillKey}"/> |
|||
</Trigger> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource DropdownBtnPressedOuterBorderFillKey}"/> |
|||
<Setter Property="Background" TargetName="Bd" Value="{StaticResource DropdownBtnPressedCenterFillKey}"/> |
|||
</Trigger> |
|||
<Trigger Property="IsEnabled" Value="False"> |
|||
<Setter Property="Background" TargetName="Bd" Value="{StaticResource ControlDisabledBackgroundKey}" /> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,135 @@ |
|||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
|||
xmlns:local="clr-namespace:Microsoft.Windows.Controls" |
|||
xmlns:primitives="clr-namespace:Microsoft.Windows.Controls.Primitives" |
|||
xmlns:coreConverters="clr-namespace:Microsoft.Windows.Controls.Core.Converters" |
|||
xmlns:magConverters="clr-namespace:Microsoft.Windows.Controls.Mag.Converters" |
|||
xmlns:chrome="clr-namespace:Microsoft.Windows.Controls.Chromes"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- Common Styles --> |
|||
<!-- Need to find a way to share these for ChildWIndow and MessageBox --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<LinearGradientBrush x:Key="WindowDarkBrush" EndPoint="0.5,1" StartPoint="0.5,0"> |
|||
<GradientStop Color="#FFA3AEB9" Offset="0"/> |
|||
<GradientStop Color="#FF8399A9" Offset="0.375"/> |
|||
<GradientStop Color="#FF718597" Offset="0.375"/> |
|||
<GradientStop Color="#FF617584" Offset="1"/> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="WindowBackgroundBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFffffff"/> |
|||
<GradientStop Offset="0.479" Color="#FFf4f5f6"/> |
|||
<GradientStop Offset="1" Color="#FFd0d6db"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="WindowButtonHoverBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FFb5bdc8"/> |
|||
<GradientStop Offset="0.370" Color="#FF8399a9"/> |
|||
<GradientStop Offset="0.370" Color="#FF718597"/> |
|||
<GradientStop Offset="0.906" Color="#FFb9c1ca"/> |
|||
<GradientStop Offset="1" Color="#FFb9c1ca"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<LinearGradientBrush x:Key="WindowButtonPressedBrush" StartPoint="0,0" EndPoint="0,1"> |
|||
<LinearGradientBrush.GradientStops> |
|||
<GradientStopCollection> |
|||
<GradientStop Offset="0" Color="#FF6b7c8d"/> |
|||
<GradientStop Offset="0.370" Color="#FF4d606f"/> |
|||
<GradientStop Offset="0.370" Color="#FF465460"/> |
|||
<GradientStop Offset="0.906" Color="#FF262d33"/> |
|||
<GradientStop Offset="1" Color="#FF262d33"/> |
|||
</GradientStopCollection> |
|||
</LinearGradientBrush.GradientStops> |
|||
</LinearGradientBrush> |
|||
|
|||
<Style x:Key="WindowCloseButtonStyle" TargetType="Button"> |
|||
<Setter Property="Foreground" Value="#FF000000"/> |
|||
<Setter Property="Padding" Value="3"/> |
|||
<Setter Property="BorderThickness" Value="1"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="Button"> |
|||
<Grid> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="CommonStates"> |
|||
<VisualState x:Name="Normal"/> |
|||
<VisualState x:Name="MouseOver"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource WindowButtonHoverBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Pressed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)"> |
|||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource WindowButtonPressedBrush}"></DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
<Border x:Name="Background" CornerRadius="0,0,2,0" Background="{StaticResource WindowDarkBrush}"> |
|||
<Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/> |
|||
</Border> |
|||
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> |
|||
<Path x:Name="path" |
|||
Height="6" |
|||
Width="7" |
|||
Stretch="Fill" |
|||
Opacity="1" |
|||
Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z" |
|||
Fill="White" Margin="0,0,0,1" Visibility="Collapsed" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- SelectorItem --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<Style TargetType="{x:Type primitives:SelectorItem}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type primitives:SelectorItem}"> |
|||
<Border x:Name="_background" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="Auto"/> |
|||
<ColumnDefinition Width="*" /> |
|||
</Grid.ColumnDefinitions> |
|||
<CheckBox Name="PART_CheckBox" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Center" Focusable="False" Margin="3,1,5,1"/> |
|||
<Border Grid.Column="1"> |
|||
<ContentPresenter Margin="2" ContentSource="Content" /> |
|||
</Border> |
|||
</Grid> |
|||
</Border> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsMouseOver" Value="true"> |
|||
<Setter TargetName="_background" Property="Background" Value="Blue"/> |
|||
<Setter Property="Foreground" Value="White"/> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
|
After Width: | Height: | Size: 312 B |
@ -0,0 +1,55 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
using System; |
|||
|
|||
namespace Xceed.Wpf.Toolkit |
|||
{ |
|||
internal class Token |
|||
{ |
|||
public string Delimiter |
|||
{ |
|||
get; |
|||
private set; |
|||
} |
|||
public object Item |
|||
{ |
|||
get; |
|||
set; |
|||
} |
|||
|
|||
private string _tokenKey; |
|||
public string TokenKey |
|||
{ |
|||
get |
|||
{ |
|||
return _tokenKey; |
|||
} |
|||
set |
|||
{ |
|||
_tokenKey = String.Format( "{0}{1}", value, Delimiter ); |
|||
} |
|||
} |
|||
|
|||
public Token( string delimiter ) |
|||
{ |
|||
Delimiter = delimiter; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace Xceed.Wpf.Toolkit |
|||
{ |
|||
public class TokenItem : ContentControl |
|||
{ |
|||
static TokenItem() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata( typeof( TokenItem ), new FrameworkPropertyMetadata( typeof( TokenItem ) ) ); |
|||
} |
|||
|
|||
public static readonly DependencyProperty TokenKeyProperty = DependencyProperty.Register( "TokenKey", typeof( string ), typeof( TokenItem ), new UIPropertyMetadata( null ) ); |
|||
public string TokenKey |
|||
{ |
|||
get |
|||
{ |
|||
return ( string )GetValue( TokenKeyProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( TokenKeyProperty, value ); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,394 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
//Based of the code written by Pavan Podila
|
|||
//http://blog.pixelingene.com/2010/10/tokenizing-control-convert-text-to-tokens/
|
|||
|
|||
using System; |
|||
using System.Linq; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
|
|||
namespace Xceed.Wpf.Toolkit |
|||
{ |
|||
public class TokenizedTextBox : ItemsControl |
|||
{ |
|||
#region Members
|
|||
|
|||
private System.Windows.Controls.RichTextBox _rtb = null; |
|||
private bool _surpressTextChanged = false; |
|||
private bool _surpressTextChangedEvent = false; |
|||
|
|||
#endregion //Members
|
|||
|
|||
#region Properties
|
|||
|
|||
public static readonly DependencyProperty SearchMemberPathProperty = DependencyProperty.Register( "SearchMemberPath", typeof( string ), typeof( TokenizedTextBox ), new UIPropertyMetadata( String.Empty ) ); |
|||
public string SearchMemberPath |
|||
{ |
|||
get |
|||
{ |
|||
return ( string )GetValue( SearchMemberPathProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( SearchMemberPathProperty, value ); |
|||
} |
|||
} |
|||
|
|||
public static readonly DependencyProperty TokenDelimiterProperty = DependencyProperty.Register( "TokenDelimiter", typeof( string ), typeof( TokenizedTextBox ), new UIPropertyMetadata( ";" ) ); |
|||
public string TokenDelimiter |
|||
{ |
|||
get |
|||
{ |
|||
return ( string )GetValue( TokenDelimiterProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( TokenDelimiterProperty, value ); |
|||
} |
|||
} |
|||
|
|||
public static readonly DependencyProperty TokenTemplateProperty = DependencyProperty.Register( "TokenTemplate", typeof( DataTemplate ), typeof( TokenizedTextBox ), new UIPropertyMetadata( null ) ); |
|||
public DataTemplate TokenTemplate |
|||
{ |
|||
get |
|||
{ |
|||
return ( DataTemplate )GetValue( TokenTemplateProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( TokenTemplateProperty, value ); |
|||
} |
|||
} |
|||
|
|||
#region Text
|
|||
|
|||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof( string ), typeof( TokenizedTextBox ), new UIPropertyMetadata( null, OnTextChanged ) ); |
|||
public string Text |
|||
{ |
|||
get |
|||
{ |
|||
return ( string )GetValue( TextProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( TextProperty, value ); |
|||
} |
|||
} |
|||
|
|||
private static void OnTextChanged( DependencyObject o, DependencyPropertyChangedEventArgs e ) |
|||
{ |
|||
TokenizedTextBox tokenizedTextBox = o as TokenizedTextBox; |
|||
if( tokenizedTextBox != null ) |
|||
tokenizedTextBox.OnTextChanged( ( string )e.OldValue, ( string )e.NewValue ); |
|||
} |
|||
|
|||
protected virtual void OnTextChanged( string oldValue, string newValue ) |
|||
{ |
|||
if( _rtb == null || _surpressTextChanged ) |
|||
return; |
|||
|
|||
//TODO: when text changes update tokens
|
|||
} |
|||
|
|||
#endregion //Text
|
|||
|
|||
public static readonly DependencyProperty ValueMemberPathProperty = DependencyProperty.Register( "ValueMemberPath", typeof( string ), typeof( TokenizedTextBox ), new UIPropertyMetadata( String.Empty ) ); |
|||
public string ValueMemberPath |
|||
{ |
|||
get |
|||
{ |
|||
return ( string )GetValue( ValueMemberPathProperty ); |
|||
} |
|||
set |
|||
{ |
|||
SetValue( ValueMemberPathProperty, value ); |
|||
} |
|||
} |
|||
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Constructors
|
|||
|
|||
static TokenizedTextBox() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata( typeof( TokenizedTextBox ), new FrameworkPropertyMetadata( typeof( TokenizedTextBox ) ) ); |
|||
} |
|||
|
|||
public TokenizedTextBox() |
|||
{ |
|||
CommandBindings.Add( new CommandBinding( TokenizedTextBoxCommands.Delete, DeleteToken ) ); |
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
if( _rtb != null ) |
|||
{ |
|||
_rtb.TextChanged -= RichTextBox_TextChanged; |
|||
_rtb.PreviewKeyDown -= RichTextBox_PreviewKeyDown; |
|||
} |
|||
_rtb = GetTemplateChild( "PART_ContentHost" ) as System.Windows.Controls.RichTextBox; |
|||
if( _rtb != null ) |
|||
{ |
|||
_rtb.TextChanged += RichTextBox_TextChanged; |
|||
_rtb.PreviewKeyDown += RichTextBox_PreviewKeyDown; |
|||
} |
|||
|
|||
InitializeTokensFromText(); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
private void RichTextBox_TextChanged( object sender, TextChangedEventArgs e ) |
|||
{ |
|||
if( _surpressTextChangedEvent ) |
|||
return; |
|||
|
|||
var text = _rtb.CaretPosition.GetTextInRun( LogicalDirection.Backward ); |
|||
var token = ResolveToken( text ); |
|||
if( token != null ) |
|||
{ |
|||
ReplaceTextWithToken( text.Trim(), token ); |
|||
} |
|||
} |
|||
|
|||
void RichTextBox_PreviewKeyDown( object sender, KeyEventArgs e ) |
|||
{ |
|||
InlineUIContainer container = null; |
|||
|
|||
if( e.Key == Key.Back ) |
|||
{ |
|||
container = _rtb.CaretPosition.GetAdjacentElement( LogicalDirection.Backward ) as InlineUIContainer; |
|||
} |
|||
else if( e.Key == Key.Delete ) |
|||
{ |
|||
//if the selected text is a blank space, I will assume that a token item is selected.
|
|||
//if a token item is selected, we need to move the caret position to the left of the element so we can grab the InlineUIContainer
|
|||
if( _rtb.Selection.Text == " " ) |
|||
{ |
|||
TextPointer moveTo = _rtb.CaretPosition.GetNextInsertionPosition( LogicalDirection.Backward ); |
|||
_rtb.CaretPosition = moveTo; |
|||
} |
|||
|
|||
//the cursor is to the left of a token item
|
|||
container = _rtb.CaretPosition.GetAdjacentElement( LogicalDirection.Forward ) as InlineUIContainer; |
|||
} |
|||
|
|||
//if the container is not null that means we have something to delete
|
|||
if( container != null ) |
|||
{ |
|||
var token = ( container as InlineUIContainer ).Child as TokenItem; |
|||
if( token != null ) |
|||
{ |
|||
SetTextInternal( Text.Replace( token.TokenKey, "" ) ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
|
|||
#region Methods
|
|||
|
|||
private void InitializeTokensFromText() |
|||
{ |
|||
if( !String.IsNullOrEmpty( Text ) ) |
|||
{ |
|||
string[] tokenKeys = Text.Split( new string[] { TokenDelimiter }, StringSplitOptions.RemoveEmptyEntries ); |
|||
foreach( string tokenKey in tokenKeys ) |
|||
{ |
|||
var para = _rtb.CaretPosition.Paragraph; |
|||
var token = new Token( TokenDelimiter ) |
|||
{ |
|||
TokenKey = tokenKey, |
|||
Item = ResolveItemByTokenKey( tokenKey ) |
|||
}; |
|||
para.Inlines.Add( CreateTokenContainer( token ) ); |
|||
} |
|||
} |
|||
} |
|||
|
|||
private Token ResolveToken( string text ) |
|||
{ |
|||
if( text.EndsWith( TokenDelimiter ) ) |
|||
return ResolveTokenBySearchMemberPath( text.Substring( 0, text.Length - 1 ).Trim() ); |
|||
|
|||
return null; |
|||
} |
|||
|
|||
private Token ResolveTokenBySearchMemberPath( string searchText ) |
|||
{ |
|||
//create a new token and default the settings to the search text
|
|||
var token = new Token( TokenDelimiter ) |
|||
{ |
|||
TokenKey = searchText, |
|||
Item = searchText |
|||
}; |
|||
|
|||
if( ItemsSource != null ) |
|||
{ |
|||
foreach( object item in ItemsSource ) |
|||
{ |
|||
var searchProperty = item.GetType().GetProperty( SearchMemberPath ); |
|||
if( searchProperty != null ) |
|||
{ |
|||
var searchValue = searchProperty.GetValue( item, null ); |
|||
if( searchText.Equals( searchValue.ToString(), StringComparison.InvariantCultureIgnoreCase ) ) |
|||
{ |
|||
var valueProperty = item.GetType().GetProperty( ValueMemberPath ); |
|||
if( valueProperty != null ) |
|||
token.TokenKey = valueProperty.GetValue( item, null ).ToString(); |
|||
|
|||
token.Item = item; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
return token; |
|||
} |
|||
|
|||
private object ResolveItemByTokenKey( string tokenKey ) |
|||
{ |
|||
if( ItemsSource != null ) |
|||
{ |
|||
foreach( object item in ItemsSource ) |
|||
{ |
|||
var property = item.GetType().GetProperty( ValueMemberPath ); |
|||
if( property != null ) |
|||
{ |
|||
var value = property.GetValue( item, null ); |
|||
if( tokenKey.Equals( value.ToString(), StringComparison.InvariantCultureIgnoreCase ) ) |
|||
return item; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return tokenKey; |
|||
} |
|||
|
|||
private void ReplaceTextWithToken( string inputText, Token token ) |
|||
{ |
|||
_surpressTextChangedEvent = true; |
|||
|
|||
var para = _rtb.CaretPosition.Paragraph; |
|||
|
|||
var matchedRun = para.Inlines.FirstOrDefault( inline => |
|||
{ |
|||
var run = inline as Run; |
|||
return ( run != null && run.Text.EndsWith( inputText ) ); |
|||
} ) as Run; |
|||
|
|||
if( matchedRun != null ) // Found a Run that matched the inputText
|
|||
{ |
|||
var tokenContainer = CreateTokenContainer( token ); |
|||
para.Inlines.InsertBefore( matchedRun, tokenContainer ); |
|||
|
|||
// Remove only if the Text in the Run is the same as inputText, else split up
|
|||
if( matchedRun.Text == inputText ) |
|||
{ |
|||
para.Inlines.Remove( matchedRun ); |
|||
} |
|||
else // Split up
|
|||
{ |
|||
var index = matchedRun.Text.IndexOf( inputText ) + inputText.Length; |
|||
var tailEnd = new Run( matchedRun.Text.Substring( index ) ); |
|||
para.Inlines.InsertAfter( matchedRun, tailEnd ); |
|||
para.Inlines.Remove( matchedRun ); |
|||
} |
|||
|
|||
//now append the Text with the token key
|
|||
SetTextInternal( Text + token.TokenKey ); |
|||
} |
|||
|
|||
_surpressTextChangedEvent = false; |
|||
} |
|||
|
|||
private InlineUIContainer CreateTokenContainer( Token token ) |
|||
{ |
|||
return new InlineUIContainer( CreateTokenItem( token ) ) |
|||
{ |
|||
BaselineAlignment = BaselineAlignment.Center |
|||
}; |
|||
} |
|||
|
|||
private TokenItem CreateTokenItem( Token token ) |
|||
{ |
|||
object item = token.Item; |
|||
|
|||
var tokenItem = new TokenItem() |
|||
{ |
|||
TokenKey = token.TokenKey, |
|||
Content = item, |
|||
ContentTemplate = TokenTemplate |
|||
}; |
|||
|
|||
if( TokenTemplate == null ) |
|||
{ |
|||
//if no template was supplied let's try to get a value from the object using the DisplayMemberPath
|
|||
if( !String.IsNullOrEmpty( DisplayMemberPath ) ) |
|||
{ |
|||
var property = item.GetType().GetProperty( DisplayMemberPath ); |
|||
if( property != null ) |
|||
{ |
|||
var value = property.GetValue( item, null ); |
|||
if( value != null ) |
|||
tokenItem.Content = value; |
|||
} |
|||
} |
|||
} |
|||
|
|||
return tokenItem; |
|||
} |
|||
|
|||
private void DeleteToken( object sender, ExecutedRoutedEventArgs e ) |
|||
{ |
|||
var para = _rtb.CaretPosition.Paragraph; |
|||
|
|||
Inline inlineToRemove = para.Inlines.Where( inline => inline is InlineUIContainer && ( ( inline as InlineUIContainer ).Child as TokenItem ).TokenKey.Equals( e.Parameter ) ).FirstOrDefault(); |
|||
|
|||
if( inlineToRemove != null ) |
|||
para.Inlines.Remove( inlineToRemove ); |
|||
|
|||
//update Text to remove delimited value
|
|||
SetTextInternal( Text.Replace( e.Parameter.ToString(), "" ) ); |
|||
} |
|||
|
|||
private void SetTextInternal( string text ) |
|||
{ |
|||
_surpressTextChanged = true; |
|||
Text = text; |
|||
_surpressTextChanged = false; |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
/************************************************************************ |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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
|
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter.
|
|||
|
|||
**********************************************************************/ |
|||
|
|||
using System.Windows.Input; |
|||
|
|||
namespace Xceed.Wpf.Toolkit |
|||
{ |
|||
public static class TokenizedTextBoxCommands |
|||
{ |
|||
private static RoutedCommand _deleteCommand = new RoutedCommand(); |
|||
|
|||
public static RoutedCommand Delete |
|||
{ |
|||
get |
|||
{ |
|||
return _deleteCommand; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
<!--********************************************************************* |
|||
|
|||
Extended WPF Toolkit |
|||
|
|||
Copyright (C) 2010-2012 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 |
|||
|
|||
This program can be provided to you by Xceed Software Inc. under a |
|||
proprietary commercial license agreement for use in non-Open Source |
|||
projects. The commercial version of Extended WPF Toolkit also includes |
|||
priority technical support, commercial updates, and many additional |
|||
useful WPF controls if you license Xceed Business Suite for WPF. |
|||
|
|||
Visit http://xceed.com and follow @datagrid on Twitter. |
|||
|
|||
********************************************************************--> |
|||
<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"> |
|||
|
|||
<Style TargetType="{x:Type local:TokenItem}"> |
|||
<Setter Property="Background" Value="#F3F7FD" /> |
|||
<Setter Property="BorderBrush" Value="#BBD8FB" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="Cursor" Value="Arrow" /> |
|||
<Setter Property="Padding" Value="5,1,5,1" /> |
|||
<Setter Property="Margin" Value="1,0" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:TokenItem}"> |
|||
<Border Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
Padding="{TemplateBinding Padding}" |
|||
Margin="{TemplateBinding Margin}"> |
|||
<StackPanel Orientation="Horizontal" Margin="1"> |
|||
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" /> |
|||
<Button Margin="3,0,0,0" Cursor="Hand" Command="local:TokenizedTextBoxCommands.Delete" CommandParameter="{TemplateBinding TokenKey}"> |
|||
<Button.Template> |
|||
<ControlTemplate TargetType="Button"> |
|||
<ContentPresenter /> |
|||
</ControlTemplate> |
|||
</Button.Template> |
|||
<Image Source="/WPFToolkit.Extended;component/TokenizedTextBox/Images/delete8.png" Width="8" Height="8" /> |
|||
</Button> |
|||
</StackPanel> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style TargetType="{x:Type local:TokenizedTextBox}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type local:TokenizedTextBox}"> |
|||
<Border x:Name="Bd" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}"> |
|||
<Grid> |
|||
<RichTextBox x:Name="PART_ContentHost" AcceptsReturn="False" IsDocumentEnabled="True" Padding="-3,0,0,0" /> |
|||
<!--<Popup> |
|||
<Grid Background="White"> |
|||
<ItemsPresenter /> |
|||
</Grid> |
|||
</Popup>--> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
</ResourceDictionary> |
|||
@ -0,0 +1,10 @@ |
|||
"" |
|||
{ |
|||
"FILE_VERSION" = "9237" |
|||
"ENLISTMENT_CHOICE" = "NEVER" |
|||
"PROJECT_FILE_RELATIVE_PATH" = "" |
|||
"NUMBER_OF_EXCLUDED_FILES" = "0" |
|||
"ORIGINAL_PROJECT_FILE_PATH" = "" |
|||
"NUMBER_OF_NESTED_PROJECTS" = "0" |
|||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" |
|||
} |
|||
|
Before Width: | Height: | Size: 682 B After Width: | Height: | Size: 682 B |