31 changed files with 3507 additions and 0 deletions
@ -0,0 +1,29 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00 |
|||
# Visual Studio 2008 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFToolkit.Extended", "Src\WPFToolkit.Extended\WPFToolkit.Extended.csproj", "{72E591D6-8F83-4D8C-8F67-9C325E623234}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(TeamFoundationVersionControl) = preSolution |
|||
SccNumberOfProjects = 2 |
|||
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} |
|||
SccTeamFoundationServer = https://tfs.codeplex.com/tfs/TFS02 |
|||
SccLocalPath0 = . |
|||
SccProjectUniqueName1 = Src\\WPFToolkit.Extended\\WPFToolkit.Extended.csproj |
|||
SccProjectName1 = Src/WPFToolkit.Extended |
|||
SccLocalPath1 = Src\\WPFToolkit.Extended |
|||
EndGlobalSection |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
EndGlobal |
|||
@ -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" = "PROJECT" |
|||
} |
|||
@ -0,0 +1,266 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Shapes; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// A control to provide a visual indicator when an application is busy.
|
|||
/// </summary>
|
|||
[TemplateVisualState(Name = VisualStates.StateIdle, GroupName = VisualStates.GroupBusyStatus)] |
|||
[TemplateVisualState(Name = VisualStates.StateBusy, GroupName = VisualStates.GroupBusyStatus)] |
|||
[TemplateVisualState(Name = VisualStates.StateVisible, GroupName = VisualStates.GroupVisibility)] |
|||
[TemplateVisualState(Name = VisualStates.StateHidden, GroupName = VisualStates.GroupVisibility)] |
|||
[StyleTypedProperty(Property = "OverlayStyle", StyleTargetType = typeof(Rectangle))] |
|||
[StyleTypedProperty(Property = "ProgressBarStyle", StyleTargetType = typeof(ProgressBar))] |
|||
public class BusyIndicator : ContentControl |
|||
{ |
|||
#region Private Members
|
|||
|
|||
/// <summary>
|
|||
/// Timer used to delay the initial display and avoid flickering.
|
|||
/// </summary>
|
|||
private DispatcherTimer _displayAfterTimer = new DispatcherTimer(); |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static BusyIndicator() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(BusyIndicator), new FrameworkPropertyMetadata(typeof(BusyIndicator))); |
|||
} |
|||
|
|||
public BusyIndicator() |
|||
{ |
|||
_displayAfterTimer.Tick += DisplayAfterTimerElapsed; |
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
/// <summary>
|
|||
/// Overrides the OnApplyTemplate method.
|
|||
/// </summary>
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
ChangeVisualState(false); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Properties
|
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the BusyContent is visible.
|
|||
/// </summary>
|
|||
protected bool IsContentVisible { get; set; } |
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
#region IsBusy
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the IsBusy dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register( |
|||
"IsBusy", |
|||
typeof(bool), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(false, new PropertyChangedCallback(OnIsBusyChanged))); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the busy indicator should show.
|
|||
/// </summary>
|
|||
public bool IsBusy |
|||
{ |
|||
get { return (bool)GetValue(IsBusyProperty); } |
|||
set { SetValue(IsBusyProperty, value); } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// IsBusyProperty property changed handler.
|
|||
/// </summary>
|
|||
/// <param name="d">BusyIndicator that changed its IsBusy.</param>
|
|||
/// <param name="e">Event arguments.</param>
|
|||
private static void OnIsBusyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
((BusyIndicator)d).OnIsBusyChanged(e); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// IsBusyProperty property changed handler.
|
|||
/// </summary>
|
|||
/// <param name="e">Event arguments.</param>
|
|||
protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
if (IsBusy) |
|||
{ |
|||
if (DisplayAfter.Equals(TimeSpan.Zero)) |
|||
{ |
|||
// Go visible now
|
|||
IsContentVisible = true; |
|||
} |
|||
else |
|||
{ |
|||
// Set a timer to go visible
|
|||
_displayAfterTimer.Interval = DisplayAfter; |
|||
_displayAfterTimer.Start(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
// No longer visible
|
|||
_displayAfterTimer.Stop(); |
|||
IsContentVisible = false; |
|||
} |
|||
|
|||
ChangeVisualState(true); |
|||
} |
|||
|
|||
#endregion //IsBusy
|
|||
|
|||
#region Busy Content
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the BusyContent dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty BusyContentProperty = DependencyProperty.Register( |
|||
"BusyContent", |
|||
typeof(object), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(null)); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating the busy content to display to the user.
|
|||
/// </summary>
|
|||
public object BusyContent |
|||
{ |
|||
get { return (object)GetValue(BusyContentProperty); } |
|||
set { SetValue(BusyContentProperty, value); } |
|||
} |
|||
|
|||
#endregion //Busy Content
|
|||
|
|||
#region Busy Content Template
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the BusyTemplate dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty BusyContentTemplateProperty = DependencyProperty.Register( |
|||
"BusyContentTemplate", |
|||
typeof(DataTemplate), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(null)); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating the template to use for displaying the busy content to the user.
|
|||
/// </summary>
|
|||
public DataTemplate BusyContentTemplate |
|||
{ |
|||
get { return (DataTemplate)GetValue(BusyContentTemplateProperty); } |
|||
set { SetValue(BusyContentTemplateProperty, value); } |
|||
} |
|||
|
|||
#endregion //Busy Content Template
|
|||
|
|||
#region Display After
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the DisplayAfter dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty DisplayAfterProperty = DependencyProperty.Register( |
|||
"DisplayAfter", |
|||
typeof(TimeSpan), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(TimeSpan.FromSeconds(0.1))); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating how long to delay before displaying the busy content.
|
|||
/// </summary>
|
|||
public TimeSpan DisplayAfter |
|||
{ |
|||
get { return (TimeSpan)GetValue(DisplayAfterProperty); } |
|||
set { SetValue(DisplayAfterProperty, value); } |
|||
} |
|||
|
|||
#endregion //Display After
|
|||
|
|||
#region Overlay Style
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the OverlayStyle dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty OverlayStyleProperty = DependencyProperty.Register( |
|||
"OverlayStyle", |
|||
typeof(Style), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(null)); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating the style to use for the overlay.
|
|||
/// </summary>
|
|||
public Style OverlayStyle |
|||
{ |
|||
get { return (Style)GetValue(OverlayStyleProperty); } |
|||
set { SetValue(OverlayStyleProperty, value); } |
|||
} |
|||
#endregion //Overlay Style
|
|||
|
|||
#region ProgressBar Style
|
|||
|
|||
/// <summary>
|
|||
/// Identifies the ProgressBarStyle dependency property.
|
|||
/// </summary>
|
|||
public static readonly DependencyProperty ProgressBarStyleProperty = DependencyProperty.Register( |
|||
"ProgressBarStyle", |
|||
typeof(Style), |
|||
typeof(BusyIndicator), |
|||
new PropertyMetadata(null)); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating the style to use for the progress bar.
|
|||
/// </summary>
|
|||
public Style ProgressBarStyle |
|||
{ |
|||
get { return (Style)GetValue(ProgressBarStyleProperty); } |
|||
set { SetValue(ProgressBarStyleProperty, value); } |
|||
} |
|||
|
|||
#endregion //ProgressBar Style
|
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
#region Methods
|
|||
|
|||
/// <summary>
|
|||
/// Handler for the DisplayAfterTimer.
|
|||
/// </summary>
|
|||
/// <param name="sender">Event sender.</param>
|
|||
/// <param name="e">Event arguments.</param>
|
|||
private void DisplayAfterTimerElapsed(object sender, EventArgs e) |
|||
{ |
|||
_displayAfterTimer.Stop(); |
|||
IsContentVisible = true; |
|||
ChangeVisualState(true); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Changes the control's visual state(s).
|
|||
/// </summary>
|
|||
/// <param name="useTransitions">True if state transitions should be used.</param>
|
|||
protected virtual void ChangeVisualState(bool useTransitions) |
|||
{ |
|||
VisualStateManager.GoToState(this, IsBusy ? VisualStates.StateBusy : VisualStates.StateIdle, useTransitions); |
|||
VisualStateManager.GoToState(this, IsContentVisible ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions); |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static partial class VisualStates |
|||
{ |
|||
/// <summary>
|
|||
/// Busyness group name.
|
|||
/// </summary>
|
|||
public const string GroupBusyStatus = "BusyStatusStates"; |
|||
|
|||
/// <summary>
|
|||
/// Busy state for BusyIndicator.
|
|||
/// </summary>
|
|||
public const string StateBusy = "Busy"; |
|||
|
|||
/// <summary>
|
|||
/// Idle state for BusyIndicator.
|
|||
/// </summary>
|
|||
public const string StateIdle = "Idle"; |
|||
|
|||
/// <summary>
|
|||
/// BusyDisplay group.
|
|||
/// </summary>
|
|||
public const string GroupVisibility = "VisibilityStates"; |
|||
|
|||
/// <summary>
|
|||
/// Visible state name for BusyIndicator.
|
|||
/// </summary>
|
|||
public const string StateVisible = "Visible"; |
|||
|
|||
/// <summary>
|
|||
/// Hidden state name for BusyIndicator.
|
|||
/// </summary>
|
|||
public const string StateHidden = "Hidden"; |
|||
} |
|||
} |
|||
@ -0,0 +1,482 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
using System.ComponentModel; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
[TemplateVisualState(GroupName = VisualStates.WindowStatesGroup, Name = VisualStates.Open)] |
|||
[TemplateVisualState(GroupName = VisualStates.WindowStatesGroup, Name = VisualStates.Closed)] |
|||
public class ChildWindow : ContentControl |
|||
{ |
|||
#region Private Members
|
|||
|
|||
private TranslateTransform _moveTransform = new TranslateTransform(); |
|||
private bool _startupPositionInitialized; |
|||
private bool _isMouseCaptured; |
|||
private Point _clickPoint; |
|||
private Point _oldPosition; |
|||
private Border _dragWidget; |
|||
private FrameworkElement _parent; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static ChildWindow() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChildWindow), new FrameworkPropertyMetadata(typeof(ChildWindow))); |
|||
} |
|||
|
|||
public ChildWindow() |
|||
{ |
|||
LayoutUpdated += (o, e) => |
|||
{ |
|||
//we only want to set the start position if this is the first time the control has bee initialized
|
|||
if (!_startupPositionInitialized) |
|||
{ |
|||
SetStartupPosition(); |
|||
_startupPositionInitialized = true; |
|||
} |
|||
}; |
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
_dragWidget = (Border)GetTemplateChild("PART_DragWidget"); |
|||
if (_dragWidget != null) |
|||
{ |
|||
_dragWidget.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(HeaderLeftMouseButtonDown), true); |
|||
_dragWidget.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderMouseLeftButtonUp), true); |
|||
_dragWidget.MouseMove += (o, e) => HeaderMouseMove(e); |
|||
} |
|||
|
|||
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
|||
if (CloseButton != null) |
|||
CloseButton.Click += (o, e) => Close(); |
|||
|
|||
Overlay = GetTemplateChild("PART_Overlay") as Panel; |
|||
WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid; |
|||
|
|||
WindowRoot.RenderTransform = _moveTransform; |
|||
|
|||
//TODO: move somewhere else
|
|||
_parent = VisualTreeHelper.GetParent(this) as FrameworkElement; |
|||
_parent.SizeChanged += (o, ea) => |
|||
{ |
|||
Overlay.Height = ea.NewSize.Height; |
|||
Overlay.Width = ea.NewSize.Width; |
|||
}; |
|||
|
|||
ChangeVisualState(); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Properties
|
|||
|
|||
#region Internal Properties
|
|||
|
|||
internal Panel Overlay { get; private set; } |
|||
internal Grid WindowRoot { get; private set; } |
|||
internal Thumb DragWidget { get; private set; } |
|||
internal Button MinimizeButton { get; private set; } |
|||
internal Button MaximizeButton { get; private set; } |
|||
internal Button CloseButton { get; private set; } |
|||
|
|||
#endregion //Internal Properties
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(ChildWindow), new UIPropertyMetadata(String.Empty)); |
|||
public string Caption |
|||
{ |
|||
get { return (string)GetValue(CaptionProperty); } |
|||
set { SetValue(CaptionProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(ChildWindow), new UIPropertyMetadata(null)); |
|||
public Brush CaptionForeground |
|||
{ |
|||
get { return (Brush)GetValue(CaptionForegroundProperty); } |
|||
set { SetValue(CaptionForegroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Style CloseButtonStyle |
|||
{ |
|||
get { return (Style)GetValue(CloseButtonStyleProperty); } |
|||
set { SetValue(CloseButtonStyleProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CloseButtonVisibilityProperty = DependencyProperty.Register("CloseButtonVisibility", typeof(Visibility), typeof(ChildWindow), new PropertyMetadata(Visibility.Visible)); |
|||
public Visibility CloseButtonVisibility |
|||
{ |
|||
get { return (Visibility)GetValue(CloseButtonVisibilityProperty); } |
|||
set { SetValue(CloseButtonVisibilityProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register("Icon", typeof(ImageSource), typeof(ChildWindow), new UIPropertyMetadata(default(ImageSource))); |
|||
public ImageSource Icon |
|||
{ |
|||
get { return (ImageSource)GetValue(IconSourceProperty); } |
|||
set { SetValue(IconSourceProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty IsModalProperty = DependencyProperty.Register("IsModal", typeof(bool), typeof(ChildWindow), new UIPropertyMetadata(true)); |
|||
public bool IsModal |
|||
{ |
|||
get { return (bool)GetValue(IsModalProperty); } |
|||
set { SetValue(IsModalProperty, value); } |
|||
} |
|||
|
|||
#region Left
|
|||
|
|||
public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnLeftPropertyChanged))); |
|||
public double Left |
|||
{ |
|||
get { return (double)GetValue(LeftProperty); } |
|||
set { SetValue(LeftProperty, value); } |
|||
} |
|||
|
|||
private static void OnLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow window = (ChildWindow)obj; |
|||
window.Left = window.GetRestrictedLeft(); |
|||
window.ProcessMove((double)e.NewValue - (double)e.OldValue, 0); |
|||
} |
|||
|
|||
#endregion //Left
|
|||
|
|||
#region OverlayBrush
|
|||
|
|||
public static readonly DependencyProperty OverlayBrushProperty = DependencyProperty.Register("OverlayBrush", typeof(Brush), typeof(ChildWindow)); |
|||
public Brush OverlayBrush |
|||
{ |
|||
get { return (Brush)GetValue(OverlayBrushProperty); } |
|||
set { SetValue(OverlayBrushProperty, value); } |
|||
} |
|||
|
|||
#endregion //OverlayBrush
|
|||
|
|||
#region OverlayOpacity
|
|||
|
|||
public static readonly DependencyProperty OverlayOpacityProperty = DependencyProperty.Register("OverlayOpacity", typeof(double), typeof(ChildWindow)); |
|||
public double OverlayOpacity |
|||
{ |
|||
get { return (double)GetValue(OverlayOpacityProperty); } |
|||
set { SetValue(OverlayOpacityProperty, value); } |
|||
} |
|||
|
|||
#endregion //OverlayOpacity
|
|||
|
|||
#region Top
|
|||
|
|||
public static readonly DependencyProperty TopProperty = DependencyProperty.Register("Top", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnTopPropertyChanged))); |
|||
public double Top |
|||
{ |
|||
get { return (double)GetValue(TopProperty); } |
|||
set { SetValue(TopProperty, value); } |
|||
} |
|||
|
|||
private static void OnTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow window = (ChildWindow)obj; |
|||
window.Top = window.GetRestrictedTop(); |
|||
window.ProcessMove(0, (double)e.NewValue - (double)e.OldValue); |
|||
} |
|||
|
|||
#endregion //TopProperty
|
|||
|
|||
public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Brush WindowBackground |
|||
{ |
|||
get { return (Brush)GetValue(WindowBackgroundProperty); } |
|||
set { SetValue(WindowBackgroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public Brush WindowBorderBrush |
|||
{ |
|||
get { return (Brush)GetValue(WindowBorderBrushProperty); } |
|||
set { SetValue(WindowBorderBrushProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(ChildWindow), new PropertyMetadata(null)); |
|||
public double WindowOpacity |
|||
{ |
|||
get { return (double)GetValue(WindowOpacityProperty); } |
|||
set { SetValue(WindowOpacityProperty, value); } |
|||
} |
|||
|
|||
#region WindowState
|
|||
|
|||
public static readonly DependencyProperty WindowStateProperty = DependencyProperty.Register("WindowState", typeof(WindowState), typeof(ChildWindow), new PropertyMetadata(WindowState.Open, new PropertyChangedCallback(OnWindowStatePropertyChanged))); |
|||
public WindowState WindowState |
|||
{ |
|||
get { return (WindowState)GetValue(WindowStateProperty); } |
|||
set { SetValue(WindowStateProperty, value); } |
|||
} |
|||
|
|||
private static void OnWindowStatePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ChildWindow window = (ChildWindow)obj; |
|||
window.SetWindowState((WindowState)e.NewValue); |
|||
} |
|||
|
|||
#endregion //WindowState
|
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
private bool? _dialogResult; |
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the ChildWindow was accepted or canceled.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// True if the child window was accepted; false if the child window was
|
|||
/// canceled. The default is null.
|
|||
/// </value>
|
|||
[TypeConverter(typeof(NullableBoolConverter))] |
|||
public bool? DialogResult |
|||
{ |
|||
get { return _dialogResult; } |
|||
set |
|||
{ |
|||
if (_dialogResult != value) |
|||
{ |
|||
_dialogResult = value; |
|||
Close(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
void HeaderLeftMouseButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
e.Handled = true; |
|||
Focus(); |
|||
_dragWidget.CaptureMouse(); |
|||
_isMouseCaptured = true; |
|||
_clickPoint = e.GetPosition(null); //save off the mouse position
|
|||
_oldPosition = new Point(Left, Top); //save off our original window position
|
|||
} |
|||
|
|||
private void HeaderMouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
e.Handled = true; |
|||
_dragWidget.ReleaseMouseCapture(); |
|||
_isMouseCaptured = false; |
|||
} |
|||
|
|||
private void HeaderMouseMove(MouseEventArgs e) |
|||
{ |
|||
if (_isMouseCaptured && Visibility == Visibility.Visible) |
|||
{ |
|||
Point currentPosition = e.GetPosition(null); //our current mouse position
|
|||
|
|||
Left = _oldPosition.X + (currentPosition.X - _clickPoint.X); |
|||
Top = _oldPosition.Y + (currentPosition.Y - _clickPoint.Y); |
|||
|
|||
//this helps keep our mouse position in sync with the drag widget position
|
|||
Point dragWidgetPosition = e.GetPosition(_dragWidget); |
|||
if (dragWidgetPosition.X < 0 || dragWidgetPosition.X > _dragWidget.ActualWidth || dragWidgetPosition.Y < 0 || dragWidgetPosition.Y > _dragWidget.ActualHeight) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_oldPosition = new Point(Left, Top); |
|||
_clickPoint = e.GetPosition(Window.GetWindow(this)); //store the point where we are relative to the window
|
|||
} |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
|
|||
#region Methods
|
|||
|
|||
#region Private
|
|||
|
|||
private double GetRestrictedLeft() |
|||
{ |
|||
if (_parent != null) |
|||
{ |
|||
if (Left < 0) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
if (Left + WindowRoot.ActualWidth > _parent.ActualWidth) |
|||
{ |
|||
return _parent.ActualWidth - WindowRoot.ActualWidth; |
|||
} |
|||
} |
|||
|
|||
return Left; |
|||
} |
|||
|
|||
private double GetRestrictedTop() |
|||
{ |
|||
if (_parent != null) |
|||
{ |
|||
if (Top < 0) |
|||
{ |
|||
return 0; |
|||
} |
|||
|
|||
if (Top + WindowRoot.ActualHeight > _parent.ActualHeight) |
|||
{ |
|||
return _parent.ActualHeight - WindowRoot.ActualHeight; |
|||
} |
|||
} |
|||
|
|||
return Top; |
|||
} |
|||
|
|||
private void SetWindowState(WindowState state) |
|||
{ |
|||
switch (state) |
|||
{ |
|||
case WindowState.Closed: |
|||
{ |
|||
ExecuteClose(); |
|||
break; |
|||
} |
|||
case WindowState.Open: |
|||
{ |
|||
ExecuteOpen(); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
ChangeVisualState(); |
|||
} |
|||
|
|||
private void ExecuteClose() |
|||
{ |
|||
CancelEventArgs e = new CancelEventArgs(); |
|||
OnClosing(e); |
|||
|
|||
if (!e.Cancel) |
|||
{ |
|||
if (!_dialogResult.HasValue) |
|||
_dialogResult = false; |
|||
|
|||
OnClosed(EventArgs.Empty); |
|||
} |
|||
else |
|||
{ |
|||
_dialogResult = null; //if the Close is cancelled, DialogResult should always be NULL:
|
|||
} |
|||
} |
|||
|
|||
private void ExecuteOpen() |
|||
{ |
|||
_dialogResult = null; //reset the dialogResult to null each time the window is opened
|
|||
SetZIndex(); |
|||
} |
|||
|
|||
private void SetZIndex() |
|||
{ |
|||
if (_parent != null) |
|||
{ |
|||
int parentIndex = (int)_parent.GetValue(Canvas.ZIndexProperty); |
|||
this.SetValue(Canvas.ZIndexProperty, ++parentIndex); |
|||
} |
|||
else |
|||
{ |
|||
this.SetValue(Canvas.ZIndexProperty, 1); |
|||
} |
|||
} |
|||
|
|||
private void SetStartupPosition() |
|||
{ |
|||
CenterChildWindow(); |
|||
} |
|||
|
|||
private void CenterChildWindow() |
|||
{ |
|||
_moveTransform.X = _moveTransform.Y = 0; |
|||
|
|||
if (_parent != null) |
|||
{ |
|||
Left = (_parent.ActualWidth - WindowRoot.ActualWidth) / 2.0; |
|||
Top = (_parent.ActualHeight - WindowRoot.ActualHeight) / 2.0; |
|||
} |
|||
} |
|||
|
|||
protected virtual void ChangeVisualState() |
|||
{ |
|||
if (WindowState == WindowState.Closed) |
|||
{ |
|||
VisualStateManager.GoToState(this, VisualStates.Closed, true); |
|||
} |
|||
else |
|||
{ |
|||
VisualStateManager.GoToState(this, VisualStates.Open, true); |
|||
} |
|||
} |
|||
|
|||
#endregion //Private
|
|||
|
|||
#region Protected
|
|||
|
|||
protected void ProcessMove(double x, double y) |
|||
{ |
|||
_moveTransform.X += x; |
|||
_moveTransform.Y += y; |
|||
} |
|||
|
|||
#endregion //Protected
|
|||
|
|||
#region Public
|
|||
|
|||
public void Show() |
|||
{ |
|||
WindowState = WindowState.Open; |
|||
} |
|||
|
|||
public void Close() |
|||
{ |
|||
WindowState = WindowState.Closed; |
|||
} |
|||
|
|||
#endregion //Public
|
|||
|
|||
#endregion //Methods
|
|||
|
|||
#region Events
|
|||
|
|||
/// <summary>
|
|||
/// Occurs when the ChildWindow is closed.
|
|||
/// </summary>
|
|||
public event EventHandler Closed; |
|||
protected virtual void OnClosed(EventArgs e) |
|||
{ |
|||
if (Closed != null) |
|||
Closed(this, e); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Occurs when the ChildWindow is closing.
|
|||
/// </summary>
|
|||
public event EventHandler<CancelEventArgs> Closing; |
|||
protected virtual void OnClosing(CancelEventArgs e) |
|||
{ |
|||
if (Closing != null) |
|||
Closing(this, e); |
|||
} |
|||
|
|||
#endregion //Events
|
|||
} |
|||
} |
|||
@ -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,13 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public enum WindowState |
|||
{ |
|||
Closed, |
|||
Open |
|||
} |
|||
} |
|||
@ -0,0 +1,390 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public class ColorPicker : Control |
|||
{ |
|||
#region Private Members
|
|||
|
|||
ToggleButton _colorPickerToggleButton; |
|||
Popup _colorPickerCanvasPopup; |
|||
Button _okButton; |
|||
private TranslateTransform _colorShadeSelectorTransform = new TranslateTransform(); |
|||
private Canvas _colorShadingCanvas; |
|||
private Canvas _colorShadeSelector; |
|||
private ColorSpectrumSlider _spectrumSlider; |
|||
private Point? _currentColorPosition; |
|||
private Color _currentColor = Colors.White; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static ColorPicker() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorPicker), new FrameworkPropertyMetadata(typeof(ColorPicker))); |
|||
} |
|||
|
|||
public ColorPicker() |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Properties
|
|||
|
|||
public static readonly DependencyProperty CurrentColorProperty = DependencyProperty.Register("CurrentColor", typeof(Color), typeof(ColorPicker), new PropertyMetadata(Colors.White)); |
|||
public Color CurrentColor |
|||
{ |
|||
get { return (Color)GetValue(CurrentColorProperty); } |
|||
set { SetValue(CurrentColorProperty, value); } |
|||
} |
|||
|
|||
#region SelectedColor
|
|||
|
|||
public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorPicker), new FrameworkPropertyMetadata(Colors.White, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(SelectedColorPropertyChanged))); |
|||
public Color SelectedColor |
|||
{ |
|||
get { return (Color)GetValue(SelectedColorProperty); } |
|||
set { SetValue(SelectedColorProperty, value); } |
|||
} |
|||
|
|||
private static void SelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ColorPicker colorPicker = (ColorPicker)d; |
|||
colorPicker.SetSelectedColor((Color)e.NewValue); |
|||
} |
|||
|
|||
#endregion //SelectedColor
|
|||
|
|||
#region ScRGB
|
|||
|
|||
#region ScA
|
|||
|
|||
public static readonly DependencyProperty ScAProperty = DependencyProperty.Register("ScA", typeof(float), typeof(ColorPicker), new PropertyMetadata((float)1, new PropertyChangedCallback(OnScAPropertyChangedChanged))); |
|||
public float ScA |
|||
{ |
|||
get { return (float)GetValue(ScAProperty); } |
|||
set { SetValue(ScAProperty, value); } |
|||
} |
|||
|
|||
private static void OnScAPropertyChangedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ColorPicker c = (ColorPicker)d; |
|||
c.SetScA((float)e.NewValue); |
|||
} |
|||
|
|||
protected virtual void SetScA(float newValue) |
|||
{ |
|||
_currentColor.ScA = newValue; |
|||
A = _currentColor.A; |
|||
CurrentColor = _currentColor; |
|||
HexadecimalString = _currentColor.ToString(); |
|||
} |
|||
|
|||
#endregion //ScA
|
|||
|
|||
#region ScR
|
|||
|
|||
public static readonly DependencyProperty ScRProperty = DependencyProperty.Register("ScR", typeof(float), typeof(ColorPicker), new PropertyMetadata((float)1, new PropertyChangedCallback(OnScRPropertyChanged))); |
|||
public float ScR |
|||
{ |
|||
get { return (float)GetValue(ScRProperty); } |
|||
set { SetValue(RProperty, value); } |
|||
} |
|||
|
|||
private static void OnScRPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //ScR
|
|||
|
|||
#region ScG
|
|||
|
|||
public static readonly DependencyProperty ScGProperty = DependencyProperty.Register("ScG", typeof(float), typeof(ColorPicker), new PropertyMetadata((float)1, new PropertyChangedCallback(OnScGPropertyChanged))); |
|||
public float ScG |
|||
{ |
|||
get { return (float)GetValue(ScGProperty); } |
|||
set { SetValue(GProperty, value); } |
|||
} |
|||
|
|||
private static void OnScGPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //ScG
|
|||
|
|||
#region ScB
|
|||
|
|||
public static readonly DependencyProperty ScBProperty = DependencyProperty.Register("ScB", typeof(float), typeof(ColorPicker), new PropertyMetadata((float)1, new PropertyChangedCallback(OnScBPropertyChanged))); |
|||
public float ScB |
|||
{ |
|||
get { return (float)GetValue(BProperty); } |
|||
set { SetValue(BProperty, value); } |
|||
} |
|||
|
|||
private static void OnScBPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //ScB
|
|||
|
|||
#endregion //ScRGB
|
|||
|
|||
#region RGB
|
|||
|
|||
#region A
|
|||
|
|||
public static readonly DependencyProperty AProperty = DependencyProperty.Register("A", typeof(byte), typeof(ColorPicker), new PropertyMetadata((byte)255, new PropertyChangedCallback(OnAPropertyChanged))); |
|||
public byte A |
|||
{ |
|||
get { return (byte)GetValue(AProperty); } |
|||
set { SetValue(AProperty, value); } |
|||
} |
|||
|
|||
private static void OnAPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
ColorPicker c = (ColorPicker)d; |
|||
c.SetA((byte)e.NewValue); |
|||
} |
|||
|
|||
protected virtual void SetA(byte newValue) |
|||
{ |
|||
_currentColor.A = newValue; |
|||
SetValue(CurrentColorProperty, _currentColor); |
|||
} |
|||
|
|||
#endregion //A
|
|||
|
|||
#region R
|
|||
|
|||
public static readonly DependencyProperty RProperty = DependencyProperty.Register("R", typeof(byte), typeof(ColorPicker), new PropertyMetadata((byte)255, new PropertyChangedCallback(OnRPropertyChanged))); |
|||
public byte R |
|||
{ |
|||
get { return (byte)GetValue(RProperty); } |
|||
set { SetValue(RProperty, value); } |
|||
} |
|||
|
|||
private static void OnRPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //R
|
|||
|
|||
#region G
|
|||
|
|||
public static readonly DependencyProperty GProperty = DependencyProperty.Register("G", typeof(byte), typeof(ColorPicker), new PropertyMetadata((byte)255, new PropertyChangedCallback(OnGPropertyChanged))); |
|||
public byte G |
|||
{ |
|||
get { return (byte)GetValue(GProperty); } |
|||
set { SetValue(GProperty, value); } |
|||
} |
|||
|
|||
private static void OnGPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //G
|
|||
|
|||
#region B
|
|||
|
|||
public static readonly DependencyProperty BProperty = DependencyProperty.Register("B", typeof(byte), typeof(ColorPicker), new PropertyMetadata((byte)255, new PropertyChangedCallback(OnBPropertyChanged))); |
|||
public byte B |
|||
{ |
|||
get { return (byte)GetValue(BProperty); } |
|||
set { SetValue(BProperty, value); } |
|||
} |
|||
|
|||
private static void OnBPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //B
|
|||
|
|||
#endregion //RGB
|
|||
|
|||
#region HexadecimalString
|
|||
|
|||
public static readonly DependencyProperty HexadecimalStringProperty = DependencyProperty.Register("HexadecimalString", typeof(string), typeof(ColorPicker), new PropertyMetadata("#FFFFFFFF", new PropertyChangedCallback(OnHexadecimalStringPropertyChanged))); |
|||
public string HexadecimalString |
|||
{ |
|||
get { return (string)GetValue(HexadecimalStringProperty); } |
|||
set { SetValue(HexadecimalStringProperty, value); } |
|||
} |
|||
|
|||
private static void OnHexadecimalStringPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //HexadecimalString
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
_colorPickerToggleButton = (ToggleButton)GetTemplateChild("PART_ColorPickerToggleButton"); |
|||
_colorPickerToggleButton.Click += ColorPickerToggleButton_Clicked; |
|||
|
|||
_colorPickerCanvasPopup = (Popup)GetTemplateChild("PART_ColorPickerCanvasPopup"); |
|||
|
|||
_colorShadingCanvas = (Canvas)GetTemplateChild("PART_ColorShadingCanvas"); |
|||
_colorShadingCanvas.MouseLeftButtonDown += ColorShadingCanvas_MouseLeftButtonDown; |
|||
_colorShadingCanvas.MouseMove += ColorShadingCanvas_MouseMove; |
|||
_colorShadingCanvas.SizeChanged += ColorShadingCanvas_SizeChanged; |
|||
|
|||
_colorShadeSelector = (Canvas)GetTemplateChild("PART_ColorShadeSelector"); |
|||
_colorShadeSelector.RenderTransform = _colorShadeSelectorTransform; |
|||
|
|||
_spectrumSlider = (ColorSpectrumSlider)GetTemplateChild("PART_SpectrumSlider"); |
|||
_spectrumSlider.ValueChanged += SpectrumSlider_ValueChanged; |
|||
|
|||
_okButton = (Button)GetTemplateChild("PART_OkButton"); |
|||
_okButton.Click += OkButton_Click; |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
void ColorShadingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
Point p = e.GetPosition(_colorShadingCanvas); |
|||
UpdateColorShadeSelectorPositionAndCalculateColor(p, true); |
|||
} |
|||
|
|||
void ColorShadingCanvas_MouseMove(object sender, MouseEventArgs e) |
|||
{ |
|||
if (e.LeftButton == MouseButtonState.Pressed) |
|||
{ |
|||
Point p = e.GetPosition(_colorShadingCanvas); |
|||
UpdateColorShadeSelectorPositionAndCalculateColor(p, true); |
|||
Mouse.Synchronize(); |
|||
} |
|||
} |
|||
|
|||
void ColorShadingCanvas_SizeChanged(object sender, SizeChangedEventArgs e) |
|||
{ |
|||
if (_currentColorPosition != null) |
|||
{ |
|||
Point _newPoint = new Point |
|||
{ |
|||
X = ((Point)_currentColorPosition).X * e.NewSize.Width, |
|||
Y = ((Point)_currentColorPosition).Y * e.NewSize.Height |
|||
}; |
|||
|
|||
UpdateColorShadeSelectorPositionAndCalculateColor(_newPoint, false); |
|||
} |
|||
} |
|||
|
|||
void SpectrumSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) |
|||
{ |
|||
if (_currentColorPosition != null) |
|||
{ |
|||
CalculateColor((Point)_currentColorPosition); |
|||
} |
|||
} |
|||
|
|||
void OkButton_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
if (_colorPickerCanvasPopup.IsOpen || _colorPickerToggleButton.IsChecked == true) |
|||
{ |
|||
CloseColorPicker(); |
|||
SelectedColor = CurrentColor; |
|||
} |
|||
} |
|||
|
|||
void ColorPickerToggleButton_Clicked(object sender, RoutedEventArgs e) |
|||
{ |
|||
_colorPickerCanvasPopup.IsOpen = _colorPickerToggleButton.IsChecked ?? false; |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
|
|||
#region Methods
|
|||
|
|||
private void CloseColorPicker() |
|||
{ |
|||
_colorPickerToggleButton.IsChecked = false; |
|||
_colorPickerCanvasPopup.IsOpen = false; |
|||
} |
|||
|
|||
private void SetSelectedColor(Color theColor) |
|||
{ |
|||
_currentColor = theColor; |
|||
SetValue(AProperty, _currentColor.A); |
|||
SetValue(RProperty, _currentColor.R); |
|||
SetValue(GProperty, _currentColor.G); |
|||
SetValue(BProperty, _currentColor.B); |
|||
UpdateColorShadeSelectorPosition(theColor); |
|||
} |
|||
|
|||
private void UpdateColorShadeSelectorPositionAndCalculateColor(Point p, bool calculateColor) |
|||
{ |
|||
if (p.Y < 0) |
|||
p.Y = 0; |
|||
|
|||
if (p.X < 0) |
|||
p.X = 0; |
|||
|
|||
if (p.X > _colorShadingCanvas.ActualWidth) |
|||
p.X = _colorShadingCanvas.ActualWidth; |
|||
|
|||
if (p.Y > _colorShadingCanvas.ActualHeight) |
|||
p.Y = _colorShadingCanvas.ActualHeight; |
|||
|
|||
_colorShadeSelectorTransform.X = p.X - (_colorShadeSelector.Width / 2); |
|||
_colorShadeSelectorTransform.Y = p.Y - (_colorShadeSelector.Height / 2); |
|||
|
|||
p.X = p.X / _colorShadingCanvas.ActualWidth; |
|||
p.Y = p.Y / _colorShadingCanvas.ActualHeight; |
|||
|
|||
_currentColorPosition = p; |
|||
|
|||
if (calculateColor) |
|||
CalculateColor(p); |
|||
} |
|||
|
|||
private void UpdateColorShadeSelectorPosition(Color color) |
|||
{ |
|||
_currentColorPosition = null; |
|||
|
|||
HsvColor hsv = ColorUtilities.ConvertRgbToHsv(color.R, color.G, color.B); |
|||
_spectrumSlider.Value = hsv.H; |
|||
|
|||
Point p = new Point(hsv.S, 1 - hsv.V); |
|||
|
|||
_currentColorPosition = p; |
|||
|
|||
_colorShadeSelectorTransform.X = (p.X * _colorShadingCanvas.Width) - 5; |
|||
_colorShadeSelectorTransform.Y = (p.Y * _colorShadingCanvas.Height) - 5; |
|||
} |
|||
|
|||
private void CalculateColor(Point p) |
|||
{ |
|||
HsvColor hsv = new HsvColor(360 - _spectrumSlider.Value, 1, 1) { S = p.X, V = 1 - p.Y }; |
|||
_currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V); ; |
|||
_currentColor.ScA = ScA; |
|||
CurrentColor = _currentColor; |
|||
HexadecimalString = _currentColor.ToString(); |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
} |
|||
} |
|||
@ -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,156 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows.Media; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static class ColorUtilities |
|||
{ |
|||
/// <summary>
|
|||
/// Converts an RGB color to an HSV color.
|
|||
/// </summary>
|
|||
/// <param name="r"></param>
|
|||
/// <param name="b"></param>
|
|||
/// <param name="g"></param>
|
|||
/// <returns></returns>
|
|||
public static HsvColor ConvertRgbToHsv(int r, int b, int g) |
|||
{ |
|||
double delta, min; |
|||
double h = 0, s, v; |
|||
|
|||
min = Math.Min(Math.Min(r, g), b); |
|||
v = Math.Max(Math.Max(r, g), b); |
|||
delta = v - min; |
|||
|
|||
if (v == 0.0) |
|||
{ |
|||
s = 0; |
|||
} |
|||
else |
|||
s = delta / v; |
|||
|
|||
if (s == 0) |
|||
h = 0.0; |
|||
|
|||
else |
|||
{ |
|||
if (r == v) |
|||
h = (g - b) / delta; |
|||
else if (g == v) |
|||
h = 2 + (b - r) / delta; |
|||
else if (b == v) |
|||
h = 4 + (r - g) / delta; |
|||
|
|||
h *= 60; |
|||
if (h < 0.0) |
|||
h = h + 360; |
|||
|
|||
} |
|||
|
|||
return new HsvColor { H = h, S = s, V = v / 255 }; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Converts an HSV color to an RGB color.
|
|||
/// </summary>
|
|||
/// <param name="h"></param>
|
|||
/// <param name="s"></param>
|
|||
/// <param name="v"></param>
|
|||
/// <returns></returns>
|
|||
public static Color ConvertHsvToRgb(double h, double s, double v) |
|||
{ |
|||
double r = 0, g = 0, b = 0; |
|||
|
|||
if (s == 0) |
|||
{ |
|||
r = v; |
|||
g = v; |
|||
b = v; |
|||
} |
|||
else |
|||
{ |
|||
int i; |
|||
double f, p, q, t; |
|||
|
|||
if (h == 360) |
|||
h = 0; |
|||
else |
|||
h = h / 60; |
|||
|
|||
i = (int)Math.Truncate(h); |
|||
f = h - i; |
|||
|
|||
p = v * (1.0 - s); |
|||
q = v * (1.0 - (s * f)); |
|||
t = v * (1.0 - (s * (1.0 - f))); |
|||
|
|||
switch (i) |
|||
{ |
|||
case 0: |
|||
{ |
|||
r = v; |
|||
g = t; |
|||
b = p; |
|||
break; |
|||
} |
|||
case 1: |
|||
{ |
|||
r = q; |
|||
g = v; |
|||
b = p; |
|||
break; |
|||
} |
|||
case 2: |
|||
{ |
|||
r = p; |
|||
g = v; |
|||
b = t; |
|||
break; |
|||
} |
|||
case 3: |
|||
{ |
|||
r = p; |
|||
g = q; |
|||
b = v; |
|||
break; |
|||
} |
|||
case 4: |
|||
{ |
|||
r = t; |
|||
g = p; |
|||
b = v; |
|||
break; |
|||
} |
|||
default: |
|||
{ |
|||
r = v; |
|||
g = p; |
|||
b = q; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
return Color.FromArgb(255, (byte)(r * 255), (byte)(g * 255), (byte)(b * 255)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Generates a list of colors with hues ranging from 0 360 and a saturation and value of 1.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public static List<Color> GenerateHsvSpectrum() |
|||
{ |
|||
List<Color> colorsList = new List<Color>(8); |
|||
|
|||
for (int i = 0; i < 29; i++) |
|||
{ |
|||
colorsList.Add(ColorUtilities.ConvertHsvToRgb(i * 12, 1, 1)); |
|||
} |
|||
|
|||
colorsList.Add(ColorUtilities.ConvertHsvToRgb(0, 1, 1)); |
|||
|
|||
return colorsList; |
|||
} |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,419 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Media; |
|||
using System.Windows.Controls.Primitives; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
[TemplateVisualState(Name = VisualStates.OK, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.OKCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.YesNo, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
[TemplateVisualState(Name = VisualStates.YesNoCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
|||
public class MessageBox : Control |
|||
{ |
|||
#region Private Members
|
|||
|
|||
/// <summary>
|
|||
/// Tracks the MessageBoxButon value passed into the InitializeContainer method
|
|||
/// </summary>
|
|||
private MessageBoxButton _button = MessageBoxButton.OK; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
static MessageBox() |
|||
{ |
|||
DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBox), new FrameworkPropertyMetadata(typeof(MessageBox))); |
|||
} |
|||
|
|||
internal MessageBox() |
|||
{ /*user cannot create instance */ } |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Properties
|
|||
|
|||
#region Protected Properties
|
|||
|
|||
/// <summary>
|
|||
/// A System.Windows.MessageBoxResult value that specifies which message box button was clicked by the user.
|
|||
/// </summary>
|
|||
protected MessageBoxResult MessageBoxResult = MessageBoxResult.None; |
|||
|
|||
protected Window Container { get; private set; } |
|||
protected Thumb DragWidget { get; private set; } |
|||
protected Button CloseButton { get; private set; } |
|||
|
|||
protected Button OkButton { get; private set; } |
|||
protected Button CancelButton { get; private set; } |
|||
protected Button YesButton { get; private set; } |
|||
protected Button NoButton { get; private set; } |
|||
|
|||
protected Button OkButton1 { get; private set; } |
|||
protected Button CancelButton1 { get; private set; } |
|||
protected Button YesButton1 { get; private set; } |
|||
protected Button NoButton1 { get; private set; } |
|||
|
|||
#endregion //Protected Properties
|
|||
|
|||
#region Dependency Properties
|
|||
|
|||
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
|||
public string Caption |
|||
{ |
|||
get { return (string)GetValue(CaptionProperty); } |
|||
set { SetValue(CaptionProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(MessageBox), new UIPropertyMetadata(null)); |
|||
public Brush CaptionForeground |
|||
{ |
|||
get { return (Brush)GetValue(CaptionForegroundProperty); } |
|||
set { SetValue(CaptionForegroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(MessageBox), new PropertyMetadata(null)); |
|||
public Style CloseButtonStyle |
|||
{ |
|||
get { return (Style)GetValue(CloseButtonStyleProperty); } |
|||
set { SetValue(CloseButtonStyleProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MessageBox), new UIPropertyMetadata(default(ImageSource))); |
|||
public ImageSource ImageSource |
|||
{ |
|||
get { return (ImageSource)GetValue(ImageSourceProperty); } |
|||
set { SetValue(ImageSourceProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
|||
public string Text |
|||
{ |
|||
get { return (string)GetValue(TextProperty); } |
|||
set { SetValue(TextProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); |
|||
public Brush WindowBackground |
|||
{ |
|||
get { return (Brush)GetValue(WindowBackgroundProperty); } |
|||
set { SetValue(WindowBackgroundProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); |
|||
public Brush WindowBorderBrush |
|||
{ |
|||
get { return (Brush)GetValue(WindowBorderBrushProperty); } |
|||
set { SetValue(WindowBorderBrushProperty, value); } |
|||
} |
|||
|
|||
public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(MessageBox), new PropertyMetadata(null)); |
|||
public double WindowOpacity |
|||
{ |
|||
get { return (double)GetValue(WindowOpacityProperty); } |
|||
set { SetValue(WindowOpacityProperty, value); } |
|||
} |
|||
|
|||
#endregion //Dependency Properties
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Base Class Overrides
|
|||
|
|||
/// <summary>
|
|||
/// Overrides the OnApplyTemplate method.
|
|||
/// </summary>
|
|||
public override void OnApplyTemplate() |
|||
{ |
|||
base.OnApplyTemplate(); |
|||
|
|||
DragWidget = (Thumb)GetTemplateChild("PART_DragWidget"); |
|||
if (DragWidget != null) |
|||
DragWidget.DragDelta += (o, e) => ProcessMove(e); |
|||
|
|||
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
|||
if (CloseButton != null) |
|||
CloseButton.Click += (o, e) => Close(); |
|||
|
|||
NoButton = (Button)GetTemplateChild("PART_NoButton"); |
|||
if (NoButton != null) |
|||
NoButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
NoButton1 = (Button)GetTemplateChild("PART_NoButton1"); |
|||
if (NoButton1 != null) |
|||
NoButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
YesButton = (Button)GetTemplateChild("PART_YesButton"); |
|||
if (YesButton != null) |
|||
YesButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
YesButton1 = (Button)GetTemplateChild("PART_YesButton1"); |
|||
if (YesButton1 != null) |
|||
YesButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
CancelButton = (Button)GetTemplateChild("PART_CancelButton"); |
|||
if (CancelButton != null) |
|||
CancelButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
CancelButton1 = (Button)GetTemplateChild("PART_CancelButton1"); |
|||
if (CancelButton1 != null) |
|||
CancelButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
OkButton = (Button)GetTemplateChild("PART_OkButton"); |
|||
if (OkButton != null) |
|||
OkButton.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
OkButton1 = (Button)GetTemplateChild("PART_OkButton1"); |
|||
if (OkButton1 != null) |
|||
OkButton1.Click += (o, e) => Button_Click(o, e); |
|||
|
|||
ChangeVisualState(_button.ToString(), true); |
|||
} |
|||
|
|||
#endregion //Base Class Overrides
|
|||
|
|||
#region Methods
|
|||
|
|||
#region Public Static
|
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText) |
|||
{ |
|||
return Show(messageText, string.Empty, MessageBoxButton.OK); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and title bar caption; and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption) |
|||
{ |
|||
return Show(messageText, caption, MessageBoxButton.OK); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button) |
|||
{ |
|||
return ShowCore(messageText, caption, button, MessageBoxImage.None); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Displays a message box that has a message and that returns a result.
|
|||
/// </summary>
|
|||
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
|||
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
|||
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
|||
/// <param name="image"> A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
|||
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
|||
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
|||
{ |
|||
return ShowCore(messageText, caption, button, icon); |
|||
} |
|||
|
|||
#endregion //Public Static
|
|||
|
|||
#region Private Static
|
|||
|
|||
private static MessageBoxResult ShowCore(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
|||
{ |
|||
MessageBox msgBox = new MessageBox(); |
|||
msgBox.InitializeMessageBox(messageText, caption, button, icon); |
|||
msgBox.Show(); |
|||
return msgBox.MessageBoxResult; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Resolves the owner Window of the MessageBox.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private static FrameworkElement ResolveOwner() |
|||
{ |
|||
FrameworkElement owner = null; |
|||
if (Application.Current != null) |
|||
{ |
|||
foreach (Window w in Application.Current.Windows) |
|||
{ |
|||
if (w.IsActive) |
|||
{ |
|||
owner = w; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return owner; |
|||
} |
|||
|
|||
#endregion //Private Static
|
|||
|
|||
#region Protected
|
|||
|
|||
/// <summary>
|
|||
/// Shows the MessageBox
|
|||
/// </summary>
|
|||
protected void Show() |
|||
{ |
|||
Container.ShowDialog(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Initializes the MessageBox.
|
|||
/// </summary>
|
|||
/// <param name="text">The text.</param>
|
|||
/// <param name="caption">The caption.</param>
|
|||
/// <param name="button">The button.</param>
|
|||
/// <param name="image">The image.</param>
|
|||
protected void InitializeMessageBox(string text, string caption, MessageBoxButton button, MessageBoxImage image) |
|||
{ |
|||
Text = text; |
|||
Caption = caption; |
|||
_button = button; |
|||
SetImageSource(image); |
|||
Container = CreateContainer(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Changes the control's visual state(s).
|
|||
/// </summary>
|
|||
/// <param name="name">name of the state</param>
|
|||
/// <param name="useTransitions">True if state transitions should be used.</param>
|
|||
protected void ChangeVisualState(string name, bool useTransitions) |
|||
{ |
|||
VisualStateManager.GoToState(this, name, useTransitions); |
|||
} |
|||
|
|||
#endregion //Protected
|
|||
|
|||
#region Private
|
|||
|
|||
/// <summary>
|
|||
/// Sets the message image source.
|
|||
/// </summary>
|
|||
/// <param name="image">The image to show.</param>
|
|||
private void SetImageSource(MessageBoxImage image) |
|||
{ |
|||
String iconName = String.Empty; |
|||
|
|||
switch (image) |
|||
{ |
|||
case MessageBoxImage.Error: |
|||
{ |
|||
iconName = "Error48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Information: |
|||
{ |
|||
iconName = "Information48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Question: |
|||
{ |
|||
iconName = "Question48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.Warning: |
|||
{ |
|||
iconName = "Warning48.png"; |
|||
break; |
|||
} |
|||
case MessageBoxImage.None: |
|||
default: |
|||
{ |
|||
return; |
|||
} |
|||
} |
|||
|
|||
ImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(String.Format("pack://application:,,,/WPFToolkit.Extended;component/MessageBox/Icons/{0}", iconName)); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Creates the container which will host the MessageBox control.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
private Window CreateContainer() |
|||
{ |
|||
return new Window() |
|||
{ |
|||
AllowsTransparency = true, |
|||
Background = Brushes.Transparent, |
|||
Content = this, |
|||
Owner = Window.GetWindow(ResolveOwner()), |
|||
ShowInTaskbar = false, |
|||
SizeToContent = System.Windows.SizeToContent.WidthAndHeight, |
|||
ResizeMode = System.Windows.ResizeMode.NoResize, |
|||
WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner, |
|||
WindowStyle = System.Windows.WindowStyle.None |
|||
}; |
|||
} |
|||
|
|||
#endregion //Private
|
|||
|
|||
#endregion //Methods
|
|||
|
|||
#region Event Handlers
|
|||
|
|||
/// <summary>
|
|||
/// Processes the move of a drag operation on the header.
|
|||
/// </summary>
|
|||
/// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
|
|||
private void ProcessMove(DragDeltaEventArgs e) |
|||
{ |
|||
Container.Left = Container.Left + e.HorizontalChange; |
|||
Container.Top = Container.Top + e.VerticalChange; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Sets the MessageBoxResult according to the button pressed and then closes the MessageBox.
|
|||
/// </summary>
|
|||
/// <param name="sender">The source of the event.</param>
|
|||
/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
Button button = e.Source as Button; |
|||
switch (button.Name) |
|||
{ |
|||
case "PART_NoButton": |
|||
case "PART_NoButton1": |
|||
MessageBoxResult = MessageBoxResult.No; |
|||
break; |
|||
case "PART_YesButton": |
|||
case "PART_YesButton1": |
|||
MessageBoxResult = MessageBoxResult.Yes; |
|||
break; |
|||
case "PART_CancelButton": |
|||
case "PART_CancelButton1": |
|||
MessageBoxResult = MessageBoxResult.Cancel; |
|||
break; |
|||
case "PART_OkButton": |
|||
case "PART_OkButton1": |
|||
MessageBoxResult = MessageBoxResult.OK; |
|||
break; |
|||
} |
|||
|
|||
Close(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Closes the MessageBox.
|
|||
/// </summary>
|
|||
private void Close() |
|||
{ |
|||
Container.Close(); |
|||
} |
|||
|
|||
#endregion //Event Handlers
|
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static partial class VisualStates |
|||
{ |
|||
public const string MessageBoxButtonsGroup = "MessageBoxButtonsGroup"; |
|||
|
|||
public const string OK = "OK"; |
|||
|
|||
public const string OKCancel = "OKCancel"; |
|||
|
|||
public const string YesNo = "YesNo"; |
|||
|
|||
public const string YesNoCancel = "YesNoCancel"; |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System.Reflection; |
|||
using System.Resources; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using System.Windows; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("WPFToolkit.Extended")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("WPFToolkit.Extended")] |
|||
[assembly: AssemblyCopyright("Copyright © 2010")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
//In order to begin building localizable applications, set
|
|||
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
|||
//inside a <PropertyGroup>. For example, if you are using US english
|
|||
//in your source files, set the <UICulture> to en-US. Then uncomment
|
|||
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
|||
//the line below to match the UICulture setting in the project file.
|
|||
|
|||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
|||
|
|||
|
|||
[assembly: ThemeInfo( |
|||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|||
//(used if a resource is not found in the page,
|
|||
// or application resource dictionaries)
|
|||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|||
//(used if a resource is not found in the page,
|
|||
// app, or any theme specific resource dictionaries)
|
|||
)] |
|||
|
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.1.0.0")] |
|||
[assembly: AssemblyFileVersion("1.1.0.0")] |
|||
@ -0,0 +1,63 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
// Runtime Version:4.0.30319.1
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Microsoft.Windows.Controls.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("Microsoft.Windows.Controls.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.1
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Microsoft.Windows.Controls.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,11 @@ |
|||
using System; |
|||
using System.Windows.Documents; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public interface ITextFormatter |
|||
{ |
|||
string GetText(FlowDocument document); |
|||
void SetText(FlowDocument document, string text); |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using System; |
|||
using System.Windows.Documents; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Formats the RichTextBox text as plain text
|
|||
/// </summary>
|
|||
public class PlainTextFormatter : ITextFormatter |
|||
{ |
|||
public string GetText(FlowDocument document) |
|||
{ |
|||
return new TextRange(document.ContentStart, document.ContentEnd).Text; |
|||
} |
|||
|
|||
public void SetText(FlowDocument document, string text) |
|||
{ |
|||
new TextRange(document.ContentStart, document.ContentEnd).Text = text; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using System; |
|||
using System.Text; |
|||
using System.Windows.Documents; |
|||
using System.IO; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Formats the RichTextBox text as RTF
|
|||
/// </summary>
|
|||
public class RtfFormatter : ITextFormatter |
|||
{ |
|||
public string GetText(FlowDocument document) |
|||
{ |
|||
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
|||
using (MemoryStream ms = new MemoryStream()) |
|||
{ |
|||
tr.Save(ms, DataFormats.Rtf); |
|||
return ASCIIEncoding.Default.GetString(ms.ToArray()); |
|||
} |
|||
} |
|||
|
|||
public void SetText(FlowDocument document, string text) |
|||
{ |
|||
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
|||
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) |
|||
{ |
|||
tr.Load(ms, DataFormats.Rtf); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using System; |
|||
using System.Text; |
|||
using System.IO; |
|||
using System.Windows.Documents; |
|||
using System.Windows; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Formats the RichTextBox text as Xaml
|
|||
/// </summary>
|
|||
public class XamlFormatter : ITextFormatter |
|||
{ |
|||
public string GetText(System.Windows.Documents.FlowDocument document) |
|||
{ |
|||
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
|||
using (MemoryStream ms = new MemoryStream()) |
|||
{ |
|||
tr.Save(ms, DataFormats.Xaml); |
|||
return ASCIIEncoding.Default.GetString(ms.ToArray()); |
|||
} |
|||
} |
|||
|
|||
public void SetText(System.Windows.Documents.FlowDocument document, string text) |
|||
{ |
|||
try |
|||
{ |
|||
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
|||
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) |
|||
{ |
|||
tr.Load(ms, DataFormats.Xaml); |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
throw new InvalidDataException("data provided is not in the correct Xaml format."); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,130 @@ |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Data; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
public class RichTextBox : System.Windows.Controls.RichTextBox |
|||
{ |
|||
#region Private Members
|
|||
|
|||
private bool _textHasLoaded; |
|||
bool isInvokePending; |
|||
|
|||
#endregion //Private Members
|
|||
|
|||
#region Constructors
|
|||
|
|||
public RichTextBox() |
|||
{ |
|||
Loaded += RichTextBox_Loaded; |
|||
} |
|||
|
|||
public RichTextBox(System.Windows.Documents.FlowDocument document) |
|||
: base(document) |
|||
{ |
|||
|
|||
} |
|||
|
|||
#endregion //Constructors
|
|||
|
|||
#region Properties
|
|||
|
|||
private ITextFormatter _textFormatter; |
|||
/// <summary>
|
|||
/// The ITextFormatter the is used to format the text of the RichTextBox.
|
|||
/// Deafult formatter is the RtfFormatter
|
|||
/// </summary>
|
|||
public ITextFormatter TextFormatter |
|||
{ |
|||
get |
|||
{ |
|||
if (_textFormatter == null) |
|||
_textFormatter = new RtfFormatter(); //default is rtf
|
|||
|
|||
return _textFormatter; |
|||
} |
|||
set |
|||
{ |
|||
_textFormatter = value; |
|||
} |
|||
} |
|||
|
|||
#region Text
|
|||
|
|||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(RichTextBox), new FrameworkPropertyMetadata(String.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnTextPropertyChanged), new CoerceValueCallback(CoerceTextProperty), true, System.Windows.Data.UpdateSourceTrigger.LostFocus)); |
|||
public string Text |
|||
{ |
|||
get { return (string)GetValue(TextProperty); } |
|||
set { SetValue(TextProperty, value); } |
|||
} |
|||
|
|||
private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
|||
{ |
|||
RichTextBox rtb = (RichTextBox)d; |
|||
|
|||
if (!rtb._textHasLoaded) |
|||
{ |
|||
rtb.TextFormatter.SetText(rtb.Document, (string)e.NewValue); |
|||
rtb._textHasLoaded = true; |
|||
} |
|||
} |
|||
|
|||
private static object CoerceTextProperty(DependencyObject d, object value) |
|||
{ |
|||
return value ?? ""; |
|||
} |
|||
|
|||
#endregion //Text
|
|||
|
|||
#endregion //Properties
|
|||
|
|||
#region Methods
|
|||
|
|||
private void InvokeUpdateText() |
|||
{ |
|||
if (!isInvokePending) |
|||
{ |
|||
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(UpdateText)); |
|||
isInvokePending = true; |
|||
} |
|||
} |
|||
|
|||
private void UpdateText() |
|||
{ |
|||
//when the Text is null and the Text hasn't been loaded, it indicates that the OnTextPropertyChanged event hasn't exceuted
|
|||
//and since we are initializing the text from here, we don't want the OnTextPropertyChanged to execute, so set the loaded flag to true.
|
|||
//this prevents the cursor to jumping to the front of the textbox after the first letter is typed.
|
|||
if (!_textHasLoaded && string.IsNullOrEmpty(Text)) |
|||
_textHasLoaded = true; |
|||
|
|||
if (_textHasLoaded) |
|||
Text = TextFormatter.GetText(Document); |
|||
|
|||
isInvokePending = false; |
|||
} |
|||
|
|||
#endregion //Methods
|
|||
|
|||
#region Event Hanlders
|
|||
|
|||
private void RichTextBox_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
Binding binding = BindingOperations.GetBinding(this, TextProperty); |
|||
if (binding != null) |
|||
{ |
|||
if (binding.UpdateSourceTrigger == UpdateSourceTrigger.Default || binding.UpdateSourceTrigger == UpdateSourceTrigger.LostFocus) |
|||
{ |
|||
LostFocus += (o, ea) => UpdateText(); //do this synchronously
|
|||
} |
|||
else |
|||
{ |
|||
TextChanged += (o, ea) => InvokeUpdateText(); //do this async
|
|||
} |
|||
} |
|||
} |
|||
|
|||
#endregion //Event Hanlders
|
|||
} |
|||
} |
|||
@ -0,0 +1,926 @@ |
|||
<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"> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- Common Styles --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<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> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- 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> |
|||
<ContentControl 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> |
|||
|
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- MessageBox --> |
|||
<!-- =============================================================================== --> |
|||
|
|||
<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 WindowDarkBrush}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="CaptionForeground" Value="#FF000000" /> |
|||
<Setter Property="CloseButtonStyle" Value="{StaticResource WindowCloseButtonStyle}" /> |
|||
<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 WindowDarkBrush}" /> |
|||
<Setter Property="WindowBackground" Value="{StaticResource WindowBackgroundBrush}" /> |
|||
<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> |
|||
|
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- 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> |
|||
|
|||
<Style TargetType="{x:Type local:ChildWindow}"> |
|||
<Setter Property="Background" Value="#FFFFFFFF"/> |
|||
<Setter Property="BorderBrush" Value="{StaticResource WindowDarkBrush}" /> |
|||
<Setter Property="BorderThickness" Value="1" /> |
|||
<Setter Property="CaptionForeground" Value="#FF000000" /> |
|||
<Setter Property="CloseButtonStyle" Value="{StaticResource WindowCloseButtonStyle}" /> |
|||
<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 WindowDarkBrush}" /> |
|||
<Setter Property="WindowBackground" Value="{StaticResource WindowBackgroundBrush}" /> |
|||
<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> |
|||
|
|||
<!--VisualStateManager--> |
|||
<VisualStateManager.VisualStateGroups> |
|||
<VisualStateGroup x:Name="WindowStatesGroup"> |
|||
<VisualState x:Name="Closed"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Visibility" Duration="0"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Collapsed</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
<VisualState x:Name="Open"> |
|||
<Storyboard> |
|||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Visibility" Duration="0"> |
|||
<DiscreteObjectKeyFrame KeyTime="0"> |
|||
<DiscreteObjectKeyFrame.Value> |
|||
<Visibility>Visible</Visibility> |
|||
</DiscreteObjectKeyFrame.Value> |
|||
</DiscreteObjectKeyFrame> |
|||
</ObjectAnimationUsingKeyFrames> |
|||
</Storyboard> |
|||
</VisualState> |
|||
</VisualStateGroup> |
|||
</VisualStateManager.VisualStateGroups> |
|||
|
|||
<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> |
|||
|
|||
<!-- =============================================================================== --> |
|||
<!-- 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,9 @@ |
|||
using System; |
|||
|
|||
namespace Microsoft.Windows.Controls |
|||
{ |
|||
internal static partial class VisualStates |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,115 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>9.0.30729</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{72E591D6-8F83-4D8C-8F67-9C325E623234}</ProjectGuid> |
|||
<OutputType>library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Microsoft.Windows.Controls</RootNamespace> |
|||
<AssemblyName>WPFToolkit.Extended</AssemblyName> |
|||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
|||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
|||
<FileAlignment>512</FileAlignment> |
|||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<WarningLevel>4</WarningLevel> |
|||
<SccProjectName>SAK</SccProjectName> |
|||
<SccLocalPath>SAK</SccLocalPath> |
|||
<SccAuxPath>SAK</SccAuxPath> |
|||
<SccProvider>SAK</SccProvider> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="System.Core"> |
|||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="WindowsBase" /> |
|||
<Reference Include="PresentationCore" /> |
|||
<Reference Include="PresentationFramework" /> |
|||
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Page Include="Themes\Generic.xaml"> |
|||
<Generator>MSBuild:Compile</Generator> |
|||
<SubType>Designer</SubType> |
|||
</Page> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="BusyIndicator\BusyIndicator.cs" /> |
|||
<Compile Include="ChildWindow\ChildWindow.cs" /> |
|||
<Compile Include="ChildWindow\VisualStates.ChildWindow.cs" /> |
|||
<Compile Include="ChildWindow\WindowState.cs" /> |
|||
<Compile Include="ColorPicker\ColorPicker.cs" /> |
|||
<Compile Include="ColorPicker\HsvColor.cs" /> |
|||
<Compile Include="ColorPicker\ColorUtilities.cs" /> |
|||
<Compile Include="ColorPicker\ColorSpectrumSlider.cs" /> |
|||
<Compile Include="MessageBox\MessageBox.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs"> |
|||
<SubType>Code</SubType> |
|||
</Compile> |
|||
<Compile Include="Properties\Resources.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DesignTime>True</DesignTime> |
|||
<DependentUpon>Resources.resx</DependentUpon> |
|||
</Compile> |
|||
<Compile Include="Properties\Settings.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Settings.settings</DependentUpon> |
|||
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
|||
</Compile> |
|||
<Compile Include="BusyIndicator\VisualStates.BusyIndicator.cs" /> |
|||
<Compile Include="RichTextBox\Formatters\ITextFormatter.cs" /> |
|||
<Compile Include="RichTextBox\Formatters\PlainTextFormatter.cs" /> |
|||
<Compile Include="RichTextBox\Formatters\RtfFormatter.cs" /> |
|||
<Compile Include="RichTextBox\Formatters\XamlFormatter.cs" /> |
|||
<Compile Include="RichTextBox\RichTextBox.cs" /> |
|||
<Compile Include="VisualStates.cs" /> |
|||
<Compile Include="MessageBox\VisualStates.MessageBox.cs" /> |
|||
<EmbeddedResource Include="Properties\Resources.resx"> |
|||
<Generator>ResXFileCodeGenerator</Generator> |
|||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
|||
</EmbeddedResource> |
|||
<None Include="Properties\Settings.settings"> |
|||
<Generator>SettingsSingleFileGenerator</Generator> |
|||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
|||
</None> |
|||
<AppDesigner Include="Properties\" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Resource Include="MessageBox\Icons\Error48.png" /> |
|||
<Resource Include="MessageBox\Icons\Information48.png" /> |
|||
<Resource Include="MessageBox\Icons\Question48.png" /> |
|||
<Resource Include="MessageBox\Icons\Warning48.png" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -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" |
|||
} |
|||
Loading…
Reference in new issue