diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/ExtendedWPFToolkit.sln b/Release/v1.4.0/ExtendedWPFToolkitSolution/ExtendedWPFToolkit.sln
new file mode 100644
index 00000000..c062fd05
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/ExtendedWPFToolkit.sln
@@ -0,0 +1,54 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFToolkit.Extended", "Src\WPFToolkit.Extended\WPFToolkit.Extended.csproj", "{72E591D6-8F83-4D8C-8F67-9C325E623234}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFToolkit.Extended.Samples", "Src\WPFToolkit.Extended.Samples\WPFToolkit.Extended.Samples.csproj", "{47B3F3DF-FAB7-4D0A-9267-109D30BF387F}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 3
+ 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
+ SccProjectUniqueName2 = Src\\WPFToolkit.Extended.Samples\\WPFToolkit.Extended.Samples.csproj
+ SccProjectName2 = Src/WPFToolkit.Extended.Samples
+ SccLocalPath2 = Src\\WPFToolkit.Extended.Samples
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ Release|x86 = Release|x86
+ 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}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|x86.ActiveCfg = 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
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|x86.ActiveCfg = Release|Any CPU
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Debug|x86.ActiveCfg = Debug|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Debug|x86.Build.0 = Debug|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Release|Any CPU.ActiveCfg = Release|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Release|Mixed Platforms.Build.0 = Release|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Release|x86.ActiveCfg = Release|x86
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/ExtendedWPFToolkit.vssscc b/Release/v1.4.0/ExtendedWPFToolkitSolution/ExtendedWPFToolkit.vssscc
new file mode 100644
index 00000000..794f014c
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/MetadataStore.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/MetadataStore.cs
new file mode 100644
index 00000000..d59e48ab
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/MetadataStore.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Microsoft.Windows.Design.Metadata;
+using Microsoft.Windows.Controls;
+using Microsoft.Windows.Design.Features;
+using System.ComponentModel;
+
+[assembly: ProvideMetadata(typeof(WPFToolkit.Extended.Design.MetadataStore))]
+
+namespace WPFToolkit.Extended.Design
+{
+ internal class MetadataStore : IProvideAttributeTable
+ {
+ public AttributeTable AttributeTable
+ {
+ get
+ {
+ AttributeTableBuilder builder = new AttributeTableBuilder();
+
+
+ //builder.AddCustomAttributes(typeof(NumericUpDown), new FeatureAttribute(typeof(NumericUpDownEditor)));
+ builder.AddCustomAttributes(typeof(NumericUpDown), "Increment",
+ new DescriptionAttribute("Specifies the amount in which to increment the value."),
+ new DisplayNameAttribute("Increment"));
+
+ builder.AddCustomAttributes(typeof(NumericUpDown), "IsEditable",
+ new DescriptionAttribute("Determines if direct entry is allowed in the text box."),
+ new DisplayNameAttribute("IsEditable"));
+
+ builder.AddCustomAttributes(typeof(NumericUpDown), "Maximum",
+ new DescriptionAttribute("Gets/Sets the maximum allowed value."),
+ new DisplayNameAttribute("Maximum"));
+
+ builder.AddCustomAttributes(typeof(NumericUpDown), "Minimum",
+ new DescriptionAttribute("Gets/Sets the minimum allowed value."),
+ new DisplayNameAttribute("Minimum"));
+
+ builder.AddCustomAttributes(typeof(NumericUpDown), "Text",
+ new DescriptionAttribute("Gets/Sets the formated string representation of the value."),
+ new DisplayNameAttribute("Text"));
+
+ builder.AddCustomAttributes(typeof(NumericUpDown), "Value",
+ new DescriptionAttribute("Gets/Sets the numeric value."),
+ new DisplayNameAttribute("Value"));
+
+ return builder.CreateTable();
+ }
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/AssemblyInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..5b13e861
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/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.Design")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WPFToolkit.Extended.Design")]
+[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.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Resources.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..7ef72466
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 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 WPFToolkit.Extended.Design.Properties
+{
+
+
+ ///
+ /// 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 ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Design.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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Resources.resx b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Resources.resx
new file mode 100644
index 00000000..ffecec85
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..72d80d66
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// 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 WPFToolkit.Extended.Design.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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.settings b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.settings
new file mode 100644
index 00000000..8f2fd95d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.csproj b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.csproj
new file mode 100644
index 00000000..fd0fa3fa
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.csproj
@@ -0,0 +1,99 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {FA6645C6-7CA5-427C-91F2-916D9FECD76C}
+ library
+ Properties
+ WPFToolkit.Extended.Design
+ WPFToolkit.Extended.Design
+ v4.0
+ Client
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ SAK
+ SAK
+ SAK
+ SAK
+
+
+ true
+ full
+ false
+ ..\WPFToolkit.Extended\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ ..\WPFToolkit.Extended\bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}
+ WPFToolkit.Extended
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.csproj.vspscc b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.csproj.vspscc
new file mode 100644
index 00000000..feffdeca
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Design/WPFToolkit.Extended.Design.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"
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml
new file mode 100644
index 00000000..00767c6d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml.cs
new file mode 100644
index 00000000..f0cfc9e7
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/App.xaml.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Windows;
+
+namespace WPFToolkit.Extended.Samples
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml
new file mode 100644
index 00000000..e61a28f8
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml.cs
new file mode 100644
index 00000000..688a567d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/MainWindow.xaml.cs
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+using System.ComponentModel;
+using System.Collections.ObjectModel;
+using Microsoft.Windows.Controls;
+using System.Text.RegularExpressions;
+using System.Diagnostics;
+
+namespace WPFToolkit.Extended.Samples
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ DataContext = new Data();
+ Loaded += new RoutedEventHandler(MainWindow_Loaded);
+ }
+
+ void MainWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+
+ }
+
+ private void Calculator_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ Debug.WriteLine(e.NewValue.HasValue ? e.NewValue.Value.ToString() : "NULL");
+ }
+
+ private void ColorCanvas_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ Debug.WriteLine(e.NewValue);
+ }
+ }
+
+ public class Data : System.ComponentModel.INotifyPropertyChanged
+ {
+
+ protected string _Text = "C2";
+ public string Text
+ {
+ get { return _Text; }
+ set
+ {
+ _Text = value;
+ NotifyPropertyChanged("Text");
+ }
+ }
+
+ private int? _integer = 5;
+ public int? Integer
+ {
+ get { return _integer; }
+ set
+ {
+ _integer = value;
+ NotifyPropertyChanged("Integer");
+ }
+ }
+
+ private double? _double = 5;
+ public double? Double
+ {
+ get { return _double; }
+ set
+ {
+ _double = value;
+ NotifyPropertyChanged("Double");
+ }
+ }
+
+ private decimal? _decimal = 5;
+ public decimal? Decimal
+ {
+ get { return _decimal; }
+ set
+ {
+ _decimal = value;
+ NotifyPropertyChanged("Decimal");
+ }
+ }
+
+
+ private DateTime? _dueDate;
+ public DateTime? DueDate
+ {
+ get { return _dueDate; }
+ set
+ {
+ _dueDate = value;
+ NotifyPropertyChanged("DueDate");
+ }
+ }
+
+
+
+ public Data()
+ {
+ //Text = "testm";
+ }
+
+ #region PropertyChanged
+ public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
+
+ private void NotifyPropertyChanged(string info)
+ {
+ if (PropertyChanged != null)
+ {
+ PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(info));
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/AssemblyInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..35e4c7aa
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/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.Samples")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WPFToolkit.Extended.Samples")]
+[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.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Resources.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..3c757353
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 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 WPFToolkit.Extended.Samples.Properties
+{
+
+
+ ///
+ /// 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 ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Samples.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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Resources.resx b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Resources.resx
new file mode 100644
index 00000000..ffecec85
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..a353c3db
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// 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 WPFToolkit.Extended.Samples.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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.settings b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.settings
new file mode 100644
index 00000000..8f2fd95d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.csproj b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.csproj
new file mode 100644
index 00000000..e49eab24
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.csproj
@@ -0,0 +1,113 @@
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {47B3F3DF-FAB7-4D0A-9267-109D30BF387F}
+ WinExe
+ Properties
+ WPFToolkit.Extended.Samples
+ WPFToolkit.Extended.Samples
+ v4.0
+ Client
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ SAK
+ SAK
+ SAK
+ SAK
+
+
+ x86
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ x86
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+ {72E591D6-8F83-4D8C-8F67-9C325E623234}
+ WPFToolkit.Extended
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.csproj.vspscc b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.csproj.vspscc
new file mode 100644
index 00000000..feffdeca
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended.Samples/WPFToolkit.Extended.Samples.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"
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/BusyIndicator.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/BusyIndicator.cs
new file mode 100644
index 00000000..6a73cd8f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/VisualStates.BusyIndicator.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/VisualStates.BusyIndicator.cs
new file mode 100644
index 00000000..5d78d952
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Implementation/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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Themes/Generic.xaml
new file mode 100644
index 00000000..7966fe0f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/BusyIndicator/Themes/Generic.xaml
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Collapsed
+
+
+
+
+
+
+ Collapsed
+
+
+
+
+
+
+
+
+
+
+ Visible
+
+
+
+
+
+
+ Visible
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ButtonSpinner.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ButtonSpinner.cs
new file mode 100644
index 00000000..fde872d8
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ButtonSpinner.cs
@@ -0,0 +1,231 @@
+using System;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Markup;
+using System.Windows.Controls.Primitives;
+
+namespace Microsoft.Windows.Controls
+{
+ ///
+ /// Represents a spinner control that includes two Buttons.
+ ///
+ [ContentProperty("Content")]
+ public class ButtonSpinner : Spinner
+ {
+ #region Properties
+
+ #region AllowSpin
+
+ public static readonly DependencyProperty AllowSpinProperty = DependencyProperty.Register("AllowSpin", typeof(bool), typeof(ButtonSpinner), new UIPropertyMetadata(true));
+ public bool AllowSpin
+ {
+ get { return (bool)GetValue(AllowSpinProperty); }
+ set { SetValue(AllowSpinProperty, value); }
+ }
+
+ #endregion //AllowSpin
+
+ #region Content
+
+ ///
+ /// Identifies the Content dependency property.
+ ///
+ public static readonly DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(object), typeof(ButtonSpinner), new PropertyMetadata(null, OnContentPropertyChanged));
+ public object Content
+ {
+ get { return GetValue(ContentProperty) as object; }
+ set { SetValue(ContentProperty, value); }
+ }
+
+ ///
+ /// ContentProperty property changed handler.
+ ///
+ /// ButtonSpinner that changed its Content.
+ /// Event arguments.
+ private static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonSpinner source = d as ButtonSpinner;
+ source.OnContentChanged(e.OldValue, e.NewValue);
+ }
+
+ #endregion //Content
+
+ #region DecreaseButton
+
+ private ButtonBase _decreaseButton;
+ ///
+ /// Gets or sets the DecreaseButton template part.
+ ///
+ private ButtonBase DecreaseButton
+ {
+ get { return _decreaseButton; }
+ set
+ {
+ if (_decreaseButton != null)
+ {
+ _decreaseButton.Click -= OnButtonClick;
+ }
+
+ _decreaseButton = value;
+
+ if (_decreaseButton != null)
+ {
+ _decreaseButton.Click += OnButtonClick;
+ }
+ }
+ }
+
+ #endregion //DecreaseButton
+
+ #region IncreaseButton
+
+ private ButtonBase _increaseButton;
+ ///
+ /// Gets or sets the IncreaseButton template part.
+ ///
+ private ButtonBase IncreaseButton
+ {
+ get { return _increaseButton; }
+ set
+ {
+ if (_increaseButton != null)
+ {
+ _increaseButton.Click -= OnButtonClick;
+ }
+
+ _increaseButton = value;
+
+ if (_increaseButton != null)
+ {
+ _increaseButton.Click += OnButtonClick;
+ }
+ }
+ }
+
+ #endregion //IncreaseButton
+
+ #region ShowButtonSpinner
+
+ public static readonly DependencyProperty ShowButtonSpinnerProperty = DependencyProperty.Register("ShowButtonSpinner", typeof(bool), typeof(ButtonSpinner), new UIPropertyMetadata(true));
+ public bool ShowButtonSpinner
+ {
+ get { return (bool)GetValue(ShowButtonSpinnerProperty); }
+ set { SetValue(ShowButtonSpinnerProperty, value); }
+ }
+
+ #endregion //ShowButtonSpinner
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static ButtonSpinner()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ButtonSpinner), new FrameworkPropertyMetadata(typeof(ButtonSpinner)));
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ IncreaseButton = GetTemplateChild("IncreaseButton") as ButtonBase;
+ DecreaseButton = GetTemplateChild("DecreaseButton") as ButtonBase;
+
+ SetButtonUsage();
+ }
+
+ ///
+ /// Cancel LeftMouseButtonUp events originating from a button that has
+ /// been changed to disabled.
+ ///
+ /// The data for the event.
+ protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
+ {
+ base.OnMouseLeftButtonUp(e);
+
+ Point mousePosition;
+ if (IncreaseButton != null && IncreaseButton.IsEnabled == false)
+ {
+ mousePosition = e.GetPosition(IncreaseButton);
+ if (mousePosition.X > 0 && mousePosition.X < IncreaseButton.ActualWidth &&
+ mousePosition.Y > 0 && mousePosition.Y < IncreaseButton.ActualHeight)
+ {
+ e.Handled = true;
+ }
+ }
+
+ if (DecreaseButton != null && DecreaseButton.IsEnabled == false)
+ {
+ mousePosition = e.GetPosition(DecreaseButton);
+ if (mousePosition.X > 0 && mousePosition.X < DecreaseButton.ActualWidth &&
+ mousePosition.Y > 0 && mousePosition.Y < DecreaseButton.ActualHeight)
+ {
+ e.Handled = true;
+ }
+ }
+ }
+
+ ///
+ /// Called when valid spin direction changed.
+ ///
+ /// The old value.
+ /// The new value.
+ protected override void OnValidSpinDirectionChanged(ValidSpinDirections oldValue, ValidSpinDirections newValue)
+ {
+ SetButtonUsage();
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ ///
+ /// Handle click event of IncreaseButton and DecreaseButton template parts,
+ /// translating Click to appropriate Spin event.
+ ///
+ /// Event sender, should be either IncreaseButton or DecreaseButton template part.
+ /// Event args.
+ private void OnButtonClick(object sender, RoutedEventArgs e)
+ {
+ if (AllowSpin)
+ {
+ SpinDirection direction = sender == IncreaseButton ? SpinDirection.Increase : SpinDirection.Decrease;
+ OnSpin(new SpinEventArgs(direction));
+ }
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ ///
+ /// Occurs when the Content property value changed.
+ ///
+ /// The old value of the Content property.
+ /// The new value of the Content property.
+ protected virtual void OnContentChanged(object oldValue, object newValue) { }
+
+ ///
+ /// Disables or enables the buttons based on the valid spin direction.
+ ///
+ private void SetButtonUsage()
+ {
+ // buttonspinner adds buttons that spin, so disable accordingly.
+ if (IncreaseButton != null)
+ {
+ IncreaseButton.IsEnabled = ((ValidSpinDirection & ValidSpinDirections.Increase) == ValidSpinDirections.Increase);
+ }
+
+ if (DecreaseButton != null)
+ {
+ DecreaseButton.IsEnabled = ((ValidSpinDirection & ValidSpinDirections.Decrease) == ValidSpinDirections.Decrease);
+ }
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinDirection.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinDirection.cs
new file mode 100644
index 00000000..aaa121fb
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinDirection.cs
@@ -0,0 +1,21 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ ///
+ /// Represents spin directions that could be initiated by the end-user.
+ ///
+ /// Preview
+ public enum SpinDirection
+ {
+ ///
+ /// Represents a spin initiated by the end-user in order to Increase a value.
+ ///
+ Increase = 0,
+
+ ///
+ /// Represents a spin initiated by the end-user in order to Decrease a value.
+ ///
+ Decrease = 1
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinEventArgs.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinEventArgs.cs
new file mode 100644
index 00000000..f8a89385
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/SpinEventArgs.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls
+{
+ ///
+ /// Provides data for the Spinner.Spin event.
+ ///
+ /// Preview
+ public class SpinEventArgs : RoutedEventArgs
+ {
+ ///
+ /// Gets the SpinDirection for the spin that has been initiated by the
+ /// end-user.
+ ///
+ public SpinDirection Direction { get; private set; }
+
+ ///
+ /// Initializes a new instance of the SpinEventArgs class.
+ ///
+ /// Spin direction.
+ public SpinEventArgs(SpinDirection direction)
+ : base()
+ {
+ Direction = direction;
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/Spinner.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/Spinner.cs
new file mode 100644
index 00000000..63b2a22a
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/Spinner.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Windows.Controls;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls
+{
+ ///
+ /// Base class for controls that represents controls that can spin.
+ ///
+ public abstract class Spinner : Control
+ {
+ #region Properties
+
+ ///
+ /// Identifies the ValidSpinDirection dependency property.
+ ///
+ public static readonly DependencyProperty ValidSpinDirectionProperty = DependencyProperty.Register("ValidSpinDirection", typeof(ValidSpinDirections), typeof(Spinner), new PropertyMetadata(ValidSpinDirections.Increase | ValidSpinDirections.Decrease, OnValidSpinDirectionPropertyChanged));
+ public ValidSpinDirections ValidSpinDirection
+ {
+ get { return (ValidSpinDirections)GetValue(ValidSpinDirectionProperty); }
+ set { SetValue(ValidSpinDirectionProperty, value); }
+ }
+
+ ///
+ /// ValidSpinDirectionProperty property changed handler.
+ ///
+ /// ButtonSpinner that changed its ValidSpinDirection.
+ /// Event arguments.
+ private static void OnValidSpinDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Spinner source = (Spinner)d;
+ ValidSpinDirections oldvalue = (ValidSpinDirections)e.OldValue;
+ ValidSpinDirections newvalue = (ValidSpinDirections)e.NewValue;
+ source.OnValidSpinDirectionChanged(oldvalue, newvalue);
+ }
+
+ #endregion //Properties
+
+ ///
+ /// Occurs when spinning is initiated by the end-user.
+ ///
+ public event EventHandler Spin;
+
+ ///
+ /// Initializes a new instance of the Spinner class.
+ ///
+ protected Spinner() { }
+
+ ///
+ /// Raises the OnSpin event when spinning is initiated by the end-user.
+ ///
+ /// Spin event args.
+ protected virtual void OnSpin(SpinEventArgs e)
+ {
+ ValidSpinDirections valid = e.Direction == SpinDirection.Increase ? ValidSpinDirections.Increase : ValidSpinDirections.Decrease;
+
+ //Only raise the event if spin is allowed.
+ if ((ValidSpinDirection & valid) == valid)
+ {
+ EventHandler handler = Spin;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
+ }
+
+ ///
+ /// Called when valid spin direction changed.
+ ///
+ /// The old value.
+ /// The new value.
+ protected virtual void OnValidSpinDirectionChanged(ValidSpinDirections oldValue, ValidSpinDirections newValue) { }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ValidSpinDirections.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ValidSpinDirections.cs
new file mode 100644
index 00000000..d744620d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Implementation/ValidSpinDirections.cs
@@ -0,0 +1,26 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ ///
+ /// Represents spin directions that are valid.
+ ///
+ [Flags]
+ public enum ValidSpinDirections
+ {
+ ///
+ /// Can not increase nor decrease.
+ ///
+ None = 0,
+
+ ///
+ /// Can increase.
+ ///
+ Increase = 1,
+
+ ///
+ /// Can decrease.
+ ///
+ Decrease = 2
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml
new file mode 100644
index 00000000..73c19ad1
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/Calculator.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/Calculator.cs
new file mode 100644
index 00000000..90f23f83
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/Calculator.cs
@@ -0,0 +1,455 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Threading;
+using Microsoft.Windows.Controls.Core.Utilities;
+
+namespace Microsoft.Windows.Controls
+{
+ public class Calculator : Control
+ {
+ #region Members
+
+ private ContentControl _buttonPanel;
+ private readonly DispatcherTimer _timer;
+ private Button _calculatorButton;
+
+ private bool _showNewNumber = true;
+ private decimal _previousValue;
+ private Operation _lastOperation = Operation.None;
+ private CalculatorButtonType _lastButtonPressed;
+
+ #endregion //Members
+
+ #region Enumerations
+
+ public enum CalculatorButtonType
+ {
+ Add,
+ Back,
+ Cancel,
+ Clear,
+ Decimal,
+ Divide,
+ Eight,
+ Equal,
+ Five,
+ Four,
+ Fraction,
+ MAdd,
+ MC,
+ MR,
+ MS,
+ MSub,
+ Multiply,
+ Negate,
+ Nine,
+ None,
+ One,
+ Percent,
+ Seven,
+ Six,
+ Sqrt,
+ Subtract,
+ Three,
+ Two,
+ Zero
+ }
+
+ public enum Operation
+ {
+ Add,
+ Subtract,
+ Divide,
+ Multiply,
+ Percent,
+ Sqrt,
+ Fraction,
+ None,
+ Clear,
+ Negate
+ }
+
+ #endregion //Enumerations
+
+ #region Properties
+
+ public ICommand CalculaterButtonClickCommand { get; private set; }
+
+ #region CalculatorButtonType
+
+ public static readonly DependencyProperty CalculatorButtonTypeProperty = DependencyProperty.RegisterAttached("CalculatorButtonType", typeof(CalculatorButtonType), typeof(Calculator), new UIPropertyMetadata(CalculatorButtonType.None, OnCalculatorButtonTypeChanged));
+ public static CalculatorButtonType GetCalculatorButtonType(DependencyObject target)
+ {
+ return (CalculatorButtonType)target.GetValue(CalculatorButtonTypeProperty);
+ }
+ public static void SetCalculatorButtonType(DependencyObject target, CalculatorButtonType value)
+ {
+ target.SetValue(CalculatorButtonTypeProperty, value);
+ }
+ private static void OnCalculatorButtonTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ OnCalculatorButtonTypeChanged(o, (CalculatorButtonType)e.OldValue, (CalculatorButtonType)e.NewValue);
+ }
+ private static void OnCalculatorButtonTypeChanged(DependencyObject o, CalculatorButtonType oldValue, CalculatorButtonType newValue)
+ {
+ Button button = o as Button;
+ button.CommandParameter = newValue;
+ button.Content = CalculatorUtilities.GetCalculatorButtonContent(newValue);
+ }
+
+ #endregion //CalculatorButtonType
+
+ #region DisplayText
+
+ public static readonly DependencyProperty DisplayTextProperty = DependencyProperty.Register("DisplayText", typeof(string), typeof(Calculator), new UIPropertyMetadata("0", OnDisplayTextChanged));
+ public string DisplayText
+ {
+ get { return (string)GetValue(DisplayTextProperty); }
+ set { SetValue(DisplayTextProperty, value); }
+ }
+
+ private static void OnDisplayTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ Calculator calculator = o as Calculator;
+ if (calculator != null)
+ calculator.OnDisplayTextChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnDisplayTextChanged(string oldValue, string newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //DisplayText
+
+ #region Memory
+
+ public static readonly DependencyProperty MemoryProperty = DependencyProperty.Register("Memory", typeof(decimal), typeof(Calculator), new UIPropertyMetadata(default(decimal)));
+ public decimal Memory
+ {
+ get { return (decimal)GetValue(MemoryProperty); }
+ set { SetValue(MemoryProperty, value); }
+ }
+
+ #endregion //Memory
+
+ #region Precision
+
+ public static readonly DependencyProperty PrecisionProperty = DependencyProperty.Register("Precision", typeof(int), typeof(Calculator), new UIPropertyMetadata(6));
+ public int Precision
+ {
+ get { return (int)GetValue(PrecisionProperty); }
+ set { SetValue(PrecisionProperty, value); }
+ }
+
+ #endregion //Precision
+
+ #region Value
+
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(decimal?), typeof(Calculator), new FrameworkPropertyMetadata(default(decimal), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged));
+ public decimal? Value
+ {
+ get { return (decimal?)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ Calculator calculator = o as Calculator;
+ if (calculator != null)
+ calculator.OnValueChanged((decimal?)e.OldValue, (decimal?)e.NewValue);
+ }
+
+ protected virtual void OnValueChanged(decimal? oldValue, decimal? newValue)
+ {
+ if (newValue.HasValue)
+ DisplayText = newValue.ToString();
+ else
+ DisplayText = "0";
+
+ RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue);
+ args.RoutedEvent = ValueChangedEvent;
+ RaiseEvent(args);
+ }
+
+ #endregion //Value
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static Calculator()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(Calculator), new FrameworkPropertyMetadata(typeof(Calculator)));
+ }
+
+ public Calculator()
+ {
+ _timer = new DispatcherTimer();
+ _timer.Interval = TimeSpan.FromMilliseconds(100);
+ _timer.Tick += Timer_Tick;
+
+ CommandBindings.Add(new CommandBinding(CalculatorCommands.CalculatorButtonClick, ExecuteCalculatorButtonClick));
+ AddHandler(MouseDownEvent, new MouseButtonEventHandler(Calculator_OnMouseDown), true);
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _buttonPanel = (ContentControl)GetTemplateChild("PART_CalculatorButtonPanel");
+ }
+
+ protected override void OnTextInput(TextCompositionEventArgs e)
+ {
+ var buttonType = CalculatorUtilities.GetCalculatorButtonTypeFromText(e.Text);
+ if (buttonType != CalculatorButtonType.None)
+ {
+ SimulateCalculatorButtonClick(buttonType);
+ ProcessCalculatorButton(buttonType);
+ }
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ private void Calculator_OnMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ Focus();
+ }
+
+ void Timer_Tick(object sender, EventArgs e)
+ {
+ VisualStateManager.GoToState(_calculatorButton, _calculatorButton.IsMouseOver ? "MouseOver" : "Normal", true);
+ _timer.Stop();
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ private void Calculate()
+ {
+ if (_lastOperation == Operation.None)
+ return;
+
+ try
+ {
+ Value = Decimal.Round(CalculateValue(_lastOperation), Precision);
+ }
+ catch
+ {
+ Value = null;
+ DisplayText = "ERROR";
+ }
+ }
+
+ private void Calculate(Operation newOperation)
+ {
+ if (!_showNewNumber)
+ Calculate();
+
+ _lastOperation = newOperation;
+ }
+
+ private void Calculate(Operation currentOperation, Operation newOperation)
+ {
+ _lastOperation = currentOperation;
+ Calculate();
+ _lastOperation = newOperation;
+ }
+
+ private decimal CalculateValue(Operation operation)
+ {
+ decimal newValue = decimal.Zero;
+ decimal currentValue = CalculatorUtilities.ParseDecimal(DisplayText);
+
+ switch (operation)
+ {
+ case Operation.Add:
+ newValue = CalculatorUtilities.Add(_previousValue, currentValue);
+ break;
+ case Operation.Subtract:
+ newValue = CalculatorUtilities.Subtract(_previousValue, currentValue);
+ break;
+ case Operation.Multiply:
+ newValue = CalculatorUtilities.Multiply(_previousValue, currentValue);
+ break;
+ case Operation.Divide:
+ newValue = CalculatorUtilities.Divide(_previousValue, currentValue);
+ break;
+ case Operation.Percent:
+ newValue = CalculatorUtilities.Percent(_previousValue, currentValue);
+ break;
+ case Operation.Sqrt:
+ newValue = CalculatorUtilities.SquareRoot(currentValue);
+ break;
+ case Operation.Fraction:
+ newValue = CalculatorUtilities.Fraction(currentValue);
+ break;
+ case Operation.Negate:
+ newValue = CalculatorUtilities.Negate(currentValue);
+ break;
+ default:
+ newValue = decimal.Zero;
+ break;
+ }
+
+ return newValue;
+ }
+
+ void ProcessBackKey()
+ {
+ string displayText;
+ if (DisplayText.Length > 1 && !(DisplayText.Length == 2 && DisplayText[0] == '-'))
+ {
+ displayText = DisplayText.Remove(DisplayText.Length - 1, 1);
+ }
+ else
+ {
+ displayText = "0";
+ _showNewNumber = true;
+ }
+
+ DisplayText = displayText;
+ }
+
+ private void ProcessCalculatorButton(CalculatorButtonType buttonType)
+ {
+ if (CalculatorUtilities.IsDigit(buttonType))
+ ProcessDigitKey(buttonType);
+ else if ((CalculatorUtilities.IsMemory(buttonType)))
+ ProcessMemoryKey(buttonType);
+ else
+ ProcessOperationKey(buttonType);
+
+ _lastButtonPressed = buttonType;
+ }
+
+ private void ProcessDigitKey(CalculatorButtonType buttonType)
+ {
+ if (_showNewNumber)
+ DisplayText = CalculatorUtilities.GetCalculatorButtonContent(buttonType);
+ else
+ DisplayText += CalculatorUtilities.GetCalculatorButtonContent(buttonType);
+
+ _showNewNumber = false;
+ }
+
+ private void ProcessMemoryKey(Calculator.CalculatorButtonType buttonType)
+ {
+ decimal currentValue = CalculatorUtilities.ParseDecimal(DisplayText);
+
+ switch (buttonType)
+ {
+ case Calculator.CalculatorButtonType.MAdd:
+ Memory += currentValue;
+ break;
+ case Calculator.CalculatorButtonType.MC:
+ Memory = decimal.Zero;
+ break;
+ case Calculator.CalculatorButtonType.MR:
+ DisplayText = Memory.ToString();
+ break;
+ case Calculator.CalculatorButtonType.MS:
+ Memory = currentValue;
+ break;
+ case Calculator.CalculatorButtonType.MSub:
+ Memory -= currentValue;
+ break;
+ default:
+ break;
+ }
+
+ _showNewNumber = true;
+ }
+
+ private void ProcessOperationKey(CalculatorButtonType buttonType)
+ {
+ switch (buttonType)
+ {
+ case CalculatorButtonType.Add:
+ Calculate(Operation.Add);
+ break;
+ case CalculatorButtonType.Subtract:
+ Calculate(Operation.Subtract);
+ break;
+ case CalculatorButtonType.Multiply:
+ Calculate(Operation.Multiply);
+ break;
+ case CalculatorButtonType.Divide:
+ Calculate(Operation.Divide);
+ break;
+ case CalculatorButtonType.Percent:
+ Calculate(Operation.Percent);
+ break;
+ case CalculatorButtonType.Sqrt:
+ Calculate(Operation.Sqrt, Operation.None);
+ break;
+ case CalculatorButtonType.Fraction:
+ Calculate(Operation.Fraction, Operation.None);
+ break;
+ case CalculatorButtonType.Negate:
+ Calculate(Operation.Negate, Operation.None);
+ break;
+ case CalculatorButtonType.Equal:
+ Calculate(Operation.None);
+ break;
+ case CalculatorButtonType.Clear:
+ Calculate(Operation.Clear, Operation.None);
+ DisplayText = Value.ToString();
+ break;
+ case CalculatorButtonType.Cancel:
+ DisplayText = _previousValue.ToString();
+ _lastOperation = Operation.None;
+ _showNewNumber = true;
+ return;
+ case CalculatorButtonType.Back:
+ ProcessBackKey();
+ return;
+ default:
+ break;
+ }
+
+ Decimal.TryParse(DisplayText, out _previousValue);
+ _showNewNumber = true;
+ }
+
+ private void SimulateCalculatorButtonClick(CalculatorButtonType buttonType)
+ {
+ _calculatorButton = CalculatorUtilities.FindButtonByCalculatorButtonType(_buttonPanel, buttonType);
+ VisualStateManager.GoToState(_calculatorButton, "Pressed", true);
+ _timer.Start();
+ }
+
+ #endregion //Methods
+
+ #region Events
+
+ public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(Calculator));
+ public event RoutedPropertyChangedEventHandler ValueChanged
+ {
+ add { AddHandler(ValueChangedEvent, value); }
+ remove { RemoveHandler(ValueChangedEvent, value); }
+ }
+
+ #endregion //Events
+
+ #region Commands
+
+ private void ExecuteCalculatorButtonClick(object sender, ExecutedRoutedEventArgs e)
+ {
+ var buttonType = (CalculatorButtonType)e.Parameter;
+ ProcessCalculatorButton(buttonType);
+ }
+
+ #endregion //Commands
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/CalculatorCommands.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/CalculatorCommands.cs
new file mode 100644
index 00000000..47fbc8df
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Implementation/CalculatorCommands.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Windows.Input;
+
+namespace Microsoft.Windows.Controls
+{
+ public static class CalculatorCommands
+ {
+ private static RoutedCommand _calculatorButtonClickCommand = new RoutedCommand();
+ public static RoutedCommand CalculatorButtonClick
+ {
+ get { return _calculatorButtonClickCommand; }
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Themes/Generic.xaml
new file mode 100644
index 00000000..37529ff7
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Calculator/Themes/Generic.xaml
@@ -0,0 +1,496 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs
new file mode 100644
index 00000000..237f990f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Implementation/CalculatorUpDown.cs
@@ -0,0 +1,165 @@
+using System;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Controls.Primitives;
+
+namespace Microsoft.Windows.Controls
+{
+ public class CalculatorUpDown : DecimalUpDown
+ {
+ #region Members
+
+ private Popup _calculatorPopup;
+ private Calculator _calculator;
+
+ #endregion //Members
+
+ #region Properties
+
+ #region DisplayText
+
+ public static readonly DependencyProperty DisplayTextProperty = DependencyProperty.Register("DisplayText", typeof(string), typeof(CalculatorUpDown), new UIPropertyMetadata("0"));
+ public string DisplayText
+ {
+ get { return (string)GetValue(DisplayTextProperty); }
+ set { SetValue(DisplayTextProperty, value); }
+ }
+
+ #endregion //DisplayText
+
+ #region EnterClosesCalculator
+
+ public static readonly DependencyProperty EnterClosesCalculatorProperty = DependencyProperty.Register("EnterClosesCalculator", typeof(bool), typeof(CalculatorUpDown), new UIPropertyMetadata(false));
+ public bool EnterClosesCalculator
+ {
+ get { return (bool)GetValue(EnterClosesCalculatorProperty); }
+ set { SetValue(EnterClosesCalculatorProperty, value); }
+ }
+
+ #endregion //EnterClosesCalculator
+
+ #region IsOpen
+
+ public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(CalculatorUpDown), new UIPropertyMetadata(false, OnIsOpenChanged));
+ public bool IsOpen
+ {
+ get { return (bool)GetValue(IsOpenProperty); }
+ set { SetValue(IsOpenProperty, value); }
+ }
+
+ private static void OnIsOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ CalculatorUpDown calculatorUpDown = o as CalculatorUpDown;
+ if (calculatorUpDown != null)
+ calculatorUpDown.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnIsOpenChanged(bool oldValue, bool newValue)
+ {
+
+ }
+
+ #endregion //IsOpen
+
+ #region Memory
+
+ public static readonly DependencyProperty MemoryProperty = DependencyProperty.Register("Memory", typeof(decimal), typeof(CalculatorUpDown), new UIPropertyMetadata(default(decimal)));
+ public decimal Memory
+ {
+ get { return (decimal)GetValue(MemoryProperty); }
+ set { SetValue(MemoryProperty, value); }
+ }
+
+ #endregion //Memory
+
+ #region Precision
+
+ public static readonly DependencyProperty PrecisionProperty = DependencyProperty.Register("Precision", typeof(int), typeof(CalculatorUpDown), new UIPropertyMetadata(6));
+ public int Precision
+ {
+ get { return (int)GetValue(PrecisionProperty); }
+ set { SetValue(PrecisionProperty, value); }
+ }
+
+ #endregion //Precision
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static CalculatorUpDown()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(CalculatorUpDown), new FrameworkPropertyMetadata(typeof(CalculatorUpDown)));
+ }
+
+ public CalculatorUpDown()
+ {
+ Keyboard.AddKeyDownHandler(this, OnKeyDown);
+ Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement);
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ _calculatorPopup = (Popup)GetTemplateChild("PART_CalculatorPopup");
+ _calculatorPopup.Opened += CalculatorPopup_Opened;
+
+ _calculator = (Calculator)GetTemplateChild("PART_Calculator");
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ void CalculatorPopup_Opened(object sender, EventArgs e)
+ {
+ _calculator.Focus();
+ }
+
+ private void OnKeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case Key.Enter:
+ {
+ if (EnterClosesCalculator && IsOpen)
+ CloseCalculatorUpDown();
+ break;
+ }
+ case Key.Escape:
+ {
+ CloseCalculatorUpDown();
+ e.Handled = true;
+ break;
+ }
+ case Key.Tab:
+ {
+ CloseCalculatorUpDown();
+ break;
+ }
+ }
+ }
+
+ private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e)
+ {
+ CloseCalculatorUpDown();
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ private void CloseCalculatorUpDown()
+ {
+ if (IsOpen)
+ IsOpen = false;
+ ReleaseMouseCapture();
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Themes/Generic.xaml
new file mode 100644
index 00000000..eb1edc87
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/CalculatorUpDown/Themes/Generic.xaml
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/ChildWindow.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/ChildWindow.cs
new file mode 100644
index 00000000..c5b839c8
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/ChildWindow.cs
@@ -0,0 +1,703 @@
+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;
+using System.Windows.Shapes;
+using System.Windows.Threading;
+
+namespace Microsoft.Windows.Controls
+{
+ public class ChildWindow : ContentControl
+ {
+ #region Private Members
+
+ private Grid _root;
+ private TranslateTransform _moveTransform = new TranslateTransform();
+ private bool _startupPositionInitialized;
+ private bool _isMouseCaptured;
+ private Point _clickPoint;
+ private Point _oldPosition;
+ private Border _dragWidget;
+ private FrameworkElement _parentContainer;
+ private Rectangle _modalLayer = new Rectangle();
+ private Canvas _modalLayerPanel = new Canvas();
+
+ private const int _horizaontalOffset = 3;
+ private const int _verticalOffset = 3;
+
+ bool _ignorePropertyChanged;
+
+ #endregion //Private Members
+
+ #region Constructors
+
+ static ChildWindow()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ChildWindow), new FrameworkPropertyMetadata(typeof(ChildWindow)));
+ }
+
+ public ChildWindow()
+ {
+ IsVisibleChanged += ChildWindow_IsVisibleChanged;
+
+ _modalLayer.Fill = OverlayBrush;
+ _modalLayer.Opacity = OverlayOpacity;
+ }
+
+ #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();
+
+ WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid;
+ WindowRoot.RenderTransform = _moveTransform;
+
+ _parentContainer = VisualTreeHelper.GetParent(this) as FrameworkElement;
+ _parentContainer.LayoutUpdated += ParentContainer_LayoutUpdated;
+ _parentContainer.SizeChanged += ParentContainer_SizeChanged;
+
+ //initialize our modal background width/height
+ _modalLayer.Height = _parentContainer.ActualHeight;
+ _modalLayer.Width = _parentContainer.ActualWidth;
+
+ //this is for XBAP applications only. When inside an XBAP the parent container has no height or width until it has loaded. Therefore
+ //we need to handle the loaded event and reposition the window.
+ if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted)
+ {
+ _parentContainer.Loaded += (o, e) =>
+ {
+ ExecuteOpen();
+ };
+ }
+
+ _root = GetTemplateChild("Root") as Grid;
+
+ Style focusStyle = _root.Resources["FocusVisualStyle"] as Style;
+ if (focusStyle != null)
+ {
+ Setter focusStyleDataContext = new Setter(Control.DataContextProperty, this);
+ focusStyle.Setters.Add(focusStyleDataContext);
+ FocusVisualStyle = focusStyle;
+ }
+
+ _root.Children.Add(_modalLayerPanel);
+ }
+
+ protected override void OnGotFocus(RoutedEventArgs e)
+ {
+ Action action = () =>
+ {
+ if (FocusedElement != null)
+ FocusedElement.Focus();
+ };
+
+ Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, action);
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+
+ if (WindowState == WindowState.Open)
+ {
+ switch (e.Key)
+ {
+ case Key.Left:
+ this.Left -= _horizaontalOffset;
+ e.Handled = true;
+ break;
+
+ case Key.Right:
+ this.Left += _horizaontalOffset;
+ e.Handled = true;
+ break;
+
+ case Key.Down:
+ this.Top += _verticalOffset;
+ e.Handled = true;
+ break;
+
+ case Key.Up:
+ this.Top -= _verticalOffset;
+ e.Handled = true;
+ break;
+ }
+ }
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Properties
+
+ #region Internal Properties
+
+ 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 Public Properties
+
+ #region Caption
+
+ public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(object), typeof(ChildWindow), new UIPropertyMetadata(String.Empty));
+ public object Caption
+ {
+ get { return (object)GetValue(CaptionProperty); }
+ set { SetValue(CaptionProperty, value); }
+ }
+
+ #endregion //Caption
+
+ #region CaptionForeground
+
+ 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); }
+ }
+
+ #endregion //CaptionForeground
+
+ #region CloseButtonStyle
+
+ 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); }
+ }
+
+ #endregion //CloseButtonStyle
+
+ #region CloseButtonVisibility
+
+ 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); }
+ }
+
+ #endregion //CloseButtonVisibility
+
+ #region DialogResult
+
+ 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 //DialogResult
+
+ #region FocusedElement
+
+ public static readonly DependencyProperty FocusedElementProperty = DependencyProperty.Register("FocusedElement", typeof(FrameworkElement), typeof(ChildWindow), new UIPropertyMetadata(null));
+ public FrameworkElement FocusedElement
+ {
+ get { return (FrameworkElement)GetValue(FocusedElementProperty); }
+ set { SetValue(FocusedElementProperty, value); }
+ }
+
+ #endregion
+
+ #region IsModal
+
+ public static readonly DependencyProperty IsModalProperty = DependencyProperty.Register("IsModal", typeof(bool), typeof(ChildWindow), new UIPropertyMetadata(false, new PropertyChangedCallback(OnIsModalPropertyChanged)));
+ public bool IsModal
+ {
+ get { return (bool)GetValue(IsModalProperty); }
+ set { SetValue(IsModalProperty, value); }
+ }
+
+ private static void OnIsModalPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ChildWindow childWindow = d as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnIsModalChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ private void OnIsModalChanged(bool oldValue, bool newValue)
+ {
+ if (newValue)
+ {
+ KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle);
+ ShowModalLayer();
+ }
+ else
+ {
+ KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Continue);
+ HideModalLayer();
+ }
+ }
+
+ #endregion //IsModal
+
+ #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 childWindow = obj as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnLeftPropertyChanged((double)e.OldValue, (double)e.NewValue);
+ }
+
+ private void OnLeftPropertyChanged(double oldValue, double newValue)
+ {
+ Left = GetRestrictedLeft();
+ ProcessMove(newValue - oldValue, 0);
+ }
+
+ #endregion //Left
+
+ #region OverlayBrush
+
+ public static readonly DependencyProperty OverlayBrushProperty = DependencyProperty.Register("OverlayBrush", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(Brushes.Gray, OnOverlayBrushChanged));
+ public Brush OverlayBrush
+ {
+ get { return (Brush)GetValue(OverlayBrushProperty); }
+ set { SetValue(OverlayBrushProperty, value); }
+ }
+
+ private static void OnOverlayBrushChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ChildWindow childWindow = d as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnOverlayBrushChanged((Brush)e.OldValue, (Brush)e.NewValue);
+ }
+
+ protected virtual void OnOverlayBrushChanged(Brush oldValue, Brush newValue)
+ {
+ _modalLayer.Fill = newValue;
+ }
+
+ #endregion //OverlayBrush
+
+ #region OverlayOpacity
+
+ public static readonly DependencyProperty OverlayOpacityProperty = DependencyProperty.Register("OverlayOpacity", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.5, OnOverlayOpacityChanged));
+ public double OverlayOpacity
+ {
+ get { return (double)GetValue(OverlayOpacityProperty); }
+ set { SetValue(OverlayOpacityProperty, value); }
+ }
+
+ private static void OnOverlayOpacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ChildWindow childWindow = d as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnOverlayOpacityChanged((double)e.OldValue, (double)e.NewValue);
+ }
+
+ protected virtual void OnOverlayOpacityChanged(double oldValue, double newValue)
+ {
+ _modalLayer.Opacity = newValue;
+ }
+
+ #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 childWindow = obj as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnTopPropertyChanged((double)e.OldValue, (double)e.NewValue);
+ }
+
+ private void OnTopPropertyChanged(double oldValue, double newValue)
+ {
+ Top = GetRestrictedTop();
+ ProcessMove(0, newValue - oldValue);
+ }
+
+ #endregion //TopProperty
+
+ #region WindowBackground
+
+ 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); }
+ }
+
+ #endregion //WindowBackground
+
+ #region WindowBorderBrush
+
+ 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); }
+ }
+
+ #endregion //WindowBorderBrush
+
+ #region WindowOpacity
+
+ 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); }
+ }
+
+ #endregion //WindowOpacity
+
+ #region WindowStartupLocation
+
+ public static readonly DependencyProperty WindowStartupLocationProperty = DependencyProperty.Register("WindowStartupLocation", typeof(WindowStartupLocation), typeof(ChildWindow), new UIPropertyMetadata(WindowStartupLocation.Manual, OnWindowStartupLocationChanged));
+ public WindowStartupLocation WindowStartupLocation
+ {
+ get { return (WindowStartupLocation)GetValue(WindowStartupLocationProperty); }
+ set { SetValue(WindowStartupLocationProperty, value); }
+ }
+
+ private static void OnWindowStartupLocationChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ChildWindow childWindow = o as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnWindowStartupLocationChanged((WindowStartupLocation)e.OldValue, (WindowStartupLocation)e.NewValue);
+ }
+
+ protected virtual void OnWindowStartupLocationChanged(WindowStartupLocation oldValue, WindowStartupLocation newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //WindowStartupLocation
+
+ #region WindowState
+
+ public static readonly DependencyProperty WindowStateProperty = DependencyProperty.Register("WindowState", typeof(WindowState), typeof(ChildWindow), new FrameworkPropertyMetadata(WindowState.Closed, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWindowStatePropertyChanged));
+ public WindowState WindowState
+ {
+ get { return (WindowState)GetValue(WindowStateProperty); }
+ set { SetValue(WindowStateProperty, value); }
+ }
+
+ private static void OnWindowStatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ChildWindow childWindow = d as ChildWindow;
+ if (childWindow != null)
+ childWindow.OnWindowStatePropertyChanged((WindowState)e.OldValue, (WindowState)e.NewValue);
+ }
+
+ protected virtual void OnWindowStatePropertyChanged(WindowState oldValue, WindowState newValue)
+ {
+ if (!_ignorePropertyChanged)
+ SetWindowState(newValue);
+ }
+
+ #endregion //WindowState
+
+ #endregion //Public Properties
+
+ #endregion //Properties
+
+ #region Event Handlers
+
+ void ChildWindow_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ if ((bool)e.NewValue)
+ Focus();
+ }
+
+ 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
+ }
+ }
+
+ private void ParentContainer_LayoutUpdated(object sender, EventArgs e)
+ {
+ if (DesignerProperties.GetIsInDesignMode(this))
+ return;
+
+ //we only want to set the start position if this is the first time the control has bee initialized
+ if (!_startupPositionInitialized)
+ {
+ ExecuteOpen();
+ _startupPositionInitialized = true;
+ }
+ }
+
+ void ParentContainer_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ //resize our modal layer
+ _modalLayer.Height = e.NewSize.Height;
+ _modalLayer.Width = e.NewSize.Width;
+
+ //reposition our window
+ Left = GetRestrictedLeft();
+ Top = GetRestrictedTop();
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ #region Private
+
+ private double GetRestrictedLeft()
+ {
+ if (Left < 0)
+ return 0;
+
+ if (_parentContainer != null)
+ {
+ if (Left + WindowRoot.ActualWidth > _parentContainer.ActualWidth && _parentContainer.ActualWidth != 0)
+ {
+ double left = _parentContainer.ActualWidth - WindowRoot.ActualWidth;
+ return left < 0 ? 0 : left;
+ }
+ }
+
+ return Left;
+ }
+
+ private double GetRestrictedTop()
+ {
+ if (Top < 0)
+ return 0;
+
+ if (_parentContainer != null)
+ {
+ if (Top + WindowRoot.ActualHeight > _parentContainer.ActualHeight && _parentContainer.ActualHeight != 0)
+ {
+ double top = _parentContainer.ActualHeight - WindowRoot.ActualHeight;
+ return top < 0 ? 0 : top;
+ }
+ }
+
+ return Top;
+ }
+
+ private void SetWindowState(WindowState state)
+ {
+ switch (state)
+ {
+ case WindowState.Closed:
+ {
+ ExecuteClose();
+ break;
+ }
+ case WindowState.Open:
+ {
+ ExecuteOpen();
+ break;
+ }
+ }
+ }
+
+ private void ExecuteClose()
+ {
+ CancelEventArgs e = new CancelEventArgs();
+ OnClosing(e);
+
+ if (!e.Cancel)
+ {
+ if (!_dialogResult.HasValue)
+ _dialogResult = false;
+
+ OnClosed(EventArgs.Empty);
+ }
+ else
+ {
+ CancelClose();
+ }
+ }
+
+ private void CancelClose()
+ {
+ _dialogResult = null; //when the close is cancelled, DialogResult should be null
+
+ _ignorePropertyChanged = true;
+ WindowState = WindowState.Open; //now reset the window state to open because the close was cancelled
+ _ignorePropertyChanged = false;
+ }
+
+ private void ExecuteOpen()
+ {
+ _dialogResult = null; //reset the dialogResult to null each time the window is opened
+
+ if (WindowStartupLocation == Controls.WindowStartupLocation.Center)
+ CenterChildWindow();
+
+ BringToFront();
+ }
+
+ private void BringToFront()
+ {
+ int index = 0;
+
+ if (_parentContainer != null)
+ index = (int)_parentContainer.GetValue(Canvas.ZIndexProperty);
+
+ SetValue(Canvas.ZIndexProperty, ++index);
+
+ if (IsModal)
+ Canvas.SetZIndex(_modalLayerPanel, index - 2);
+ }
+
+ private void CenterChildWindow()
+ {
+ if (_parentContainer != null)
+ {
+ Left = (_parentContainer.ActualWidth - WindowRoot.ActualWidth) / 2.0;
+ Top = (_parentContainer.ActualHeight - WindowRoot.ActualHeight) / 2.0;
+ }
+ }
+
+ private void ShowModalLayer()
+ {
+ if (!DesignerProperties.GetIsInDesignMode(this))
+ {
+ if (!_modalLayerPanel.Children.Contains(_modalLayer))
+ _modalLayerPanel.Children.Add(_modalLayer);
+
+ _modalLayer.Visibility = System.Windows.Visibility.Visible;
+ }
+ }
+
+ private void HideModalLayer()
+ {
+ _modalLayer.Visibility = System.Windows.Visibility.Collapsed;
+ }
+
+ private void ProcessMove(double x, double y)
+ {
+ _moveTransform.X += x;
+ _moveTransform.Y += y;
+ }
+
+ #endregion //Private
+
+ #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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowStartupLocation.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowStartupLocation.cs
new file mode 100644
index 00000000..e212e837
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowStartupLocation.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ public enum WindowStartupLocation
+ {
+ Center,
+ Manual
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowState.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowState.cs
new file mode 100644
index 00000000..c5055e8d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Implementation/WindowState.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ public enum WindowState
+ {
+ Closed,
+ Open
+ }
+}
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Themes/Generic.xaml
new file mode 100644
index 00000000..6b8fea5f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ChildWindow/Themes/Generic.xaml
@@ -0,0 +1,211 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Implementation/ButtonChrome.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Implementation/ButtonChrome.cs
new file mode 100644
index 00000000..b6c2b9e1
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Implementation/ButtonChrome.cs
@@ -0,0 +1,208 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Microsoft.Windows.Controls.Chromes
+{
+ public class ButtonChrome : Control
+ {
+ #region CornerRadius
+
+ public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(ButtonChrome), new UIPropertyMetadata(default(CornerRadius), new PropertyChangedCallback(OnCornerRadiusChanged)));
+ public CornerRadius CornerRadius
+ {
+ get { return (CornerRadius)GetValue(CornerRadiusProperty); }
+ set { SetValue(CornerRadiusProperty, value); }
+ }
+
+ private static void OnCornerRadiusChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnCornerRadiusChanged((CornerRadius)e.OldValue, (CornerRadius)e.NewValue);
+ }
+
+ protected virtual void OnCornerRadiusChanged(CornerRadius oldValue, CornerRadius newValue)
+ {
+ //we always want the InnerBorderRadius to be one less than the CornerRadius
+ CornerRadius newInnerCornerRadius = new CornerRadius(Math.Max(0, newValue.TopLeft - 1),
+ Math.Max(0, newValue.TopRight - 1),
+ Math.Max(0, newValue.BottomRight - 1),
+ Math.Max(0, newValue.BottomLeft - 1));
+
+ InnerCornerRadius = newInnerCornerRadius;
+ }
+
+ #endregion //CornerRadius
+
+ #region InnerCornerRadius
+
+ public static readonly DependencyProperty InnerCornerRadiusProperty = DependencyProperty.Register("InnerCornerRadius", typeof(CornerRadius), typeof(ButtonChrome), new UIPropertyMetadata(default(CornerRadius), new PropertyChangedCallback(OnInnerCornerRadiusChanged)));
+ public CornerRadius InnerCornerRadius
+ {
+ get { return (CornerRadius)GetValue(InnerCornerRadiusProperty); }
+ set { SetValue(InnerCornerRadiusProperty, value); }
+ }
+
+ private static void OnInnerCornerRadiusChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnInnerCornerRadiusChanged((CornerRadius)e.OldValue, (CornerRadius)e.NewValue);
+ }
+
+ protected virtual void OnInnerCornerRadiusChanged(CornerRadius oldValue, CornerRadius newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //InnerCornerRadius
+
+ #region RenderChecked
+
+ public static readonly DependencyProperty RenderCheckedProperty = DependencyProperty.Register("RenderChecked", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(false, OnRenderCheckedChanged));
+ public bool RenderChecked
+ {
+ get { return (bool)GetValue(RenderCheckedProperty); }
+ set { SetValue(RenderCheckedProperty, value); }
+ }
+
+ private static void OnRenderCheckedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderCheckedChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderCheckedChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderChecked
+
+ #region RenderEnabled
+
+ public static readonly DependencyProperty RenderEnabledProperty = DependencyProperty.Register("RenderEnabled", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(true, OnRenderEnabledChanged));
+ public bool RenderEnabled
+ {
+ get { return (bool)GetValue(RenderEnabledProperty); }
+ set { SetValue(RenderEnabledProperty, value); }
+ }
+
+ private static void OnRenderEnabledChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderEnabledChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderEnabledChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderEnabled
+
+ #region RenderFocused
+
+ public static readonly DependencyProperty RenderFocusedProperty = DependencyProperty.Register("RenderFocused", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(false, OnRenderFocusedChanged));
+ public bool RenderFocused
+ {
+ get { return (bool)GetValue(RenderFocusedProperty); }
+ set { SetValue(RenderFocusedProperty, value); }
+ }
+
+ private static void OnRenderFocusedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderFocusedChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderFocusedChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderFocused
+
+ #region RenderMouseOver
+
+ public static readonly DependencyProperty RenderMouseOverProperty = DependencyProperty.Register("RenderMouseOver", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(false, OnRenderMouseOverChanged));
+ public bool RenderMouseOver
+ {
+ get { return (bool)GetValue(RenderMouseOverProperty); }
+ set { SetValue(RenderMouseOverProperty, value); }
+ }
+
+ private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderMouseOverChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderMouseOverChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderMouseOver
+
+ #region RenderNormal
+
+ public static readonly DependencyProperty RenderNormalProperty = DependencyProperty.Register("RenderNormal", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(true, OnRenderNormalChanged));
+ public bool RenderNormal
+ {
+ get { return (bool)GetValue(RenderNormalProperty); }
+ set { SetValue(RenderNormalProperty, value); }
+ }
+
+ private static void OnRenderNormalChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderNormalChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderNormalChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderNormal
+
+ #region RenderPressed
+
+ public static readonly DependencyProperty RenderPressedProperty = DependencyProperty.Register("RenderPressed", typeof(bool), typeof(ButtonChrome), new UIPropertyMetadata(false, OnRenderPressedChanged));
+ public bool RenderPressed
+ {
+ get { return (bool)GetValue(RenderPressedProperty); }
+ set { SetValue(RenderPressedProperty, value); }
+ }
+
+ private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ButtonChrome buttonChrome = o as ButtonChrome;
+ if (buttonChrome != null)
+ buttonChrome.OnRenderPressedChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnRenderPressedChanged(bool oldValue, bool newValue)
+ {
+ // TODO: Add your property changed side-effects. Descendants can override as well.
+ }
+
+ #endregion //RenderPressed
+
+ #region Contsructors
+
+ static ButtonChrome()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ButtonChrome), new FrameworkPropertyMetadata(typeof(ButtonChrome)));
+ }
+
+ #endregion //Contsructors
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Themes/Generic.xaml
new file mode 100644
index 00000000..0f0fd301
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Chromes/Themes/Generic.xaml
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+ 2.75
+ 1.75
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorCanvas.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorCanvas.cs
new file mode 100644
index 00000000..c65ecc46
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorCanvas.cs
@@ -0,0 +1,365 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+using Microsoft.Windows.Controls.Primitives;
+using Microsoft.Windows.Controls.Core.Utilities;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls
+{
+ public class ColorCanvas : Control
+ {
+ #region Private Members
+
+ private TranslateTransform _colorShadeSelectorTransform = new TranslateTransform();
+ private Canvas _colorShadingCanvas;
+ private Canvas _colorShadeSelector;
+ private ColorSpectrumSlider _spectrumSlider;
+ private Point? _currentColorPosition;
+ private bool _surpressPropertyChanged;
+
+ #endregion //Private Members
+
+ #region Properties
+
+ #region SelectedColor
+
+ public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorCanvas), new FrameworkPropertyMetadata(Colors.Black, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedColorChanged));
+ public Color SelectedColor
+ {
+ get { return (Color)GetValue(SelectedColorProperty); }
+ set { SetValue(SelectedColorProperty, value); }
+ }
+
+ private static void OnSelectedColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnSelectedColorChanged((Color)e.OldValue, (Color)e.NewValue);
+ }
+
+ protected virtual void OnSelectedColorChanged(Color oldValue, Color newValue)
+ {
+ HexadecimalString = newValue.ToString();
+ UpdateRGBValues(newValue);
+ UpdateColorShadeSelectorPosition(newValue);
+
+ RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue);
+ args.RoutedEvent = SelectedColorChangedEvent;
+ RaiseEvent(args);
+ }
+
+ #endregion //SelectedColor
+
+ #region RGB
+
+ #region A
+
+ public static readonly DependencyProperty AProperty = DependencyProperty.Register("A", typeof(byte), typeof(ColorCanvas), new UIPropertyMetadata((byte)255, OnAChanged));
+ public byte A
+ {
+ get { return (byte)GetValue(AProperty); }
+ set { SetValue(AProperty, value); }
+ }
+
+ private static void OnAChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnAChanged((byte)e.OldValue, (byte)e.NewValue);
+ }
+
+ protected virtual void OnAChanged(byte oldValue, byte newValue)
+ {
+ if (!_surpressPropertyChanged)
+ UpdateSelectedColor();
+ }
+
+ #endregion //A
+
+ #region R
+
+ public static readonly DependencyProperty RProperty = DependencyProperty.Register("R", typeof(byte), typeof(ColorCanvas), new UIPropertyMetadata((byte)0, OnRChanged));
+ public byte R
+ {
+ get { return (byte)GetValue(RProperty); }
+ set { SetValue(RProperty, value); }
+ }
+
+ private static void OnRChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnRChanged((byte)e.OldValue, (byte)e.NewValue);
+ }
+
+ protected virtual void OnRChanged(byte oldValue, byte newValue)
+ {
+ if (!_surpressPropertyChanged)
+ UpdateSelectedColor();
+ }
+
+ #endregion //R
+
+ #region G
+
+ public static readonly DependencyProperty GProperty = DependencyProperty.Register("G", typeof(byte), typeof(ColorCanvas), new UIPropertyMetadata((byte)0, OnGChanged));
+ public byte G
+ {
+ get { return (byte)GetValue(GProperty); }
+ set { SetValue(GProperty, value); }
+ }
+
+ private static void OnGChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnGChanged((byte)e.OldValue, (byte)e.NewValue);
+ }
+
+ protected virtual void OnGChanged(byte oldValue, byte newValue)
+ {
+ if (!_surpressPropertyChanged)
+ UpdateSelectedColor();
+ }
+
+ #endregion //G
+
+ #region B
+
+ public static readonly DependencyProperty BProperty = DependencyProperty.Register("B", typeof(byte), typeof(ColorCanvas), new UIPropertyMetadata((byte)0, OnBChanged));
+ public byte B
+ {
+ get { return (byte)GetValue(BProperty); }
+ set { SetValue(BProperty, value); }
+ }
+
+ private static void OnBChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnBChanged((byte)e.OldValue, (byte)e.NewValue);
+ }
+
+ protected virtual void OnBChanged(byte oldValue, byte newValue)
+ {
+ if (!_surpressPropertyChanged)
+ UpdateSelectedColor();
+ }
+
+ #endregion //B
+
+ #endregion //RGB
+
+ #region HexadecimalString
+
+ public static readonly DependencyProperty HexadecimalStringProperty = DependencyProperty.Register("HexadecimalString", typeof(string), typeof(ColorCanvas), new UIPropertyMetadata("#FFFFFFFF", OnHexadecimalStringChanged));
+ public string HexadecimalString
+ {
+ get { return (string)GetValue(HexadecimalStringProperty); }
+ set { SetValue(HexadecimalStringProperty, value); }
+ }
+
+ private static void OnHexadecimalStringChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ ColorCanvas colorCanvas = o as ColorCanvas;
+ if (colorCanvas != null)
+ colorCanvas.OnHexadecimalStringChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnHexadecimalStringChanged(string oldValue, string newValue)
+ {
+ if (!SelectedColor.ToString().Equals(newValue))
+ UpdateSelectedColor((Color)ColorConverter.ConvertFromString(newValue));
+ }
+
+ #endregion //HexadecimalString
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static ColorCanvas()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorCanvas), new FrameworkPropertyMetadata(typeof(ColorCanvas)));
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _colorShadingCanvas = (Canvas)GetTemplateChild("PART_ColorShadingCanvas");
+ _colorShadingCanvas.MouseLeftButtonDown += ColorShadingCanvas_MouseLeftButtonDown;
+ _colorShadingCanvas.MouseLeftButtonUp += ColorShadingCanvas_MouseLeftButtonUp;
+ _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;
+
+ UpdateRGBValues(SelectedColor);
+ UpdateColorShadeSelectorPosition(SelectedColor);
+ }
+
+ protected override void OnPreviewKeyDown(KeyEventArgs e)
+ {
+ //hitting enter on textbox will update value of underlying source
+ if (e.Key == Key.Enter && e.OriginalSource is TextBox)
+ {
+ BindingExpression be = ((TextBox)e.OriginalSource).GetBindingExpression(TextBox.TextProperty);
+ be.UpdateSource();
+ }
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ void ColorShadingCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ Point p = e.GetPosition(_colorShadingCanvas);
+ UpdateColorShadeSelectorPositionAndCalculateColor(p, true);
+ _colorShadingCanvas.CaptureMouse();
+ }
+
+ void ColorShadingCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
+ {
+ _colorShadingCanvas.ReleaseMouseCapture();
+ }
+
+ 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);
+ }
+ }
+
+ #endregion //Event Handlers
+
+ #region Events
+
+ public static readonly RoutedEvent SelectedColorChangedEvent = EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(ColorCanvas));
+ public event RoutedPropertyChangedEventHandler SelectedColorChanged
+ {
+ add { AddHandler(SelectedColorChangedEvent, value); }
+ remove { RemoveHandler(SelectedColorChangedEvent, value); }
+ }
+
+ #endregion //Events
+
+ #region Methods
+
+ private void UpdateSelectedColor()
+ {
+ SelectedColor = Color.FromArgb(A, R, G, B);
+ }
+
+ private void UpdateSelectedColor(Color color)
+ {
+ SelectedColor = Color.FromArgb(color.A, color.R, color.G, color.B);
+ }
+
+ private void UpdateRGBValues(Color color)
+ {
+ _surpressPropertyChanged = true;
+
+ A = color.A;
+ R = color.R;
+ G = color.G;
+ B = color.B;
+
+ _surpressPropertyChanged = false;
+ }
+
+ 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)
+ {
+ if (_spectrumSlider == null || _colorShadingCanvas == null)
+ return;
+
+ _currentColorPosition = null;
+
+ HsvColor hsv = ColorUtilities.ConvertRgbToHsv(color.R, color.G, color.B);
+
+ if (!(color.R == color.G && color.R == 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 };
+ var currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V);
+ currentColor.A = A;
+ SelectedColor = currentColor;
+ HexadecimalString = SelectedColor.ToString();
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorSpectrumSlider.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorSpectrumSlider.cs
new file mode 100644
index 00000000..54bb6e9e
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Implementation/ColorSpectrumSlider.cs
@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Shapes;
+using Microsoft.Windows.Controls.Core.Utilities;
+
+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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Themes/Generic.xaml
new file mode 100644
index 00000000..6cc8d243
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorCanvas/Themes/Generic.xaml
@@ -0,0 +1,346 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorItem.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorItem.cs
new file mode 100644
index 00000000..0f846a9a
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorItem.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Windows.Media;
+
+namespace Microsoft.Windows.Controls
+{
+ public class ColorItem
+ {
+ public Color Color { get; set; }
+ public string Name { get; set; }
+
+ public ColorItem(Color color, string name)
+ {
+ Color = color;
+ Name = name;
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs
new file mode 100644
index 00000000..aa87a36f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Implementation/ColorPicker.cs
@@ -0,0 +1,317 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Controls.Primitives;
+using System.Collections.ObjectModel;
+using System.Windows.Input;
+using Microsoft.Windows.Controls.Core.Utilities;
+
+namespace Microsoft.Windows.Controls
+{
+ public class ColorPicker : Control
+ {
+ #region Members
+
+ private Popup _colorPickerCanvasPopup;
+ private ListBox _availableColors;
+ private ListBox _standardColors;
+ private ListBox _recentColors;
+
+ #endregion //Members
+
+ #region Properties
+
+ #region AvailableColors
+
+ public static readonly DependencyProperty AvailableColorsProperty = DependencyProperty.Register("AvailableColors", typeof(ObservableCollection), typeof(ColorPicker), new UIPropertyMetadata(CreateAvailableColors()));
+ public ObservableCollection AvailableColors
+ {
+ get { return (ObservableCollection)GetValue(AvailableColorsProperty); }
+ set { SetValue(AvailableColorsProperty, value); }
+ }
+
+ #endregion //AvailableColors
+
+ #region ButtonStyle
+
+ public static readonly DependencyProperty ButtonStyleProperty = DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(ColorPicker));
+ public Style ButtonStyle
+ {
+ get { return (Style)GetValue(ButtonStyleProperty); }
+ set { SetValue(ButtonStyleProperty, value); }
+ }
+
+ #endregion //ButtonStyle
+
+ #region DisplayColorAndName
+
+ public static readonly DependencyProperty DisplayColorAndNameProperty = DependencyProperty.Register("DisplayColorAndName", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false));
+ public bool DisplayColorAndName
+ {
+ get { return (bool)GetValue(DisplayColorAndNameProperty); }
+ set { SetValue(DisplayColorAndNameProperty, value); }
+ }
+
+ #endregion //DisplayColorAndName
+
+ #region IsOpen
+
+ public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false));
+ public bool IsOpen
+ {
+ get { return (bool)GetValue(IsOpenProperty); }
+ set { SetValue(IsOpenProperty, value); }
+ }
+
+ #endregion //IsOpen
+
+ #region RecentColors
+
+ public static readonly DependencyProperty RecentColorsProperty = DependencyProperty.Register("RecentColors", typeof(ObservableCollection), typeof(ColorPicker), new UIPropertyMetadata(null));
+ public ObservableCollection RecentColors
+ {
+ get { return (ObservableCollection)GetValue(RecentColorsProperty); }
+ set { SetValue(RecentColorsProperty, value); }
+ }
+
+ #endregion //RecentColors
+
+ #region SelectedColor
+
+ public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register("SelectedColor", typeof(Color), typeof(ColorPicker), new FrameworkPropertyMetadata(Colors.Black, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallback(OnSelectedColorPropertyChanged)));
+ public Color SelectedColor
+ {
+ get { return (Color)GetValue(SelectedColorProperty); }
+ set { SetValue(SelectedColorProperty, value); }
+ }
+
+ private static void OnSelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ColorPicker colorPicker = (ColorPicker)d;
+ if (colorPicker != null)
+ colorPicker.OnSelectedColorChanged((Color)e.OldValue, (Color)e.NewValue);
+ }
+
+ private void OnSelectedColorChanged(Color oldValue, Color newValue)
+ {
+ SelectedColorText = newValue.GetColorName();
+
+ RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue);
+ args.RoutedEvent = ColorPicker.SelectedColorChangedEvent;
+ RaiseEvent(args);
+ }
+
+ #endregion //SelectedColor
+
+ #region SelectedColorText
+
+ public static readonly DependencyProperty SelectedColorTextProperty = DependencyProperty.Register("SelectedColorText", typeof(string), typeof(ColorPicker), new UIPropertyMetadata("Black"));
+ public string SelectedColorText
+ {
+ get { return (string)GetValue(SelectedColorTextProperty); }
+ protected set { SetValue(SelectedColorTextProperty, value); }
+ }
+
+ #endregion //SelectedColorText
+
+ #region ShowAdvancedButton
+
+ public static readonly DependencyProperty ShowAdvancedButtonProperty = DependencyProperty.Register("ShowAdvancedButton", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true));
+ public bool ShowAdvancedButton
+ {
+ get { return (bool)GetValue(ShowAdvancedButtonProperty); }
+ set { SetValue(ShowAdvancedButtonProperty, value); }
+ }
+
+ #endregion //ShowAdvancedButton
+
+ #region ShowAvailableColors
+
+ public static readonly DependencyProperty ShowAvailableColorsProperty = DependencyProperty.Register("ShowAvailableColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true));
+ public bool ShowAvailableColors
+ {
+ get { return (bool)GetValue(ShowAvailableColorsProperty); }
+ set { SetValue(ShowAvailableColorsProperty, value); }
+ }
+
+ #endregion //ShowAvailableColors
+
+ #region ShowRecentColors
+
+ public static readonly DependencyProperty ShowRecentColorsProperty = DependencyProperty.Register("ShowRecentColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(false));
+ public bool ShowRecentColors
+ {
+ get { return (bool)GetValue(ShowRecentColorsProperty); }
+ set { SetValue(ShowRecentColorsProperty, value); }
+ }
+
+ #endregion //DisplayRecentColors
+
+ #region ShowStandardColors
+
+ public static readonly DependencyProperty ShowStandardColorsProperty = DependencyProperty.Register("ShowStandardColors", typeof(bool), typeof(ColorPicker), new UIPropertyMetadata(true));
+ public bool ShowStandardColors
+ {
+ get { return (bool)GetValue(ShowStandardColorsProperty); }
+ set { SetValue(ShowStandardColorsProperty, value); }
+ }
+
+ #endregion //DisplayStandardColors
+
+ #region StandardColors
+
+ public static readonly DependencyProperty StandardColorsProperty = DependencyProperty.Register("StandardColors", typeof(ObservableCollection), typeof(ColorPicker), new UIPropertyMetadata(CreateStandardColors()));
+ public ObservableCollection StandardColors
+ {
+ get { return (ObservableCollection)GetValue(StandardColorsProperty); }
+ set { SetValue(StandardColorsProperty, value); }
+ }
+
+ #endregion //StandardColors
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static ColorPicker()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(ColorPicker), new FrameworkPropertyMetadata(typeof(ColorPicker)));
+ }
+
+ public ColorPicker()
+ {
+ RecentColors = new ObservableCollection();
+ Keyboard.AddKeyDownHandler(this, OnKeyDown);
+ Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement);
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _colorPickerCanvasPopup = (Popup)GetTemplateChild("PART_ColorPickerPalettePopup");
+ //_colorPickerCanvasPopup.Opened += ColorPickerCanvasPopup_Opened;
+
+ _availableColors = (ListBox)GetTemplateChild("PART_AvailableColors");
+ _availableColors.SelectionChanged += Color_SelectionChanged;
+
+ _standardColors = (ListBox)GetTemplateChild("PART_StandardColors");
+ _standardColors.SelectionChanged += Color_SelectionChanged;
+
+ _recentColors = (ListBox)GetTemplateChild("PART_RecentColors");
+ _recentColors.SelectionChanged += Color_SelectionChanged;
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ void ColorPickerCanvasPopup_Opened(object sender, EventArgs e)
+ {
+
+ }
+
+ private void OnKeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case Key.Escape:
+ case Key.Tab:
+ {
+ CloseColorPicker();
+ break;
+ }
+ }
+ }
+
+ private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e)
+ {
+ CloseColorPicker();
+ }
+
+ private void Color_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ ListBox lb = (ListBox)sender;
+
+ if (e.AddedItems.Count > 0)
+ {
+ var colorItem = (ColorItem)e.AddedItems[0];
+ SelectedColor = colorItem.Color;
+ UpdateRecentColors(colorItem);
+ CloseColorPicker();
+ lb.SelectedIndex = -1; //for now I don't care about keeping track of the selected color
+ }
+ }
+
+ #endregion //Event Handlers
+
+ #region Events
+
+ public static readonly RoutedEvent SelectedColorChangedEvent = EventManager.RegisterRoutedEvent("SelectedColorChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(ColorPicker));
+ public event RoutedPropertyChangedEventHandler SelectedColorChanged
+ {
+ add { AddHandler(SelectedColorChangedEvent, value); }
+ remove { RemoveHandler(SelectedColorChangedEvent, value); }
+ }
+
+ #endregion //Events
+
+ #region Methods
+
+ private void CloseColorPicker()
+ {
+ if (IsOpen)
+ IsOpen = false;
+ ReleaseMouseCapture();
+ }
+
+ private void UpdateRecentColors(ColorItem colorItem)
+ {
+ if (!RecentColors.Contains(colorItem))
+ RecentColors.Add(colorItem);
+
+ if (RecentColors.Count > 10) //don't allow more than ten, maybe make a property that can be set by the user.
+ RecentColors.RemoveAt(0);
+ }
+
+ private static ObservableCollection CreateStandardColors()
+ {
+ ObservableCollection _standardColors = new ObservableCollection();
+ _standardColors.Add(new ColorItem(Colors.Transparent, "Transparent"));
+ _standardColors.Add(new ColorItem(Colors.White, "White"));
+ _standardColors.Add(new ColorItem(Colors.Gray, "Gray"));
+ _standardColors.Add(new ColorItem(Colors.Black, "Black"));
+ _standardColors.Add(new ColorItem(Colors.Red, "Red"));
+ _standardColors.Add(new ColorItem(Colors.Green, "Green"));
+ _standardColors.Add(new ColorItem(Colors.Blue, "Blue"));
+ _standardColors.Add(new ColorItem(Colors.Yellow, "Yellow"));
+ _standardColors.Add(new ColorItem(Colors.Orange, "Orange"));
+ _standardColors.Add(new ColorItem(Colors.Purple, "Purple"));
+ return _standardColors;
+ }
+
+ private static ObservableCollection CreateAvailableColors()
+ {
+ ObservableCollection _standardColors = new ObservableCollection();
+
+ foreach (var item in ColorUtilities.KnownColors)
+ {
+ if (!String.Equals(item.Key, "Transparent"))
+ {
+ var colorItem = new ColorItem(item.Value, item.Key);
+ if (!_standardColors.Contains(colorItem))
+ _standardColors.Add(colorItem);
+ }
+ }
+
+ return _standardColors;
+ }
+
+ #endregion //Methods
+ }
+}
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml
new file mode 100644
index 00000000..12d36ca1
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml
@@ -0,0 +1,278 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/CalculatorMemoryToVisibilityConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/CalculatorMemoryToVisibilityConverter.cs
new file mode 100644
index 00000000..9b9b2b76
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/CalculatorMemoryToVisibilityConverter.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Windows.Data;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls.Core.Converters
+{
+ public class CalculatorMemoryToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return (decimal)value == decimal.Zero ? Visibility.Hidden : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs
new file mode 100644
index 00000000..6bb19191
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/ColorToSolidColorBrushConverter.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace Microsoft.Windows.Controls.Core.Converters
+{
+ public class ColorToSolidColorBrushConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ ///
+ /// Converts a Color to a SolidColorBrush.
+ ///
+ /// The Color produced by the binding source.
+ /// The type of the binding target property.
+ /// The converter parameter to use.
+ /// The culture to use in the converter.
+ ///
+ /// A converted SolidColorBrush. If the method returns null, the valid null value is used.
+ ///
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value != null)
+ return new SolidColorBrush((Color)value);
+
+ return value;
+ }
+
+
+ ///
+ /// Converts a SolidColorBrush to a Color.
+ ///
+ /// Currently not used in toolkit, but provided for developer use in their own projects
+ /// The SolidColorBrush that is produced by the binding target.
+ /// The type to convert to.
+ /// The converter parameter to use.
+ /// The culture to use in the converter.
+ ///
+ /// A converted value. If the method returns null, the valid null value is used.
+ ///
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value != null)
+ return ((SolidColorBrush)value).Color;
+
+ return value;
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/InverseBoolConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/InverseBoolConverter.cs
new file mode 100644
index 00000000..2bcdc0fe
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/InverseBoolConverter.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls.Core.Converters
+{
+ public class InverseBoolConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return !(bool)value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/SolidColorBrushToColorConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/SolidColorBrushToColorConverter.cs
new file mode 100644
index 00000000..901f235b
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/SolidColorBrushToColorConverter.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace Microsoft.Windows.Controls.Core.Converters
+{
+ public class SolidColorBrushToColorConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ SolidColorBrush brush = value as SolidColorBrush;
+ if (brush != null)
+ return brush.Color;
+
+ return default(Color);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value != null)
+ {
+ Color color = (Color)value;
+ return new SolidColorBrush(color);
+ }
+
+ return default(SolidColorBrush);
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/TimeFormatToDateTimeFormatConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/TimeFormatToDateTimeFormatConverter.cs
new file mode 100644
index 00000000..6eda8ab7
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Converters/TimeFormatToDateTimeFormatConverter.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls.Core.Converters
+{
+ public class TimeFormatToDateTimeFormatConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ TimeFormat timeFormat = (TimeFormat)value;
+ switch (timeFormat)
+ {
+ case TimeFormat.Custom:
+ return DateTimeFormat.Custom;
+ case TimeFormat.ShortTime:
+ return DateTimeFormat.ShortTime;
+ case TimeFormat.LongTime:
+ return DateTimeFormat.LongTime;
+ default:
+ return DateTimeFormat.ShortTime;
+ }
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/HsvColor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/HsvColor.cs
new file mode 100644
index 00000000..4756686c
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/HsvColor.cs
@@ -0,0 +1,18 @@
+using System;
+
+namespace Microsoft.Windows.Controls.Primitives
+{
+ 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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs
new file mode 100644
index 00000000..eeb2c0a0
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/InputBase.cs
@@ -0,0 +1,81 @@
+using System;
+using System.Windows.Controls;
+using System.Windows;
+using System.Globalization;
+
+namespace Microsoft.Windows.Controls.Primitives
+{
+ public abstract class InputBase : Control
+ {
+ #region Properties
+
+ #region CultureInfo
+
+ public static readonly DependencyProperty CultureInfoProperty = DependencyProperty.Register("CultureInfo", typeof(CultureInfo), typeof(InputBase), new UIPropertyMetadata(CultureInfo.CurrentCulture));
+ public CultureInfo CultureInfo
+ {
+ get { return (CultureInfo)GetValue(CultureInfoProperty); }
+ set { SetValue(CultureInfoProperty, value); }
+ }
+
+ #endregion //CultureInfo
+
+ #region IsEditable
+
+ public static readonly DependencyProperty IsEditableProperty = DependencyProperty.Register("IsEditable", typeof(bool), typeof(InputBase), new PropertyMetadata(true));
+ public bool IsEditable
+ {
+ get { return (bool)GetValue(IsEditableProperty); }
+ set { SetValue(IsEditableProperty, value); }
+ }
+
+ #endregion //IsEditable
+
+ #region Text
+
+ public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(InputBase), new UIPropertyMetadata(default(String), OnTextChanged));
+ public string Text
+ {
+ get { return (string)GetValue(TextProperty); }
+ set { SetValue(TextProperty, value); }
+ }
+
+ private static void OnTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ InputBase inputBase = o as InputBase;
+ if (inputBase != null)
+ inputBase.OnTextChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnTextChanged(string oldValue, string newValue)
+ {
+
+ }
+
+ #endregion //Text
+
+ #region Watermark
+
+ public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(object), typeof(InputBase), new UIPropertyMetadata(null));
+ public object Watermark
+ {
+ get { return (object)GetValue(WatermarkProperty); }
+ set { SetValue(WatermarkProperty, value); }
+ }
+
+ #endregion //Watermark
+
+ #region WatermarkTemplate
+
+ public static readonly DependencyProperty WatermarkTemplateProperty = DependencyProperty.Register("WatermarkTemplate", typeof(DataTemplate), typeof(InputBase), new UIPropertyMetadata(null));
+ public DataTemplate WatermarkTemplate
+ {
+ get { return (DataTemplate)GetValue(WatermarkTemplateProperty); }
+ set { SetValue(WatermarkTemplateProperty, value); }
+ }
+
+ #endregion //WatermarkTemplate
+
+ #endregion //Properties
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs
new file mode 100644
index 00000000..3001fa37
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Primitives/UpDownBase.cs
@@ -0,0 +1,288 @@
+using System;
+using System.Windows.Controls;
+using Microsoft.Windows.Controls.Primitives;
+using System.Windows.Input;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls.Primitives
+{
+ public abstract class UpDownBase : InputBase
+ {
+ #region Members
+
+ ///
+ /// Name constant for Text template part.
+ ///
+ internal const string ElementTextName = "TextBox";
+
+ ///
+ /// Name constant for Spinner template part.
+ ///
+ internal const string ElementSpinnerName = "Spinner";
+
+ ///
+ /// Flags if the Text and Value properties are in the process of being sync'd
+ ///
+ private bool _isSyncingTextAndValueProperties;
+
+ #endregion //Members
+
+ #region Properties
+
+ protected Spinner Spinner { get; private set; }
+ protected TextBox TextBox { get; private set; }
+
+ #region AllowSpin
+
+ public static readonly DependencyProperty AllowSpinProperty = DependencyProperty.Register("AllowSpin", typeof(bool), typeof(UpDownBase), new UIPropertyMetadata(true));
+ public bool AllowSpin
+ {
+ get { return (bool)GetValue(AllowSpinProperty); }
+ set { SetValue(AllowSpinProperty, value); }
+ }
+
+ #endregion //AllowSpin
+
+ #region ShowButtonSpinner
+
+ public static readonly DependencyProperty ShowButtonSpinnerProperty = DependencyProperty.Register("ShowButtonSpinner", typeof(bool), typeof(UpDownBase), new UIPropertyMetadata(true));
+ public bool ShowButtonSpinner
+ {
+ get { return (bool)GetValue(ShowButtonSpinnerProperty); }
+ set { SetValue(ShowButtonSpinnerProperty, value); }
+ }
+
+ #endregion //ShowButtonSpinner
+
+ #region Value
+
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(T), typeof(UpDownBase), new FrameworkPropertyMetadata(default(T), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged, OnCoerceValue));
+ public T Value
+ {
+ get { return (T)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ private static object OnCoerceValue(DependencyObject o, object value)
+ {
+ UpDownBase upDownBase = o as UpDownBase;
+ if (upDownBase != null)
+ return upDownBase.OnCoerceValue((T)value);
+ else
+ return value;
+ }
+
+ protected virtual T OnCoerceValue(T value)
+ {
+ return value;
+ }
+
+ private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ UpDownBase upDownBase = o as UpDownBase;
+ if (upDownBase != null)
+ upDownBase.OnValueChanged((T)e.OldValue, (T)e.NewValue);
+ }
+
+ protected virtual void OnValueChanged(T oldValue, T newValue)
+ {
+ SyncTextAndValueProperties(ValueProperty, string.Empty);
+
+ RoutedPropertyChangedEventArgs args = new RoutedPropertyChangedEventArgs(oldValue, newValue);
+ args.RoutedEvent = ValueChangedEvent;
+ RaiseEvent(args);
+ }
+
+ #endregion //Value
+
+ #endregion //Properties
+
+ #region Constructors
+
+ internal UpDownBase() { }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ protected override void OnAccessKey(AccessKeyEventArgs e)
+ {
+ if (TextBox != null)
+ TextBox.Focus();
+
+ base.OnAccessKey(e);
+ }
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ TextBox = GetTemplateChild(ElementTextName) as TextBox;
+ Spinner = GetTemplateChild(ElementSpinnerName) as Spinner;
+ Spinner.Spin += OnSpinnerSpin;
+ }
+
+ protected override void OnGotFocus(RoutedEventArgs e)
+ {
+ if (TextBox != null)
+ TextBox.Focus();
+ }
+
+ protected override void OnPreviewKeyDown(KeyEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case Key.Up:
+ {
+ if (AllowSpin)
+ DoIncrement();
+ e.Handled = true;
+ break;
+ }
+ case Key.Down:
+ {
+ if (AllowSpin)
+ DoDecrement();
+ e.Handled = true;
+ break;
+ }
+ case Key.Enter:
+ {
+ if (IsEditable)
+ {
+ var binding = BindingOperations.GetBindingExpression(TextBox, System.Windows.Controls.TextBox.TextProperty);
+ binding.UpdateSource();
+ }
+ break;
+ }
+ }
+ }
+
+ protected override void OnMouseWheel(MouseWheelEventArgs e)
+ {
+ base.OnMouseWheel(e);
+
+ if (!e.Handled && AllowSpin && TextBox.IsFocused)
+ {
+ if (e.Delta < 0)
+ {
+ DoDecrement();
+ }
+ else if (0 < e.Delta)
+ {
+ DoIncrement();
+ }
+
+ e.Handled = true;
+ }
+ }
+
+ protected override void OnTextChanged(string oldValue, string newValue)
+ {
+ SyncTextAndValueProperties(InputBase.TextProperty, newValue);
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ private void OnSpinnerSpin(object sender, SpinEventArgs e)
+ {
+ if (AllowSpin)
+ OnSpin(e);
+ }
+
+ #endregion //Event Handlers
+
+ #region Events
+
+ public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(UpDownBase));
+ public event RoutedPropertyChangedEventHandler ValueChanged
+ {
+ add { AddHandler(ValueChangedEvent, value); }
+ remove { RemoveHandler(ValueChangedEvent, value); }
+ }
+
+ #endregion //Events
+
+ #region Methods
+
+ protected virtual void OnSpin(SpinEventArgs e)
+ {
+ if (e == null)
+ throw new ArgumentNullException("e");
+
+ if (e.Direction == SpinDirection.Increase)
+ DoIncrement();
+ else
+ DoDecrement();
+ }
+
+ ///
+ /// Performs an increment if conditions allow it.
+ ///
+ private void DoDecrement()
+ {
+ if (Spinner == null || (Spinner.ValidSpinDirection & ValidSpinDirections.Decrease) == ValidSpinDirections.Decrease)
+ {
+ OnDecrement();
+ }
+ }
+
+ ///
+ /// Performs a decrement if conditions allow it.
+ ///
+ private void DoIncrement()
+ {
+ if (Spinner == null || (Spinner.ValidSpinDirection & ValidSpinDirections.Increase) == ValidSpinDirections.Increase)
+ {
+ OnIncrement();
+ }
+ }
+
+ protected void SyncTextAndValueProperties(DependencyProperty p, string text)
+ {
+ //prevents recursive syncing properties
+ if (_isSyncingTextAndValueProperties)
+ return;
+
+ _isSyncingTextAndValueProperties = true;
+
+ //this only occures when the user typed in the value
+ if (InputBase.TextProperty == p)
+ {
+ Value = ConvertTextToValue(text);
+ }
+
+ Text = ConvertValueToText();
+
+#if VS2008
+ //there is a bug in .NET 3.5 which will not correctly update the textbox text through binding.
+ TextBox.Text = Text;
+#endif
+
+ _isSyncingTextAndValueProperties = false;
+ }
+
+ #region Abstract
+
+ ///
+ /// Called by OnSpin when the spin direction is SpinDirection.Increase.
+ ///
+ protected abstract void OnIncrement();
+
+ ///
+ /// Called by OnSpin when the spin direction is SpinDirection.Descrease.
+ ///
+ protected abstract void OnDecrement();
+
+ protected abstract T ConvertTextToValue(string text);
+
+ protected abstract string ConvertValueToText();
+
+ #endregion //Abstract
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/UIElementAdorner.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/UIElementAdorner.cs
new file mode 100644
index 00000000..263ca034
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/UIElementAdorner.cs
@@ -0,0 +1,215 @@
+using System;
+using System.Collections;
+using System.Windows.Media;
+using System.Windows.Documents;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls.Core
+{
+ ///
+ /// An adorner that can display one and only one UIElement.
+ /// That element can be a panel, which contains multiple other elements.
+ /// The element is added to the adorner's visual and logical trees, enabling it to
+ /// particpate in dependency property value inheritance, amongst other things.
+ ///
+ internal class UIElementAdorner
+ : Adorner
+ where TElement : UIElement
+ {
+ #region Fields
+
+ TElement _child = null;
+ double _offsetLeft = 0;
+ double _offsetTop = 0;
+
+ #endregion // Fields
+
+ #region Constructor
+
+ ///
+ /// Constructor.
+ ///
+ /// The element to which the adorner will be bound.
+ public UIElementAdorner(UIElement adornedElement)
+ : base(adornedElement)
+ {
+ }
+
+ #endregion // Constructor
+
+ #region Public Interface
+
+ #region Child
+
+ ///
+ /// Gets/sets the child element hosted in the adorner.
+ ///
+ public TElement Child
+ {
+ get { return _child; }
+ set
+ {
+ if (value == _child)
+ return;
+
+ if (_child != null)
+ {
+ base.RemoveLogicalChild(_child);
+ base.RemoveVisualChild(_child);
+ }
+
+ _child = value;
+
+ if (_child != null)
+ {
+ base.AddLogicalChild(_child);
+ base.AddVisualChild(_child);
+ }
+ }
+ }
+
+ #endregion // Child
+
+ #region GetDesiredTransform
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
+ {
+ GeneralTransformGroup result = new GeneralTransformGroup();
+ result.Children.Add(base.GetDesiredTransform(transform));
+ result.Children.Add(new TranslateTransform(_offsetLeft, _offsetTop));
+ return result;
+ }
+
+ #endregion // GetDesiredTransform
+
+ #region OffsetLeft
+
+ ///
+ /// Gets/sets the horizontal offset of the adorner.
+ ///
+ public double OffsetLeft
+ {
+ get { return _offsetLeft; }
+ set
+ {
+ _offsetLeft = value;
+ UpdateLocation();
+ }
+ }
+
+ #endregion // OffsetLeft
+
+ #region SetOffsets
+
+ ///
+ /// Updates the location of the adorner in one atomic operation.
+ ///
+ public void SetOffsets(double left, double top)
+ {
+ _offsetLeft = left;
+ _offsetTop = top;
+ this.UpdateLocation();
+ }
+
+ #endregion // SetOffsets
+
+ #region OffsetTop
+
+ ///
+ /// Gets/sets the vertical offset of the adorner.
+ ///
+ public double OffsetTop
+ {
+ get { return _offsetTop; }
+ set
+ {
+ _offsetTop = value;
+ UpdateLocation();
+ }
+ }
+
+ #endregion // OffsetTop
+
+ #endregion // Public Interface
+
+ #region Protected Overrides
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Size MeasureOverride(Size constraint)
+ {
+ if (_child == null)
+ return base.MeasureOverride(constraint);
+
+ _child.Measure(constraint);
+ return _child.DesiredSize;
+ }
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ if (_child == null)
+ return base.ArrangeOverride(finalSize);
+
+ _child.Arrange(new Rect(finalSize));
+ return finalSize;
+ }
+
+ ///
+ /// Override.
+ ///
+ protected override IEnumerator LogicalChildren
+ {
+ get
+ {
+ ArrayList list = new ArrayList();
+ if (_child != null)
+ list.Add(_child);
+ return list.GetEnumerator();
+ }
+ }
+
+ ///
+ /// Override.
+ ///
+ ///
+ ///
+ protected override Visual GetVisualChild(int index)
+ {
+ return _child;
+ }
+
+ ///
+ /// Override.
+ ///
+ protected override int VisualChildrenCount
+ {
+ get { return _child == null ? 0 : 1; }
+ }
+
+ #endregion // Protected Overrides
+
+ #region Private Helpers
+
+ void UpdateLocation()
+ {
+ AdornerLayer adornerLayer = base.Parent as AdornerLayer;
+ if (adornerLayer != null)
+ adornerLayer.Update(base.AdornedElement);
+ }
+
+ #endregion // Private Helpers
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/CalculatorUtilities.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/CalculatorUtilities.cs
new file mode 100644
index 00000000..bb1337f1
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/CalculatorUtilities.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Windows.Controls;
+using System.Windows;
+using System.Windows.Media;
+using System.Globalization;
+
+namespace Microsoft.Windows.Controls.Core.Utilities
+{
+ static class CalculatorUtilities
+ {
+ public static Calculator.CalculatorButtonType GetCalculatorButtonTypeFromText(string text)
+ {
+ switch (text)
+ {
+ case "0": return Calculator.CalculatorButtonType.Zero;
+ case "1": return Calculator.CalculatorButtonType.One;
+ case "2": return Calculator.CalculatorButtonType.Two;
+ case "3": return Calculator.CalculatorButtonType.Three;
+ case "4": return Calculator.CalculatorButtonType.Four;
+ case "5": return Calculator.CalculatorButtonType.Five;
+ case "6": return Calculator.CalculatorButtonType.Six;
+ case "7": return Calculator.CalculatorButtonType.Seven;
+ case "8": return Calculator.CalculatorButtonType.Eight;
+ case "9": return Calculator.CalculatorButtonType.Nine;
+ case "+": return Calculator.CalculatorButtonType.Add;
+ case "-": return Calculator.CalculatorButtonType.Subtract;
+ case "*": return Calculator.CalculatorButtonType.Multiply;
+ case "/": return Calculator.CalculatorButtonType.Divide;
+ case "%": return Calculator.CalculatorButtonType.Percent;
+ case "\b": return Calculator.CalculatorButtonType.Back;
+ case "\r":
+ case "=": return Calculator.CalculatorButtonType.Equal;
+ }
+
+ //the check for the decimal is not in the switch statement. To help localize we check against the current culture's decimal seperator
+ if (text == CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator)
+ return Calculator.CalculatorButtonType.Decimal;
+
+ //check for the escape key
+ if (text == ((char)27).ToString())
+ return Calculator.CalculatorButtonType.Clear;
+
+ return Calculator.CalculatorButtonType.None;
+ }
+
+ public static Button FindButtonByCalculatorButtonType(DependencyObject parent, Calculator.CalculatorButtonType type)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
+ {
+ var child = VisualTreeHelper.GetChild(parent, i);
+
+ object buttonType = child.GetValue(Button.CommandParameterProperty);
+
+ if (buttonType != null && (Calculator.CalculatorButtonType)buttonType == type)
+ {
+ return child as Button;
+ }
+ else
+ {
+ var result = FindButtonByCalculatorButtonType(child, type);
+
+ if (result != null)
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public static string GetCalculatorButtonContent(Calculator.CalculatorButtonType type)
+ {
+ string content = string.Empty;
+ switch (type)
+ {
+ case Calculator.CalculatorButtonType.Add:
+ content = "+";
+ break;
+ case Calculator.CalculatorButtonType.Back:
+ content = "Back";
+ break;
+ case Calculator.CalculatorButtonType.Cancel:
+ content = "CE";
+ break;
+ case Calculator.CalculatorButtonType.Clear:
+ content = "C";
+ break;
+ case Calculator.CalculatorButtonType.Decimal:
+ content = CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator;
+ break;
+ case Calculator.CalculatorButtonType.Divide:
+ content = "/";
+ break;
+ case Calculator.CalculatorButtonType.Eight:
+ content = "8";
+ break;
+ case Calculator.CalculatorButtonType.Equal:
+ content = "=";
+ break;
+ case Calculator.CalculatorButtonType.Five:
+ content = "5";
+ break;
+ case Calculator.CalculatorButtonType.Four:
+ content = "4";
+ break;
+ case Calculator.CalculatorButtonType.Fraction:
+ content = "1/x";
+ break;
+ case Calculator.CalculatorButtonType.MAdd:
+ content = "M+";
+ break;
+ case Calculator.CalculatorButtonType.MC:
+ content = "MC";
+ break;
+ case Calculator.CalculatorButtonType.MR:
+ content = "MR";
+ break;
+ case Calculator.CalculatorButtonType.MS:
+ content = "MS";
+ break;
+ case Calculator.CalculatorButtonType.MSub:
+ content = "M-";
+ break;
+ case Calculator.CalculatorButtonType.Multiply:
+ content = "*";
+ break;
+ case Calculator.CalculatorButtonType.Nine:
+ content = "9";
+ break;
+ case Calculator.CalculatorButtonType.None:
+ break;
+ case Calculator.CalculatorButtonType.One:
+ content = "1";
+ break;
+ case Calculator.CalculatorButtonType.Percent:
+ content = "%";
+ break;
+ case Calculator.CalculatorButtonType.Seven:
+ content = "7";
+ break;
+ case Calculator.CalculatorButtonType.Negate:
+ content = "+/-";
+ break;
+ case Calculator.CalculatorButtonType.Six:
+ content = "6";
+ break;
+ case Calculator.CalculatorButtonType.Sqrt:
+ content = "Sqrt";
+ break;
+ case Calculator.CalculatorButtonType.Subtract:
+ content = "-";
+ break;
+ case Calculator.CalculatorButtonType.Three:
+ content = "3";
+ break;
+ case Calculator.CalculatorButtonType.Two:
+ content = "2";
+ break;
+ case Calculator.CalculatorButtonType.Zero:
+ content = "0";
+ break;
+ }
+ return content;
+ }
+
+ public static bool IsDigit(Calculator.CalculatorButtonType buttonType)
+ {
+ switch (buttonType)
+ {
+ case Calculator.CalculatorButtonType.Zero:
+ case Calculator.CalculatorButtonType.One:
+ case Calculator.CalculatorButtonType.Two:
+ case Calculator.CalculatorButtonType.Three:
+ case Calculator.CalculatorButtonType.Four:
+ case Calculator.CalculatorButtonType.Five:
+ case Calculator.CalculatorButtonType.Six:
+ case Calculator.CalculatorButtonType.Seven:
+ case Calculator.CalculatorButtonType.Eight:
+ case Calculator.CalculatorButtonType.Nine:
+ case Calculator.CalculatorButtonType.Decimal:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public static bool IsMemory(Calculator.CalculatorButtonType buttonType)
+ {
+ switch (buttonType)
+ {
+ case Calculator.CalculatorButtonType.MAdd:
+ case Calculator.CalculatorButtonType.MC:
+ case Calculator.CalculatorButtonType.MR:
+ case Calculator.CalculatorButtonType.MS:
+ case Calculator.CalculatorButtonType.MSub:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public static decimal ParseDecimal(string text)
+ {
+ return Decimal.Parse(text, CultureInfo.CurrentCulture);
+ }
+
+ public static decimal Add(decimal firstNumber, decimal secondNumber)
+ {
+ return firstNumber + secondNumber;
+ }
+
+ public static decimal Subtract(decimal firstNumber, decimal secondNumber)
+ {
+ return firstNumber - secondNumber;
+ }
+
+ public static decimal Multiply(decimal firstNumber, decimal secondNumber)
+ {
+ return firstNumber * secondNumber;
+ }
+
+ public static decimal Divide(decimal firstNumber, decimal secondNumber)
+ {
+ return firstNumber / secondNumber;
+ }
+
+ public static decimal Percent(decimal firstNumber, decimal secondNumber)
+ {
+ return firstNumber * secondNumber / 100M;
+ }
+
+ public static decimal SquareRoot(decimal operand)
+ {
+ return Convert.ToDecimal(Math.Sqrt(Convert.ToDouble(operand)));
+ }
+
+ public static decimal Fraction(decimal operand)
+ {
+ return 1 / operand;
+ }
+
+ public static decimal Negate(decimal operand)
+ {
+ return operand * -1M;
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs
new file mode 100644
index 00000000..cb2d7c18
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ColorUtilities.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Linq;
+using System.Windows.Media;
+using System.Reflection;
+using System.Collections.Generic;
+using Microsoft.Windows.Controls.Primitives;
+
+namespace Microsoft.Windows.Controls.Core.Utilities
+{
+ static class ColorUtilities
+ {
+ public static readonly Dictionary KnownColors = GetKnownColors();
+
+ public static string GetColorName(this Color color)
+ {
+ string colorName = KnownColors.Where(kvp => kvp.Value.Equals(color)).Select(kvp => kvp.Key).FirstOrDefault();
+
+ if (String.IsNullOrEmpty(colorName))
+ colorName = color.ToString();
+
+ return colorName;
+ }
+
+ private static Dictionary GetKnownColors()
+ {
+ var colorProperties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public);
+ return colorProperties.ToDictionary(p => p.Name, p => (Color)p.GetValue(null, null));
+ }
+
+ ///
+ /// 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/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ContextMenuUtilities.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ContextMenuUtilities.cs
new file mode 100644
index 00000000..59b38f93
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Core/Utilities/ContextMenuUtilities.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls.Core.Utilities
+{
+ public class ContextMenuUtilities
+ {
+ public static readonly DependencyProperty OpenOnMouseLeftButtonClickProperty = DependencyProperty.RegisterAttached("OpenOnMouseLeftButtonClick", typeof(bool), typeof(ContextMenuUtilities), new FrameworkPropertyMetadata(false, OpenOnMouseLeftButtonClickChanged));
+ public static void SetOpenOnMouseLeftButtonClick(FrameworkElement element, bool value)
+ {
+ element.SetValue(OpenOnMouseLeftButtonClickProperty, value);
+ }
+ public static bool GetOpenOnMouseLeftButtonClick(FrameworkElement element)
+ {
+ return (bool)element.GetValue(OpenOnMouseLeftButtonClickProperty);
+ }
+
+ public static void OpenOnMouseLeftButtonClickChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
+ {
+ var control = (FrameworkElement)sender;
+ if ((bool)e.NewValue)
+ {
+ control.PreviewMouseLeftButtonDown += (s, args) =>
+ {
+ if (control.ContextMenu != null)
+ {
+ control.ContextMenu.PlacementTarget = control;
+ control.ContextMenu.IsOpen = true;
+ }
+ };
+ }
+ //TODO: remove handler when set to false
+ }
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Implementation/DateTimePicker.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Implementation/DateTimePicker.cs
new file mode 100644
index 00000000..763f383d
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Implementation/DateTimePicker.cs
@@ -0,0 +1,267 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+#if VS2008
+using Microsoft.Windows.Controls.Primitives;
+#else
+using System.Windows.Controls.Primitives;
+#endif
+
+namespace Microsoft.Windows.Controls
+{
+ public class DateTimePicker : Control
+ {
+ #region Members
+
+ private Calendar _calendar;
+
+ #endregion //Members
+
+ #region Properties
+
+ #region AllowSpin
+
+ public static readonly DependencyProperty AllowSpinProperty = DependencyProperty.Register("AllowSpin", typeof(bool), typeof(DateTimePicker), new UIPropertyMetadata(true));
+ public bool AllowSpin
+ {
+ get { return (bool)GetValue(AllowSpinProperty); }
+ set { SetValue(AllowSpinProperty, value); }
+ }
+
+ #endregion //AllowSpin
+
+ #region Format
+
+ public static readonly DependencyProperty FormatProperty = DependencyProperty.Register("Format", typeof(DateTimeFormat), typeof(DateTimePicker), new UIPropertyMetadata(DateTimeFormat.FullDateTime, OnFormatChanged));
+ public DateTimeFormat Format
+ {
+ get { return (DateTimeFormat)GetValue(FormatProperty); }
+ set { SetValue(FormatProperty, value); }
+ }
+
+ private static void OnFormatChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ DateTimePicker DateTimePicker = o as DateTimePicker;
+ if (DateTimePicker != null)
+ DateTimePicker.OnFormatChanged((DateTimeFormat)e.OldValue, (DateTimeFormat)e.NewValue);
+ }
+
+ protected virtual void OnFormatChanged(DateTimeFormat oldValue, DateTimeFormat newValue)
+ {
+
+ }
+
+ #endregion //Format
+
+ #region FormatString
+
+ public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(DateTimePicker), new UIPropertyMetadata(default(String), OnFormatStringChanged));
+ public string FormatString
+ {
+ get { return (string)GetValue(FormatStringProperty); }
+ set { SetValue(FormatStringProperty, value); }
+ }
+
+ private static void OnFormatStringChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ DateTimePicker DateTimePicker = o as DateTimePicker;
+ if (DateTimePicker != null)
+ DateTimePicker.OnFormatStringChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnFormatStringChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue))
+ throw new ArgumentException("CustomFormat should be specified.", FormatString);
+ }
+
+ #endregion //FormatString
+
+ #region IsOpen
+
+ public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(DateTimePicker), new UIPropertyMetadata(false));
+ public bool IsOpen
+ {
+ get { return (bool)GetValue(IsOpenProperty); }
+ set { SetValue(IsOpenProperty, value); }
+ }
+
+ #endregion //IsOpen
+
+ #region ShowButtonSpinner
+
+ public static readonly DependencyProperty ShowButtonSpinnerProperty = DependencyProperty.Register("ShowButtonSpinner", typeof(bool), typeof(DateTimePicker), new UIPropertyMetadata(true));
+ public bool ShowButtonSpinner
+ {
+ get { return (bool)GetValue(ShowButtonSpinnerProperty); }
+ set { SetValue(ShowButtonSpinnerProperty, value); }
+ }
+
+ #endregion //ShowButtonSpinner
+
+ #region TimeWatermark
+
+ public static readonly DependencyProperty TimeWatermarkProperty = DependencyProperty.Register("TimeWatermark", typeof(object), typeof(DateTimePicker), new UIPropertyMetadata(null));
+ public object TimeWatermark
+ {
+ get { return (object)GetValue(TimeWatermarkProperty); }
+ set { SetValue(TimeWatermarkProperty, value); }
+ }
+
+ #endregion //TimeWatermark
+
+ #region TimeWatermarkTemplate
+
+ public static readonly DependencyProperty TimeWatermarkTemplateProperty = DependencyProperty.Register("TimeWatermarkTemplate", typeof(DataTemplate), typeof(DateTimePicker), new UIPropertyMetadata(null));
+ public DataTemplate TimeWatermarkTemplate
+ {
+ get { return (DataTemplate)GetValue(TimeWatermarkTemplateProperty); }
+ set { SetValue(TimeWatermarkTemplateProperty, value); }
+ }
+
+ #endregion //TimeWatermarkTemplate
+
+ #region Value
+
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(DateTime?), typeof(DateTimePicker), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged, OnCoerceValue));
+ public DateTime? Value
+ {
+ get { return (DateTime?)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ private static object OnCoerceValue(DependencyObject o, object value)
+ {
+ DateTimePicker dateTimePicker = o as DateTimePicker;
+ if (dateTimePicker != null)
+ return dateTimePicker.OnCoerceValue((DateTime?)value);
+ else
+ return value;
+ }
+
+ private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ DateTimePicker dateTimePicker = o as DateTimePicker;
+ if (dateTimePicker != null)
+ dateTimePicker.OnValueChanged((DateTime?)e.OldValue, (DateTime?)e.NewValue);
+ }
+
+ protected virtual DateTime? OnCoerceValue(DateTime? value)
+ {
+ // TODO: Keep the proposed value within the desired range.
+ return value;
+ }
+
+ protected virtual void OnValueChanged(DateTime? oldValue, DateTime? newValue)
+ {
+ if (_calendar != null && _calendar.SelectedDate.HasValue && newValue.HasValue && _calendar.SelectedDate.Value != newValue.Value)
+ {
+ _calendar.SelectedDate = newValue;
+ _calendar.DisplayDate = newValue.Value;
+ }
+ }
+
+ #endregion //Value
+
+ #region Watermark
+
+ public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(object), typeof(DateTimePicker), new UIPropertyMetadata(null));
+ public object Watermark
+ {
+ get { return (object)GetValue(WatermarkProperty); }
+ set { SetValue(WatermarkProperty, value); }
+ }
+
+ #endregion //Watermark
+
+ #region WatermarkTemplate
+
+ public static readonly DependencyProperty WatermarkTemplateProperty = DependencyProperty.Register("WatermarkTemplate", typeof(DataTemplate), typeof(DateTimePicker), new UIPropertyMetadata(null));
+ public DataTemplate WatermarkTemplate
+ {
+ get { return (DataTemplate)GetValue(WatermarkTemplateProperty); }
+ set { SetValue(WatermarkTemplateProperty, value); }
+ }
+
+ #endregion //WatermarkTemplate
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static DateTimePicker()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(DateTimePicker), new FrameworkPropertyMetadata(typeof(DateTimePicker)));
+ }
+
+ public DateTimePicker()
+ {
+ Keyboard.AddKeyDownHandler(this, OnKeyDown);
+ Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement);
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _calendar = (Calendar)GetTemplateChild("Part_Calendar");
+ _calendar.SelectedDatesChanged += Calendar_SelectedDatesChanged;
+ _calendar.SelectedDate = Value ?? null;
+ }
+
+ protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
+ {
+ if (Mouse.Captured is CalendarItem)
+ Mouse.Capture(null);
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Handlers
+
+ private void OnKeyDown(object sender, KeyEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case Key.Escape:
+ case Key.Tab:
+ {
+ CloseDateTimePicker();
+ break;
+ }
+ }
+ }
+
+ private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e)
+ {
+ CloseDateTimePicker();
+ }
+
+ void Calendar_SelectedDatesChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (e.AddedItems.Count > 0)
+ {
+ var newDate = (DateTime?)e.AddedItems[0];
+ Value = newDate;
+ }
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ private void CloseDateTimePicker()
+ {
+ if (IsOpen)
+ IsOpen = false;
+ ReleaseMouseCapture();
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml
new file mode 100644
index 00000000..5c8f8122
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeFormat.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeFormat.cs
new file mode 100644
index 00000000..f6c54305
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeFormat.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ public enum DateTimeFormat
+ {
+ Custom,
+ FullDateTime,
+ LongDate,
+ LongTime,
+ MonthDay,
+ RFC1123,
+ ShortDate,
+ ShortTime,
+ SortableDateTime,
+ UniversalSortableDateTime,
+ YearMonth
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeInfo.cs
new file mode 100644
index 00000000..8f4f7765
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeInfo.cs
@@ -0,0 +1,14 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ internal class DateTimeInfo
+ {
+ public string Content { get; set; }
+ public string Format { get; set; }
+ public bool IsReadOnly { get; set; }
+ public int Length { get; set; }
+ public int StartPosition { get; set; }
+ public DateTimePart Type { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeParser.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeParser.cs
new file mode 100644
index 00000000..4a8050bd
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeParser.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Linq;
+using System.Globalization;
+
+namespace Microsoft.Windows.Controls
+{
+ internal class DateTimeParser
+ {
+ #region Properties
+
+ private DateTimeFormatInfo DateTimeFormatInfo { get; set; }
+
+ public string Format { get; set; }
+
+ #endregion //Properties
+
+ #region Constructors
+
+ public DateTimeParser(DateTimeFormatInfo dateTimeFormatInfo)
+ {
+ DateTimeFormatInfo = dateTimeFormatInfo;
+ }
+
+ public DateTimeParser(DateTimeFormatInfo dateTimeFormatInfo, string format)
+ {
+ DateTimeFormatInfo = dateTimeFormatInfo;
+ Format = format;
+ }
+
+ #endregion //Constructors
+
+ #region Methods
+
+ public bool TryParse(string value, out DateTime result, DateTime currentDate)
+ {
+ bool success = false;
+ result = currentDate;
+
+ if (string.IsNullOrEmpty(value))
+ return false;
+
+ var dateTimeString = ResolveDateTimeString(value, currentDate);
+
+ if (!String.IsNullOrEmpty(dateTimeString))
+ success = DateTime.TryParse(dateTimeString, DateTimeFormatInfo, DateTimeStyles.None, out result);
+
+ if (!success)
+ result = currentDate;
+
+ return success;
+ }
+
+ private string ResolveDateTimeString(string dateTime, DateTime currentDate)
+ {
+ // 1/1/0001 12:00:00 AM
+ string[] dateParts = new string[3] { currentDate.Month.ToString(), currentDate.Day.ToString(), currentDate.Year.ToString() };
+ string[] timeParts = new string[3] { currentDate.Hour.ToString(), currentDate.Minute.ToString(), currentDate.Second.ToString() };
+ string designator = "AM";
+
+ string[] dateTimeSeparators = new string[] { ",", " ", "-", DateTimeFormatInfo.DateSeparator, DateTimeFormatInfo.TimeSeparator };
+
+ var dateTimeParts = dateTime.Split(dateTimeSeparators, StringSplitOptions.RemoveEmptyEntries).ToList();
+ var formats = Format.Split(dateTimeSeparators, StringSplitOptions.RemoveEmptyEntries).ToList();
+
+ //something went wrong
+ if (dateTimeParts.Count != formats.Count)
+ return string.Empty;
+
+ for (int i = 0; i < formats.Count; i++)
+ {
+ var format = formats[i];
+ if (!format.Contains("ddd") && !format.Contains("GMT"))
+ {
+ if (format.Contains("M"))
+ dateParts[0] = dateTimeParts[i];
+ else if (format.Contains("d"))
+ dateParts[1] = dateTimeParts[i];
+ else if (format.Contains("y"))
+ {
+ dateParts[2] = dateTimeParts[i];
+ if (dateParts[2].Length == 2)
+ dateParts[2] = string.Format("{0}{1}", currentDate.Year / 100, dateParts[2]);
+ }
+ else if (format.Contains("h") || format.Contains("H"))
+ timeParts[0] = dateTimeParts[i];
+ else if (format.Contains("m"))
+ timeParts[1] = dateTimeParts[i];
+ else if (format.Contains("s"))
+ timeParts[2] = dateTimeParts[i];
+ else if (format.Contains("t"))
+ designator = dateTimeParts[i];
+ }
+ }
+
+ var date = string.Join(DateTimeFormatInfo.DateSeparator, dateParts);
+ var time = string.Join(DateTimeFormatInfo.TimeSeparator, timeParts);
+
+ return String.Format("{0} {1} {2}", date, time, designator);
+ }
+
+ #endregion // Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimePart.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimePart.cs
new file mode 100644
index 00000000..d4ec352c
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimePart.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace Microsoft.Windows.Controls
+{
+ public enum DateTimePart
+ {
+ Day,
+ DayName,
+ AmPmDesignator,
+ Millisecond,
+ Hour12,
+ Hour24,
+ Minute,
+ Month,
+ MonthName,
+ Other,
+ Period,
+ TimeZone,
+ Second,
+ Year
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs
new file mode 100644
index 00000000..ea584493
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Implementation/DateTimeUpDown.cs
@@ -0,0 +1,554 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Input;
+using Microsoft.Windows.Controls.Primitives;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls
+{
+ public class DateTimeUpDown : UpDownBase
+ {
+ #region Members
+
+ private List _dateTimeInfoList = new List();
+ private DateTimeInfo _selectedDateTimeInfo;
+ private bool _fireSelectionChangedEvent = true;
+
+ private DateTimeParser _dateTimeParser;
+
+ #endregion //Members
+
+ #region Properties
+
+ private DateTimeFormatInfo DateTimeFormatInfo { get; set; }
+
+ #region DefaultValue
+
+ public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("DefaultValue", typeof(DateTime), typeof(DateTimeUpDown), new UIPropertyMetadata(DateTime.Now));
+ public DateTime DefaultValue
+ {
+ get { return (DateTime)GetValue(DefaultValueProperty); }
+ set { SetValue(DefaultValueProperty, value); }
+ }
+
+ #endregion //DefaultValue
+
+ #region Format
+
+ public static readonly DependencyProperty FormatProperty = DependencyProperty.Register("Format", typeof(DateTimeFormat), typeof(DateTimeUpDown), new UIPropertyMetadata(DateTimeFormat.FullDateTime, OnFormatChanged));
+ public DateTimeFormat Format
+ {
+ get { return (DateTimeFormat)GetValue(FormatProperty); }
+ set { SetValue(FormatProperty, value); }
+ }
+
+ private static void OnFormatChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ DateTimeUpDown dateTimeUpDown = o as DateTimeUpDown;
+ if (dateTimeUpDown != null)
+ dateTimeUpDown.OnFormatChanged((DateTimeFormat)e.OldValue, (DateTimeFormat)e.NewValue);
+ }
+
+ protected virtual void OnFormatChanged(DateTimeFormat oldValue, DateTimeFormat newValue)
+ {
+ _dateTimeParser.Format = GetFormatString(newValue);
+
+ //if using a CustomFormat then the initialization occurs on the CustomFormatString property
+ if (newValue != DateTimeFormat.Custom)
+ InitializeDateTimeInfoListAndParseValue();
+
+ Text = ConvertValueToText();
+ }
+
+ #endregion //Format
+
+ #region FormatString
+
+ public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(DateTimeUpDown), new UIPropertyMetadata(default(String), OnFormatStringChanged));
+ public string FormatString
+ {
+ get { return (string)GetValue(FormatStringProperty); }
+ set { SetValue(FormatStringProperty, value); }
+ }
+
+ private static void OnFormatStringChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ DateTimeUpDown dateTimeUpDown = o as DateTimeUpDown;
+ if (dateTimeUpDown != null)
+ dateTimeUpDown.OnFormatStringChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnFormatStringChanged(string oldValue, string newValue)
+ {
+ if (string.IsNullOrEmpty(newValue))
+ throw new ArgumentException("CustomFormat should be specified.", FormatString);
+
+ InitializeDateTimeInfoListAndParseValue();
+ }
+
+ #endregion //FormatString
+
+ #region Maximum
+
+
+
+ #endregion //Maximum
+
+ #region Minimum
+
+
+
+ #endregion //Minimum
+
+ #endregion //Properties
+
+ #region Constructors
+
+ static DateTimeUpDown()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(DateTimeUpDown), new FrameworkPropertyMetadata(typeof(DateTimeUpDown)));
+ }
+
+ public DateTimeUpDown()
+ {
+ DateTimeFormatInfo = DateTimeFormatInfo.GetInstance(CultureInfo);
+ _dateTimeParser = new DateTimeParser(DateTimeFormatInfo, GetFormatString(Format));
+ InitializeDateTimeInfoList();
+ }
+
+ #endregion //Constructors
+
+ #region Base Class Overrides
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+ TextBox.SelectionChanged += TextBox_SelectionChanged;
+ }
+
+ protected override void OnIncrement()
+ {
+ if (Value.HasValue)
+ UpdateDateTime(1);
+ else
+ Value = DefaultValue;
+ }
+
+ protected override void OnDecrement()
+ {
+ if (Value.HasValue)
+ UpdateDateTime(-1);
+ else
+ Value = DefaultValue;
+ }
+
+ protected override void OnPreviewKeyDown(KeyEventArgs e)
+ {
+ switch (e.Key)
+ {
+ case Key.Enter:
+ {
+ if (IsEditable)
+ {
+ _fireSelectionChangedEvent = false;
+ BindingExpression binding = BindingOperations.GetBindingExpression(TextBox, System.Windows.Controls.TextBox.TextProperty);
+ binding.UpdateSource();
+ _fireSelectionChangedEvent = true;
+ e.Handled = true;
+ }
+ return;
+ }
+ default:
+ {
+ _fireSelectionChangedEvent = false;
+ break;
+ }
+ }
+
+ base.OnPreviewKeyDown(e);
+ }
+
+ protected override void OnTextChanged(string previousValue, string currentValue)
+ {
+ //TODO: clean this up and make sure it doesn't fire recursively
+ if (String.IsNullOrEmpty(currentValue))
+ {
+ Value = null;
+ return;
+ }
+
+ DateTime current = Value.HasValue ? Value.Value : DateTime.Now;
+ DateTime result;
+ var success = _dateTimeParser.TryParse(currentValue, out result, current);
+
+ SyncTextAndValueProperties(InputBase.TextProperty, result.ToString());
+ }
+
+ protected override DateTime? OnCoerceValue(DateTime? value)
+ {
+ //if the user entered a string value to represent a date or time, we need to parse that string into a valid DatTime value
+ if (value != null && !(value is DateTime))
+ {
+ return DateTime.Parse(value.ToString(), DateTimeFormatInfo);
+ }
+
+ return value;
+ }
+
+ protected override DateTime? ConvertTextToValue(string text)
+ {
+ if (string.IsNullOrEmpty(text))
+ return null;
+
+ return DateTime.Parse(text, CultureInfo.CurrentCulture);
+ }
+
+ protected override string ConvertValueToText()
+ {
+ if (Value == null) return string.Empty;
+
+ DateTime dt = DateTime.Parse(Value.ToString(), CultureInfo);
+ return dt.ToString(GetFormatString(Format), CultureInfo);
+ }
+
+ protected override void OnValueChanged(DateTime? oldValue, DateTime? newValue)
+ {
+ //whenever the value changes we need to parse out the value into out DateTimeInfo segments so we can keep track of the individual pieces
+ //but only if it is not null
+ if (newValue != null)
+ ParseValueIntoDateTimeInfo();
+
+ base.OnValueChanged(oldValue, newValue);
+ }
+
+ #endregion //Base Class Overrides
+
+ #region Event Hanlders
+
+ void TextBox_SelectionChanged(object sender, RoutedEventArgs e)
+ {
+ if (_fireSelectionChangedEvent)
+ PerformMouseSelection();
+ else
+ _fireSelectionChangedEvent = true;
+ }
+
+ #endregion //Event Hanlders
+
+ #region Methods
+
+ private void InitializeDateTimeInfoListAndParseValue()
+ {
+ InitializeDateTimeInfoList();
+ if (Value != null)
+ ParseValueIntoDateTimeInfo();
+ }
+
+ private void InitializeDateTimeInfoList()
+ {
+ _dateTimeInfoList.Clear();
+
+ string format = GetFormatString(Format);
+ while (format.Length > 0)
+ {
+ int elementLength = GetElementLengthByFormat(format);
+ DateTimeInfo info = null;
+
+ switch (format[0])
+ {
+ case '"':
+ case '\'':
+ {
+ int closingQuotePosition = format.IndexOf(format[0], 1);
+ info = new DateTimeInfo { IsReadOnly = true, Type = DateTimePart.Other, Length = 1, Content = format.Substring(1, Math.Max(1, closingQuotePosition - 1)) };
+ elementLength = Math.Max(1, closingQuotePosition + 1);
+ break;
+ }
+ case 'D':
+ case 'd':
+ {
+ string d = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ d = "%" + d;
+
+ if (elementLength > 2)
+ info = new DateTimeInfo { IsReadOnly = true, Type = DateTimePart.DayName, Format = d };
+ else
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Day, Format = d };
+ break;
+ }
+ case 'F':
+ case 'f':
+ {
+ string f = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ f = "%" + f;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Millisecond, Format = f };
+ break;
+ }
+ case 'h':
+ {
+ string h = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ h = "%" + h;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Hour12, Format = h };
+ break;
+ }
+ case 'H':
+ {
+ string H = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ H = "%" + H;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Hour24, Format = H };
+ break;
+ }
+ case 'M':
+ {
+ string M = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ M = "%" + M;
+
+ if (elementLength >= 3)
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.MonthName, Format = M };
+ else
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Month, Format = M };
+ break;
+ }
+ case 'S':
+ case 's':
+ {
+ string s = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ s = "%" + s;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Second, Format = s };
+ break;
+ }
+ case 'T':
+ case 't':
+ {
+ string t = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ t = "%" + t;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.AmPmDesignator, Format = t };
+ break;
+ }
+ case 'Y':
+ case 'y':
+ {
+ string y = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ y = "%" + y;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Year, Format = y };
+ break;
+ }
+ case '\\':
+ {
+ if (format.Length >= 2)
+ {
+ info = new DateTimeInfo { IsReadOnly = true, Content = format.Substring(1, 1), Length = 1, Type = DateTimePart.Other };
+ elementLength = 2;
+ }
+ break;
+ }
+ case 'g':
+ {
+ string g = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ g = "%" + g;
+
+ info = new DateTimeInfo { IsReadOnly = true, Type = DateTimePart.Period, Format = format.Substring(0, elementLength) };
+ break;
+ }
+ case 'm':
+ {
+ string m = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ m = "%" + m;
+
+ info = new DateTimeInfo { IsReadOnly = false, Type = DateTimePart.Minute, Format = m };
+ break;
+ }
+ case 'z':
+ {
+ string z = format.Substring(0, elementLength);
+ if (elementLength == 1)
+ z = "%" + z;
+
+ info = new DateTimeInfo { IsReadOnly = true, Type = DateTimePart.TimeZone, Format = z };
+ break;
+ }
+ default:
+ {
+ elementLength = 1;
+ info = new DateTimeInfo { IsReadOnly = true, Length = 1, Content = format[0].ToString(), Type = DateTimePart.Other };
+ break;
+ }
+ }
+
+ _dateTimeInfoList.Add(info);
+ format = format.Substring(elementLength);
+ }
+ }
+
+ private static int GetElementLengthByFormat(string format)
+ {
+ for (int i = 1; i < format.Length; i++)
+ {
+ if (String.Compare(format[i].ToString(), format[0].ToString(), false) != 0)
+ {
+ return i;
+ }
+ }
+ return format.Length;
+ }
+
+ private void ParseValueIntoDateTimeInfo()
+ {
+ string text = string.Empty;
+
+ _dateTimeInfoList.ForEach(info =>
+ {
+ if (info.Format == null)
+ {
+ info.StartPosition = text.Length;
+ info.Length = info.Content.Length;
+ text += info.Content;
+ }
+ else
+ {
+ DateTime date = DateTime.Parse(Value.ToString());
+ info.StartPosition = text.Length;
+ info.Content = date.ToString(info.Format, DateTimeFormatInfo);
+ info.Length = info.Content.Length;
+ text += info.Content;
+ }
+ });
+ }
+
+ private void PerformMouseSelection()
+ {
+ _dateTimeInfoList.ForEach(info =>
+ {
+ if ((info.StartPosition <= TextBox.SelectionStart) && (TextBox.SelectionStart < (info.StartPosition + info.Length)))
+ {
+ Select(info);
+ return;
+ }
+ });
+ }
+
+ private void Select(DateTimeInfo info)
+ {
+ _fireSelectionChangedEvent = false;
+ TextBox.Select(info.StartPosition, info.Length);
+ _fireSelectionChangedEvent = true;
+ _selectedDateTimeInfo = info;
+ }
+
+ private string GetFormatString(DateTimeFormat dateTimeFormat)
+ {
+ switch (dateTimeFormat)
+ {
+ case DateTimeFormat.ShortDate:
+ return DateTimeFormatInfo.ShortDatePattern;
+ case DateTimeFormat.LongDate:
+ return DateTimeFormatInfo.LongDatePattern;
+ case DateTimeFormat.ShortTime:
+ return DateTimeFormatInfo.ShortTimePattern;
+ case DateTimeFormat.LongTime:
+ return DateTimeFormatInfo.LongTimePattern;
+ case DateTimeFormat.FullDateTime:
+ return DateTimeFormatInfo.FullDateTimePattern;
+ case DateTimeFormat.MonthDay:
+ return DateTimeFormatInfo.MonthDayPattern;
+ case DateTimeFormat.RFC1123:
+ return DateTimeFormatInfo.RFC1123Pattern;
+ case DateTimeFormat.SortableDateTime:
+ return DateTimeFormatInfo.SortableDateTimePattern;
+ case DateTimeFormat.UniversalSortableDateTime:
+ return DateTimeFormatInfo.UniversalSortableDateTimePattern;
+ case DateTimeFormat.YearMonth:
+ return DateTimeFormatInfo.YearMonthPattern;
+ case DateTimeFormat.Custom:
+ return FormatString;
+ default:
+ throw new ArgumentException("Not a supported format");
+ }
+ }
+
+ private void UpdateDateTime(int value)
+ {
+ _fireSelectionChangedEvent = false;
+ DateTimeInfo info = _selectedDateTimeInfo;
+
+ //this only occurs when the user manually type in a value for the Value Property
+ if (info == null)
+ info = _dateTimeInfoList[0];
+
+ switch (info.Type)
+ {
+ case DateTimePart.Year:
+ {
+ Value = ((DateTime)Value).AddYears(value);
+ break;
+ }
+ case DateTimePart.Month:
+ case DateTimePart.MonthName:
+ {
+ Value = ((DateTime)Value).AddMonths(value);
+ break;
+ }
+ case DateTimePart.Day:
+ case DateTimePart.DayName:
+ {
+ Value = ((DateTime)Value).AddDays(value);
+ break;
+ }
+ case DateTimePart.Hour12:
+ case DateTimePart.Hour24:
+ {
+ Value = ((DateTime)Value).AddHours(value);
+ break;
+ }
+ case DateTimePart.Minute:
+ {
+ Value = ((DateTime)Value).AddMinutes(value);
+ break;
+ }
+ case DateTimePart.Second:
+ {
+ Value = ((DateTime)Value).AddSeconds(value);
+ break;
+ }
+ case DateTimePart.Millisecond:
+ {
+ Value = ((DateTime)Value).AddMilliseconds(value);
+ break;
+ }
+ case DateTimePart.AmPmDesignator:
+ {
+ Value = ((DateTime)Value).AddHours(value * 12);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ //we loose our selection when the Value is set so we need to reselect it without firing the selection changed event
+ TextBox.Select(info.StartPosition, info.Length);
+ _fireSelectionChangedEvent = true;
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Themes/Generic.xaml
new file mode 100644
index 00000000..264bd815
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/DateTimeUpDown/Themes/Generic.xaml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/BorderThicknessToStrokeThicknessConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/BorderThicknessToStrokeThicknessConverter.cs
new file mode 100644
index 00000000..1f672cda
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/BorderThicknessToStrokeThicknessConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Windows.Data;
+using System.Windows;
+
+namespace Microsoft.Windows.Controls.Mag.Converters
+{
+ internal class BorderThicknessToStrokeThicknessConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ Thickness thickness = (Thickness)value;
+ return (thickness.Bottom + thickness.Left + thickness.Right + thickness.Top) / 4;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/RadiusConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/RadiusConverter.cs
new file mode 100644
index 00000000..532a3552
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Converters/RadiusConverter.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Windows.Data;
+
+namespace Microsoft.Windows.Controls.Mag.Converters
+{
+ internal class RadiusConverter : IValueConverter
+ {
+ #region IValueConverter Members
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ return (double)value * 2;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Magnifier.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Magnifier.cs
new file mode 100644
index 00000000..2ea13e1b
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/Magnifier.cs
@@ -0,0 +1,166 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Microsoft.Windows.Controls
+{
+ public class Magnifier : Control
+ {
+ #region Properties
+
+ #region DefaultSize
+
+ internal Size DefaultSize
+ {
+ get
+ {
+ return new Size(2 * Radius, 2 * Radius);
+ }
+ }
+
+ #endregion //DefaultSize
+
+ #region MagnifierWidth
+
+ public static readonly DependencyProperty MagnifierWidthProperty = DependencyProperty.Register("MagnifierWidth", typeof(double), typeof(Magnifier), new UIPropertyMetadata(50.0));
+ internal double MagnifierWidth
+ {
+ get { return (double)GetValue(MagnifierWidthProperty); }
+ set { SetValue(MagnifierWidthProperty, value); }
+ }
+
+ #endregion //MagnifierWidth
+
+ #region MagnifierHeight
+
+ public static readonly DependencyProperty MagnifierHeightProperty = DependencyProperty.Register("MagnifierHeight", typeof(double), typeof(Magnifier), new UIPropertyMetadata(50.0));
+ internal double MagnifierHeight
+ {
+ get { return (double)GetValue(MagnifierHeightProperty); }
+ set { SetValue(MagnifierHeightProperty, value); }
+ }
+
+ #endregion //MagnifierWidth
+
+ #region Radius
+
+ public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(Magnifier), new FrameworkPropertyMetadata(50.0, new PropertyChangedCallback(OnRadiusPropertyChanged)));
+ public double Radius
+ {
+ get { return (double)GetValue(RadiusProperty); }
+ set { SetValue(RadiusProperty, value); }
+ }
+
+ private static void OnRadiusPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Magnifier m = (Magnifier)d;
+ m.OnRadiusChanged(e);
+ }
+
+ protected virtual void OnRadiusChanged(DependencyPropertyChangedEventArgs e)
+ {
+ ResolveViewBox();
+ }
+
+ #endregion //Radius
+
+ #region Target
+
+ public static readonly DependencyProperty TargetProperty = DependencyProperty.Register("Target", typeof(UIElement), typeof(Magnifier));
+ public UIElement Target
+ {
+ get { return (UIElement)GetValue(TargetProperty); }
+ set { SetValue(TargetProperty, value); }
+ }
+
+ #endregion //Target
+
+ #region ViewBox
+
+ public static readonly DependencyProperty ViewBoxProperty = DependencyProperty.Register("ViewBox", typeof(Rect), typeof(Magnifier), new FrameworkPropertyMetadata(default(Rect)));
+ internal Rect ViewBox
+ {
+ get { return (Rect)GetValue(ViewBoxProperty); }
+ set { SetValue(ViewBoxProperty, value); }
+ }
+
+ #endregion //ViewBox
+
+ #region ZoomFactor
+
+ public static readonly DependencyProperty ZoomFactorProperty = DependencyProperty.Register("ZoomFactor", typeof(double), typeof(Magnifier), new FrameworkPropertyMetadata(0.5, OnZoomFactorPropertyChanged, OnCoerceZoomFactorProperty));
+ public double ZoomFactor
+ {
+ get { return (double)GetValue(ZoomFactorProperty); }
+ set { SetValue(ZoomFactorProperty, value); }
+ }
+
+ private static void OnZoomFactorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Magnifier m = (Magnifier)d;
+ m.OnZoomFactorChanged(e);
+ }
+
+ protected virtual void OnZoomFactorChanged(DependencyPropertyChangedEventArgs e)
+ {
+ ResolveViewBox();
+ }
+
+ private static object OnCoerceZoomFactorProperty(DependencyObject d, object value)
+ {
+ Magnifier m = (Magnifier)d;
+ return m.OnCoerceZoomFactor(value);
+ }
+
+ protected virtual object OnCoerceZoomFactor(object value)
+ {
+ double zoomFactor = (double)value;
+
+ if (zoomFactor > 1)
+ zoomFactor = 1;
+ else if (zoomFactor < 0)
+ zoomFactor = 0;
+
+ return zoomFactor;
+ }
+
+ #endregion //ZoomFactor
+
+ #endregion //Properties
+
+ #region Constructors
+
+ ///
+ /// Initializes static members of the class.
+ ///
+ static Magnifier()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(Magnifier), new FrameworkPropertyMetadata(typeof(Magnifier)));
+ }
+
+ public Magnifier()
+ {
+ ResolveViewBox();
+ }
+
+ #endregion
+
+ #region Methods
+
+ private void ResolveViewBox()
+ {
+ double correction = (BorderThickness.Bottom + BorderThickness.Left + BorderThickness.Right + BorderThickness.Top == 0) ? 1 : 0;
+
+ double width = DefaultSize.Width * ZoomFactor;
+ double height = DefaultSize.Height * ZoomFactor;
+
+ MagnifierWidth = DefaultSize.Width - correction;
+ MagnifierHeight = DefaultSize.Height - correction;
+
+ ViewBox = new Rect(ViewBox.Location, new Size(width, height));
+ }
+
+ #endregion //Methods
+
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierAdorner.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierAdorner.cs
new file mode 100644
index 00000000..2b31e80f
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierAdorner.cs
@@ -0,0 +1,96 @@
+using System;
+using System.Windows.Documents;
+using System.Windows;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Microsoft.Windows.Controls
+{
+ public class MagnifierAdorner : Adorner
+ {
+ #region Members
+
+ private Magnifier _magnifier;
+ private Point _currentMousePosition;
+
+ #endregion
+
+ #region Constructors
+
+ public MagnifierAdorner(UIElement element, Magnifier magnifier)
+ : base(element)
+ {
+ InputManager.Current.PostProcessInput += Current_PostProcessInput;
+ _magnifier = magnifier;
+ UpdateViewBox();
+ AddVisualChild(_magnifier);
+ }
+
+ #endregion
+
+ #region Private/Internal methods
+
+ private void Current_PostProcessInput(object sender, ProcessInputEventArgs e)
+ {
+ Point pt = Mouse.GetPosition(this);
+
+ if (_currentMousePosition == pt)
+ return;
+
+ _currentMousePosition = pt;
+ UpdateViewBox();
+ InvalidateArrange();
+ }
+
+ internal void UpdateViewBox()
+ {
+ var viewBoxLocation = CalculateViewBoxLocation();
+ _magnifier.ViewBox = new Rect(viewBoxLocation, _magnifier.ViewBox.Size);
+ }
+
+ private Point CalculateViewBoxLocation()
+ {
+ double offsetX = 0, offsetY = 0;
+
+ Point adorner = Mouse.GetPosition(this);
+ Point element = Mouse.GetPosition(AdornedElement);
+
+ offsetX = element.X - adorner.X;
+ offsetY = element.Y - adorner.Y;
+
+ double left = _currentMousePosition.X - ((_magnifier.ViewBox.Width / 2) + offsetX);
+ double top = _currentMousePosition.Y - ((_magnifier.ViewBox.Height / 2) + offsetY);
+ return new Point(left, top);
+ }
+
+ #endregion
+
+ #region Overrides
+
+ protected override Visual GetVisualChild(int index)
+ {
+ return _magnifier;
+ }
+
+ protected override int VisualChildrenCount
+ {
+ get { return 1; }
+ }
+
+ protected override Size MeasureOverride(Size constraint)
+ {
+ _magnifier.Measure(constraint);
+ return base.MeasureOverride(constraint);
+ }
+
+ protected override Size ArrangeOverride(Size finalSize)
+ {
+ double x = _currentMousePosition.X - (_magnifier.DefaultSize.Width / 2);
+ double y = _currentMousePosition.Y - (_magnifier.DefaultSize.Height / 2);
+ _magnifier.Arrange(new Rect(x, y, _magnifier.DefaultSize.Width, _magnifier.DefaultSize.Height));
+ return base.ArrangeOverride(finalSize);
+ }
+
+ #endregion
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierManager.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierManager.cs
new file mode 100644
index 00000000..eaaa2c7e
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Implementation/MagnifierManager.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Windows;
+using System.Windows.Documents;
+using System.Windows.Input;
+
+namespace Microsoft.Windows.Controls
+{
+ public class MagnifierManager : DependencyObject
+ {
+ #region Members
+
+ private MagnifierAdorner _adorner;
+ private UIElement _element;
+
+ #endregion //Members
+
+ #region Properties
+
+ public static readonly DependencyProperty CurrentProperty = DependencyProperty.RegisterAttached("Magnifier", typeof(Magnifier), typeof(UIElement), new FrameworkPropertyMetadata(null, OnMagnifierChanged));
+ public static void SetMagnifier(UIElement element, Magnifier value)
+ {
+ element.SetValue(CurrentProperty, value);
+ }
+ public static Magnifier GetMagnifier(UIElement element)
+ {
+ return (Magnifier)element.GetValue(CurrentProperty);
+ }
+
+ private static void OnMagnifierChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ UIElement target = d as UIElement;
+
+ if (target == null)
+ throw new ArgumentException("Magnifier can only be attached to a UIElement.");
+
+ MagnifierManager manager = new MagnifierManager();
+ manager.AttachToMagnifier(target, e.NewValue as Magnifier);
+ }
+
+ #endregion //Properties
+
+ #region Event Handlers
+
+ void Element_MouseLeave(object sender, MouseEventArgs e)
+ {
+ HideAdorner();
+ }
+
+ void Element_MouseEnter(object sender, MouseEventArgs e)
+ {
+ ShowAdorner();
+ }
+
+ #endregion //Event Handlers
+
+ #region Methods
+
+ private void AttachToMagnifier(UIElement element, Magnifier magnifier)
+ {
+ _element = element;
+ _element.MouseEnter += Element_MouseEnter;
+ _element.MouseLeave += Element_MouseLeave;
+
+ magnifier.Target = _element;
+
+ _adorner = new MagnifierAdorner(_element, magnifier);
+ }
+
+ void ShowAdorner()
+ {
+ VerifyAdornerLayer();
+ _adorner.Visibility = Visibility.Visible;
+ }
+
+ bool VerifyAdornerLayer()
+ {
+ if (_adorner.Parent != null)
+ return true;
+
+ AdornerLayer layer = AdornerLayer.GetAdornerLayer(_element);
+ if (layer == null)
+ return false;
+
+ layer.Add(_adorner);
+ return true;
+ }
+
+ void HideAdorner()
+ {
+ if (_adorner.Visibility == Visibility.Visible)
+ {
+ _adorner.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ #endregion //Methods
+ }
+}
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Themes/Generic.xaml
new file mode 100644
index 00000000..bcbf1567
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Magnifier/Themes/Generic.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Implementation/MaskedTextBox.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Implementation/MaskedTextBox.cs
new file mode 100644
index 00000000..6dd0f035
--- /dev/null
+++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Implementation/MaskedTextBox.cs
@@ -0,0 +1,432 @@
+using System;
+using System.ComponentModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using Microsoft.Windows.Controls.Primitives;
+
+namespace Microsoft.Windows.Controls
+{
+ public class MaskedTextBox : InputBase
+ {
+ #region Members
+
+ ///
+ /// Flags if the Text and Value properties are in the process of being sync'd
+ ///
+ private bool _isSyncingTextAndValueProperties;
+ private bool _isInitialized;
+
+ #endregion //Members
+
+ #region Properties
+
+ protected MaskedTextProvider MaskProvider { get; set; }
+ private TextBox TextBox { get; set; }
+
+ #region IncludePrompt
+
+ public static readonly DependencyProperty IncludePromptProperty = DependencyProperty.Register("IncludePrompt", typeof(bool), typeof(MaskedTextBox), new UIPropertyMetadata(false, OnIncludePromptPropertyChanged));
+ public bool IncludePrompt
+ {
+ get { return (bool)GetValue(IncludePromptProperty); }
+ set { SetValue(IncludePromptProperty, value); }
+ }
+
+ private static void OnIncludePromptPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ MaskedTextBox maskedTextBox = o as MaskedTextBox;
+ if (maskedTextBox != null)
+ maskedTextBox.OnIncludePromptChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnIncludePromptChanged(bool oldValue, bool newValue)
+ {
+ ResolveMaskProvider(Mask);
+ }
+
+ #endregion //IncludePrompt
+
+ #region IncludeLiterals
+
+ public static readonly DependencyProperty IncludeLiteralsProperty = DependencyProperty.Register("IncludeLiterals", typeof(bool), typeof(MaskedTextBox), new UIPropertyMetadata(true, OnIncludeLiteralsPropertyChanged));
+ public bool IncludeLiterals
+ {
+ get { return (bool)GetValue(IncludeLiteralsProperty); }
+ set { SetValue(IncludeLiteralsProperty, value); }
+ }
+
+ private static void OnIncludeLiteralsPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ MaskedTextBox maskedTextBox = o as MaskedTextBox;
+ if (maskedTextBox != null)
+ maskedTextBox.OnIncludeLiteralsChanged((bool)e.OldValue, (bool)e.NewValue);
+ }
+
+ protected virtual void OnIncludeLiteralsChanged(bool oldValue, bool newValue)
+ {
+ ResolveMaskProvider(Mask);
+ }
+
+ #endregion //IncludeLiterals
+
+ #region Mask
+
+ public static readonly DependencyProperty MaskProperty = DependencyProperty.Register("Mask", typeof(string), typeof(MaskedTextBox), new UIPropertyMetadata(default(String), OnMaskPropertyChanged));
+ public string Mask
+ {
+ get { return (string)GetValue(MaskProperty); }
+ set { SetValue(MaskProperty, value); }
+ }
+
+ private static void OnMaskPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ MaskedTextBox maskedTextBox = o as MaskedTextBox;
+ if (maskedTextBox != null)
+ maskedTextBox.OnMaskChanged((string)e.OldValue, (string)e.NewValue);
+ }
+
+ protected virtual void OnMaskChanged(string oldValue, string newValue)
+ {
+ ResolveMaskProvider(newValue);
+ UpdateText(MaskProvider, 0);
+ }
+
+ #endregion //Mask
+
+ #region Value
+
+ public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(MaskedTextBox), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged));
+ public object Value
+ {
+ get { return (object)GetValue(ValueProperty); }
+ set { SetValue(ValueProperty, value); }
+ }
+
+ private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
+ {
+ MaskedTextBox maskedTextBox = o as MaskedTextBox;
+ if (maskedTextBox != null)
+ maskedTextBox.OnValueChanged((object)e.OldValue, (object)e.NewValue);
+ }
+
+ protected virtual void OnValueChanged(object oldValue, object newValue)
+ {
+ if (_isInitialized)
+ SyncTextAndValueProperties(DateTimeUpDown.ValueProperty, newValue);
+
+ RoutedPropertyChangedEventArgs