From 8ce6714ab51f6f796cf76d03d4d5b86d298cf1ae Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Fri, 3 Sep 2010 01:07:35 +0000 Subject: [PATCH] added Extended WPF Toolkit solution for Visual Studio 2008 and .NET 3.5 - this has a dependency on the WPFToolkit --- .../ExtendedWPFToolkit.sln | 29 + .../ExtendedWPFToolkit.vssscc | 10 + .../BusyIndicator/BusyIndicator.cs | 266 +++++ .../VisualStates.BusyIndicator.cs | 37 + .../ChildWindow/ChildWindow.cs | 482 +++++++++ .../ChildWindow/VisualStates.ChildWindow.cs | 22 + .../ChildWindow/WindowState.cs | 13 + .../ColorPicker/ColorPicker.cs | 390 ++++++++ .../ColorPicker/ColorSpectrumSlider.cs | 85 ++ .../ColorPicker/ColorUtilities.cs | 156 +++ .../ColorPicker/HsvColor.cs | 18 + .../MessageBox/Icons/Error48.png | Bin 0 -> 4170 bytes .../MessageBox/Icons/Information48.png | Bin 0 -> 5101 bytes .../MessageBox/Icons/Question48.png | Bin 0 -> 5492 bytes .../MessageBox/Icons/Warning48.png | Bin 0 -> 3281 bytes .../MessageBox/MessageBox.cs | 419 ++++++++ .../MessageBox/VisualStates.MessageBox.cs | 17 + .../Properties/AssemblyInfo.cs | 55 ++ .../Properties/Resources.Designer.cs | 63 ++ .../Properties/Resources.resx | 117 +++ .../Properties/Settings.Designer.cs | 26 + .../Properties/Settings.settings | 7 + .../RichTextBox/Formatters/ITextFormatter.cs | 11 + .../Formatters/PlainTextFormatter.cs | 21 + .../RichTextBox/Formatters/RtfFormatter.cs | 33 + .../RichTextBox/Formatters/XamlFormatter.cs | 40 + .../RichTextBox/RichTextBox.cs | 130 +++ .../WPFToolkit.Extended/Themes/Generic.xaml | 926 ++++++++++++++++++ .../Src/WPFToolkit.Extended/VisualStates.cs | 9 + .../WPFToolkit.Extended.csproj | 115 +++ .../WPFToolkit.Extended.csproj.vspscc | 10 + 31 files changed, 3507 insertions(+) create mode 100644 ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln create mode 100644 ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/BusyIndicator.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/VisualStates.BusyIndicator.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/VisualStates.ChildWindow.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/WindowState.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorPicker.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorSpectrumSlider.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorUtilities.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/HsvColor.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/VisualStates.MessageBox.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/VisualStates.cs create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj create mode 100644 ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc diff --git a/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln b/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln new file mode 100644 index 00000000..e1ed3032 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln @@ -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 diff --git a/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc b/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc new file mode 100644 index 00000000..794f014c --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc @@ -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" +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/BusyIndicator.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/BusyIndicator.cs new file mode 100644 index 00000000..6a73cd8f --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/BusyIndicator.cs @@ -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 +{ + /// + /// A control to provide a visual indicator when an application is busy. + /// + [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 + + /// + /// Timer used to delay the initial display and avoid flickering. + /// + 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 + + /// + /// Overrides the OnApplyTemplate method. + /// + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + ChangeVisualState(false); + } + + #endregion //Base Class Overrides + + #region Properties + + /// + /// Gets or sets a value indicating whether the BusyContent is visible. + /// + protected bool IsContentVisible { get; set; } + + #endregion //Properties + + #region Dependency Properties + + #region IsBusy + + /// + /// Identifies the IsBusy dependency property. + /// + public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register( + "IsBusy", + typeof(bool), + typeof(BusyIndicator), + new PropertyMetadata(false, new PropertyChangedCallback(OnIsBusyChanged))); + + /// + /// Gets or sets a value indicating whether the busy indicator should show. + /// + public bool IsBusy + { + get { return (bool)GetValue(IsBusyProperty); } + set { SetValue(IsBusyProperty, value); } + } + + /// + /// IsBusyProperty property changed handler. + /// + /// BusyIndicator that changed its IsBusy. + /// Event arguments. + private static void OnIsBusyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((BusyIndicator)d).OnIsBusyChanged(e); + } + + /// + /// IsBusyProperty property changed handler. + /// + /// Event arguments. + 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 + + /// + /// Identifies the BusyContent dependency property. + /// + public static readonly DependencyProperty BusyContentProperty = DependencyProperty.Register( + "BusyContent", + typeof(object), + typeof(BusyIndicator), + new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating the busy content to display to the user. + /// + public object BusyContent + { + get { return (object)GetValue(BusyContentProperty); } + set { SetValue(BusyContentProperty, value); } + } + + #endregion //Busy Content + + #region Busy Content Template + + /// + /// Identifies the BusyTemplate dependency property. + /// + public static readonly DependencyProperty BusyContentTemplateProperty = DependencyProperty.Register( + "BusyContentTemplate", + typeof(DataTemplate), + typeof(BusyIndicator), + new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating the template to use for displaying the busy content to the user. + /// + public DataTemplate BusyContentTemplate + { + get { return (DataTemplate)GetValue(BusyContentTemplateProperty); } + set { SetValue(BusyContentTemplateProperty, value); } + } + + #endregion //Busy Content Template + + #region Display After + + /// + /// Identifies the DisplayAfter dependency property. + /// + public static readonly DependencyProperty DisplayAfterProperty = DependencyProperty.Register( + "DisplayAfter", + typeof(TimeSpan), + typeof(BusyIndicator), + new PropertyMetadata(TimeSpan.FromSeconds(0.1))); + + /// + /// Gets or sets a value indicating how long to delay before displaying the busy content. + /// + public TimeSpan DisplayAfter + { + get { return (TimeSpan)GetValue(DisplayAfterProperty); } + set { SetValue(DisplayAfterProperty, value); } + } + + #endregion //Display After + + #region Overlay Style + + /// + /// Identifies the OverlayStyle dependency property. + /// + public static readonly DependencyProperty OverlayStyleProperty = DependencyProperty.Register( + "OverlayStyle", + typeof(Style), + typeof(BusyIndicator), + new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating the style to use for the overlay. + /// + public Style OverlayStyle + { + get { return (Style)GetValue(OverlayStyleProperty); } + set { SetValue(OverlayStyleProperty, value); } + } + #endregion //Overlay Style + + #region ProgressBar Style + + /// + /// Identifies the ProgressBarStyle dependency property. + /// + public static readonly DependencyProperty ProgressBarStyleProperty = DependencyProperty.Register( + "ProgressBarStyle", + typeof(Style), + typeof(BusyIndicator), + new PropertyMetadata(null)); + + /// + /// Gets or sets a value indicating the style to use for the progress bar. + /// + public Style ProgressBarStyle + { + get { return (Style)GetValue(ProgressBarStyleProperty); } + set { SetValue(ProgressBarStyleProperty, value); } + } + + #endregion //ProgressBar Style + + #endregion //Dependency Properties + + #region Methods + + /// + /// Handler for the DisplayAfterTimer. + /// + /// Event sender. + /// Event arguments. + private void DisplayAfterTimerElapsed(object sender, EventArgs e) + { + _displayAfterTimer.Stop(); + IsContentVisible = true; + ChangeVisualState(true); + } + + /// + /// Changes the control's visual state(s). + /// + /// True if state transitions should be used. + 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 + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/VisualStates.BusyIndicator.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/VisualStates.BusyIndicator.cs new file mode 100644 index 00000000..5d78d952 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/VisualStates.BusyIndicator.cs @@ -0,0 +1,37 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + internal static partial class VisualStates + { + /// + /// Busyness group name. + /// + public const string GroupBusyStatus = "BusyStatusStates"; + + /// + /// Busy state for BusyIndicator. + /// + public const string StateBusy = "Busy"; + + /// + /// Idle state for BusyIndicator. + /// + public const string StateIdle = "Idle"; + + /// + /// BusyDisplay group. + /// + public const string GroupVisibility = "VisibilityStates"; + + /// + /// Visible state name for BusyIndicator. + /// + public const string StateVisible = "Visible"; + + /// + /// Hidden state name for BusyIndicator. + /// + public const string StateHidden = "Hidden"; + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs new file mode 100644 index 00000000..8a44695d --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/ChildWindow.cs @@ -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; + /// + /// Gets or sets a value indicating whether the ChildWindow was accepted or canceled. + /// + /// + /// True if the child window was accepted; false if the child window was + /// canceled. The default is null. + /// + [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 + + /// + /// Occurs when the ChildWindow is closed. + /// + public event EventHandler Closed; + protected virtual void OnClosed(EventArgs e) + { + if (Closed != null) + Closed(this, e); + } + + /// + /// Occurs when the ChildWindow is closing. + /// + public event EventHandler Closing; + protected virtual void OnClosing(CancelEventArgs e) + { + if (Closing != null) + Closing(this, e); + } + + #endregion //Events + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/VisualStates.ChildWindow.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/VisualStates.ChildWindow.cs new file mode 100644 index 00000000..eb3a4ea9 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/VisualStates.ChildWindow.cs @@ -0,0 +1,22 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + internal static partial class VisualStates + { + /// + /// Window State group name. + /// + public const string WindowStatesGroup = "WindowStatesGroup"; + + /// + /// Open state name for ChildWindow. + /// + public const string Open = "Open"; + + /// + /// Closed state name for ChildWindow. + /// + public const string Closed = "Closed"; + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/WindowState.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/WindowState.cs new file mode 100644 index 00000000..cc001a25 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ChildWindow/WindowState.cs @@ -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 + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorPicker.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorPicker.cs new file mode 100644 index 00000000..6e6b86b9 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorPicker.cs @@ -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 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 + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorSpectrumSlider.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorSpectrumSlider.cs new file mode 100644 index 00000000..c4eac2d8 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorSpectrumSlider.cs @@ -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 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 + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorUtilities.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorUtilities.cs new file mode 100644 index 00000000..e621c22b --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/ColorUtilities.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Windows.Media; + +namespace Microsoft.Windows.Controls +{ + internal static class ColorUtilities + { + /// + /// Converts an RGB color to an HSV color. + /// + /// + /// + /// + /// + 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 }; + } + + /// + /// Converts an HSV color to an RGB color. + /// + /// + /// + /// + /// + 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)); + } + + /// + /// Generates a list of colors with hues ranging from 0 360 and a saturation and value of 1. + /// + /// + public static List GenerateHsvSpectrum() + { + List colorsList = new List(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; + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/HsvColor.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/HsvColor.cs new file mode 100644 index 00000000..eed5c3bd --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/HsvColor.cs @@ -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; + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png new file mode 100644 index 0000000000000000000000000000000000000000..4304d43b5fb9ed5285608ab9a278e0eb8261b2ef GIT binary patch literal 4170 zcmV-Q5Vh}#P)pU{7FPXRA@uxS!Z}uWfpduTin%kSKSpvK}8TdHdLypU>A@gtRVKT zfCUf~U677|k0??COHipH^p*(*B0>U5NH35~CS{ULxl=Nekn-+(zT7*{%`l0<-T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wg-U(Tp|(cx?HEpdw+@-q=~^BUiwPtIfDtI- zLRKzlV-{@OpoANh(ZOqI zX3@X$Dmbp_7y?j5$@X#7{$a!jq*9so^1I3cXAQS>%)=}aH~&AYfn#$6K{SxV^*mh2 z>ymoTB=T;vp2b*4Ijf_()G0=?k+HDgHtb*!w{z`n zH{5`&-MS%`d&YL@f-QWr7ef&c+sbQ+ufMKNZc@yWffyNEWonck%_gr!!cC5q;by%1 zIor=jYem{K+^-TcfiD;YK-4))moB}42Zt!m-Ex2knen%Lipf|jCK(fB@rR5m1~D1B zBAHy1`;9eZpRd3ET4}nNbXc*^$!(4csz5*c>@(@Q%GkW5U=?Ky6X$2mnsvdy0VUMw U78JaYB>(^b07*qoM6N<$f{feW*#H0l literal 0 HcmV?d00001 diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png new file mode 100644 index 0000000000000000000000000000000000000000..3507518716c6898b5526a9619a5e2605b8bb27f3 GIT binary patch literal 5101 zcmZ8lWmpqz+ol@?C(yzhr-{*Lb@5gmt|L!`^^SaLaj(wsBWu)VzBOxJSe59rM^iKv|1r61o(Uj~s z`cI;TYngeIkTA7h1!&eYQ#odMC#t|84}=Yx zIc941J{a@eLjG9F6$@#dAuMz?O!?0sD`vd=RQjqhn35gs+H(^2Nu?9zgX3(ush2xV zvD~tW>=JFeY%$GBH=mAobvX-Vjm^yPv9PdcX=y$1^OL2cr#CP#AjF$kTDtdG)xk;m z`T6Aob_E)nntGwhyg7HQ{fj%SN(;W62O*JimBw8-+$||7z8r|-W{1oZ4#hbCu zs0#>K4dy6?oQ5$c?wD6O&Nr0RhnV%ocYl<0j^pugZUwKR6Z~8|m$I_*$yDUykYL)T zrgSP;kCW7Hd>l)vbpmU#*nBUF6wxQa&i75z7MH;uRJ%Zi9Zid=I1rq2KN+rD1`D6m z1h2((--Fn_pq-zeZ*h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#&0x_olKo&xthU@xq^+C^Og@ zUj1eS_ZMg~yx~a_HSL?FC)BaB#F@@(oag- z{<cbO=l#NJy(pQQeH!f_?c1T!2@~9rEKCDO zUFi>qd7Lq%?(0y+PTMdy=>y6Sz;%04PR^`%)Q&tot6Q$JE0=5)m$|J$Jlj9C_Zc$e zrP8L3j-h?XZ|f*Dx)6(gbYm>>ggpBLV(1fPt!h#0-d5RXFtU^=f&38p?%4y zsGy$DRq2qoqbqA25B4okn!RIV3dy~=Ma#|$hgu7@CzGFACRQ)m(xz6tU_f`^pZ`0O NM_@h8a&_CV{{x~L{;>c6 literal 0 HcmV?d00001 diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png new file mode 100644 index 0000000000000000000000000000000000000000..dad7dd09af4316e01b95d656b50d943f0f4ffe8d GIT binary patch literal 5492 zcmV-)6^rVLP)paCP_p=RA@uBT8Up(<<_?P15~8UG>6;Qpq1s4+~v-i86 zwbrwS_dPx};BWZn>{Cfta3&4kpU=T!w*oBpD8>q}Qmpi*_>?K1E4=Pw>6Ie<=#~!ymu$>;O2b#S ziI`#*iSO-V5tdP=7;@{@EzpS6zbzW1$};hKMn(p*N~*EqYzihGxrM1_(U^5A1>c;@ z#v=D30xie(z*?M4Y{I3?R`?clz)z%5_vxM24#&GKI2754H8-lU%&QzfxE5mm*(}Vo zO~z!?C~S01M}Ao?B*LDap4v;7E-m|uKK}j31bkp%APP%L;T~IxPY(xUqH!3eolL|$ zrz`>}#>#7zFp6%1M{Wl~OS=$L(T&8a9wgWFAmvvgf8U|RRdyqws0+3!ZP*y7!BVeE ze0#A7vmG)q#UcUI%wyq`REi?%WNzSzjS%pmp`j=&E``cF4{z@Yz$eC0m~KlxyX0e$ zX9afLZiGu_2mFh=5n9%R*h&G}i}ZRRvjND`^a-ysM0h`?wpV#hp1)qu4U_mbtnk&~ zyDM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p)Dd4Du*b&bzd-l_N0MI-qf(G&HfnzJ@o42+ zuq2U78d_qfLzV1>w%o}`*yahog|BZinj`HKJ5oGZ@62LdK8eE32t=ac*F^7?t!oL&ey<3dREI`sH6A`yb?lXqoSE#dRFykylTgoI}g=cUuuLsdhh?`}ez)%w%L>r+Z z#N}->A)1;-qJgL)zy@U{t3ZFom=8+^L2e}Es|O)pHVFCrLCA~H z9h|%{#A1w1aWDSPMFMId2Gb)3LAZJvt zt13U`g0e4M*mU!*=fngQe?9?4$6Zl)%vE$x$UowSyu)tDJ>5xMaFOSlEULr5ai=N^?T|+u%I|fx$!J+ P00000NkvXXu0mjf8D~qm literal 0 HcmV?d00001 diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs new file mode 100644 index 00000000..317dd405 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/MessageBox.cs @@ -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 + + /// + /// Tracks the MessageBoxButon value passed into the InitializeContainer method + /// + 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 + + /// + /// A System.Windows.MessageBoxResult value that specifies which message box button was clicked by the user. + /// + 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 + + /// + /// Overrides the OnApplyTemplate method. + /// + 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 + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText) + { + return Show(messageText, string.Empty, MessageBoxButton.OK); + } + + /// + /// Displays a message box that has a message and title bar caption; and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption) + { + return Show(messageText, caption, MessageBoxButton.OK); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxButton value that specifies which button or buttons to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button) + { + return ShowCore(messageText, caption, button, MessageBoxImage.None); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxButton value that specifies which button or buttons to display. + /// A System.Windows.MessageBoxImage value that specifies the icon to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + 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; + } + + /// + /// Resolves the owner Window of the MessageBox. + /// + /// + 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 + + /// + /// Shows the MessageBox + /// + protected void Show() + { + Container.ShowDialog(); + } + + /// + /// Initializes the MessageBox. + /// + /// The text. + /// The caption. + /// The button. + /// The image. + protected void InitializeMessageBox(string text, string caption, MessageBoxButton button, MessageBoxImage image) + { + Text = text; + Caption = caption; + _button = button; + SetImageSource(image); + Container = CreateContainer(); + } + + /// + /// Changes the control's visual state(s). + /// + /// name of the state + /// True if state transitions should be used. + protected void ChangeVisualState(string name, bool useTransitions) + { + VisualStateManager.GoToState(this, name, useTransitions); + } + + #endregion //Protected + + #region Private + + /// + /// Sets the message image source. + /// + /// The image to show. + 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)); + } + + /// + /// Creates the container which will host the MessageBox control. + /// + /// + 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 + + /// + /// Processes the move of a drag operation on the header. + /// + /// The instance containing the event data. + private void ProcessMove(DragDeltaEventArgs e) + { + Container.Left = Container.Left + e.HorizontalChange; + Container.Top = Container.Top + e.VerticalChange; + } + + /// + /// Sets the MessageBoxResult according to the button pressed and then closes the MessageBox. + /// + /// The source of the event. + /// The instance containing the event data. + 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(); + } + + /// + /// Closes the MessageBox. + /// + private void Close() + { + Container.Close(); + } + + #endregion //Event Handlers + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/VisualStates.MessageBox.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/VisualStates.MessageBox.cs new file mode 100644 index 00000000..d47fcb08 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/VisualStates.MessageBox.cs @@ -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"; + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4826befc --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs @@ -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 +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the 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")] diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs new file mode 100644 index 00000000..eaf63633 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Windows.Controls.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx new file mode 100644 index 00000000..ffecec85 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs new file mode 100644 index 00000000..4a0f1423 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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; + } + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings new file mode 100644 index 00000000..8f2fd95d --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs new file mode 100644 index 00000000..f8e22d41 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs @@ -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); + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs new file mode 100644 index 00000000..1c792a32 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs @@ -0,0 +1,21 @@ +using System; +using System.Windows.Documents; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as plain text + /// + 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; + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs new file mode 100644 index 00000000..e5a1def6 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs @@ -0,0 +1,33 @@ +using System; +using System.Text; +using System.Windows.Documents; +using System.IO; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as RTF + /// + 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); + } + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs new file mode 100644 index 00000000..07e1d31a --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs @@ -0,0 +1,40 @@ +using System; +using System.Text; +using System.IO; +using System.Windows.Documents; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as Xaml + /// + 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."); + } + } + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs new file mode 100644 index 00000000..b449b1f1 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs @@ -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; + /// + /// The ITextFormatter the is used to format the text of the RichTextBox. + /// Deafult formatter is the RtfFormatter + /// + 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 + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml new file mode 100644 index 00000000..7b03163c --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml @@ -0,0 +1,926 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Collapsed + + + + + + + Collapsed + + + + + + + + + + + Visible + + + + + + + Visible + + + + + + + + + + + + + True + + + + + + + + + + + False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/VisualStates.cs b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/VisualStates.cs new file mode 100644 index 00000000..721a96e2 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/VisualStates.cs @@ -0,0 +1,9 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + internal static partial class VisualStates + { + + } +} diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj new file mode 100644 index 00000000..9b450cc2 --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {72E591D6-8F83-4D8C-8F67-9C325E623234} + library + Properties + Microsoft.Windows.Controls + WPFToolkit.Extended + v3.5 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + 3.5 + + + + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + \ No newline at end of file diff --git a/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc @@ -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" +}