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/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 args = new RoutedPropertyChangedEventArgs(oldValue, newValue); + args.RoutedEvent = MaskedTextBox.ValueChangedEvent; + RaiseEvent(args); + } + + #endregion //Value + + #region ValueType + + public static readonly DependencyProperty ValueTypeProperty = DependencyProperty.Register("ValueType", typeof(Type), typeof(MaskedTextBox), new UIPropertyMetadata(typeof(String), OnValueTypeChanged)); + public Type ValueType + { + get { return (Type)GetValue(ValueTypeProperty); } + set { SetValue(ValueTypeProperty, value); } + } + + private static void OnValueTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + MaskedTextBox maskedTextBox = o as MaskedTextBox; + if (maskedTextBox != null) + maskedTextBox.OnValueTypeChanged((Type)e.OldValue, (Type)e.NewValue); + } + + protected virtual void OnValueTypeChanged(Type oldValue, Type newValue) + { + if (_isInitialized) + SyncTextAndValueProperties(InputBase.TextProperty, Text); + } + + #endregion //ValueType + + #endregion //Properties + + #region Constructors + + static MaskedTextBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(MaskedTextBox), new FrameworkPropertyMetadata(typeof(MaskedTextBox))); + } + + #endregion //Constructors + + #region Overrides + + public override void OnApplyTemplate() + { + TextBox = GetTemplateChild("TextBox") as TextBox; + TextBox.PreviewTextInput += TextBox_PreviewTextInput; + TextBox.PreviewKeyDown += TextBox_PreviewKeyDown; + + TextBox.CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, Paste)); //handle paste + TextBox.CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, null, CanCut)); //surpress cut + } + + protected override void OnAccessKey(AccessKeyEventArgs e) + { + if (TextBox != null) + TextBox.Focus(); + + base.OnAccessKey(e); + } + + protected override void OnGotFocus(RoutedEventArgs e) + { + if (TextBox != null) + TextBox.Focus(); + } + + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + if (!_isInitialized) + { + _isInitialized = true; + SyncTextAndValueProperties(ValueProperty, Value); + } + } + + protected override void OnTextChanged(string previousValue, string currentValue) + { + if (_isInitialized) + SyncTextAndValueProperties(InputBase.TextProperty, currentValue); + } + + #endregion + + #region Event Handlers + + void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e) + { + //if the text is readonly do not add the text + if (TextBox.IsReadOnly) + { + e.Handled = true; + return; + } + + int position = TextBox.SelectionStart; + MaskedTextProvider provider = MaskProvider; + if (position < TextBox.Text.Length) + { + position = GetNextCharacterPosition(position); + + if (Keyboard.IsKeyToggled(Key.Insert)) + { + if (provider.Replace(e.Text, position)) + position++; + } + else + { + if (provider.InsertAt(e.Text, position)) + position++; + } + + position = GetNextCharacterPosition(position); + } + + UpdateText(provider, position); + e.Handled = true; + + base.OnPreviewTextInput(e); + } + + void TextBox_PreviewKeyDown(object sender, KeyEventArgs e) + { + MaskedTextProvider provider = MaskProvider; + int position = TextBox.SelectionStart; + int selectionlength = TextBox.SelectionLength; + // If no selection use the start position else use end position + int endposition = (selectionlength == 0) ? position : position + selectionlength - 1; + + if (e.Key == Key.Delete && position < TextBox.Text.Length)//handle the delete key + { + if (provider.RemoveAt(position, endposition)) + UpdateText(provider, position); + + e.Handled = true; + } + else if (e.Key == Key.Space) + { + if (provider.InsertAt(" ", position)) + UpdateText(provider, position); + e.Handled = true; + } + else if (e.Key == Key.Back)//handle the back space + { + if ((position > 0) && (selectionlength == 0)) + { + position--; + if (provider.RemoveAt(position)) + UpdateText(provider, position); + } + + if (selectionlength != 0) + { + if (provider.RemoveAt(position, endposition)) + { + if (position > 0) + position--; + + UpdateText(provider, position); + } + } + + e.Handled = true; + } + + base.OnPreviewKeyDown(e); + } + + #endregion //Event Handlers + + #region Events + + public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(MaskedTextBox)); + public event RoutedPropertyChangedEventHandler ValueChanged + { + add { AddHandler(ValueChangedEvent, value); } + remove { RemoveHandler(ValueChangedEvent, value); } + } + + #endregion //Events + + #region Methods + + #region Private + + private void UpdateText(MaskedTextProvider provider, int position) + { + if (provider == null) + throw new ArgumentNullException("MaskedTextProvider", "Mask cannot be null."); + + Text = provider.ToDisplayString(); + + if (TextBox != null) + TextBox.SelectionStart = position; + } + + private int GetNextCharacterPosition(int startPosition) + { + int position = MaskProvider.FindEditPositionFrom(startPosition, true); + return position == -1 ? startPosition : position; + } + + private void ResolveMaskProvider(string mask) + { + //do not create a mask provider if the Mask is empty, which can occur if the IncludePrompt and IncludeLiterals properties + //are set prior to the Mask. + if (String.IsNullOrEmpty(mask)) + return; + + MaskProvider = new MaskedTextProvider(mask) + { + IncludePrompt = this.IncludePrompt, + IncludeLiterals = this.IncludeLiterals + }; + } + + #endregion //Private + + private object ConvertTextToValue(string text) + { + object convertedValue = null; + + Type dataType = ValueType; + + string valueToConvert = MaskProvider.ToString().Trim(); + + if (valueToConvert.GetType() == dataType || dataType.IsInstanceOfType(valueToConvert)) + { + convertedValue = valueToConvert; + } +#if !VS2008 + else if (String.IsNullOrWhiteSpace(valueToConvert)) + { + convertedValue = Activator.CreateInstance(dataType); + } +#else + else if (String.IsNullOrEmpty(valueToConvert)) + { + convertedValue = Activator.CreateInstance(dataType); + } +#endif + else if (null == convertedValue && valueToConvert is IConvertible) + { + convertedValue = Convert.ChangeType(valueToConvert, dataType); + } + + return convertedValue; + } + + private string ConvertValueToText(object value) + { + if (value == null) + value = string.Empty; + + //I have only seen this occur while in Blend, but we need it here so the Blend designer doesn't crash. + if (MaskProvider == null) + return value.ToString(); + + MaskProvider.Set(value.ToString()); + return MaskProvider.ToDisplayString(); + } + + protected void SyncTextAndValueProperties(DependencyProperty p, object newValue) + { + //prevents recursive syncing properties + if (_isSyncingTextAndValueProperties) + return; + + _isSyncingTextAndValueProperties = true; + + //this only occures when the user typed in the value + if (InputBase.TextProperty == p) + { + if (newValue != null) + SetValue(MaskedTextBox.ValueProperty, ConvertTextToValue(newValue.ToString())); + } + + SetValue(InputBase.TextProperty, ConvertValueToText(newValue)); + + _isSyncingTextAndValueProperties = false; + } + + #endregion //Methods + + #region Commands + + private void Paste(object sender, RoutedEventArgs e) + { + MaskedTextProvider provider = MaskProvider; + int position = TextBox.SelectionStart; + + object data = Clipboard.GetData(DataFormats.Text); + if (data != null) + { + string text = data.ToString().Trim(); + if (text.Length > 0) + { + provider.Set(text); + UpdateText(provider, position); + } + } + } + + private void CanCut(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = false; + e.Handled = true; + } + + #endregion //Commands + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml new file mode 100644 index 00000000..4b44a502 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png new file mode 100644 index 00000000..4304d43b Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png new file mode 100644 index 00000000..35075187 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png new file mode 100644 index 00000000..dad7dd09 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png new file mode 100644 index 00000000..ecb7fe86 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs new file mode 100644 index 00000000..8b9de3df --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/MessageBox.cs @@ -0,0 +1,517 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Controls.Primitives; + +namespace Microsoft.Windows.Controls +{ + [TemplateVisualState(Name = VisualStates.OK, GroupName = VisualStates.MessageBoxButtonsGroup)] + [TemplateVisualState(Name = VisualStates.OKCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] + [TemplateVisualState(Name = VisualStates.YesNo, GroupName = VisualStates.MessageBoxButtonsGroup)] + [TemplateVisualState(Name = VisualStates.YesNoCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] + public class MessageBox : Control + { + #region Private Members + + /// + /// Tracks the MessageBoxButon value passed into the InitializeContainer method + /// + private MessageBoxButton _button = MessageBoxButton.OK; + + /// + /// Tracks the MessageBoxResult to set as the default and focused button + /// + private MessageBoxResult _defaultResult = MessageBoxResult.None; + + /// + /// Tracks the owner of the MessageBox + /// + private Window _owner; + + #endregion //Private Members + + #region Constructors + + static MessageBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBox), new FrameworkPropertyMetadata(typeof(MessageBox))); + } + + internal MessageBox() + { /*user cannot create instance */ } + + #endregion //Constructors + + #region Properties + + #region Protected Properties + + /// + /// A System.Windows.MessageBoxResult value that specifies which message box button was clicked by the user. + /// + protected MessageBoxResult MessageBoxResult = MessageBoxResult.None; + + protected Window Container { get; private set; } + protected Thumb DragWidget { get; private set; } + + #endregion //Protected Properties + + #region Dependency Properties + + public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); + public string Caption + { + get { return (string)GetValue(CaptionProperty); } + set { SetValue(CaptionProperty, value); } + } + + public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(MessageBox), new UIPropertyMetadata(null)); + public Brush CaptionForeground + { + get { return (Brush)GetValue(CaptionForegroundProperty); } + set { SetValue(CaptionForegroundProperty, value); } + } + + public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(MessageBox), new PropertyMetadata(null)); + public Style CloseButtonStyle + { + get { return (Style)GetValue(CloseButtonStyleProperty); } + set { SetValue(CloseButtonStyleProperty, value); } + } + + public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MessageBox), new UIPropertyMetadata(default(ImageSource))); + public ImageSource ImageSource + { + get { return (ImageSource)GetValue(ImageSourceProperty); } + set { SetValue(ImageSourceProperty, value); } + } + + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); + public Brush WindowBackground + { + get { return (Brush)GetValue(WindowBackgroundProperty); } + set { SetValue(WindowBackgroundProperty, value); } + } + + public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); + public Brush WindowBorderBrush + { + get { return (Brush)GetValue(WindowBorderBrushProperty); } + set { SetValue(WindowBorderBrushProperty, value); } + } + + public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(MessageBox), new PropertyMetadata(null)); + public double WindowOpacity + { + get { return (double)GetValue(WindowOpacityProperty); } + set { SetValue(WindowOpacityProperty, value); } + } + + #endregion //Dependency Properties + + #endregion //Properties + + #region Base Class Overrides + + /// + /// Overrides the OnApplyTemplate method. + /// + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + DragWidget = GetTemplateChild("PART_DragWidget") as Thumb; + if (DragWidget != null) + DragWidget.DragDelta += (o, e) => ProcessMove(e); + + AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Button_Click)); + + ChangeVisualState(_button.ToString(), true); + + SetDefaultResult(); + } + + #endregion //Base Class Overrides + + #region Methods + + #region Public Static + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText) + { + return Show(messageText, string.Empty, MessageBoxButton.OK); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.Windows.Window that represents the owner of the MessageBox + /// A System.String that specifies the text to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(Window owner, string messageText) + { + return Show(owner, messageText, string.Empty, MessageBoxButton.OK); + } + + /// + /// Displays a message box that has a message and title bar caption; and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption) + { + return Show(messageText, caption, MessageBoxButton.OK); + } + + + public static MessageBoxResult Show(Window owner, string messageText, string caption) + { + return Show(owner, messageText, caption, MessageBoxButton.OK); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxButton value that specifies which button or buttons to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button) + { + return ShowCore(null, messageText, caption, button, MessageBoxImage.None, MessageBoxResult.None); + } + + + public static MessageBoxResult Show(Window owner, string messageText, string caption, MessageBoxButton button) + { + return ShowCore(owner, messageText, caption, button, MessageBoxImage.None, MessageBoxResult.None); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxButton value that specifies which button or buttons to display. + /// A System.Windows.MessageBoxImage value that specifies the icon to display. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) + { + return ShowCore(null, messageText, caption, button, icon, MessageBoxResult.None); + } + + + public static MessageBoxResult Show(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) + { + return ShowCore(owner, messageText, caption, button, icon, MessageBoxResult.None); + } + + /// + /// Displays a message box that has a message and that returns a result. + /// + /// A System.String that specifies the text to display. + /// A System.String that specifies the title bar caption to display. + /// A System.Windows.MessageBoxButton value that specifies which button or buttons to display. + /// A System.Windows.MessageBoxImage value that specifies the icon to display. + /// A System.Windows.MessageBoxResult value that specifies the default result of the MessageBox. + /// A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user. + public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) + { + return ShowCore(null, messageText, caption, button, icon, defaultResult); + } + + + public static MessageBoxResult Show(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) + { + return ShowCore(owner, messageText, caption, button, icon, defaultResult); + } + + #endregion //Public Static + + #region Protected + + /// + /// Shows the container which contains the MessageBox. + /// + protected void Show() + { + Container.ShowDialog(); + } + + /// + /// Initializes the MessageBox. + /// + /// The text. + /// The caption. + /// The button. + /// The image. + protected void InitializeMessageBox(Window owner, string text, string caption, MessageBoxButton button, MessageBoxImage image, MessageBoxResult defaultResult) + { + Text = text; + Caption = caption; + _button = button; + _defaultResult = defaultResult; + _owner = owner; + SetImageSource(image); + Container = CreateContainer(); + } + + /// + /// Changes the control's visual state(s). + /// + /// name of the state + /// True if state transitions should be used. + protected void ChangeVisualState(string name, bool useTransitions) + { + VisualStateManager.GoToState(this, name, useTransitions); + } + + #endregion //Protected + + #region Private + + /// + /// Sets the button that represents the _defaultResult to the default button and gives it focus. + /// + private void SetDefaultResult() + { + var defaultButton = GetDefaultButtonFromDefaultResult(); + if (defaultButton != null) + { + defaultButton.IsDefault = true; + defaultButton.Focus(); + } + } + + /// + /// Gets the default button from the _defaultResult. + /// + /// The default button that represents the defaultResult + private Button GetDefaultButtonFromDefaultResult() + { + Button defaultButton = null; + switch (_defaultResult) + { + case MessageBoxResult.Cancel: + defaultButton = GetMessageBoxButton("PART_CancelButton"); + break; + case MessageBoxResult.No: + defaultButton = GetMessageBoxButton("PART_NoButton"); + break; + case MessageBoxResult.OK: + defaultButton = GetMessageBoxButton("PART_OkButton"); + break; + case MessageBoxResult.Yes: + defaultButton = GetMessageBoxButton("PART_YesButton"); + break; + case MessageBoxResult.None: + defaultButton = GetDefaultButton(); + break; + } + return defaultButton; + } + + /// + /// Gets the default button. + /// + /// Used when the _defaultResult is set to None + /// The button to use as the default + private Button GetDefaultButton() + { + Button defaultButton = null; + switch (_button) + { + case MessageBoxButton.OK: + case MessageBoxButton.OKCancel: + defaultButton = GetMessageBoxButton("PART_OkButton"); + break; + case MessageBoxButton.YesNo: + case MessageBoxButton.YesNoCancel: + defaultButton = GetMessageBoxButton("PART_YesButton"); + break; + } + return defaultButton; + } + + /// + /// Gets a message box button. + /// + /// The name of the button to get. + /// The button + private Button GetMessageBoxButton(string name) + { + Button button = GetTemplateChild(name) as Button; + return button; + } + + /// + /// Shows the MessageBox. + /// + /// The message text. + /// The caption. + /// The button. + /// The icon. + /// The default result. + /// + private static MessageBoxResult ShowCore(Window owner, string messageText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) + { + MessageBox msgBox = new MessageBox(); + msgBox.InitializeMessageBox(owner, messageText, caption, button, icon, defaultResult); + msgBox.Show(); + return msgBox.MessageBoxResult; + } + + /// + /// Resolves the owner Window of the MessageBox. + /// + /// the owner Window + private static Window ResolveOwnerWindow() + { + Window owner = null; + if (Application.Current != null) + { + foreach (Window w in Application.Current.Windows) + { + if (w.IsActive) + { + owner = w; + break; + } + } + } + return owner; + } + + /// + /// Sets the message image source. + /// + /// The image to show. + private void SetImageSource(MessageBoxImage image) + { + String iconName = String.Empty; + + switch (image) + { + case MessageBoxImage.Error: + { + iconName = "Error48.png"; + break; + } + case MessageBoxImage.Information: + { + iconName = "Information48.png"; + break; + } + case MessageBoxImage.Question: + { + iconName = "Question48.png"; + break; + } + case MessageBoxImage.Warning: + { + iconName = "Warning48.png"; + break; + } + case MessageBoxImage.None: + default: + { + return; + } + } + + ImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(String.Format("pack://application:,,,/WPFToolkit.Extended;component/MessageBox/Icons/{0}", iconName)); + } + + /// + /// Creates the container which will host the MessageBox control. + /// + /// + private Window CreateContainer() + { + var newWindow = new Window(); + newWindow.AllowsTransparency = true; + newWindow.Background = Brushes.Transparent; + newWindow.Content = this; + newWindow.Owner = _owner ?? ResolveOwnerWindow(); + + if (newWindow.Owner != null) + newWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; + else + newWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; + + newWindow.ShowInTaskbar = false; + newWindow.SizeToContent = System.Windows.SizeToContent.WidthAndHeight; + newWindow.ResizeMode = System.Windows.ResizeMode.NoResize; + newWindow.WindowStyle = System.Windows.WindowStyle.None; + return newWindow; + } + + #endregion //Private + + #endregion //Methods + + #region Event Handlers + + /// + /// Processes the move of a drag operation on the header. + /// + /// The instance containing the event data. + private void ProcessMove(DragDeltaEventArgs e) + { + Container.Left = Container.Left + e.HorizontalChange; + Container.Top = Container.Top + e.VerticalChange; + } + + /// + /// Sets the MessageBoxResult according to the button pressed and then closes the MessageBox. + /// + /// The source of the event. + /// The instance containing the event data. + private void Button_Click(object sender, RoutedEventArgs e) + { + Button button = e.OriginalSource as Button; + switch (button.Name) + { + case "PART_NoButton": + MessageBoxResult = MessageBoxResult.No; + break; + case "PART_YesButton": + MessageBoxResult = MessageBoxResult.Yes; + break; + case "PART_CloseButton": + case "PART_CancelButton": + MessageBoxResult = MessageBoxResult.Cancel; + break; + case "PART_OkButton": + MessageBoxResult = MessageBoxResult.OK; + break; + } + + Close(); + } + + /// + /// Closes the MessageBox. + /// + private void Close() + { + Container.Close(); + } + + #endregion //Event Handlers + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/VisualStates.MessageBox.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/VisualStates.MessageBox.cs new file mode 100644 index 00000000..d47fcb08 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Implementation/VisualStates.MessageBox.cs @@ -0,0 +1,17 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + internal static partial class VisualStates + { + public const string MessageBoxButtonsGroup = "MessageBoxButtonsGroup"; + + public const string OK = "OK"; + + public const string OKCancel = "OKCancel"; + + public const string YesNo = "YesNo"; + + public const string YesNoCancel = "YesNoCancel"; + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml new file mode 100644 index 00000000..efbd5084 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs new file mode 100644 index 00000000..13c4aa9b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DecimalUpDown.cs @@ -0,0 +1,79 @@ +using System; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + public class DecimalUpDown : NumericUpDown + { + #region Constructors + + static DecimalUpDown() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(typeof(DecimalUpDown))); + DefaultValueProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(default(decimal))); + IncrementProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(1m)); + MaximumProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(decimal.MaxValue)); + MinimumProperty.OverrideMetadata(typeof(DecimalUpDown), new FrameworkPropertyMetadata(decimal.MinValue)); + } + + #endregion //Constructors + + #region Base Class Overrides + + protected override decimal? OnCoerceValue(decimal? value) + { + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + + protected override void OnIncrement() + { + if (Value.HasValue) + Value += Increment; + else + Value = DefaultValue; + } + + protected override void OnDecrement() + { + if (Value.HasValue) + Value -= Increment; + else + Value = DefaultValue; + } + + protected override decimal? ConvertTextToValue(string text) + { + decimal? result = null; + + if (String.IsNullOrEmpty(text)) + return result; + + try + { + result = FormatString.Contains("P") ? ParsePercent(text, CultureInfo) : ParseDecimal(text, CultureInfo); + } + catch + { + Text = ConvertValueToText(); + return Value; + } + + return result; + } + + protected override string ConvertValueToText() + { + if (Value == null) + return string.Empty; + + return Value.Value.ToString(FormatString, CultureInfo); + } + + #endregion //Base Class Overrides + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs new file mode 100644 index 00000000..acf85de9 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/DoubleUpDown.cs @@ -0,0 +1,79 @@ +using System; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + public class DoubleUpDown : NumericUpDown + { + #region Constructors + + static DoubleUpDown() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(typeof(DoubleUpDown))); + DefaultValueProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(default(double))); + IncrementProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(1d)); + MaximumProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(double.MaxValue)); + MinimumProperty.OverrideMetadata(typeof(DoubleUpDown), new FrameworkPropertyMetadata(double.MinValue)); + } + + #endregion //Constructors + + #region Base Class Overrides + + protected override double? OnCoerceValue(double? value) + { + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + + protected override void OnIncrement() + { + if (Value.HasValue) + Value += Increment; + else + Value = DefaultValue; + } + + protected override void OnDecrement() + { + if (Value.HasValue) + Value -= Increment; + else + Value = DefaultValue; + } + + protected override double? ConvertTextToValue(string text) + { + double? result = null; + + if (String.IsNullOrEmpty(text)) + return result; + + try + { + result = FormatString.Contains("P") ? Decimal.ToDouble(ParsePercent(text, CultureInfo)) : ParseDouble(text, CultureInfo); + } + catch + { + Text = ConvertValueToText(); + return Value; + } + + return result; + } + + protected override string ConvertValueToText() + { + if (Value == null) + return string.Empty; + + return Value.Value.ToString(FormatString, CultureInfo); + } + + #endregion //Base Class Overrides + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs new file mode 100644 index 00000000..1362a52d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/IntegerUpDown.cs @@ -0,0 +1,80 @@ +using System; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + public class IntegerUpDown : NumericUpDown + { + #region Constructors + + static IntegerUpDown() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(typeof(IntegerUpDown))); + DefaultValueProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(0)); + IncrementProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(1)); + MaximumProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(int.MaxValue)); + MinimumProperty.OverrideMetadata(typeof(IntegerUpDown), new FrameworkPropertyMetadata(int.MinValue)); + } + + #endregion //Constructors + + #region Base Class Overrides + + protected override int? OnCoerceValue(int? value) + { + if (value < Minimum) + return Minimum; + else if (value > Maximum) + return Maximum; + else + return value; + } + + protected override void OnIncrement() + { + if (Value.HasValue) + Value += Increment; + else + Value = DefaultValue; + } + + protected override void OnDecrement() + { + if (Value.HasValue) + Value -= Increment; + else + Value = DefaultValue; + } + + protected override int? ConvertTextToValue(string text) + { + int? result = null; + + if (String.IsNullOrEmpty(text)) + return result; + + try + { + //don't know why someone would format an integer as %, but just in case they do. + result = FormatString.Contains("P") ? Decimal.ToInt32(ParsePercent(text, CultureInfo)) : ParseInt(text, CultureInfo); + } + catch + { + Text = ConvertValueToText(); + return Value; + } + + return result; + } + + protected override string ConvertValueToText() + { + if (Value == null) + return string.Empty; + + return Value.Value.ToString(FormatString, CultureInfo); + } + + #endregion //Base Class Overrides + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs new file mode 100644 index 00000000..96d0d0eb --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Implementation/NumericUpDown.cs @@ -0,0 +1,202 @@ +using System; +using System.Windows; +using System.Windows.Input; +using Microsoft.Windows.Controls.Primitives; +using System.Globalization; + +namespace Microsoft.Windows.Controls +{ + public abstract class NumericUpDown : UpDownBase + { + #region Properties + + #region DefaultValue + + public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("DefaultValue", typeof(T), typeof(NumericUpDown), new UIPropertyMetadata(default(T))); + public T DefaultValue + { + get { return (T)GetValue(DefaultValueProperty); } + set { SetValue(DefaultValueProperty, value); } + } + + #endregion //DefaultValue + + #region FormatString + + public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(NumericUpDown), new UIPropertyMetadata(String.Empty, OnFormatStringChanged)); + public string FormatString + { + get { return (string)GetValue(FormatStringProperty); } + set { SetValue(FormatStringProperty, value); } + } + + private static void OnFormatStringChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + NumericUpDown numericUpDown = o as NumericUpDown; + if (numericUpDown != null) + numericUpDown.OnFormatStringChanged((string)e.OldValue, (string)e.NewValue); + } + + protected virtual void OnFormatStringChanged(string oldValue, string newValue) + { + Text = ConvertValueToText(); + } + + #endregion //FormatString + + #region Increment + + public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(T), typeof(NumericUpDown), new PropertyMetadata(default(T))); + public T Increment + { + get { return (T)GetValue(IncrementProperty); } + set { SetValue(IncrementProperty, value); } + } + + #endregion + + #region Maximum + + public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(T), typeof(NumericUpDown), new UIPropertyMetadata(default(T), OnMaximumChanged)); + public T Maximum + { + get { return (T)GetValue(MaximumProperty); } + set { SetValue(MaximumProperty, value); } + } + + private static void OnMaximumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + NumericUpDown numericUpDown = o as NumericUpDown; + if (numericUpDown != null) + numericUpDown.OnMaximumChanged((T)e.OldValue, (T)e.NewValue); + } + + protected virtual void OnMaximumChanged(T oldValue, T newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Maximum + + #region Minimum + + public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(T), typeof(NumericUpDown), new UIPropertyMetadata(default(T), OnMinimumChanged)); + public T Minimum + { + get { return (T)GetValue(MinimumProperty); } + set { SetValue(MinimumProperty, value); } + } + + private static void OnMinimumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + NumericUpDown numericUpDown = o as NumericUpDown; + if (numericUpDown != null) + numericUpDown.OnMinimumChanged((T)e.OldValue, (T)e.NewValue); + } + + protected virtual void OnMinimumChanged(T oldValue, T newValue) + { + //SetValidSpinDirection(); + } + + #endregion //Minimum + + #region SelectAllOnGotFocus + + public static readonly DependencyProperty SelectAllOnGotFocusProperty = DependencyProperty.Register("SelectAllOnGotFocus", typeof(bool), typeof(NumericUpDown), new PropertyMetadata(false)); + public bool SelectAllOnGotFocus + { + get { return (bool)GetValue(SelectAllOnGotFocusProperty); } + set { SetValue(SelectAllOnGotFocusProperty, value); } + } + + #endregion //SelectAllOnGotFocus + + #endregion //Properties + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (SelectAllOnGotFocus) + { + //in order to select all the text we must handle both the keybord (tabbing) and mouse (clicking) events + TextBox.GotKeyboardFocus += OnTextBoxGotKeyBoardFocus; + TextBox.PreviewMouseLeftButtonDown += OnTextBoxPreviewMouseLeftButtonDown; + } + + //SetValidSpinDirection(); + } + + #endregion //Base Class Overrides + + #region Event Handlers + + private void OnTextBoxGotKeyBoardFocus(object sender, RoutedEventArgs e) + { + TextBox.SelectAll(); + } + + void OnTextBoxPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (!TextBox.IsKeyboardFocused) + { + e.Handled = true; + TextBox.Focus(); + } + } + + #endregion //Event Handlers + + #region Methods + + /// + /// Sets the valid spin direction based on current value, minimum and maximum. + /// + //private void SetValidSpinDirection() + //{ + // ValidSpinDirections validDirections = ValidSpinDirections.None; + + // if (Value < Maximum) + // validDirections = validDirections | ValidSpinDirections.Increase; + + // if (Value > Minimum) + // validDirections = validDirections | ValidSpinDirections.Decrease; + + // if (Spinner != null) + // Spinner.ValidSpinDirection = validDirections; + //} + + + protected static decimal ParseDecimal(string text, IFormatProvider cultureInfo) + { + return Decimal.Parse(text, NumberStyles.Any, cultureInfo); + } + + protected static double ParseDouble(string text, IFormatProvider cultureInfo) + { + return Double.Parse(text, NumberStyles.Any, cultureInfo); + } + + protected static int ParseInt(string text, IFormatProvider cultureInfo) + { + return Int32.Parse(text, NumberStyles.Any, cultureInfo); + } + + protected static decimal ParsePercent(string text, IFormatProvider cultureInfo) + { + NumberFormatInfo info = NumberFormatInfo.GetInstance(cultureInfo); + + text = text.Replace(info.PercentSymbol, null); + + decimal result = Decimal.Parse(text, NumberStyles.Any, info); + result = result / 100; + + return result; + } + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml new file mode 100644 index 00000000..7293f996 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..854114b6 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs @@ -0,0 +1,63 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Markup; + +// 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("Extended WPF Toolkit")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Extended WPF Toolkit")] +[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)] + +[assembly: CLSCompliant(true)] + +//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.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] + +[assembly: XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "extToolkit")] +[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "Microsoft.Windows.Controls")] +[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "Microsoft.Windows.Controls.PropertyGrid")] diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs new file mode 100644 index 00000000..eaf63633 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Windows.Controls.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.Controls.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.resx b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.resx new file mode 100644 index 00000000..ffecec85 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs new file mode 100644 index 00000000..4a0f1423 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Windows.Controls.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.settings b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.settings new file mode 100644 index 00000000..8f2fd95d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png new file mode 100644 index 00000000..0146e932 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png new file mode 100644 index 00000000..51510df8 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png new file mode 100644 index 00000000..0f523fbd Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png new file mode 100644 index 00000000..7dd3b491 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png new file mode 100644 index 00000000..ec521dd4 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png new file mode 100644 index 00000000..7275c981 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png new file mode 100644 index 00000000..b3138ba3 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png new file mode 100644 index 00000000..7a6005d6 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Commands/PropertyItemCommands.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Commands/PropertyItemCommands.cs new file mode 100644 index 00000000..f1db5ce6 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Commands/PropertyItemCommands.cs @@ -0,0 +1,17 @@ +using System; +using System.Windows.Input; + +namespace Microsoft.Windows.Controls.PropertyGrid.Commands +{ + public static class PropertyItemCommands + { + private static RoutedCommand _resetValueCommand = new RoutedCommand(); + public static RoutedCommand ResetValue + { + get + { + return _resetValueCommand; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Converters/ValueSourceToImagePathConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Converters/ValueSourceToImagePathConverter.cs new file mode 100644 index 00000000..51aadbb7 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Converters/ValueSourceToImagePathConverter.cs @@ -0,0 +1,48 @@ +using System; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media.Imaging; + +namespace Microsoft.Windows.Controls.PropertyGrid.Converters +{ + public class ValueSourceToImagePathConverter : IValueConverter + { + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + BaseValueSource bvs = (BaseValueSource)value; + + string uriPrefix = "/WPFToolkit.Extended;component/PropertyGrid/Images/"; + string imageName = "AdvancedProperties11"; + + switch (bvs) + { + case BaseValueSource.Inherited: + case BaseValueSource.DefaultStyle: + case BaseValueSource.ImplicitStyleReference: + imageName = "Inheritance11"; + break; + case BaseValueSource.DefaultStyleTrigger: + break; + case BaseValueSource.Style: + imageName = "Style11"; + break; + + case BaseValueSource.Local: + imageName = "Local11"; + break; + } + + + return new BitmapImage(new Uri(String.Format("{0}{1}.png", uriPrefix, imageName), UriKind.RelativeOrAbsolute)); + } + + 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/PropertyGrid/Implementation/Converters/ValueSourceToToolTipConverter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Converters/ValueSourceToToolTipConverter.cs new file mode 100644 index 00000000..2b70c134 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Converters/ValueSourceToToolTipConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Windows; +using System.Windows.Data; + +namespace Microsoft.Windows.Controls.PropertyGrid.Converters +{ + class ValueSourceToToolTipConverter : IValueConverter + { + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + BaseValueSource bvs = (BaseValueSource)value; + string toolTip = "Advanced Properties"; + + switch (bvs) + { + case BaseValueSource.Inherited: + case BaseValueSource.DefaultStyle: + case BaseValueSource.ImplicitStyleReference: + toolTip = "Inheritance"; + break; + case BaseValueSource.Style: + toolTip = "Style Setter"; + break; + + case BaseValueSource.Local: + toolTip = "Local"; + break; + } + + return toolTip; + } + + 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/PropertyGrid/Implementation/CustomTypeEditorCollection.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/CustomTypeEditorCollection.cs new file mode 100644 index 00000000..585ba312 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/CustomTypeEditorCollection.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.ObjectModel; +using Microsoft.Windows.Controls.PropertyGrid.Editors; + +namespace Microsoft.Windows.Controls.PropertyGrid +{ + public class CustomTypeEditorCollection : ObservableCollection + { + public ICustomTypeEditor this[string propertyName] + { + get + { + foreach (var item in Items) + { + if (item.Properties.Contains(propertyName)) + return item; + } + + return null; + } + } + + public ICustomTypeEditor this[Type targetType] + { + get + { + foreach (var item in Items) + { + if (item.TargetType == targetType) + return item; + } + + return null; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs new file mode 100644 index 00000000..90e4ec02 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CheckBoxEditor.cs @@ -0,0 +1,18 @@ +using System.Windows; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class CheckBoxEditor : TypeEditor + { + protected override void SetControlProperties() + { + Editor.Margin = new Thickness(5, 0, 0, 0); + } + + protected override void SetValueDependencyProperty() + { + ValueProperty = CheckBox.IsCheckedProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ColorEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ColorEditor.cs new file mode 100644 index 00000000..a77ff2ce --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ColorEditor.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class ColorEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = ColorPicker.SelectedColorProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ComboBoxEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ComboBoxEditor.cs new file mode 100644 index 00000000..20b8537d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ComboBoxEditor.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public abstract class ComboBoxEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = ComboBox.SelectedItemProperty; + } + + public override void Attach(PropertyItem propertyItem) + { + SetItemsSource(propertyItem); + base.Attach(propertyItem); + } + + protected abstract IList CreateItemsSource(PropertyItem propertyItem); + + private void SetItemsSource(PropertyItem propertyItem) + { + Editor.ItemsSource = CreateItemsSource(propertyItem); + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CustomTypeEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CustomTypeEditor.cs new file mode 100644 index 00000000..36ac5730 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/CustomTypeEditor.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class CustomTypeEditor : ICustomTypeEditor + { + public ITypeEditor Editor { get; set; } + + private IList _properties = new List(); + public IList Properties + { + get { return _properties; } + set { _properties = value; } + } + + public Type TargetType { get; set; } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DateTimeUpDownEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DateTimeUpDownEditor.cs new file mode 100644 index 00000000..abe8ad77 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DateTimeUpDownEditor.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class DateTimeUpDownEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = DateTimeUpDown.ValueProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DecimalUpDownEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DecimalUpDownEditor.cs new file mode 100644 index 00000000..7e8e9e28 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DecimalUpDownEditor.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class DecimalUpDownEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = DecimalUpDown.ValueProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DoubleUpDownEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DoubleUpDownEditor.cs new file mode 100644 index 00000000..28551aea --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/DoubleUpDownEditor.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class DoubleUpDownEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = DoubleUpDown.ValueProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs new file mode 100644 index 00000000..fb5def1a --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/EnumComboBoxEditor.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class EnumComboBoxEditor : ComboBoxEditor + { + protected override IList CreateItemsSource(PropertyItem propertyItem) + { + return GetValues(propertyItem.PropertyType); + } + + private static object[] GetValues(Type enumType) + { + List values = new List(); + + var fields = enumType.GetFields().Where(x => x.IsLiteral); + foreach (FieldInfo field in fields) + { + values.Add(field.GetValue(enumType)); + } + + return values.ToArray(); + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/FontComboBoxEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/FontComboBoxEditor.cs new file mode 100644 index 00000000..987e45d6 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/FontComboBoxEditor.cs @@ -0,0 +1,75 @@ +using System.Linq; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Media; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class FontComboBoxEditor : ComboBoxEditor + { + protected override IList CreateItemsSource(PropertyItem propertyItem) + { + if (propertyItem.PropertyType == typeof(FontFamily)) + return GetFontFamilies(); + else if (propertyItem.PropertyType == typeof(FontWeight)) + return GetFontWeights(); + else if (propertyItem.PropertyType == typeof(FontStyle)) + return GetFontStyles(); + else if (propertyItem.PropertyType == typeof(FontStretch)) + return GetFontStretches(); + + return null; + } + + private static IList GetFontFamilies() + { +#if !VS2008 + return Fonts.SystemFontFamilies.ToList(); +#else + return Fonts.SystemFontFamilies.Cast().ToList(); +#endif + } + + private static IList GetFontWeights() + { + return new List() + { + FontWeights.Black, + FontWeights.Bold, + FontWeights.ExtraBlack, + FontWeights.ExtraBold, + FontWeights.ExtraLight, + FontWeights.Light, + FontWeights.Medium, + FontWeights.Normal, + FontWeights.SemiBold, + FontWeights.Thin + }; + } + + private static IList GetFontStyles() + { + return new List() + { + FontStyles.Italic, + FontStyles.Normal + }; + } + + private static IList GetFontStretches() + { + return new List() + { + FontStretches.Condensed, + FontStretches.Expanded, + FontStretches.ExtraCondensed, + FontStretches.ExtraExpanded, + FontStretches.Normal, + FontStretches.SemiCondensed, + FontStretches.SemiExpanded, + FontStretches.UltraCondensed, + FontStretches.UltraExpanded + }; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ICustomTypeEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ICustomTypeEditor.cs new file mode 100644 index 00000000..241d944c --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ICustomTypeEditor.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public interface ICustomTypeEditor + { + ITypeEditor Editor { get; set; } + IList Properties { get; set; } + Type TargetType { get; set; } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ITypeEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ITypeEditor.cs new file mode 100644 index 00000000..43cf6259 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/ITypeEditor.cs @@ -0,0 +1,10 @@ +using System.Windows; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public interface ITypeEditor + { + void Attach(PropertyItem propertyItem); + FrameworkElement ResolveEditor(); + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs new file mode 100644 index 00000000..fede0db8 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/IntegerUpDownEditor.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class IntegerUpDownEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = IntegerUpDown.ValueProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs new file mode 100644 index 00000000..67505e9e --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBlockEditor.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class TextBlockEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = TextBlock.TextProperty; + } + + protected override void SetControlProperties() + { + Editor.Margin = new System.Windows.Thickness(5, 0, 0, 0); + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBoxEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBoxEditor.cs new file mode 100644 index 00000000..5efae112 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TextBoxEditor.cs @@ -0,0 +1,13 @@ +using System; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public class TextBoxEditor : TypeEditor + { + protected override void SetValueDependencyProperty() + { + ValueProperty = TextBox.TextProperty; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TypeEditor.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TypeEditor.cs new file mode 100644 index 00000000..aa4e8eef --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/Editors/TypeEditor.cs @@ -0,0 +1,70 @@ +using System; +using System.Windows; +using System.Windows.Data; + +namespace Microsoft.Windows.Controls.PropertyGrid.Editors +{ + public abstract class TypeEditor : ITypeEditor + where T : FrameworkElement, new() + { + #region Properties + + protected T Editor { get; set; } + protected DependencyProperty ValueProperty { get; set; } + + #endregion //Properties + + #region Constructors + + public TypeEditor() + { + Editor = new T(); + SetValueDependencyProperty(); + SetControlProperties(); + } + + #endregion //Constructors + + #region ITypeEditor Members + + public virtual void Attach(PropertyItem propertyItem) + { + ResolveValueBinding(propertyItem); + } + + public virtual FrameworkElement ResolveEditor() + { + return Editor; + } + + #endregion //ITypeEditor Members + + #region Methods + + protected virtual IValueConverter CreateValueConverter() + { + return null; + } + + protected virtual void ResolveValueBinding(PropertyItem propertyItem) + { + var _binding = new Binding("Value"); + _binding.Source = propertyItem; + _binding.ValidatesOnExceptions = true; + _binding.ValidatesOnDataErrors = true; + _binding.Mode = propertyItem.IsWriteable ? BindingMode.TwoWay : BindingMode.OneWay; + _binding.Converter = CreateValueConverter(); + BindingOperations.SetBinding(Editor, ValueProperty, _binding); + } + + protected virtual void SetControlProperties() + { + //TODO: implement in derived class + } + + protected abstract void SetValueDependencyProperty(); + + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCategoryItem.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCategoryItem.cs new file mode 100644 index 00000000..27089598 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCategoryItem.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows; + +namespace Microsoft.Windows.Controls.PropertyGrid +{ + public class PropertyCategoryItem : Control + { + public static readonly DependencyProperty CategoryProperty = DependencyProperty.Register("Category", typeof(string), typeof(PropertyCategoryItem), new UIPropertyMetadata(String.Empty, new PropertyChangedCallback(OnCategoryChanged), new CoerceValueCallback(OnCoerceCategory))); + + private static object OnCoerceCategory(DependencyObject o, object value) + { + PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; + if (propertyCategoryItem != null) + return propertyCategoryItem.OnCoerceCategory((string)value); + else + return value; + } + + private static void OnCategoryChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyCategoryItem propertyCategoryItem = o as PropertyCategoryItem; + if (propertyCategoryItem != null) + propertyCategoryItem.OnCategoryChanged((string)e.OldValue, (string)e.NewValue); + } + + protected virtual string OnCoerceCategory(string value) + { + // TODO: Keep the proposed value within the desired range. + return value; + } + + protected virtual void OnCategoryChanged(string oldValue, string newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + public string Category + { + // IMPORTANT: To maintain parity between setting a property in XAML and procedural code, do not touch the getter and setter inside this dependency property! + get + { + return (string)GetValue(CategoryProperty); + } + set + { + SetValue(CategoryProperty, value); + } + } + + + private List _Properties = new List(); + public List Properties + { + get + { + return _Properties; + } + set + { + _Properties = value; + } + } + + + static PropertyCategoryItem() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyCategoryItem), new FrameworkPropertyMetadata(typeof(PropertyCategoryItem))); + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCollection.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCollection.cs new file mode 100644 index 00000000..95834089 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyCollection.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace Microsoft.Windows.Controls.PropertyGrid +{ + public class PropertyCollection : ObservableCollection + { + public PropertyCollection() + { + + } + public PropertyCollection(List list) + : base(list) + { + + } + public PropertyCollection(IEnumerable collection) + : base(collection) + { + + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs new file mode 100644 index 00000000..6ae1a563 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyGrid.cs @@ -0,0 +1,425 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Media; +using System.Windows.Controls.Primitives; +using System.ComponentModel; +using System.Windows.Input; +using Microsoft.Windows.Controls.PropertyGrid.Editors; + +namespace Microsoft.Windows.Controls.PropertyGrid +{ + public class PropertyGrid : Control + { + #region Members + + private Thumb _dragThumb; + private List _propertyItemsCache; + + #endregion //Members + + #region Properties + + #region CustomTypeEditors + + public static readonly DependencyProperty CustomTypeEditorsProperty = DependencyProperty.Register("CustomTypeEditors", typeof(CustomTypeEditorCollection), typeof(PropertyGrid), new UIPropertyMetadata(new CustomTypeEditorCollection())); + public CustomTypeEditorCollection CustomTypeEditors + { + get { return (CustomTypeEditorCollection)GetValue(CustomTypeEditorsProperty); } + set { SetValue(CustomTypeEditorsProperty, value); } + } + + #endregion //CustomTypeEditors + + #region IsCategorized + + public static readonly DependencyProperty IsCategorizedProperty = DependencyProperty.Register("IsCategorized", typeof(bool), typeof(PropertyGrid), new UIPropertyMetadata(true, OnIsCategorizedChanged)); + public bool IsCategorized + { + get { return (bool)GetValue(IsCategorizedProperty); } + set { SetValue(IsCategorizedProperty, value); } + } + + private static void OnIsCategorizedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyGrid = o as PropertyGrid; + if (propertyGrid != null) + propertyGrid.OnIsCategorizedChanged((bool)e.OldValue, (bool)e.NewValue); + } + + protected virtual void OnIsCategorizedChanged(bool oldValue, bool newValue) + { + InitializePropertyGrid(newValue); + } + + #endregion //IsCategorized + + #region NameColumnWidth + + public static readonly DependencyProperty NameColumnWidthProperty = DependencyProperty.Register("NameColumnWidth", typeof(double), typeof(PropertyGrid), new UIPropertyMetadata(150.0)); + public double NameColumnWidth + { + get { return (double)GetValue(NameColumnWidthProperty); } + set { SetValue(NameColumnWidthProperty, value); } + } + + #endregion //NameColumnWidth + + #region Properties + + public static readonly DependencyProperty PropertiesProperty = DependencyProperty.Register("Properties", typeof(PropertyCollection), typeof(PropertyGrid), new UIPropertyMetadata(null)); + public PropertyCollection Properties + { + get { return (PropertyCollection)GetValue(PropertiesProperty); } + private set { SetValue(PropertiesProperty, value); } + } + + #endregion //Properties + + #region SelectedObject + + public static readonly DependencyProperty SelectedObjectProperty = DependencyProperty.Register("SelectedObject", typeof(object), typeof(PropertyGrid), new UIPropertyMetadata(null, OnSelectedObjectChanged)); + public object SelectedObject + { + get { return (object)GetValue(SelectedObjectProperty); } + set { SetValue(SelectedObjectProperty, value); } + } + + private static void OnSelectedObjectChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyInspector = o as PropertyGrid; + if (propertyInspector != null) + propertyInspector.OnSelectedObjectChanged((object)e.OldValue, (object)e.NewValue); + } + + protected virtual void OnSelectedObjectChanged(object oldValue, object newValue) + { + SetSelectedObjectNameBinding(newValue); + + SelectedObjectType = newValue.GetType(); + + _propertyItemsCache = GetObjectProperties(newValue); + + InitializePropertyGrid(IsCategorized); + } + + #endregion //SelectedObject + + #region SelectedObjectType + + public static readonly DependencyProperty SelectedObjectTypeProperty = DependencyProperty.Register("SelectedObjectType", typeof(Type), typeof(PropertyGrid), new UIPropertyMetadata(null, OnSelectedObjectTypeChanged)); + public Type SelectedObjectType + { + get { return (Type)GetValue(SelectedObjectTypeProperty); } + private set { SetValue(SelectedObjectTypeProperty, value); } + } + + private static void OnSelectedObjectTypeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyGrid = o as PropertyGrid; + if (propertyGrid != null) + propertyGrid.OnSelectedObjectTypeChanged((Type)e.OldValue, (Type)e.NewValue); + } + + protected virtual void OnSelectedObjectTypeChanged(Type oldValue, Type newValue) + { + SelectedObjectTypeName = newValue.Name; + } + + #endregion //SelectedObjectType + + #region SelectedObjectTypeName + + public static readonly DependencyProperty SelectedObjectTypeNameProperty = DependencyProperty.Register("SelectedObjectTypeName", typeof(string), typeof(PropertyGrid), new UIPropertyMetadata(string.Empty)); + public string SelectedObjectTypeName + { + get { return (string)GetValue(SelectedObjectTypeNameProperty); } + private set { SetValue(SelectedObjectTypeNameProperty, value); } + } + + #endregion //SelectedObjectTypeName + + #region SelectedObjectName + + public static readonly DependencyProperty SelectedObjectNameProperty = DependencyProperty.Register("SelectedObjectName", typeof(string), typeof(PropertyGrid), new UIPropertyMetadata(string.Empty, OnSelectedObjectNameChanged, OnCoerceSelectedObjectName)); + public string SelectedObjectName + { + get { return (string)GetValue(SelectedObjectNameProperty); } + private set { SetValue(SelectedObjectNameProperty, value); } + } + + private static object OnCoerceSelectedObjectName(DependencyObject o, object baseValue) + { + if (String.IsNullOrEmpty((String)baseValue)) + return ""; + + return baseValue; + } + + private static void OnSelectedObjectNameChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyGrid = o as PropertyGrid; + if (propertyGrid != null) + propertyGrid.SelectedObjectNameChanged((string)e.OldValue, (string)e.NewValue); + } + + protected virtual void SelectedObjectNameChanged(string oldValue, string newValue) + { + + } + + #endregion //SelectedObjectName + + #region SelectedProperty + + public static readonly DependencyProperty SelectedPropertyProperty = DependencyProperty.Register("SelectedProperty", typeof(PropertyItem), typeof(PropertyGrid), new UIPropertyMetadata(null, OnSelectedPropertyChanged)); + public PropertyItem SelectedProperty + { + get { return (PropertyItem)GetValue(SelectedPropertyProperty); } + internal set { SetValue(SelectedPropertyProperty, value); } + } + + private static void OnSelectedPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyGrid propertyGrid = o as PropertyGrid; + if (propertyGrid != null) + propertyGrid.OnSelectedPropertyChanged((PropertyItem)e.OldValue, (PropertyItem)e.NewValue); + } + + protected virtual void OnSelectedPropertyChanged(PropertyItem oldValue, PropertyItem newValue) + { + if (oldValue != null) + oldValue.IsSelected = false; + + if (newValue != null) + newValue.IsSelected = true; + } + + #endregion //SelectedProperty + + #region DisplaySummary + + public static readonly DependencyProperty DisplaySummaryProperty = DependencyProperty.Register("DisplaySummary", typeof(bool), typeof(PropertyGrid), new UIPropertyMetadata(true)); + public bool DisplaySummary + { + get { return (bool)GetValue(DisplaySummaryProperty); } + set { SetValue(DisplaySummaryProperty, value); } + } + + #endregion //DisplaySummary + + #endregion //Properties + + #region Constructors + + static PropertyGrid() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGrid), new FrameworkPropertyMetadata(typeof(PropertyGrid))); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _dragThumb = (Thumb)GetTemplateChild("PART_DragThumb"); + _dragThumb.DragDelta += DragThumb_DragDelta; + } + + protected override void OnPreviewKeyDown(KeyEventArgs e) + { + //hitting enter on textbox will update value of underlying source + if (this.SelectedProperty != null && 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 DragThumb_DragDelta(object sender, DragDeltaEventArgs e) + { + NameColumnWidth = Math.Max(0, NameColumnWidth + e.HorizontalChange); + } + + #endregion //Event Handlers + + #region Methods + + private void InitializePropertyGrid(bool isCategorized) + { + LoadProperties(isCategorized); + SetDragThumbMargin(isCategorized); + } + + private void LoadProperties(bool isCategorized) + { + if (isCategorized) + Properties = GetCategorizedProperties(_propertyItemsCache); + else + Properties = GetAlphabetizedProperties(_propertyItemsCache); + } + + private List GetObjectProperties(object instance) + { + var propertyItems = new List(); + if (instance == null) + return propertyItems; + + var properties = TypeDescriptor.GetProperties(instance.GetType(), new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.All) }); + + try + { + + // Get all properties of the type + propertyItems.AddRange(properties.Cast(). + Where(p => p.IsBrowsable && p.Name != "GenericParameterAttributes"). + Select(property => CreatePropertyItem(property, instance, this))); + } + catch (Exception ex) + { + } + + return propertyItems; + } + + private PropertyItem CreatePropertyItem(PropertyDescriptor property, object instance, PropertyGrid grid) + { + PropertyItem propertyItem = new PropertyItem(instance, property, grid); + + var binding = new Binding(property.Name) + { + Source = instance, + ValidatesOnExceptions = true, + ValidatesOnDataErrors = true, + Mode = propertyItem.IsWriteable ? BindingMode.TwoWay : BindingMode.OneWay + }; + propertyItem.SetBinding(PropertyItem.ValueProperty, binding); + + ITypeEditor editor = null; + + //check for custom editor + if (CustomTypeEditors.Count > 0) + { + //first check if the custom editor is type based + ICustomTypeEditor customEditor = CustomTypeEditors[propertyItem.PropertyType]; + if (customEditor == null) + { + //must be property based + customEditor = CustomTypeEditors[propertyItem.Name]; + } + + if (customEditor != null) + editor = customEditor.Editor; + } + + try + { + //no custom editor found + if (editor == null) + { + if (propertyItem.IsReadOnly) + editor = new TextBlockEditor(); + else if (propertyItem.PropertyType == typeof(bool)) + editor = new CheckBoxEditor(); + else if (propertyItem.PropertyType == typeof(decimal) || propertyItem.PropertyType == typeof(decimal?)) + editor = new DecimalUpDownEditor(); + else if (propertyItem.PropertyType == typeof(double) || propertyItem.PropertyType == typeof(double?)) + editor = new DoubleUpDownEditor(); + else if (propertyItem.PropertyType == typeof(int) || propertyItem.PropertyType == typeof(int?)) + editor = new IntegerUpDownEditor(); + else if (propertyItem.PropertyType == typeof(DateTime)) + editor = new DateTimeUpDownEditor(); + else if (propertyItem.PropertyType.IsEnum) + editor = new EnumComboBoxEditor(); + else if (propertyItem.PropertyType == typeof(FontFamily) || propertyItem.PropertyType == typeof(FontWeight) || propertyItem.PropertyType == typeof(FontStyle) || propertyItem.PropertyType == typeof(FontStretch)) + editor = new FontComboBoxEditor(); + else + editor = new TextBoxEditor(); + } + } + catch (Exception ex) + { + + } + + editor.Attach(propertyItem); + propertyItem.Editor = editor.ResolveEditor(); + + return propertyItem; + } + + private static PropertyCollection GetCategorizedProperties(List propertyItems) + { + PropertyCollection propertyCollection = new PropertyCollection(); + + CollectionViewSource src = new CollectionViewSource { Source = propertyItems }; + src.GroupDescriptions.Add(new PropertyGroupDescription("Category")); + src.SortDescriptions.Add(new SortDescription("Category", ListSortDirection.Ascending)); + src.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); + + foreach (CollectionViewGroup item in src.View.Groups) + { + PropertyCategoryItem propertyCategoryItem = new PropertyCategoryItem { Category = item.Name.ToString() }; + foreach (var propertyitem in item.Items) + { + propertyCategoryItem.Properties.Add((PropertyItem)propertyitem); + } + propertyCollection.Add(propertyCategoryItem); + } + + return propertyCollection; + } + + private static PropertyCollection GetAlphabetizedProperties(List propertyItems) + { + PropertyCollection propertyCollection = new PropertyCollection(); + + if (propertyItems == null) + return propertyCollection; + + CollectionViewSource src = new CollectionViewSource { Source = propertyItems }; + src.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); + + foreach (var item in ((ListCollectionView)(src.View))) + { + propertyCollection.Add((PropertyItem)item); + } + + return propertyCollection; + } + + private void SetSelectedObjectNameBinding(object selectedObject) + { + if (selectedObject is FrameworkElement) + { + var binding = new Binding("Name"); + binding.Source = selectedObject; + binding.Mode = BindingMode.OneWay; + BindingOperations.SetBinding(this, PropertyGrid.SelectedObjectNameProperty, binding); + } + } + + private void SetDragThumbMargin(bool isCategorized) + { + if (_dragThumb == null) + return; + + if (isCategorized) + _dragThumb.Margin = new Thickness(6, 0, 0, 0); + else + _dragThumb.Margin = new Thickness(-1, 0, 0, 0); + } + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs new file mode 100644 index 00000000..fa3f2be7 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Implementation/PropertyItem.cs @@ -0,0 +1,258 @@ +using System; +using System.Linq; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Input; +using Microsoft.Windows.Controls.PropertyGrid.Commands; +using System.Windows.Markup.Primitives; + +namespace Microsoft.Windows.Controls.PropertyGrid +{ + public class PropertyItem : Control + { + #region Members + + private DependencyPropertyDescriptor _dpDescriptor; + private MarkupObject _markupObject; + + #endregion //Members + + #region Properties + + #region Category + + public static readonly DependencyProperty CategoryProperty = DependencyProperty.Register("Category", typeof(string), typeof(PropertyItem), new UIPropertyMetadata(string.Empty)); + public string Category + { + get { return (string)GetValue(CategoryProperty); } + set { SetValue(CategoryProperty, value); } + } + + #endregion //Category + + public string Description { get { return PropertyDescriptor.Description; } } + + #region Editor + + public static readonly DependencyProperty EditorProperty = DependencyProperty.Register("Editor", typeof(FrameworkElement), typeof(PropertyItem), new UIPropertyMetadata(null)); + public FrameworkElement Editor + { + get { return (FrameworkElement)GetValue(EditorProperty); } + set { SetValue(EditorProperty, value); } + } + + #endregion //Editor + + private object _instance; + public object Instance + { + get + { + return _instance; + } + private set + { + _instance = value; + _markupObject = MarkupWriter.GetMarkupObjectFor(_instance); + } + } + + /// + /// Gets if the property is data bound + /// + public bool IsDataBound + { + get + { + var dependencyObject = Instance as DependencyObject; + if (dependencyObject != null && _dpDescriptor != null) + return BindingOperations.GetBindingExpressionBase(dependencyObject, _dpDescriptor.DependencyProperty) != null; + + return false; + } + } + + public bool IsDynamicResource + { + get + { + var markupProperty = _markupObject.Properties.Where(p => p.Name == PropertyDescriptor.Name).FirstOrDefault(); + if (markupProperty != null) + return markupProperty.Value is DynamicResourceExtension; + return false; + } + } + + public bool HasResourceApplied + { + //TODO: need to find a better way to determine if a StaticResource has been applied to any property not just a style + get + { + var markupProperty = _markupObject.Properties.Where(p => p.Name == PropertyDescriptor.Name).FirstOrDefault(); + if (markupProperty != null) + return markupProperty.Value is Style; + + return false; + } + } + + public bool IsReadOnly { get { return PropertyDescriptor.IsReadOnly; } } + + #region IsSelected + + public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register("IsSelected", typeof(bool), typeof(PropertyItem), new UIPropertyMetadata(false, OnIsSelectedChanged)); + public bool IsSelected + { + get { return (bool)GetValue(IsSelectedProperty); } + set { SetValue(IsSelectedProperty, value); } + } + + private static void OnIsSelectedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyItem propertyItem = o as PropertyItem; + if (propertyItem != null) + propertyItem.OnIsSelectedChanged((bool)e.OldValue, (bool)e.NewValue); + } + + protected virtual void OnIsSelectedChanged(bool oldValue, bool newValue) + { + if (newValue) + PropertyGrid.SelectedProperty = this; + } + + #endregion //IsSelected + + public bool IsWriteable { get { return !IsReadOnly; } } + + private PropertyDescriptor _propertyDescriptor; + public PropertyDescriptor PropertyDescriptor + { + get + { + return _propertyDescriptor; + } + private set + { + _propertyDescriptor = value; + Name = _propertyDescriptor.Name; + Category = _propertyDescriptor.Category; + _dpDescriptor = DependencyPropertyDescriptor.FromProperty(_propertyDescriptor); + } + } + + public PropertyGrid PropertyGrid { get; private set; } + + public Type PropertyType { get { return PropertyDescriptor.PropertyType; } } + + public ICommand ResetValueCommand { get; private set; } + + #region Value + + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(PropertyItem), new UIPropertyMetadata(null, OnValueChanged)); + public object Value + { + get { return (object)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + + private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + PropertyItem propertyItem = o as PropertyItem; + if (propertyItem != null) + propertyItem.OnValueChanged((object)e.OldValue, (object)e.NewValue); + } + + protected virtual void OnValueChanged(object oldValue, object newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + #endregion //Value + + /// + /// Gets the value source. + /// + public BaseValueSource ValueSource + { + get + { + var dependencyObject = Instance as DependencyObject; + if (_dpDescriptor != null && dependencyObject != null) + return DependencyPropertyHelper.GetValueSource(dependencyObject, _dpDescriptor.DependencyProperty).BaseValueSource; + + return BaseValueSource.Unknown; + } + } + + #endregion //Properties + + #region Constructor + + static PropertyItem() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyItem), new FrameworkPropertyMetadata(typeof(PropertyItem))); + } + + public PropertyItem(object instance, PropertyDescriptor property, PropertyGrid propertyGrid) + { + + PropertyDescriptor = property; + PropertyGrid = propertyGrid; + Instance = instance; + + CommandBindings.Add(new CommandBinding(PropertyItemCommands.ResetValue, ExecuteResetValueCommand, CanExecuteResetValueCommand)); + + AddHandler(Mouse.MouseDownEvent, new MouseButtonEventHandler(PropertyItem_MouseDown), true); + AddHandler(Mouse.PreviewMouseDownEvent, new MouseButtonEventHandler(PropertyItem_PreviewMouseDown), true); + } + + #endregion //Constructor + + #region Event Handlers + + void PropertyItem_MouseDown(object sender, MouseButtonEventArgs e) + { + if (Editor != null) + Editor.Focus(); + + e.Handled = true; + } + + void PropertyItem_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + IsSelected = true; + + //if it is a comboBox then the selection will not take when Focus is called + if (!(e.Source is ComboBox)) + Focus(); + } + + #endregion //Event Handlers + + #region Commands + + private void ExecuteResetValueCommand(object sender, ExecutedRoutedEventArgs e) + { + if (PropertyDescriptor.CanResetValue(Instance)) + PropertyDescriptor.ResetValue(Instance); + + //TODO: notify UI that the ValueSource may have changed to update the icon + } + + private void CanExecuteResetValueCommand(object sender, CanExecuteRoutedEventArgs e) + { + bool canExecute = false; + + if (PropertyDescriptor.CanResetValue(Instance) && !PropertyDescriptor.IsReadOnly) + { + canExecute = true; + } + + e.CanExecute = canExecute; + } + + #endregion //Commands + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml new file mode 100644 index 00000000..f851614b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs new file mode 100644 index 00000000..f8e22d41 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/ITextFormatter.cs @@ -0,0 +1,11 @@ +using System; +using System.Windows.Documents; + +namespace Microsoft.Windows.Controls +{ + public interface ITextFormatter + { + string GetText(FlowDocument document); + void SetText(FlowDocument document, string text); + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs new file mode 100644 index 00000000..1c792a32 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/PlainTextFormatter.cs @@ -0,0 +1,21 @@ +using System; +using System.Windows.Documents; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as plain text + /// + public class PlainTextFormatter : ITextFormatter + { + public string GetText(FlowDocument document) + { + return new TextRange(document.ContentStart, document.ContentEnd).Text; + } + + public void SetText(FlowDocument document, string text) + { + new TextRange(document.ContentStart, document.ContentEnd).Text = text; + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs new file mode 100644 index 00000000..9b2b895c --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/RtfFormatter.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using System.Windows.Documents; +using System.IO; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as RTF + /// + public class RtfFormatter : ITextFormatter + { + public string GetText(FlowDocument document) + { + TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); + using (MemoryStream ms = new MemoryStream()) + { + tr.Save(ms, DataFormats.Rtf); + return ASCIIEncoding.Default.GetString(ms.ToArray()); + } + } + + public void SetText(FlowDocument document, string text) + { + try + { + //if the text is null/empty clear the contents of the RTB. If you were to pass a null/empty string + //to the TextRange.Load method an exception would occur. + if (String.IsNullOrEmpty(text)) + { + document.Blocks.Clear(); + } + else + { + TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); + using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) + { + tr.Load(ms, DataFormats.Rtf); + } + } + } + catch + { + throw new InvalidDataException("Data provided is not in the correct RTF format."); + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs new file mode 100644 index 00000000..250f391b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/Formatters/XamlFormatter.cs @@ -0,0 +1,49 @@ +using System; +using System.Text; +using System.IO; +using System.Windows.Documents; +using System.Windows; + +namespace Microsoft.Windows.Controls +{ + /// + /// Formats the RichTextBox text as Xaml + /// + public class XamlFormatter : ITextFormatter + { + public string GetText(System.Windows.Documents.FlowDocument document) + { + TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); + using (MemoryStream ms = new MemoryStream()) + { + tr.Save(ms, DataFormats.Xaml); + return ASCIIEncoding.Default.GetString(ms.ToArray()); + } + } + + public void SetText(System.Windows.Documents.FlowDocument document, string text) + { + try + { + //if the text is null/empty clear the contents of the RTB. If you were to pass a null/empty string + //to the TextRange.Load method an exception would occur. + if (String.IsNullOrEmpty(text)) + { + document.Blocks.Clear(); + } + else + { + TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); + using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) + { + tr.Load(ms, DataFormats.Xaml); + } + } + } + catch + { + throw new InvalidDataException("Data provided is not in the correct Xaml format."); + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs new file mode 100644 index 00000000..bb4f57a7 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs @@ -0,0 +1,129 @@ +using System; +using System.Windows; +using System.Windows.Data; + +namespace Microsoft.Windows.Controls +{ + public class RichTextBox : System.Windows.Controls.RichTextBox + { + #region Private Members + + private bool _textSetInternally; + + #endregion //Private Members + + #region Constructors + + public RichTextBox() + { + Loaded += RichTextBox_Loaded; + } + + public RichTextBox(System.Windows.Documents.FlowDocument document) + : base(document) + { + + } + + #endregion //Constructors + + #region Properties + + #region Text + + public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(RichTextBox), new FrameworkPropertyMetadata(String.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTextPropertyChanged, CoerceTextProperty, true, UpdateSourceTrigger.LostFocus)); + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + + private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RichTextBox rtb = (RichTextBox)d; + + // if the text is not being set internally then load the text into the RichTextBox + if (!rtb._textSetInternally) + rtb.TextFormatter.SetText(rtb.Document, (string)e.NewValue); + } + + private static object CoerceTextProperty(DependencyObject d, object value) + { + return value ?? ""; + } + + #endregion //Text + + #region TextFormatter + + private ITextFormatter _textFormatter; + /// + /// The ITextFormatter the is used to format the text of the RichTextBox. + /// Deafult formatter is the RtfFormatter + /// + public ITextFormatter TextFormatter + { + get + { + if (_textFormatter == null) + _textFormatter = new RtfFormatter(); //default is rtf + + return _textFormatter; + } + set + { + if (_textFormatter != value) + { + _textFormatter = value; + _textFormatter.SetText(Document, Text); + } + } + } + + #endregion //TextFormatter + + #endregion //Properties + + #region Methods + + private void UpdateText() + { + _textSetInternally = true; + + Text = TextFormatter.GetText(Document); + + _textSetInternally = false; + } + + /// + /// Clears the content of the RichTextBox. + /// + public void Clear() + { + Document.Blocks.Clear(); + } + + #endregion //Methods + + #region Event Hanlders + + private void RichTextBox_Loaded(object sender, RoutedEventArgs e) + { + Binding binding = BindingOperations.GetBinding(this, TextProperty); + + if (binding != null) + { + if (binding.UpdateSourceTrigger == UpdateSourceTrigger.Default || binding.UpdateSourceTrigger == UpdateSourceTrigger.LostFocus) + { + PreviewLostKeyboardFocus += (o, ea) => UpdateText(); + } + else + { + TextChanged += (o, ea) => UpdateText(); + } + } + } + + #endregion //Event Hanlders + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/IRichTextBoxFormatBar.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/IRichTextBoxFormatBar.cs new file mode 100644 index 00000000..46c38afe --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/IRichTextBoxFormatBar.cs @@ -0,0 +1,12 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + public interface IRichTextBoxFormatBar + { + /// + /// Represents the RichTextBox that will be the target for all text manipulations in the format bar. + /// + global::System.Windows.Controls.RichTextBox Target { get; set; } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png new file mode 100644 index 00000000..8fb36a1a Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png new file mode 100644 index 00000000..73e7c15e Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png new file mode 100644 index 00000000..1030a021 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png new file mode 100644 index 00000000..d9207308 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png new file mode 100644 index 00000000..8259a9e1 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png new file mode 100644 index 00000000..c5499bce Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png new file mode 100644 index 00000000..51dffb73 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png new file mode 100644 index 00000000..03f6fde2 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png new file mode 100644 index 00000000..cb8e400a Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png new file mode 100644 index 00000000..4a3783f2 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png new file mode 100644 index 00000000..72689482 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml new file mode 100644 index 00000000..ae4b1845 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml.cs new file mode 100644 index 00000000..98f39321 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBar.xaml.cs @@ -0,0 +1,232 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using System.Windows.Media; +using System.Windows.Controls.Primitives; +using Microsoft.Windows.Controls.Core; + +namespace Microsoft.Windows.Controls +{ + /// + /// Interaction logic for RichTextBoxFormatBar.xaml + /// + public partial class RichTextBoxFormatBar : UserControl, IRichTextBoxFormatBar + { + #region Properties + + #region RichTextBox + + public static readonly DependencyProperty TargetProperty = DependencyProperty.Register("Target", typeof(global::System.Windows.Controls.RichTextBox), typeof(RichTextBoxFormatBar), new PropertyMetadata(null, OnRichTextBoxPropertyChanged)); + public global::System.Windows.Controls.RichTextBox Target + { + get { return (global::System.Windows.Controls.RichTextBox)GetValue(TargetProperty); } + set { SetValue(TargetProperty, value); } + } + + private static void OnRichTextBoxPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + RichTextBoxFormatBar formatBar = d as RichTextBoxFormatBar; + } + + #endregion //RichTextBox + + public static double[] FontSizes + { + get + { + return new double[] { + 3.0, 4.0, 5.0, 6.0, 6.5, 7.0, 7.5, 8.0, 8.5, 9.0, 9.5, + 10.0, 10.5, 11.0, 11.5, 12.0, 12.5, 13.0, 13.5, 14.0, 15.0, + 16.0, 17.0, 18.0, 19.0, 20.0, 22.0, 24.0, 26.0, 28.0, 30.0, + 32.0, 34.0, 36.0, 38.0, 40.0, 44.0, 48.0, 52.0, 56.0, 60.0, 64.0, 68.0, 72.0, 76.0, + 80.0, 88.0, 96.0, 104.0, 112.0, 120.0, 128.0, 136.0, 144.0 + }; + } + } + + #endregion + + #region Constructors + + public RichTextBoxFormatBar() + { + InitializeComponent(); + Loaded += FormatToolbar_Loaded; + + _cmbFontFamilies.ItemsSource = Fonts.SystemFontFamilies; + _cmbFontSizes.ItemsSource = FontSizes; + } + + #endregion //Constructors + + #region Event Hanlders + + void FormatToolbar_Loaded(object sender, RoutedEventArgs e) + { + UpdateVisualState(); + } + + private void FontFamily_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count == 0) + return; + + FontFamily editValue = (FontFamily)e.AddedItems[0]; + ApplyPropertyValueToSelectedText(TextElement.FontFamilyProperty, editValue); + } + + private void FontSize_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count == 0) + return; + + ApplyPropertyValueToSelectedText(TextElement.FontSizeProperty, e.AddedItems[0]); + } + + void FontColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Color selectedColor = (Color)e.NewValue; + ApplyPropertyValueToSelectedText(TextElement.ForegroundProperty, new SolidColorBrush(selectedColor)); + } + + private void FontBackgroundColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs e) + { + Color selectedColor = (Color)e.NewValue; + ApplyPropertyValueToSelectedText(TextElement.BackgroundProperty, new SolidColorBrush(selectedColor)); + } + + private void Bullets_Clicked(object sender, RoutedEventArgs e) + { + if (BothSelectionListsAreChecked()) + { + _btnNumbers.IsChecked = false; + } + } + + private void Numbers_Clicked(object sender, RoutedEventArgs e) + { + if (BothSelectionListsAreChecked()) + { + _btnBullets.IsChecked = false; + } + } + + private void DragWidget_DragDelta(object sender, DragDeltaEventArgs e) + { + ProcessMove(e); + } + + #endregion //Event Hanlders + + #region Methods + + private void UpdateVisualState() + { + UpdateToggleButtonState(); + UpdateSelectedFontFamily(); + UpdateSelectedFontSize(); + UpdateFontColor(); + UpdateFontBackgroundColor(); + UpdateSelectionListType(); + } + + private void UpdateToggleButtonState() + { + UpdateItemCheckedState(_btnBold, TextElement.FontWeightProperty, FontWeights.Bold); + UpdateItemCheckedState(_btnItalic, TextElement.FontStyleProperty, FontStyles.Italic); + UpdateItemCheckedState(_btnUnderline, Inline.TextDecorationsProperty, TextDecorations.Underline); + + UpdateItemCheckedState(_btnAlignLeft, Paragraph.TextAlignmentProperty, TextAlignment.Left); + UpdateItemCheckedState(_btnAlignCenter, Paragraph.TextAlignmentProperty, TextAlignment.Center); + UpdateItemCheckedState(_btnAlignRight, Paragraph.TextAlignmentProperty, TextAlignment.Right); + } + + void UpdateItemCheckedState(ToggleButton button, DependencyProperty formattingProperty, object expectedValue) + { + object currentValue = Target.Selection.GetPropertyValue(formattingProperty); + button.IsChecked = (currentValue == DependencyProperty.UnsetValue) ? false : currentValue != null && currentValue.Equals(expectedValue); + } + + private void UpdateSelectedFontFamily() + { + object value = Target.Selection.GetPropertyValue(TextElement.FontFamilyProperty); + FontFamily currentFontFamily = (FontFamily)((value == DependencyProperty.UnsetValue) ? null : value); + if (currentFontFamily != null) + { + _cmbFontFamilies.SelectedItem = currentFontFamily; + } + } + + private void UpdateSelectedFontSize() + { + object value = Target.Selection.GetPropertyValue(TextElement.FontSizeProperty); + _cmbFontSizes.SelectedValue = (value == DependencyProperty.UnsetValue) ? null : value; + } + + private void UpdateFontColor() + { + object value = Target.Selection.GetPropertyValue(TextElement.ForegroundProperty); + Color currentColor = (Color)((value == DependencyProperty.UnsetValue) ? Colors.Black : ((SolidColorBrush)value).Color); + _cmbFontColor.SelectedColor = currentColor; + } + + private void UpdateFontBackgroundColor() + { + object value = Target.Selection.GetPropertyValue(TextElement.BackgroundProperty); + Color currentColor = (Color)((value == null || value == DependencyProperty.UnsetValue) ? default(Color) : ((SolidColorBrush)value).Color); + _cmbFontBackgroundColor.SelectedColor = currentColor; + } + + /// + /// Updates the visual state of the List styles, such as Numbers and Bullets. + /// + private void UpdateSelectionListType() + { + //uncheck both + _btnBullets.IsChecked = false; + _btnNumbers.IsChecked = false; + + Paragraph startParagraph = Target.Selection.Start.Paragraph; + Paragraph endParagraph = Target.Selection.End.Paragraph; + if (startParagraph != null && endParagraph != null && (startParagraph.Parent is ListItem) && (endParagraph.Parent is ListItem) && object.ReferenceEquals(((ListItem)startParagraph.Parent).List, ((ListItem)endParagraph.Parent).List)) + { + TextMarkerStyle markerStyle = ((ListItem)startParagraph.Parent).List.MarkerStyle; + if (markerStyle == TextMarkerStyle.Disc) //bullets + { + _btnBullets.IsChecked = true; + } + else if (markerStyle == TextMarkerStyle.Decimal) //numbers + { + _btnNumbers.IsChecked = true; + } + } + } + + /// + /// Checks to see if both selection lists are checked. (Bullets and Numbers) + /// + /// + private bool BothSelectionListsAreChecked() + { + return _btnBullets.IsChecked == true && _btnNumbers.IsChecked == true; + } + + void ApplyPropertyValueToSelectedText(DependencyProperty formattingProperty, object value) + { + if (value == null) + return; + + Target.Selection.ApplyPropertyValue(formattingProperty, value); + } + + private void ProcessMove(DragDeltaEventArgs e) + { + AdornerLayer layer = AdornerLayer.GetAdornerLayer(Target); + UIElementAdorner adorner = layer.GetAdorners(Target)[0] as UIElementAdorner; + adorner.SetOffsets(adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange); + } + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs new file mode 100644 index 00000000..b1cff436 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs @@ -0,0 +1,193 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Documents; +using Microsoft.Windows.Controls.Core; +using System.Windows.Input; + +namespace Microsoft.Windows.Controls +{ + public class RichTextBoxFormatBarManager : DependencyObject + { + #region Members + + private global::System.Windows.Controls.RichTextBox _richTextBox; + private UIElementAdorner _adorner; + private IRichTextBoxFormatBar _toolbar; + + #endregion //Members + + #region Properties + + #region FormatBar + + public static readonly DependencyProperty FormatBarProperty = DependencyProperty.RegisterAttached("FormatBar", typeof(IRichTextBoxFormatBar), typeof(RichTextBox), new PropertyMetadata(null, OnFormatBarPropertyChanged)); + public static void SetFormatBar(UIElement element, IRichTextBoxFormatBar value) + { + element.SetValue(FormatBarProperty, value); + } + public static IRichTextBoxFormatBar GetFormatBar(UIElement element) + { + return (IRichTextBoxFormatBar)element.GetValue(FormatBarProperty); + } + + private static void OnFormatBarPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + global::System.Windows.Controls.RichTextBox rtb = d as global::System.Windows.Controls.RichTextBox; + if (rtb == null) + throw new Exception("A FormatBar can only be applied to a RichTextBox."); + + RichTextBoxFormatBarManager manager = new RichTextBoxFormatBarManager(); + manager.AttachFormatBarToRichtextBox(rtb, e.NewValue as IRichTextBoxFormatBar); + } + + #endregion //FormatBar + + public bool IsAdornerVisible + { + get { return _adorner.Visibility == Visibility.Visible; } + } + + #endregion //Properties + + #region Event Handlers + + void RichTextBox_MouseButtonUp(object sender, MouseButtonEventArgs e) + { + if (e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released) + { + TextRange selectedText = new TextRange(_richTextBox.Selection.Start, _richTextBox.Selection.End); +#if !VS2008 + if (selectedText.Text.Length > 0 && !String.IsNullOrWhiteSpace(selectedText.Text)) + ShowAdorner(); +#else + if (selectedText.Text.Length > 0 && !String.IsNullOrEmpty(selectedText.Text)) + ShowAdorner(); +#endif + else + HideAdorner(); + + e.Handled = true; + } + else + HideAdorner(); + } + + void RichTextBox_PreviewMouseMove(object sender, MouseEventArgs e) + { + //if the mouse moves outside the richtextbox bounds hide the adorner + //though this deosn't always work, especially if the user moves the mouse very quickly. + //need to find a better solution, but this will work for now. + Point p = e.GetPosition(_richTextBox); + if (p.X <= 5.0 || p.X >= _richTextBox.ActualWidth - 5 || p.Y <= 3.0 || p.Y >= _richTextBox.ActualHeight - 3) + HideAdorner(); + } + + void RichTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + //this fixes the bug when applying text transformations the text would lose it's highlight. That was because the RichTextBox was losing focus + //so we just give it focus again and it seems to do the trick of re-highlighting it. + if (!_richTextBox.IsFocused && !_richTextBox.Selection.IsEmpty) + _richTextBox.Focus(); + } + + #endregion //Event Handlers + + #region Methods + + /// + /// Attaches a FormatBar to a RichtextBox + /// + /// The RichtextBox to attach to. + /// The Formatbar to attach. + private void AttachFormatBarToRichtextBox(global::System.Windows.Controls.RichTextBox richTextBox, IRichTextBoxFormatBar formatBar) + { + _richTextBox = richTextBox; + _richTextBox.PreviewMouseMove += RichTextBox_PreviewMouseMove; + //we cannot use the PreviewMouseLeftButtonUp event because of selection bugs. + //we cannot use the MouseLeftButtonUp event because it is handled by the RichTextBox and does not bubble up to here, so we must + //add a hander to the MouseUpEvent using the Addhandler syntax, and specify to listen for handled events too. + _richTextBox.AddHandler(Mouse.MouseUpEvent, new MouseButtonEventHandler(RichTextBox_MouseButtonUp), true); + _richTextBox.TextChanged += RichTextBox_TextChanged; + + _adorner = new UIElementAdorner(_richTextBox); + + formatBar.Target = _richTextBox; + _toolbar = formatBar; + } + + /// + /// Shows the FormatBar + /// + void ShowAdorner() + { + if (_adorner.Visibility == Visibility.Visible) + return; + + VerifyAdornerLayer(); + + Control adorningEditor = _toolbar as Control; + _adorner.Child = adorningEditor; + _adorner.Visibility = Visibility.Visible; + + PositionFormatBar(adorningEditor); + } + + /// + /// Positions the FormatBar so that is does not go outside the bounds of the RichTextBox or covers the selected text + /// + /// + private void PositionFormatBar(Control adorningEditor) + { + Point mousePosition = Mouse.GetPosition(_richTextBox); + + double left = mousePosition.X; + double top = (mousePosition.Y - 15) - adorningEditor.ActualHeight; + + //top + if (top < 0) + { + top = mousePosition.Y + 10; + } + + //right boundary + if (left + adorningEditor.ActualWidth > _richTextBox.ActualWidth - 20) + { + left = left - (adorningEditor.ActualWidth - (_richTextBox.ActualWidth - left)); + } + + _adorner.SetOffsets(left, top); + } + + /// + /// Ensures that the IRichTextFormatBar is in the adorner layer. + /// + /// True if the IRichTextFormatBar is in the adorner layer, else false. + bool VerifyAdornerLayer() + { + if (_adorner.Parent != null) + return true; + + AdornerLayer layer = AdornerLayer.GetAdornerLayer(_richTextBox); + if (layer == null) + return false; + + layer.Add(_adorner); + return true; + } + + /// + /// Hides the IRichTextFormatBar that is in the adornor layer. + /// + void HideAdorner() + { + if (IsAdornerVisible) + { + _adorner.Visibility = Visibility.Collapsed; + _adorner.Child = null; + } + } + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Implementation/SplitButton.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Implementation/SplitButton.cs new file mode 100644 index 00000000..e667053d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Implementation/SplitButton.cs @@ -0,0 +1,283 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Controls.Primitives; +using System.ComponentModel; + +namespace Microsoft.Windows.Controls +{ + public class SplitButton : ContentControl, ICommandSource + { + #region Members + Button _actionButton; + ToggleButton _toggleButton; + Popup _popup; + + #endregion //Members + + #region Constructors + + static SplitButton() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(SplitButton), new FrameworkPropertyMetadata(typeof(SplitButton))); + } + + public SplitButton() + { + Keyboard.AddKeyDownHandler(this, OnKeyDown); + Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); + } + + #endregion //Constructors + + #region Properties + + #region DropDownContent + + public static readonly DependencyProperty DropDownContentProperty = DependencyProperty.Register("DropDownContent", typeof(object), typeof(SplitButton), new UIPropertyMetadata(null, OnDropDownContentChanged)); + public object DropDownContent + { + get { return (object)GetValue(DropDownContentProperty); } + set { SetValue(DropDownContentProperty, value); } + } + + private static void OnDropDownContentChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + SplitButton splitButton = o as SplitButton; + if (splitButton != null) + splitButton.OnDropDownContentChanged((object)e.OldValue, (object)e.NewValue); + } + + protected virtual void OnDropDownContentChanged(object oldValue, object newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + #endregion //DropDownContent + + #region IsOpen + + public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(SplitButton), new UIPropertyMetadata(false, OnIsOpenChanged)); + public bool IsOpen + { + get { return (bool)GetValue(IsOpenProperty); } + set { SetValue(IsOpenProperty, value); } + } + + private static void OnIsOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + SplitButton splitButton = o as SplitButton; + if (splitButton != null) + splitButton.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue); + } + + protected virtual void OnIsOpenChanged(bool oldValue, bool newValue) + { + // TODO: check for cancel event args on an OnOpening event + } + + #endregion //IsOpen + + #endregion //Properties + + #region Events + + public static readonly RoutedEvent ClickEvent = EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(SplitButton)); + public event RoutedEventHandler Click + { + add { AddHandler(ClickEvent, value); } + remove { RemoveHandler(ClickEvent, value); } + } + + #endregion //Events + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _actionButton = (Button)GetTemplateChild("PART_ActionButton"); + _actionButton.Click += ActionButton_Click; + + _toggleButton = (ToggleButton)GetTemplateChild("PART_ToggleButton"); + + _popup = (Popup)GetTemplateChild("PART_Popup"); + //_popup.Opened += Popup_Opened; + } + + #endregion //Base Class Overrides + + #region Event Handlers + + void ActionButton_Click(object sender, RoutedEventArgs e) + { + OnClick(); + } + + void Popup_Opened(object sender, EventArgs e) + { + + } + + private void OnKeyDown(object sender, KeyEventArgs e) + { + switch (e.Key) + { + case Key.Escape: + { + CloseDropDown(); + break; + } + } + } + + private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e) + { + CloseDropDown(); + } + + void CanExecuteChanged(object sender, EventArgs e) + { + if (Command != null) + { + RoutedCommand command = Command as RoutedCommand; + + // If a RoutedCommand. + if (command != null) + IsEnabled = command.CanExecute(CommandParameter, CommandTarget) ? true : false; + // If a not RoutedCommand. + else + IsEnabled = Command.CanExecute(CommandParameter) ? true : false; + } + } + + #endregion //Event Handlers + + #region Methods + + #region Protected + + protected virtual void OnClick() + { + RaiseClickEvent(); + RaiseCommand(); + } + #endregion //Protected + + #region Private + + /// + /// Raises the click event. + /// + private void RaiseClickEvent() + { + RoutedEventArgs args = new RoutedEventArgs(SplitButton.ClickEvent, this); + RaiseEvent(args); + } + + /// + /// Raises the command's Execute event. + /// + private void RaiseCommand() + { + if (Command != null) + { + RoutedCommand routedCommand = Command as RoutedCommand; + + if (routedCommand == null) + ((ICommand)Command).Execute(CommandParameter); + else + routedCommand.Execute(CommandParameter, CommandTarget); + } + } + + /// + /// Unhooks a command from the Command property. + /// + /// The old command. + /// The new command. + private void UnhookCommand(ICommand oldCommand, ICommand newCommand) + { + EventHandler handler = CanExecuteChanged; + oldCommand.CanExecuteChanged -= handler; + } + + /// + /// Hooks up a command to the CanExecuteChnaged event handler. + /// + /// The old command. + /// The new command. + private void HookUpCommand(ICommand oldCommand, ICommand newCommand) + { + EventHandler handler = new EventHandler(CanExecuteChanged); + canExecuteChangedHandler = handler; + if (newCommand != null) + newCommand.CanExecuteChanged += canExecuteChangedHandler; + } + + /// + /// Closes the drop down. + /// + private void CloseDropDown() + { + if (IsOpen) + IsOpen = false; + ReleaseMouseCapture(); + } + + #endregion //Private + + #endregion //Methods + + #region ICommandSource Members + + // Keeps a copy of the CanExecuteChnaged handler so it doesn't get garbage collected. + private static EventHandler canExecuteChangedHandler; + + #region Command + + public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(SplitButton), new PropertyMetadata((ICommand)null, OnCommandChanged)); + [TypeConverter(typeof(CommandConverter))] + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + + private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + SplitButton splitButton = d as SplitButton; + if (splitButton != null) + splitButton.OnCommandChanged((ICommand)e.OldValue, (ICommand)e.NewValue); + } + + protected virtual void OnCommandChanged(ICommand oldValue, ICommand newValue) + { + // If old command is not null, then we need to remove the handlers. + if (oldValue != null) + UnhookCommand(oldValue, newValue); + + HookUpCommand(oldValue, newValue); + } + + #endregion //Command + + public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter", typeof(object), typeof(SplitButton), new PropertyMetadata(null)); + public object CommandParameter + { + get { return GetValue(CommandParameterProperty); } + set { SetValue(CommandParameterProperty, value); } + } + + public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register("CommandTarget", typeof(IInputElement), typeof(SplitButton), new PropertyMetadata(null)); + public IInputElement CommandTarget + { + get { return (IInputElement)GetValue(CommandTargetProperty); } + set { SetValue(CommandTargetProperty, value); } + } + + #endregion + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml new file mode 100644 index 00000000..9e863a17 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml new file mode 100644 index 00000000..e1ef5440 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml new file mode 100644 index 00000000..febe9614 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/Themes/Generic.xaml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeFormat.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeFormat.cs new file mode 100644 index 00000000..0e0714ed --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeFormat.cs @@ -0,0 +1,10 @@ + +namespace Microsoft.Windows.Controls +{ + public enum TimeFormat + { + Custom, + ShortTime, + LongTime + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeItem.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeItem.cs new file mode 100644 index 00000000..6b88f1d5 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimeItem.cs @@ -0,0 +1,34 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + public class TimeItem + { + public string Display { get; set; } + public TimeSpan Time { get; set; } + + public TimeItem(string display, TimeSpan time) + { + Display = display; + Time = time; + } + + #region Base Class Overrides + + public override bool Equals(object obj) + { + var item = obj as TimeItem; + if (item != null) + return Time == item.Time; + else + return false; + } + + public override int GetHashCode() + { + return Time.GetHashCode(); + } + + #endregion //Base Class Overrides + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimePicker.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimePicker.cs new file mode 100644 index 00000000..04836a2a --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Implementation/TimePicker.cs @@ -0,0 +1,409 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Collections; +using System.Globalization; + +namespace Microsoft.Windows.Controls +{ + public class TimePicker : Control + { + #region Members + + ListBox _timeListBox; + private DateTimeFormatInfo DateTimeFormatInfo { get; set; } + internal static readonly TimeSpan EndTimeDefaultValue = new TimeSpan(23, 59, 0); + internal static readonly TimeSpan StartTimeDefaultValue = new TimeSpan(0, 0, 0); + internal static readonly TimeSpan TimeIntervalDefaultValue = new TimeSpan(1, 0, 0); + + #endregion //Members + + #region Properties + + #region AllowSpin + + public static readonly DependencyProperty AllowSpinProperty = DependencyProperty.Register("AllowSpin", typeof(bool), typeof(TimePicker), new UIPropertyMetadata(true)); + public bool AllowSpin + { + get { return (bool)GetValue(AllowSpinProperty); } + set { SetValue(AllowSpinProperty, value); } + } + + #endregion //AllowSpin + + #region EndTime + + public static readonly DependencyProperty EndTimeProperty = DependencyProperty.Register("EndTime", typeof(TimeSpan), typeof(TimePicker), new UIPropertyMetadata(EndTimeDefaultValue, new PropertyChangedCallback(OnEndTimeChanged), new CoerceValueCallback(OnCoerceEndTime))); + + private static object OnCoerceEndTime(DependencyObject o, object value) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + return timePicker.OnCoerceEndTime((TimeSpan)value); + else + return value; + } + + private static void OnEndTimeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.OnEndTimeChanged((TimeSpan)e.OldValue, (TimeSpan)e.NewValue); + } + + protected virtual TimeSpan OnCoerceEndTime(TimeSpan value) + { + // TODO: Keep the proposed value within the desired range. + return value; + } + + protected virtual void OnEndTimeChanged(TimeSpan oldValue, TimeSpan newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + public TimeSpan EndTime + { + // IMPORTANT: To maintain parity between setting a property in XAML and procedural code, do not touch the getter and setter inside this dependency property! + get + { + return (TimeSpan)GetValue(EndTimeProperty); + } + set + { + SetValue(EndTimeProperty, value); + } + } + + + #endregion //EndTime + + #region Format + + public static readonly DependencyProperty FormatProperty = DependencyProperty.Register("Format", typeof(TimeFormat), typeof(TimePicker), new UIPropertyMetadata(TimeFormat.ShortTime, OnFormatChanged)); + public TimeFormat Format + { + get { return (TimeFormat)GetValue(FormatProperty); } + set { SetValue(FormatProperty, value); } + } + + private static void OnFormatChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.OnFormatChanged((TimeFormat)e.OldValue, (TimeFormat)e.NewValue); + } + + protected virtual void OnFormatChanged(TimeFormat oldValue, TimeFormat newValue) + { + + } + + #endregion //Format + + #region FormatString + + public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(TimePicker), 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) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.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(TimePicker), new UIPropertyMetadata(false)); + public bool IsOpen + { + get { return (bool)GetValue(IsOpenProperty); } + set { SetValue(IsOpenProperty, value); } + } + + #endregion //IsOpen + + #region Maximum + + + + #endregion //Maximum + + #region Minimum + + + + #endregion //Minimum + + #region ShowButtonSpinner + + public static readonly DependencyProperty ShowButtonSpinnerProperty = DependencyProperty.Register("ShowButtonSpinner", typeof(bool), typeof(TimePicker), new UIPropertyMetadata(true)); + public bool ShowButtonSpinner + { + get { return (bool)GetValue(ShowButtonSpinnerProperty); } + set { SetValue(ShowButtonSpinnerProperty, value); } + } + + #endregion //ShowButtonSpinner + + #region StartTime + + public static readonly DependencyProperty StartTimeProperty = DependencyProperty.Register("StartTime", typeof(TimeSpan), typeof(TimePicker), new UIPropertyMetadata(StartTimeDefaultValue, new PropertyChangedCallback(OnStartTimeChanged), new CoerceValueCallback(OnCoerceStartTime))); + + private static object OnCoerceStartTime(DependencyObject o, object value) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + return timePicker.OnCoerceStartTime((TimeSpan)value); + else + return value; + } + + private static void OnStartTimeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.OnStartTimeChanged((TimeSpan)e.OldValue, (TimeSpan)e.NewValue); + } + + protected virtual TimeSpan OnCoerceStartTime(TimeSpan value) + { + // TODO: Keep the proposed value within the desired range. + return value; + } + + protected virtual void OnStartTimeChanged(TimeSpan oldValue, TimeSpan newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + public TimeSpan StartTime + { + // IMPORTANT: To maintain parity between setting a property in XAML and procedural code, do not touch the getter and setter inside this dependency property! + get + { + return (TimeSpan)GetValue(StartTimeProperty); + } + set + { + SetValue(StartTimeProperty, value); + } + } + + + #endregion //StartTime + + #region TimeInterval + + public static readonly DependencyProperty TimeIntervalProperty = DependencyProperty.Register("TimeInterval", typeof(TimeSpan), typeof(TimePicker), new UIPropertyMetadata(TimeIntervalDefaultValue, OnTimeIntervalChanged)); + public TimeSpan TimeInterval + { + get { return (TimeSpan)GetValue(TimeIntervalProperty); } + set { SetValue(TimeIntervalProperty, value); } + } + + private static void OnTimeIntervalChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.OnTimeIntervalChanged((TimeSpan)e.OldValue, (TimeSpan)e.NewValue); + } + + protected virtual void OnTimeIntervalChanged(TimeSpan oldValue, TimeSpan newValue) + { + // TODO: Add your property changed side-effects. Descendants can override as well. + } + + #endregion //TimeInterval + + #region Value + + public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(DateTime?), typeof(TimePicker), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged)); + public DateTime? Value + { + get { return (DateTime?)GetValue(ValueProperty); } + set { SetValue(ValueProperty, value); } + } + + private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + TimePicker timePicker = o as TimePicker; + if (timePicker != null) + timePicker.OnValueChanged((DateTime?)e.OldValue, (DateTime?)e.NewValue); + } + + protected virtual void OnValueChanged(DateTime? oldValue, DateTime? newValue) + { + //TODO: refactor this + if (newValue.HasValue && _timeListBox != null) + { + var items = _timeListBox.ItemsSource; + foreach (TimeItem item in items) + { + if (item.Time == newValue.Value.TimeOfDay) + { + int index = _timeListBox.Items.IndexOf(item); + if (_timeListBox.SelectedIndex != index) + _timeListBox.SelectedIndex = index; + break; + } + } + } + } + + #endregion //Value + + #region Watermark + + public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(object), typeof(TimePicker), 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(TimePicker), new UIPropertyMetadata(null)); + public DataTemplate WatermarkTemplate + { + get { return (DataTemplate)GetValue(WatermarkTemplateProperty); } + set { SetValue(WatermarkTemplateProperty, value); } + } + + #endregion //WatermarkTemplate + + #endregion //Properties + + #region Constructors + + static TimePicker() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TimePicker), new FrameworkPropertyMetadata(typeof(TimePicker))); + } + + public TimePicker() + { + DateTimeFormatInfo = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture); + Keyboard.AddKeyDownHandler(this, OnKeyDown); + Mouse.AddPreviewMouseDownOutsideCapturedElementHandler(this, OnMouseDownOutsideCapturedElement); + } + + #endregion //Constructors + + #region Base Class Overrides + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _timeListBox = (ListBox)GetTemplateChild("PART_TimeListItems"); + _timeListBox.ItemsSource = GenerateTimeListItemsSource(); + _timeListBox.SelectionChanged += TimeListBox_SelectionChanged; + } + + #endregion //Base Class Overrides + + #region Event Handlers + + private void OnKeyDown(object sender, KeyEventArgs e) + { + switch (e.Key) + { + case Key.Escape: + case Key.Tab: + { + CloseTimePicker(); + break; + } + } + } + + private void OnMouseDownOutsideCapturedElement(object sender, MouseButtonEventArgs e) + { + CloseTimePicker(); + } + + void TimeListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.AddedItems.Count > 0) + { + TimeItem selectedTimeListItem = (TimeItem)e.AddedItems[0]; + var time = selectedTimeListItem.Time; ; + var date = Value ?? DateTime.MinValue; + + Value = new DateTime(date.Year, date.Month, date.Day, time.Hours, time.Minutes, time.Seconds, time.Milliseconds); + } + + CloseTimePicker(); + } + + #endregion //Event Handlers + + #region Methods + + private void CloseTimePicker() + { + if (IsOpen) + IsOpen = false; + ReleaseMouseCapture(); + } + + public IEnumerable GenerateTimeListItemsSource() + { + TimeSpan time = StartTime; + TimeSpan endTime = EndTime; + + if (endTime <= time) + { + endTime = EndTimeDefaultValue; + time = StartTimeDefaultValue; + } + + TimeSpan timeInterval = TimeInterval; + + if (time != null && endTime != null && timeInterval != null && timeInterval.Ticks > 0) + { + while (time <= endTime) + { + yield return new TimeItem(DateTime.MinValue.Add(time).ToString(GetTimeFormat(), CultureInfo.CurrentCulture), time); + time = time.Add(timeInterval); + } + yield break; + } + } + + private string GetTimeFormat() + { + switch (Format) + { + case TimeFormat.Custom: + return FormatString; + case TimeFormat.LongTime: + return DateTimeFormatInfo.LongTimePattern; + case TimeFormat.ShortTime: + return DateTimeFormatInfo.ShortTimePattern; + default: + return DateTimeFormatInfo.ShortTimePattern; + } + } + + #endregion //Methods + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml new file mode 100644 index 00000000..a0aa2027 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/VisualStates.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/VisualStates.cs new file mode 100644 index 00000000..721a96e2 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/VisualStates.cs @@ -0,0 +1,9 @@ +using System; + +namespace Microsoft.Windows.Controls +{ + internal static partial class VisualStates + { + + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj new file mode 100644 index 00000000..bcc065fc --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -0,0 +1,325 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {72E591D6-8F83-4D8C-8F67-9C325E623234} + library + Properties + Microsoft.Windows.Controls + WPFToolkit.Extended + v4.0 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + sn.snk + + + + + + + + + + + 4.0 + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + RichTextBoxFormatBar.xaml + + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Implementation/WatermarkTextBox.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Implementation/WatermarkTextBox.cs new file mode 100644 index 00000000..7a6b67bd --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Implementation/WatermarkTextBox.cs @@ -0,0 +1,44 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace Microsoft.Windows.Controls +{ + public class WatermarkTextBox : TextBox + { + #region Properties + + #region Watermark + + public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register("Watermark", typeof(object), typeof(WatermarkTextBox), 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(WatermarkTextBox), new UIPropertyMetadata(null)); + public DataTemplate WatermarkTemplate + { + get { return (DataTemplate)GetValue(WatermarkTemplateProperty); } + set { SetValue(WatermarkTemplateProperty, value); } + } + + #endregion //WatermarkTemplate + + #endregion //Properties + + #region Constructors + + static WatermarkTextBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(WatermarkTextBox), new FrameworkPropertyMetadata(typeof(WatermarkTextBox))); + } + + #endregion //Constructors + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml new file mode 100644 index 00000000..c1c0ddf3 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/sn.snk b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/sn.snk new file mode 100644 index 00000000..1bdc9120 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/sn.snk differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln new file mode 100644 index 00000000..d0d4034b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.sln @@ -0,0 +1,38 @@ + +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.Examples", "Src\WPFToolkit.Extended.Examples\WPFToolkit.Extended.Examples.csproj", "{747652D0-6AA6-4F96-99F7-0C834274FAB2}" +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.Examples\\WPFToolkit.Extended.Examples.csproj + SccProjectName2 = Src/WPFToolkit.Extended.Examples + SccLocalPath2 = Src\\WPFToolkit.Extended.Examples + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {72E591D6-8F83-4D8C-8F67-9C325E623234}.Debug|Any CPU.Build.0 = Debug|Any CPU + {72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Any CPU.ActiveCfg = Release|Any CPU + {72E591D6-8F83-4D8C-8F67-9C325E623234}.Release|Any CPU.Build.0 = Release|Any CPU + {747652D0-6AA6-4F96-99F7-0C834274FAB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {747652D0-6AA6-4F96-99F7-0C834274FAB2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {747652D0-6AA6-4F96-99F7-0C834274FAB2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {747652D0-6AA6-4F96-99F7-0C834274FAB2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc new file mode 100644 index 00000000..794f014c --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/ExtendedWPFToolkit.vssscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/App.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/App.xaml new file mode 100644 index 00000000..b6483ed1 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/App.xaml.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/App.xaml.cs new file mode 100644 index 00000000..490ee2d0 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/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.Examples +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/AssemblyInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..af4eebe1 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/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.Examples")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("WPFToolkit.Extended.Examples")] +[assembly: AssemblyCopyright("Copyright © Microsoft 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_35/Src/WPFToolkit.Extended.Examples/Properties/Resources.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Resources.Designer.cs new file mode 100644 index 00000000..c3711362 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.225 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WPFToolkit.Extended.Examples.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Examples.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_35/Src/WPFToolkit.Extended.Examples/Properties/Resources.resx b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Resources.resx new file mode 100644 index 00000000..ffecec85 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/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_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.Designer.cs new file mode 100644 index 00000000..edee43de --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.225 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WPFToolkit.Extended.Examples.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_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.settings b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.settings new file mode 100644 index 00000000..8f2fd95d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.csproj b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.csproj new file mode 100644 index 00000000..1fce92a3 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.csproj @@ -0,0 +1,122 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {747652D0-6AA6-4F96-99F7-0C834274FAB2} + WinExe + Properties + WPFToolkit.Extended.Examples + WPFToolkit.Extended.Examples + v3.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + SAK + SAK + SAK + SAK + + + + + 3.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + 3.5 + + + 3.5 + + + + + + + + + + + MSBuild:Compile + Designer + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile + Designer + + + App.xaml + Code + + + Window1.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_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.csproj.vspscc b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/WPFToolkit.Extended.Examples.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_35/Src/WPFToolkit.Extended.Examples/Window1.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Window1.xaml new file mode 100644 index 00000000..c76c960b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Window1.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Window1.xaml.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Window1.xaml.cs new file mode 100644 index 00000000..ae35ac34 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended.Examples/Window1.xaml.cs @@ -0,0 +1,33 @@ +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; + +namespace WPFToolkit.Extended.Examples +{ + /// + /// Interaction logic for Window1.xaml + /// + public partial class Window1 : Window + { + public Window1() + { + InitializeComponent(); + Loaded += new RoutedEventHandler(Window1_Loaded); + } + + void Window1_Loaded(object sender, RoutedEventArgs e) + { + + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/BusyIndicator/Themes/Generic.xaml new file mode 100644 index 00000000..01119b0a --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ButtonSpinner/Themes/Generic.xaml new file mode 100644 index 00000000..73c19ad1 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/Calculator/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Calculator/Themes/Generic.xaml new file mode 100644 index 00000000..37529ff7 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/Chromes/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Chromes/Themes/Generic.xaml new file mode 100644 index 00000000..0f0fd301 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/ColorCanvas/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorCanvas/Themes/Generic.xaml new file mode 100644 index 00000000..6cc8d243 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/ColorPicker/Themes/Generic.xaml new file mode 100644 index 00000000..ddcd39f7 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml new file mode 100644 index 00000000..7a5862af --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/DateTimePicker/Themes/Generic.xaml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/DateTimeUpDown/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/DateTimeUpDown/Themes/Generic.xaml new file mode 100644 index 00000000..2ef7bf2b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/Magnifier/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Magnifier/Themes/Generic.xaml new file mode 100644 index 00000000..bcbf1567 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/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_35/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml new file mode 100644 index 00000000..8743492f --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MaskedTextBox/Themes/Generic.xaml @@ -0,0 +1,36 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png new file mode 100644 index 00000000..4304d43b Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Error48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png new file mode 100644 index 00000000..35075187 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Information48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png new file mode 100644 index 00000000..dad7dd09 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Question48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png new file mode 100644 index 00000000..ecb7fe86 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Icons/Warning48.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml new file mode 100644 index 00000000..efbd5084 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/MessageBox/Themes/Generic.xaml @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml new file mode 100644 index 00000000..93ba331b --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/NumericUpDown/Themes/Generic.xaml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..1a90ce26 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/AssemblyInfo.cs @@ -0,0 +1,62 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; +using System.Windows.Markup; +using System; + +// 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("Extended WPF Toolkit")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Extended WPF Toolkit")] +[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)] +[assembly: CLSCompliant(true)] + +//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.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] + +[assembly: XmlnsPrefix("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "extToolkit")] +[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "Microsoft.Windows.Controls")] +[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended", "Microsoft.Windows.Controls.PropertyGrid")] diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs new file mode 100644 index 00000000..eaf63633 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Windows.Controls.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.Controls.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx new file mode 100644 index 00000000..ffecec85 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs new file mode 100644 index 00000000..4a0f1423 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.Windows.Controls.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings new file mode 100644 index 00000000..8f2fd95d --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png new file mode 100644 index 00000000..0146e932 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/AdvancedProperties11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png new file mode 100644 index 00000000..51510df8 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Categorize16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png new file mode 100644 index 00000000..0f523fbd Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Database11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png new file mode 100644 index 00000000..7dd3b491 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Inheritance11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png new file mode 100644 index 00000000..ec521dd4 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Local11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png new file mode 100644 index 00000000..7275c981 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Resource11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png new file mode 100644 index 00000000..b3138ba3 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/SortAscending16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png new file mode 100644 index 00000000..7a6005d6 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Images/Style11.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml new file mode 100644 index 00000000..da8090bc --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/PropertyGrid/Themes/Generic.xaml @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png new file mode 100644 index 00000000..8fb36a1a Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bold16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png new file mode 100644 index 00000000..73e7c15e Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Bullets16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png new file mode 100644 index 00000000..1030a021 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/CenterAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png new file mode 100644 index 00000000..d9207308 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/FontColorPicker16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png new file mode 100644 index 00000000..8259a9e1 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Italic16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png new file mode 100644 index 00000000..c5499bce Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/JustifyAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png new file mode 100644 index 00000000..51dffb73 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/LeftAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png new file mode 100644 index 00000000..03f6fde2 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Numbering16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png new file mode 100644 index 00000000..cb8e400a Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/RightAlign16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png new file mode 100644 index 00000000..4a3783f2 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png new file mode 100644 index 00000000..72689482 Binary files /dev/null and b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/RichTextBoxFormatBar/Images/Underline16.png differ diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml new file mode 100644 index 00000000..b4cc1be5 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/SplitButton/Themes/Generic.xaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml new file mode 100644 index 00000000..e1ef5440 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Common/Generic_Common.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml new file mode 100644 index 00000000..45bf4339 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/Themes/Generic.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml new file mode 100644 index 00000000..235c58c6 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/TimePicker/Themes/Generic.xaml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj new file mode 100644 index 00000000..ab5e5da3 --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj @@ -0,0 +1,507 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {72E591D6-8F83-4D8C-8F67-9C325E623234} + library + Properties + Microsoft.Windows.Controls + WPFToolkit.Extended + v3.5 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + SAK + SAK + SAK + SAK + true + ..\..\..\ExtendedWPFToolkitSolution\Src\WPFToolkit.Extended\sn.snk + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + TRACE;DEBUG;VS2008 + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE;VS2008 + prompt + 4 + + + + + + + 3.5 + + + + + 3.0 + + + 3.0 + + + 3.0 + + + 3.0 + + + + + + RichTextBoxFormatBar\RichTextBoxFormatBar.xaml + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + BusyIndicator\Implementation\BusyIndicator.cs + + + BusyIndicator\Implementation\VisualStates.BusyIndicator.cs + + + ButtonSpinner\Implementation\ButtonSpinner.cs + + + ButtonSpinner\Implementation\SpinDirection.cs + + + ButtonSpinner\Implementation\SpinEventArgs.cs + + + ButtonSpinner\Implementation\Spinner.cs + + + ButtonSpinner\Implementation\ValidSpinDirections.cs + + + CalculatorUpDown\Implementation\CalculatorUpDown.cs + + + Calculator\Implementation\Calculator.cs + + + Calculator\Implementation\CalculatorCommands.cs + + + ChildWindow\Implementation\ChildWindow.cs + + + ChildWindow\Implementation\WindowStartupLocation.cs + + + ChildWindow\Implementation\WindowState.cs + + + Chromes\Implementation\ButtonChrome.cs + + + ColorCanvas\Implementation\ColorCanvas.cs + + + ColorCanvas\Implementation\ColorSpectrumSlider.cs + + + ColorPicker\Implementation\ColorItem.cs + + + ColorPicker\Implementation\ColorPicker.cs + + + Core\Converters\CalculatorMemoryToVisibilityConverter.cs + + + Core\Converters\ColorToSolidColorBrushConverter.cs + + + Core\Converters\InverseBoolConverter.cs + + + Core\Converters\SolidColorBrushToColorConverter.cs + + + Core\Converters\TimeFormatToDateTimeFormatConverter.cs + + + Core\Primitives\HsvColor.cs + + + Core\Primitives\InputBase.cs + + + Core\Primitives\UpDownBase.cs + + + Core\UIElementAdorner.cs + + + Core\Utilities\CalculatorUtilities.cs + + + Core\Utilities\ColorUtilities.cs + + + Core\Utilities\ContextMenuUtilities.cs + + + DateTimePicker\Implementation\DateTimePicker.cs + + + DateTimeUpDown\Implementation\DateTimeFormat.cs + + + DateTimeUpDown\Implementation\DateTimeInfo.cs + + + DateTimeUpDown\Implementation\DateTimeParser.cs + + + DateTimeUpDown\Implementation\DateTimePart.cs + + + DateTimeUpDown\Implementation\DateTimeUpDown.cs + + + Magnifier\Implementation\Converters\BorderThicknessToStrokeThicknessConverter.cs + + + Magnifier\Implementation\Converters\RadiusConverter.cs + + + Magnifier\Implementation\Magnifier.cs + + + Magnifier\Implementation\MagnifierAdorner.cs + + + Magnifier\Implementation\MagnifierManager.cs + + + MaskedTextBox\Implementation\MaskedTextBox.cs + + + MessageBox\Implementation\MessageBox.cs + + + MessageBox\Implementation\VisualStates.MessageBox.cs + + + NumericUpDown\Implementation\DecimalUpDown.cs + + + NumericUpDown\Implementation\DoubleUpDown.cs + + + NumericUpDown\Implementation\IntegerUpDown.cs + + + NumericUpDown\Implementation\NumericUpDown.cs + + + PropertyGrid\Implementation\Commands\PropertyItemCommands.cs + + + PropertyGrid\Implementation\Converters\ValueSourceToImagePathConverter.cs + + + PropertyGrid\Implementation\Converters\ValueSourceToToolTipConverter.cs + + + PropertyGrid\Implementation\CustomTypeEditorCollection.cs + + + PropertyGrid\Implementation\Editors\CheckBoxEditor.cs + + + PropertyGrid\Implementation\Editors\ColorEditor.cs + + + PropertyGrid\Implementation\Editors\ComboBoxEditor.cs + + + PropertyGrid\Implementation\Editors\CustomTypeEditor.cs + + + PropertyGrid\Implementation\Editors\DateTimeUpDownEditor.cs + + + PropertyGrid\Implementation\Editors\DecimalUpDownEditor.cs + + + PropertyGrid\Implementation\Editors\DoubleUpDownEditor.cs + + + PropertyGrid\Implementation\Editors\EnumComboBoxEditor.cs + + + PropertyGrid\Implementation\Editors\FontComboBoxEditor.cs + + + PropertyGrid\Implementation\Editors\ICustomTypeEditor.cs + + + PropertyGrid\Implementation\Editors\IntegerUpDownEditor.cs + + + PropertyGrid\Implementation\Editors\ITypeEditor.cs + + + PropertyGrid\Implementation\Editors\TextBlockEditor.cs + + + PropertyGrid\Implementation\Editors\TextBoxEditor.cs + + + PropertyGrid\Implementation\Editors\TypeEditor.cs + + + PropertyGrid\Implementation\PropertyCategoryItem.cs + + + PropertyGrid\Implementation\PropertyCollection.cs + + + PropertyGrid\Implementation\PropertyGrid.cs + + + PropertyGrid\Implementation\PropertyItem.cs + + + RichTextBoxFormatBar\IRichTextBoxFormatBar.cs + + + RichTextBoxFormatBar\RichTextBoxFormatBar.xaml.cs + RichTextBoxFormatBar.xaml + + + RichTextBoxFormatBar\RichTextBoxFormatBarManager.cs + + + RichTextBox\Formatters\ITextFormatter.cs + + + RichTextBox\Formatters\PlainTextFormatter.cs + + + RichTextBox\Formatters\RtfFormatter.cs + + + RichTextBox\Formatters\XamlFormatter.cs + + + RichTextBox\RichTextBox.cs + + + SplitButton\Implementation\SplitButton.cs + + + TimePicker\Implementation\TimeFormat.cs + + + TimePicker\Implementation\TimeItem.cs + + + TimePicker\Implementation\TimePicker.cs + + + VisualStates.cs + + + WatermarkTextBox\Implementation\WatermarkTextBox.cs + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + sn.snk + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WPFToolkit.Extended.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml new file mode 100644 index 00000000..83ce7afd --- /dev/null +++ b/Release/v1.4.0/ExtendedWPFToolkitSolution_35/Src/WPFToolkit.Extended/WatermarkTextBox/Themes/Generic.xaml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file