@ -0,0 +1,69 @@ |
|||||
|
|
||||
|
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 |
||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFToolkit.Extended.Design", "Src\WPFToolkit.Extended.Design\WPFToolkit.Extended.Design.csproj", "{FA6645C6-7CA5-427C-91F2-916D9FECD76C}" |
||||
|
EndProject |
||||
|
Global |
||||
|
GlobalSection(TeamFoundationVersionControl) = preSolution |
||||
|
SccNumberOfProjects = 4 |
||||
|
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 |
||||
|
SccProjectUniqueName3 = Src\\WPFToolkit.Extended.Design\\WPFToolkit.Extended.Design.csproj |
||||
|
SccProjectName3 = Src/WPFToolkit.Extended.Design |
||||
|
SccLocalPath3 = Src\\WPFToolkit.Extended.Design |
||||
|
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 |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Debug|Any CPU.Build.0 = Debug|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Debug|x86.ActiveCfg = Debug|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Release|Any CPU.ActiveCfg = Release|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Release|Any CPU.Build.0 = Release|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Release|Mixed Platforms.Build.0 = Release|Any CPU |
||||
|
{FA6645C6-7CA5-427C-91F2-916D9FECD76C}.Release|x86.ActiveCfg = Release|Any CPU |
||||
|
EndGlobalSection |
||||
|
GlobalSection(SolutionProperties) = preSolution |
||||
|
HideSolutionNode = FALSE |
||||
|
EndGlobalSection |
||||
|
EndGlobal |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" |
||||
|
} |
||||
@ -0,0 +1,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(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
|
//the line below to match the UICulture setting in the project file.
|
||||
|
|
||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
|
||||
|
|
||||
|
[assembly: ThemeInfo( |
||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// or application resource dictionaries)
|
||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// app, or any theme specific resource dictionaries)
|
||||
|
)] |
||||
|
|
||||
|
|
||||
|
// Version information for an assembly consists of the following four values:
|
||||
|
//
|
||||
|
// Major Version
|
||||
|
// Minor Version
|
||||
|
// Build Number
|
||||
|
// Revision
|
||||
|
//
|
||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
|
// by using the '*' as shown below:
|
||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
[assembly: AssemblyVersion("1.0.0.0")] |
||||
|
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
@ -0,0 +1,71 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace WPFToolkit.Extended.Design.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
|
/// </summary>
|
||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
|
// class via a tool like ResGen or Visual Studio.
|
||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
|
// with the /str option, or rebuild your VS project.
|
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
internal class Resources |
||||
|
{ |
||||
|
|
||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||
|
|
||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||
|
|
||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||
|
internal Resources() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Resources.ResourceManager ResourceManager |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if ((resourceMan == null)) |
||||
|
{ |
||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Design.Properties.Resources", typeof(Resources).Assembly); |
||||
|
resourceMan = temp; |
||||
|
} |
||||
|
return resourceMan; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||
|
/// resource lookups using this strongly typed resource class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Globalization.CultureInfo Culture |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return resourceCulture; |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
resourceCulture = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<root> |
||||
|
<!-- |
||||
|
Microsoft ResX Schema |
||||
|
|
||||
|
Version 2.0 |
||||
|
|
||||
|
The primary goals of this format is to allow a simple XML format |
||||
|
that is mostly human readable. The generation and parsing of the |
||||
|
various data types are done through the TypeConverter classes |
||||
|
associated with the data types. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
... ado.net/XML headers & schema ... |
||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
|
<resheader name="version">2.0</resheader> |
||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
|
</data> |
||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
|
<comment>This is a comment</comment> |
||||
|
</data> |
||||
|
|
||||
|
There are any number of "resheader" rows that contain simple |
||||
|
name/value pairs. |
||||
|
|
||||
|
Each data row contains a name, and value. The row also contains a |
||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||
|
text/value conversion through the TypeConverter architecture. |
||||
|
Classes that don't support this are serialized and stored with the |
||||
|
mimetype set. |
||||
|
|
||||
|
The mimetype is used for serialized objects, and tells the |
||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||
|
|
||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
|
that the ResXResourceWriter will generate, however the reader can |
||||
|
read any of the formats listed below. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
|
value : The object must be serialized into a byte array |
||||
|
: using a System.ComponentModel.TypeConverter |
||||
|
: and then encoded with base64 encoding. |
||||
|
--> |
||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:choice maxOccurs="unbounded"> |
||||
|
<xsd:element name="metadata"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="assembly"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="data"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="resheader"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:choice> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:schema> |
||||
|
<resheader name="resmimetype"> |
||||
|
<value>text/microsoft-resx</value> |
||||
|
</resheader> |
||||
|
<resheader name="version"> |
||||
|
<value>2.0</value> |
||||
|
</resheader> |
||||
|
<resheader name="reader"> |
||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
<resheader name="writer"> |
||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
</root> |
||||
@ -0,0 +1,30 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace 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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version='1.0' encoding='utf-8'?> |
||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||
|
<Profiles> |
||||
|
<Profile Name="(Default)" /> |
||||
|
</Profiles> |
||||
|
<Settings /> |
||||
|
</SettingsFile> |
||||
@ -0,0 +1,99 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
|
<ProductVersion>8.0.30703</ProductVersion> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
<ProjectGuid>{FA6645C6-7CA5-427C-91F2-916D9FECD76C}</ProjectGuid> |
||||
|
<OutputType>library</OutputType> |
||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
|
<RootNamespace>WPFToolkit.Extended.Design</RootNamespace> |
||||
|
<AssemblyName>WPFToolkit.Extended.Design</AssemblyName> |
||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<SccProjectName>SAK</SccProjectName> |
||||
|
<SccLocalPath>SAK</SccLocalPath> |
||||
|
<SccAuxPath>SAK</SccAuxPath> |
||||
|
<SccProvider>SAK</SccProvider> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>..\WPFToolkit.Extended\bin\Debug\</OutputPath> |
||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>..\WPFToolkit.Extended\bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<Reference Include="Microsoft.Windows.Design.Extensibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
||||
|
<Reference Include="Microsoft.Windows.Design.Interaction, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> |
||||
|
<Reference Include="System" /> |
||||
|
<Reference Include="System.Data" /> |
||||
|
<Reference Include="System.Xml" /> |
||||
|
<Reference Include="Microsoft.CSharp" /> |
||||
|
<Reference Include="System.Core" /> |
||||
|
<Reference Include="System.Xml.Linq" /> |
||||
|
<Reference Include="System.Data.DataSetExtensions" /> |
||||
|
<Reference Include="System.Xaml"> |
||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="WindowsBase" /> |
||||
|
<Reference Include="PresentationCore" /> |
||||
|
<Reference Include="PresentationFramework" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="MetadataStore.cs" /> |
||||
|
<Compile Include="Properties\AssemblyInfo.cs"> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DesignTime>True</DesignTime> |
||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||
|
</Compile> |
||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||
|
</EmbeddedResource> |
||||
|
<None Include="Properties\Settings.settings"> |
||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||
|
</None> |
||||
|
<AppDesigner Include="Properties\" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WPFToolkit.Extended\WPFToolkit.Extended.csproj"> |
||||
|
<Project>{72E591D6-8F83-4D8C-8F67-9C325E623234}</Project> |
||||
|
<Name>WPFToolkit.Extended</Name> |
||||
|
</ProjectReference> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Folder Include="EditorControls\" /> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
|
Other similar extension points exist, see Microsoft.Common.targets. |
||||
|
<Target Name="BeforeBuild"> |
||||
|
</Target> |
||||
|
<Target Name="AfterBuild"> |
||||
|
</Target> |
||||
|
--> |
||||
|
</Project> |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<Application x:Class="WPFToolkit.Extended.Samples.App" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
StartupUri="MainWindow.xaml"> |
||||
|
<Application.Resources> |
||||
|
|
||||
|
</Application.Resources> |
||||
|
</Application> |
||||
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for App.xaml
|
||||
|
/// </summary>
|
||||
|
public partial class App : Application |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
<Window x:Class="WPFToolkit.Extended.Samples.MainWindow" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended" |
||||
|
Title="MainWindow" Height="350" Width="525" > |
||||
|
<Grid> |
||||
|
|
||||
|
</Grid> |
||||
|
</Window> |
||||
@ -0,0 +1,27 @@ |
|||||
|
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.Samples |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for MainWindow.xaml
|
||||
|
/// </summary>
|
||||
|
public partial class MainWindow : Window |
||||
|
{ |
||||
|
public MainWindow() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
|
//the line below to match the UICulture setting in the project file.
|
||||
|
|
||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
|
||||
|
|
||||
|
[assembly: ThemeInfo( |
||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// or application resource dictionaries)
|
||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// app, or any theme specific resource dictionaries)
|
||||
|
)] |
||||
|
|
||||
|
|
||||
|
// Version information for an assembly consists of the following four values:
|
||||
|
//
|
||||
|
// Major Version
|
||||
|
// Minor Version
|
||||
|
// Build Number
|
||||
|
// Revision
|
||||
|
//
|
||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
|
// by using the '*' as shown below:
|
||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
[assembly: AssemblyVersion("1.0.0.0")] |
||||
|
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
@ -0,0 +1,71 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace WPFToolkit.Extended.Samples.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
|
/// </summary>
|
||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
|
// class via a tool like ResGen or Visual Studio.
|
||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
|
// with the /str option, or rebuild your VS project.
|
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
internal class Resources |
||||
|
{ |
||||
|
|
||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||
|
|
||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||
|
|
||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||
|
internal Resources() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Resources.ResourceManager ResourceManager |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if ((resourceMan == null)) |
||||
|
{ |
||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Samples.Properties.Resources", typeof(Resources).Assembly); |
||||
|
resourceMan = temp; |
||||
|
} |
||||
|
return resourceMan; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||
|
/// resource lookups using this strongly typed resource class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Globalization.CultureInfo Culture |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return resourceCulture; |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
resourceCulture = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<root> |
||||
|
<!-- |
||||
|
Microsoft ResX Schema |
||||
|
|
||||
|
Version 2.0 |
||||
|
|
||||
|
The primary goals of this format is to allow a simple XML format |
||||
|
that is mostly human readable. The generation and parsing of the |
||||
|
various data types are done through the TypeConverter classes |
||||
|
associated with the data types. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
... ado.net/XML headers & schema ... |
||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
|
<resheader name="version">2.0</resheader> |
||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
|
</data> |
||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
|
<comment>This is a comment</comment> |
||||
|
</data> |
||||
|
|
||||
|
There are any number of "resheader" rows that contain simple |
||||
|
name/value pairs. |
||||
|
|
||||
|
Each data row contains a name, and value. The row also contains a |
||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||
|
text/value conversion through the TypeConverter architecture. |
||||
|
Classes that don't support this are serialized and stored with the |
||||
|
mimetype set. |
||||
|
|
||||
|
The mimetype is used for serialized objects, and tells the |
||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||
|
|
||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
|
that the ResXResourceWriter will generate, however the reader can |
||||
|
read any of the formats listed below. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
|
value : The object must be serialized into a byte array |
||||
|
: using a System.ComponentModel.TypeConverter |
||||
|
: and then encoded with base64 encoding. |
||||
|
--> |
||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:choice maxOccurs="unbounded"> |
||||
|
<xsd:element name="metadata"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="assembly"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="data"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="resheader"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:choice> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:schema> |
||||
|
<resheader name="resmimetype"> |
||||
|
<value>text/microsoft-resx</value> |
||||
|
</resheader> |
||||
|
<resheader name="version"> |
||||
|
<value>2.0</value> |
||||
|
</resheader> |
||||
|
<resheader name="reader"> |
||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
<resheader name="writer"> |
||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
</root> |
||||
@ -0,0 +1,30 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace 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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version='1.0' encoding='utf-8'?> |
||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||
|
<Profiles> |
||||
|
<Profile Name="(Default)" /> |
||||
|
</Profiles> |
||||
|
<Settings /> |
||||
|
</SettingsFile> |
||||
@ -0,0 +1,113 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
|
<ProductVersion>8.0.30703</ProductVersion> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
<ProjectGuid>{47B3F3DF-FAB7-4D0A-9267-109D30BF387F}</ProjectGuid> |
||||
|
<OutputType>WinExe</OutputType> |
||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
|
<RootNamespace>WPFToolkit.Extended.Samples</RootNamespace> |
||||
|
<AssemblyName>WPFToolkit.Extended.Samples</AssemblyName> |
||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<SccProjectName>SAK</SccProjectName> |
||||
|
<SccLocalPath>SAK</SccLocalPath> |
||||
|
<SccAuxPath>SAK</SccAuxPath> |
||||
|
<SccProvider>SAK</SccProvider> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> |
||||
|
<PlatformTarget>x86</PlatformTarget> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> |
||||
|
<PlatformTarget>x86</PlatformTarget> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<Reference Include="System" /> |
||||
|
<Reference Include="System.Data" /> |
||||
|
<Reference Include="System.Xml" /> |
||||
|
<Reference Include="Microsoft.CSharp" /> |
||||
|
<Reference Include="System.Core" /> |
||||
|
<Reference Include="System.Xml.Linq" /> |
||||
|
<Reference Include="System.Data.DataSetExtensions" /> |
||||
|
<Reference Include="System.Xaml"> |
||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="WindowsBase" /> |
||||
|
<Reference Include="PresentationCore" /> |
||||
|
<Reference Include="PresentationFramework" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ApplicationDefinition Include="App.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</ApplicationDefinition> |
||||
|
<Page Include="MainWindow.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</Page> |
||||
|
<Compile Include="App.xaml.cs"> |
||||
|
<DependentUpon>App.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="MainWindow.xaml.cs"> |
||||
|
<DependentUpon>MainWindow.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="Properties\AssemblyInfo.cs"> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DesignTime>True</DesignTime> |
||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||
|
</Compile> |
||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||
|
</EmbeddedResource> |
||||
|
<None Include="Properties\Settings.settings"> |
||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||
|
</None> |
||||
|
<AppDesigner Include="Properties\" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WPFToolkit.Extended\WPFToolkit.Extended.csproj"> |
||||
|
<Project>{72E591D6-8F83-4D8C-8F67-9C325E623234}</Project> |
||||
|
<Name>WPFToolkit.Extended</Name> |
||||
|
</ProjectReference> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
|
Other similar extension points exist, see Microsoft.Common.targets. |
||||
|
<Target Name="BeforeBuild"> |
||||
|
</Target> |
||||
|
<Target Name="AfterBuild"> |
||||
|
</Target> |
||||
|
--> |
||||
|
</Project> |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" |
||||
|
} |
||||
@ -0,0 +1,266 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Shapes; |
||||
|
using System.Windows.Threading; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// A control to provide a visual indicator when an application is busy.
|
||||
|
/// </summary>
|
||||
|
[TemplateVisualState(Name = VisualStates.StateIdle, GroupName = VisualStates.GroupBusyStatus)] |
||||
|
[TemplateVisualState(Name = VisualStates.StateBusy, GroupName = VisualStates.GroupBusyStatus)] |
||||
|
[TemplateVisualState(Name = VisualStates.StateVisible, GroupName = VisualStates.GroupVisibility)] |
||||
|
[TemplateVisualState(Name = VisualStates.StateHidden, GroupName = VisualStates.GroupVisibility)] |
||||
|
[StyleTypedProperty(Property = "OverlayStyle", StyleTargetType = typeof(Rectangle))] |
||||
|
[StyleTypedProperty(Property = "ProgressBarStyle", StyleTargetType = typeof(ProgressBar))] |
||||
|
public class BusyIndicator : ContentControl |
||||
|
{ |
||||
|
#region Private Members
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Timer used to delay the initial display and avoid flickering.
|
||||
|
/// </summary>
|
||||
|
private DispatcherTimer _displayAfterTimer = new DispatcherTimer(); |
||||
|
|
||||
|
#endregion //Private Members
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static BusyIndicator() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(BusyIndicator), new FrameworkPropertyMetadata(typeof(BusyIndicator))); |
||||
|
} |
||||
|
|
||||
|
public BusyIndicator() |
||||
|
{ |
||||
|
_displayAfterTimer.Tick += DisplayAfterTimerElapsed; |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the OnApplyTemplate method.
|
||||
|
/// </summary>
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
ChangeVisualState(false); |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating whether the BusyContent is visible.
|
||||
|
/// </summary>
|
||||
|
protected bool IsContentVisible { get; set; } |
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Dependency Properties
|
||||
|
|
||||
|
#region IsBusy
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the IsBusy dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register( |
||||
|
"IsBusy", |
||||
|
typeof(bool), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(false, new PropertyChangedCallback(OnIsBusyChanged))); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating whether the busy indicator should show.
|
||||
|
/// </summary>
|
||||
|
public bool IsBusy |
||||
|
{ |
||||
|
get { return (bool)GetValue(IsBusyProperty); } |
||||
|
set { SetValue(IsBusyProperty, value); } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// IsBusyProperty property changed handler.
|
||||
|
/// </summary>
|
||||
|
/// <param name="d">BusyIndicator that changed its IsBusy.</param>
|
||||
|
/// <param name="e">Event arguments.</param>
|
||||
|
private static void OnIsBusyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
((BusyIndicator)d).OnIsBusyChanged(e); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// IsBusyProperty property changed handler.
|
||||
|
/// </summary>
|
||||
|
/// <param name="e">Event arguments.</param>
|
||||
|
protected virtual void OnIsBusyChanged(DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
if (IsBusy) |
||||
|
{ |
||||
|
if (DisplayAfter.Equals(TimeSpan.Zero)) |
||||
|
{ |
||||
|
// Go visible now
|
||||
|
IsContentVisible = true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// Set a timer to go visible
|
||||
|
_displayAfterTimer.Interval = DisplayAfter; |
||||
|
_displayAfterTimer.Start(); |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// No longer visible
|
||||
|
_displayAfterTimer.Stop(); |
||||
|
IsContentVisible = false; |
||||
|
} |
||||
|
|
||||
|
ChangeVisualState(true); |
||||
|
} |
||||
|
|
||||
|
#endregion //IsBusy
|
||||
|
|
||||
|
#region Busy Content
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the BusyContent dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty BusyContentProperty = DependencyProperty.Register( |
||||
|
"BusyContent", |
||||
|
typeof(object), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(null)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating the busy content to display to the user.
|
||||
|
/// </summary>
|
||||
|
public object BusyContent |
||||
|
{ |
||||
|
get { return (object)GetValue(BusyContentProperty); } |
||||
|
set { SetValue(BusyContentProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Busy Content
|
||||
|
|
||||
|
#region Busy Content Template
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the BusyTemplate dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty BusyContentTemplateProperty = DependencyProperty.Register( |
||||
|
"BusyContentTemplate", |
||||
|
typeof(DataTemplate), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(null)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating the template to use for displaying the busy content to the user.
|
||||
|
/// </summary>
|
||||
|
public DataTemplate BusyContentTemplate |
||||
|
{ |
||||
|
get { return (DataTemplate)GetValue(BusyContentTemplateProperty); } |
||||
|
set { SetValue(BusyContentTemplateProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Busy Content Template
|
||||
|
|
||||
|
#region Display After
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the DisplayAfter dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty DisplayAfterProperty = DependencyProperty.Register( |
||||
|
"DisplayAfter", |
||||
|
typeof(TimeSpan), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(TimeSpan.FromSeconds(0.1))); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating how long to delay before displaying the busy content.
|
||||
|
/// </summary>
|
||||
|
public TimeSpan DisplayAfter |
||||
|
{ |
||||
|
get { return (TimeSpan)GetValue(DisplayAfterProperty); } |
||||
|
set { SetValue(DisplayAfterProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Display After
|
||||
|
|
||||
|
#region Overlay Style
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the OverlayStyle dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty OverlayStyleProperty = DependencyProperty.Register( |
||||
|
"OverlayStyle", |
||||
|
typeof(Style), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(null)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating the style to use for the overlay.
|
||||
|
/// </summary>
|
||||
|
public Style OverlayStyle |
||||
|
{ |
||||
|
get { return (Style)GetValue(OverlayStyleProperty); } |
||||
|
set { SetValue(OverlayStyleProperty, value); } |
||||
|
} |
||||
|
#endregion //Overlay Style
|
||||
|
|
||||
|
#region ProgressBar Style
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the ProgressBarStyle dependency property.
|
||||
|
/// </summary>
|
||||
|
public static readonly DependencyProperty ProgressBarStyleProperty = DependencyProperty.Register( |
||||
|
"ProgressBarStyle", |
||||
|
typeof(Style), |
||||
|
typeof(BusyIndicator), |
||||
|
new PropertyMetadata(null)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating the style to use for the progress bar.
|
||||
|
/// </summary>
|
||||
|
public Style ProgressBarStyle |
||||
|
{ |
||||
|
get { return (Style)GetValue(ProgressBarStyleProperty); } |
||||
|
set { SetValue(ProgressBarStyleProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //ProgressBar Style
|
||||
|
|
||||
|
#endregion //Dependency Properties
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Handler for the DisplayAfterTimer.
|
||||
|
/// </summary>
|
||||
|
/// <param name="sender">Event sender.</param>
|
||||
|
/// <param name="e">Event arguments.</param>
|
||||
|
private void DisplayAfterTimerElapsed(object sender, EventArgs e) |
||||
|
{ |
||||
|
_displayAfterTimer.Stop(); |
||||
|
IsContentVisible = true; |
||||
|
ChangeVisualState(true); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Changes the control's visual state(s).
|
||||
|
/// </summary>
|
||||
|
/// <param name="useTransitions">True if state transitions should be used.</param>
|
||||
|
protected virtual void ChangeVisualState(bool useTransitions) |
||||
|
{ |
||||
|
VisualStateManager.GoToState(this, IsBusy ? VisualStates.StateBusy : VisualStates.StateIdle, useTransitions); |
||||
|
VisualStateManager.GoToState(this, IsContentVisible ? VisualStates.StateVisible : VisualStates.StateHidden, useTransitions); |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
internal static partial class VisualStates |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Busyness group name.
|
||||
|
/// </summary>
|
||||
|
public const string GroupBusyStatus = "BusyStatusStates"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Busy state for BusyIndicator.
|
||||
|
/// </summary>
|
||||
|
public const string StateBusy = "Busy"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Idle state for BusyIndicator.
|
||||
|
/// </summary>
|
||||
|
public const string StateIdle = "Idle"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// BusyDisplay group.
|
||||
|
/// </summary>
|
||||
|
public const string GroupVisibility = "VisibilityStates"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Visible state name for BusyIndicator.
|
||||
|
/// </summary>
|
||||
|
public const string StateVisible = "Visible"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Hidden state name for BusyIndicator.
|
||||
|
/// </summary>
|
||||
|
public const string StateHidden = "Hidden"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,191 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Markup; |
||||
|
using System.Windows.Controls.Primitives; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents a spinner control that includes two Buttons.
|
||||
|
/// </summary>
|
||||
|
[ContentProperty("Content")] |
||||
|
public class ButtonSpinner : Spinner |
||||
|
{ |
||||
|
#region Properties
|
||||
|
|
||||
|
#region Content
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the Content dependency property.
|
||||
|
/// </summary>
|
||||
|
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); } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// ContentProperty property changed handler.
|
||||
|
/// </summary>
|
||||
|
/// <param name="d">ButtonSpinner that changed its Content.</param>
|
||||
|
/// <param name="e">Event arguments.</param>
|
||||
|
private static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
ButtonSpinner source = d as ButtonSpinner; |
||||
|
source.OnContentChanged(e.OldValue, e.NewValue); |
||||
|
} |
||||
|
|
||||
|
#endregion //Content
|
||||
|
|
||||
|
private ButtonBase _increaseButton; |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the IncreaseButton template part.
|
||||
|
/// </summary>
|
||||
|
private ButtonBase IncreaseButton |
||||
|
{ |
||||
|
get { return _increaseButton; } |
||||
|
set |
||||
|
{ |
||||
|
if (_increaseButton != null) |
||||
|
{ |
||||
|
_increaseButton.Click -= OnButtonClick; |
||||
|
} |
||||
|
|
||||
|
_increaseButton = value; |
||||
|
|
||||
|
if (_increaseButton != null) |
||||
|
{ |
||||
|
_increaseButton.Click += OnButtonClick; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
private ButtonBase _decreaseButton; |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the DecreaseButton template part.
|
||||
|
/// </summary>
|
||||
|
private ButtonBase DecreaseButton |
||||
|
{ |
||||
|
get { return _decreaseButton; } |
||||
|
set |
||||
|
{ |
||||
|
if (_decreaseButton != null) |
||||
|
{ |
||||
|
_decreaseButton.Click -= OnButtonClick; |
||||
|
} |
||||
|
|
||||
|
_decreaseButton = value; |
||||
|
|
||||
|
if (_decreaseButton != null) |
||||
|
{ |
||||
|
_decreaseButton.Click += OnButtonClick; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#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(); |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Occurs when the Content property value changed.
|
||||
|
/// </summary>
|
||||
|
/// <param name="oldValue">The old value of the Content property.</param>
|
||||
|
/// <param name="newValue">The new value of the Content property.</param>
|
||||
|
protected virtual void OnContentChanged(object oldValue, object newValue) { } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Handle click event of IncreaseButton and DecreaseButton template parts,
|
||||
|
/// translating Click to appropriate Spin event.
|
||||
|
/// </summary>
|
||||
|
/// <param name="sender">Event sender, should be either IncreaseButton or DecreaseButton template part.</param>
|
||||
|
/// <param name="e">Event args.</param>
|
||||
|
private void OnButtonClick(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
SpinDirection direction = sender == IncreaseButton ? SpinDirection.Increase : SpinDirection.Decrease; |
||||
|
OnSpin(new SpinEventArgs(direction)); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Cancel LeftMouseButtonUp events originating from a button that has
|
||||
|
/// been changed to disabled.
|
||||
|
/// </summary>
|
||||
|
/// <param name="e">The data for the event.</param>
|
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Called when valid spin direction changed.
|
||||
|
/// </summary>
|
||||
|
/// <param name="oldValue">The old value.</param>
|
||||
|
/// <param name="newValue">The new value.</param>
|
||||
|
protected override void OnValidSpinDirectionChanged(ValidSpinDirections oldValue, ValidSpinDirections newValue) |
||||
|
{ |
||||
|
SetButtonUsage(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Disables or enables the buttons based on the valid spin direction.
|
||||
|
/// </summary>
|
||||
|
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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents spin directions that could be initiated by the end-user.
|
||||
|
/// </summary>
|
||||
|
/// <QualityBand>Preview</QualityBand>
|
||||
|
public enum SpinDirection |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents a spin initiated by the end-user in order to Increase a value.
|
||||
|
/// </summary>
|
||||
|
Increase = 0, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a spin initiated by the end-user in order to Decrease a value.
|
||||
|
/// </summary>
|
||||
|
Decrease = 1 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Provides data for the Spinner.Spin event.
|
||||
|
/// </summary>
|
||||
|
/// <QualityBand>Preview</QualityBand>
|
||||
|
public class SpinEventArgs : RoutedEventArgs |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets the SpinDirection for the spin that has been initiated by the
|
||||
|
/// end-user.
|
||||
|
/// </summary>
|
||||
|
public SpinDirection Direction { get; private set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the SpinEventArgs class.
|
||||
|
/// </summary>
|
||||
|
/// <param name="direction">Spin direction.</param>
|
||||
|
public SpinEventArgs(SpinDirection direction) |
||||
|
: base() |
||||
|
{ |
||||
|
Direction = direction; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,75 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Base class for controls that represents controls that can spin.
|
||||
|
/// </summary>
|
||||
|
public abstract class Spinner : Control |
||||
|
{ |
||||
|
#region Properties
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Identifies the ValidSpinDirection dependency property.
|
||||
|
/// </summary>
|
||||
|
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); } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// ValidSpinDirectionProperty property changed handler.
|
||||
|
/// </summary>
|
||||
|
/// <param name="d">ButtonSpinner that changed its ValidSpinDirection.</param>
|
||||
|
/// <param name="e">Event arguments.</param>
|
||||
|
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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Occurs when spinning is initiated by the end-user.
|
||||
|
/// </summary>
|
||||
|
public event EventHandler<SpinEventArgs> Spin; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the Spinner class.
|
||||
|
/// </summary>
|
||||
|
protected Spinner() { } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Raises the OnSpin event when spinning is initiated by the end-user.
|
||||
|
/// </summary>
|
||||
|
/// <param name="e">Spin event args.</param>
|
||||
|
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<SpinEventArgs> handler = Spin; |
||||
|
if (handler != null) |
||||
|
{ |
||||
|
handler(this, e); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Called when valid spin direction changed.
|
||||
|
/// </summary>
|
||||
|
/// <param name="oldValue">The old value.</param>
|
||||
|
/// <param name="newValue">The new value.</param>
|
||||
|
protected virtual void OnValidSpinDirectionChanged(ValidSpinDirections oldValue, ValidSpinDirections newValue) { } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents spin directions that are valid.
|
||||
|
/// </summary>
|
||||
|
[Flags] |
||||
|
public enum ValidSpinDirections |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Can not increase nor decrease.
|
||||
|
/// </summary>
|
||||
|
None = 0, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Can increase.
|
||||
|
/// </summary>
|
||||
|
Increase = 1, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Can decrease.
|
||||
|
/// </summary>
|
||||
|
Decrease = 2 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,539 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Input; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Controls.Primitives; |
||||
|
using System.ComponentModel; |
||||
|
using System.Windows.Shapes; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
[TemplateVisualState(GroupName = VisualStates.WindowStatesGroup, Name = VisualStates.Open)] |
||||
|
[TemplateVisualState(GroupName = VisualStates.WindowStatesGroup, Name = VisualStates.Closed)] |
||||
|
public class ChildWindow : ContentControl |
||||
|
{ |
||||
|
#region Private Members
|
||||
|
|
||||
|
private Grid _root; |
||||
|
private TranslateTransform _moveTransform = new TranslateTransform(); |
||||
|
private bool _startupPositionInitialized; |
||||
|
private bool _isMouseCaptured; |
||||
|
private Point _clickPoint; |
||||
|
private Point _oldPosition; |
||||
|
private Border _dragWidget; |
||||
|
private FrameworkElement _parentContainer; |
||||
|
private Rectangle _modalLayer = new Rectangle(); |
||||
|
private Canvas _modalLayerPanel = new Canvas(); |
||||
|
|
||||
|
#endregion //Private Members
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static ChildWindow() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(ChildWindow), new FrameworkPropertyMetadata(typeof(ChildWindow))); |
||||
|
} |
||||
|
|
||||
|
public ChildWindow() |
||||
|
{ |
||||
|
_modalLayer.Fill = new SolidColorBrush(Colors.Gray); |
||||
|
_modalLayer.Opacity = 0.5; |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
|
||||
|
_dragWidget = (Border)GetTemplateChild("PART_DragWidget"); |
||||
|
if (_dragWidget != null) |
||||
|
{ |
||||
|
_dragWidget.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(HeaderLeftMouseButtonDown), true); |
||||
|
_dragWidget.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(HeaderMouseLeftButtonUp), true); |
||||
|
_dragWidget.MouseMove += (o, e) => HeaderMouseMove(e); |
||||
|
} |
||||
|
|
||||
|
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
||||
|
if (CloseButton != null) |
||||
|
CloseButton.Click += (o, e) => Close(); |
||||
|
|
||||
|
//Overlay = GetTemplateChild("PART_Overlay") as Panel;
|
||||
|
WindowRoot = GetTemplateChild("PART_WindowRoot") as Grid; |
||||
|
|
||||
|
WindowRoot.RenderTransform = _moveTransform; |
||||
|
|
||||
|
|
||||
|
_parentContainer = VisualTreeHelper.GetParent(this) as FrameworkElement; |
||||
|
|
||||
|
//this is for XBAP applications only. When inside an XBAP the parent container has no height or width until it has loaded. Therefore
|
||||
|
//we need to handle the loaded event and reposition the window.
|
||||
|
if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted) |
||||
|
{ |
||||
|
_parentContainer.Loaded += (o, e) => |
||||
|
{ |
||||
|
CenterChildWindow(); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
_parentContainer.LayoutUpdated += ParentContainer_LayoutUpdated; |
||||
|
_parentContainer.SizeChanged += (o, ea) => |
||||
|
{ |
||||
|
_modalLayer.Height = ea.NewSize.Height; |
||||
|
_modalLayer.Width = ea.NewSize.Width; |
||||
|
}; |
||||
|
|
||||
|
_root = GetTemplateChild("Root") as Grid; |
||||
|
_root.Children.Add(_modalLayerPanel); |
||||
|
|
||||
|
ChangeVisualState(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region Internal Properties
|
||||
|
|
||||
|
internal Grid WindowRoot { get; private set; } |
||||
|
internal Thumb DragWidget { get; private set; } |
||||
|
internal Button MinimizeButton { get; private set; } |
||||
|
internal Button MaximizeButton { get; private set; } |
||||
|
internal Button CloseButton { get; private set; } |
||||
|
|
||||
|
#endregion //Internal Properties
|
||||
|
|
||||
|
#region Dependency Properties
|
||||
|
|
||||
|
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(ChildWindow), new UIPropertyMetadata(String.Empty)); |
||||
|
public string Caption |
||||
|
{ |
||||
|
get { return (string)GetValue(CaptionProperty); } |
||||
|
set { SetValue(CaptionProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(ChildWindow), new UIPropertyMetadata(null)); |
||||
|
public Brush CaptionForeground |
||||
|
{ |
||||
|
get { return (Brush)GetValue(CaptionForegroundProperty); } |
||||
|
set { SetValue(CaptionForegroundProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(ChildWindow), new PropertyMetadata(null)); |
||||
|
public Style CloseButtonStyle |
||||
|
{ |
||||
|
get { return (Style)GetValue(CloseButtonStyleProperty); } |
||||
|
set { SetValue(CloseButtonStyleProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty CloseButtonVisibilityProperty = DependencyProperty.Register("CloseButtonVisibility", typeof(Visibility), typeof(ChildWindow), new PropertyMetadata(Visibility.Visible)); |
||||
|
public Visibility CloseButtonVisibility |
||||
|
{ |
||||
|
get { return (Visibility)GetValue(CloseButtonVisibilityProperty); } |
||||
|
set { SetValue(CloseButtonVisibilityProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register("Icon", typeof(ImageSource), typeof(ChildWindow), new UIPropertyMetadata(default(ImageSource))); |
||||
|
public ImageSource Icon |
||||
|
{ |
||||
|
get { return (ImageSource)GetValue(IconSourceProperty); } |
||||
|
set { SetValue(IconSourceProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty IsModalProperty = DependencyProperty.Register("IsModal", typeof(bool), typeof(ChildWindow), new UIPropertyMetadata(false, new PropertyChangedCallback(OnIsModalPropertyChanged))); |
||||
|
public bool IsModal |
||||
|
{ |
||||
|
get { return (bool)GetValue(IsModalProperty); } |
||||
|
set { SetValue(IsModalProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnIsModalPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
ChildWindow childWindow = (ChildWindow)d; |
||||
|
if ((bool)e.NewValue) |
||||
|
childWindow.ShowModalLayer(); |
||||
|
else |
||||
|
childWindow.HideModalLayer(); |
||||
|
} |
||||
|
|
||||
|
#region Left
|
||||
|
|
||||
|
public static readonly DependencyProperty LeftProperty = DependencyProperty.Register("Left", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnLeftPropertyChanged))); |
||||
|
public double Left |
||||
|
{ |
||||
|
get { return (double)GetValue(LeftProperty); } |
||||
|
set { SetValue(LeftProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnLeftPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
ChildWindow window = (ChildWindow)obj; |
||||
|
window.Left = window.GetRestrictedLeft(); |
||||
|
window.ProcessMove((double)e.NewValue - (double)e.OldValue, 0); |
||||
|
} |
||||
|
|
||||
|
#endregion //Left
|
||||
|
|
||||
|
#region OverlayBrush
|
||||
|
|
||||
|
public static readonly DependencyProperty OverlayBrushProperty = DependencyProperty.Register("OverlayBrush", typeof(Brush), typeof(ChildWindow)); |
||||
|
public Brush OverlayBrush |
||||
|
{ |
||||
|
get { return (Brush)GetValue(OverlayBrushProperty); } |
||||
|
set { SetValue(OverlayBrushProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //OverlayBrush
|
||||
|
|
||||
|
#region OverlayOpacity
|
||||
|
|
||||
|
public static readonly DependencyProperty OverlayOpacityProperty = DependencyProperty.Register("OverlayOpacity", typeof(double), typeof(ChildWindow)); |
||||
|
public double OverlayOpacity |
||||
|
{ |
||||
|
get { return (double)GetValue(OverlayOpacityProperty); } |
||||
|
set { SetValue(OverlayOpacityProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //OverlayOpacity
|
||||
|
|
||||
|
#region Top
|
||||
|
|
||||
|
public static readonly DependencyProperty TopProperty = DependencyProperty.Register("Top", typeof(double), typeof(ChildWindow), new PropertyMetadata(0.0, new PropertyChangedCallback(OnTopPropertyChanged))); |
||||
|
public double Top |
||||
|
{ |
||||
|
get { return (double)GetValue(TopProperty); } |
||||
|
set { SetValue(TopProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnTopPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
ChildWindow window = (ChildWindow)obj; |
||||
|
window.Top = window.GetRestrictedTop(); |
||||
|
window.ProcessMove(0, (double)e.NewValue - (double)e.OldValue); |
||||
|
} |
||||
|
|
||||
|
#endregion //TopProperty
|
||||
|
|
||||
|
public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
||||
|
public Brush WindowBackground |
||||
|
{ |
||||
|
get { return (Brush)GetValue(WindowBackgroundProperty); } |
||||
|
set { SetValue(WindowBackgroundProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(ChildWindow), new PropertyMetadata(null)); |
||||
|
public Brush WindowBorderBrush |
||||
|
{ |
||||
|
get { return (Brush)GetValue(WindowBorderBrushProperty); } |
||||
|
set { SetValue(WindowBorderBrushProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(ChildWindow), new PropertyMetadata(null)); |
||||
|
public double WindowOpacity |
||||
|
{ |
||||
|
get { return (double)GetValue(WindowOpacityProperty); } |
||||
|
set { SetValue(WindowOpacityProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#region WindowState
|
||||
|
|
||||
|
public static readonly DependencyProperty WindowStateProperty = DependencyProperty.Register("WindowState", typeof(WindowState), typeof(ChildWindow), new PropertyMetadata(WindowState.Open, new PropertyChangedCallback(OnWindowStatePropertyChanged))); |
||||
|
public WindowState WindowState |
||||
|
{ |
||||
|
get { return (WindowState)GetValue(WindowStateProperty); } |
||||
|
set { SetValue(WindowStateProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnWindowStatePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
ChildWindow window = (ChildWindow)obj; |
||||
|
window.SetWindowState((WindowState)e.NewValue); |
||||
|
} |
||||
|
|
||||
|
#endregion //WindowState
|
||||
|
|
||||
|
#endregion //Dependency Properties
|
||||
|
|
||||
|
private bool? _dialogResult; |
||||
|
/// <summary>
|
||||
|
/// Gets or sets a value indicating whether the ChildWindow was accepted or canceled.
|
||||
|
/// </summary>
|
||||
|
/// <value>
|
||||
|
/// True if the child window was accepted; false if the child window was
|
||||
|
/// canceled. The default is null.
|
||||
|
/// </value>
|
||||
|
[TypeConverter(typeof(NullableBoolConverter))] |
||||
|
public bool? DialogResult |
||||
|
{ |
||||
|
get { return _dialogResult; } |
||||
|
set |
||||
|
{ |
||||
|
if (_dialogResult != value) |
||||
|
{ |
||||
|
_dialogResult = value; |
||||
|
Close(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Event Handlers
|
||||
|
|
||||
|
void HeaderLeftMouseButtonDown(object sender, MouseButtonEventArgs e) |
||||
|
{ |
||||
|
e.Handled = true; |
||||
|
Focus(); |
||||
|
_dragWidget.CaptureMouse(); |
||||
|
_isMouseCaptured = true; |
||||
|
_clickPoint = e.GetPosition(null); //save off the mouse position
|
||||
|
_oldPosition = new Point(Left, Top); //save off our original window position
|
||||
|
} |
||||
|
|
||||
|
private void HeaderMouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
||||
|
{ |
||||
|
e.Handled = true; |
||||
|
_dragWidget.ReleaseMouseCapture(); |
||||
|
_isMouseCaptured = false; |
||||
|
} |
||||
|
|
||||
|
private void HeaderMouseMove(MouseEventArgs e) |
||||
|
{ |
||||
|
if (_isMouseCaptured && Visibility == Visibility.Visible) |
||||
|
{ |
||||
|
Point currentPosition = e.GetPosition(null); //our current mouse position
|
||||
|
|
||||
|
Left = _oldPosition.X + (currentPosition.X - _clickPoint.X); |
||||
|
Top = _oldPosition.Y + (currentPosition.Y - _clickPoint.Y); |
||||
|
|
||||
|
//this helps keep our mouse position in sync with the drag widget position
|
||||
|
Point dragWidgetPosition = e.GetPosition(_dragWidget); |
||||
|
if (dragWidgetPosition.X < 0 || dragWidgetPosition.X > _dragWidget.ActualWidth || dragWidgetPosition.Y < 0 || dragWidgetPosition.Y > _dragWidget.ActualHeight) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
_oldPosition = new Point(Left, Top); |
||||
|
_clickPoint = e.GetPosition(Window.GetWindow(this)); //store the point where we are relative to the window
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ParentContainer_LayoutUpdated(object sender, EventArgs e) |
||||
|
{ |
||||
|
if (DesignerProperties.GetIsInDesignMode(this)) |
||||
|
return; |
||||
|
|
||||
|
//we only want to set the start position if this is the first time the control has bee initialized
|
||||
|
if (!_startupPositionInitialized) |
||||
|
{ |
||||
|
SetStartupPosition(); |
||||
|
_startupPositionInitialized = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Handlers
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
#region Private
|
||||
|
|
||||
|
private double GetRestrictedLeft() |
||||
|
{ |
||||
|
if (_parentContainer != null) |
||||
|
{ |
||||
|
if (Left < 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
if (Left + WindowRoot.ActualWidth > _parentContainer.ActualWidth && _parentContainer.ActualWidth != 0) |
||||
|
{ |
||||
|
return _parentContainer.ActualWidth - WindowRoot.ActualWidth; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Left; |
||||
|
} |
||||
|
|
||||
|
private double GetRestrictedTop() |
||||
|
{ |
||||
|
if (_parentContainer != null ) |
||||
|
{ |
||||
|
if (Top < 0) |
||||
|
{ |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
if (Top + WindowRoot.ActualHeight > _parentContainer.ActualHeight && _parentContainer.ActualHeight != 0) |
||||
|
{ |
||||
|
return _parentContainer.ActualHeight - WindowRoot.ActualHeight; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return Top; |
||||
|
} |
||||
|
|
||||
|
private void SetWindowState(WindowState state) |
||||
|
{ |
||||
|
switch (state) |
||||
|
{ |
||||
|
case WindowState.Closed: |
||||
|
{ |
||||
|
ExecuteClose(); |
||||
|
break; |
||||
|
} |
||||
|
case WindowState.Open: |
||||
|
{ |
||||
|
ExecuteOpen(); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ChangeVisualState(); |
||||
|
} |
||||
|
|
||||
|
private void ExecuteClose() |
||||
|
{ |
||||
|
CancelEventArgs e = new CancelEventArgs(); |
||||
|
OnClosing(e); |
||||
|
|
||||
|
if (!e.Cancel) |
||||
|
{ |
||||
|
if (!_dialogResult.HasValue) |
||||
|
_dialogResult = false; |
||||
|
|
||||
|
OnClosed(EventArgs.Empty); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_dialogResult = null; //if the Close is cancelled, DialogResult should always be NULL:
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ExecuteOpen() |
||||
|
{ |
||||
|
_dialogResult = null; //reset the dialogResult to null each time the window is opened
|
||||
|
BringToFront(); |
||||
|
} |
||||
|
|
||||
|
private void BringToFront() |
||||
|
{ |
||||
|
int index = 0; |
||||
|
|
||||
|
if (_parentContainer != null) |
||||
|
{ |
||||
|
index = (int)_parentContainer.GetValue(Canvas.ZIndexProperty); |
||||
|
} |
||||
|
|
||||
|
this.SetValue(Canvas.ZIndexProperty, ++index); |
||||
|
|
||||
|
if (IsModal) |
||||
|
{ |
||||
|
Canvas.SetZIndex(_modalLayerPanel, -1); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void SetStartupPosition() |
||||
|
{ |
||||
|
CenterChildWindow(); |
||||
|
BringToFront(); |
||||
|
} |
||||
|
|
||||
|
private void CenterChildWindow() |
||||
|
{ |
||||
|
_moveTransform.X = _moveTransform.Y = 0; |
||||
|
|
||||
|
if (_parentContainer != null) |
||||
|
{ |
||||
|
Left = (_parentContainer.ActualWidth - WindowRoot.ActualWidth) / 2.0; |
||||
|
Top = (_parentContainer.ActualHeight - WindowRoot.ActualHeight) / 2.0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual void ChangeVisualState() |
||||
|
{ |
||||
|
if (WindowState == WindowState.Closed) |
||||
|
{ |
||||
|
VisualStateManager.GoToState(this, VisualStates.Closed, true); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
VisualStateManager.GoToState(this, VisualStates.Open, true); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ShowModalLayer() |
||||
|
{ |
||||
|
if (!DesignerProperties.GetIsInDesignMode(this)) |
||||
|
{ |
||||
|
if (!_modalLayerPanel.Children.Contains(_modalLayer)) |
||||
|
_modalLayerPanel.Children.Add(_modalLayer); |
||||
|
|
||||
|
BringToFront(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void HideModalLayer() |
||||
|
{ |
||||
|
if (_modalLayerPanel.Children.Contains(_modalLayer)) |
||||
|
_modalLayerPanel.Children.Remove(_modalLayer); |
||||
|
} |
||||
|
|
||||
|
#endregion //Private
|
||||
|
|
||||
|
#region Protected
|
||||
|
|
||||
|
protected void ProcessMove(double x, double y) |
||||
|
{ |
||||
|
_moveTransform.X += x; |
||||
|
_moveTransform.Y += y; |
||||
|
} |
||||
|
|
||||
|
#endregion //Protected
|
||||
|
|
||||
|
#region Public
|
||||
|
|
||||
|
public void Show() |
||||
|
{ |
||||
|
WindowState = WindowState.Open; |
||||
|
} |
||||
|
|
||||
|
public void Close() |
||||
|
{ |
||||
|
WindowState = WindowState.Closed; |
||||
|
} |
||||
|
|
||||
|
#endregion //Public
|
||||
|
|
||||
|
#endregion //Methods
|
||||
|
|
||||
|
#region Events
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Occurs when the ChildWindow is closed.
|
||||
|
/// </summary>
|
||||
|
public event EventHandler Closed; |
||||
|
protected virtual void OnClosed(EventArgs e) |
||||
|
{ |
||||
|
if (Closed != null) |
||||
|
Closed(this, e); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Occurs when the ChildWindow is closing.
|
||||
|
/// </summary>
|
||||
|
public event EventHandler<CancelEventArgs> Closing; |
||||
|
protected virtual void OnClosing(CancelEventArgs e) |
||||
|
{ |
||||
|
if (Closing != null) |
||||
|
Closing(this, e); |
||||
|
} |
||||
|
|
||||
|
#endregion //Events
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
internal static partial class VisualStates |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Window State group name.
|
||||
|
/// </summary>
|
||||
|
public const string WindowStatesGroup = "WindowStatesGroup"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Open state name for ChildWindow.
|
||||
|
/// </summary>
|
||||
|
public const string Open = "Open"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Closed state name for ChildWindow.
|
||||
|
/// </summary>
|
||||
|
public const string Closed = "Closed"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public enum WindowState |
||||
|
{ |
||||
|
Closed, |
||||
|
Open |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,221 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Controls.Primitives; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Reflection; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public class ColorPicker : Control |
||||
|
{ |
||||
|
#region Members
|
||||
|
|
||||
|
ToggleButton _colorPickerToggleButton; |
||||
|
Popup _colorPickerCanvasPopup; |
||||
|
ListBox _availableColors; |
||||
|
ListBox _standardColors; |
||||
|
ListBox _recentColors; |
||||
|
|
||||
|
#endregion //Members
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region AvailableColors
|
||||
|
|
||||
|
public static readonly DependencyProperty AvailableColorsProperty = DependencyProperty.Register("AvailableColors", typeof(ObservableCollection<ColorItem>), typeof(ColorPicker), new UIPropertyMetadata(CreateAvailableColors())); |
||||
|
public ObservableCollection<ColorItem> AvailableColors |
||||
|
{ |
||||
|
get { return (ObservableCollection<ColorItem>)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 RecenColors
|
||||
|
|
||||
|
public static readonly DependencyProperty RecentColorsProperty = DependencyProperty.Register("RecentColors", typeof(ObservableCollection<ColorItem>), typeof(ColorPicker), new UIPropertyMetadata(null)); |
||||
|
public ObservableCollection<ColorItem> RecentColors |
||||
|
{ |
||||
|
get { return (ObservableCollection<ColorItem>)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) |
||||
|
{ |
||||
|
RoutedPropertyChangedEventArgs<Color> args = new RoutedPropertyChangedEventArgs<Color>(oldValue, newValue); |
||||
|
args.RoutedEvent = ColorPicker.SelectedColorChangedEvent; |
||||
|
RaiseEvent(args); |
||||
|
} |
||||
|
|
||||
|
#endregion //SelectedColor
|
||||
|
|
||||
|
#region StandardColors
|
||||
|
|
||||
|
public static readonly DependencyProperty StandardColorsProperty = DependencyProperty.Register("StandardColors", typeof(ObservableCollection<ColorItem>), typeof(ColorPicker), new UIPropertyMetadata(CreateStandardColors())); |
||||
|
public ObservableCollection<ColorItem> StandardColors |
||||
|
{ |
||||
|
get { return (ObservableCollection<ColorItem>)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<ColorItem>(); |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
|
||||
|
_colorPickerToggleButton = (ToggleButton)GetTemplateChild("PART_ColorPickerToggleButton"); |
||||
|
_colorPickerToggleButton.Click += ColorPickerToggleButton_Clicked; |
||||
|
|
||||
|
_colorPickerCanvasPopup = (Popup)GetTemplateChild("PART_ColorPickerPalettePopup"); |
||||
|
|
||||
|
_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 ColorPickerToggleButton_Clicked(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
_colorPickerCanvasPopup.IsOpen = _colorPickerToggleButton.IsChecked ?? false; |
||||
|
} |
||||
|
|
||||
|
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<Color>), typeof(ColorPicker)); |
||||
|
public event RoutedPropertyChangedEventHandler<Color> SelectedColorChanged |
||||
|
{ |
||||
|
add { AddHandler(SelectedColorChangedEvent, value); } |
||||
|
remove { RemoveHandler(SelectedColorChangedEvent, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Events
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
private void CloseColorPicker() |
||||
|
{ |
||||
|
_colorPickerToggleButton.IsChecked = false; |
||||
|
_colorPickerCanvasPopup.IsOpen = false; |
||||
|
} |
||||
|
|
||||
|
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<ColorItem> CreateStandardColors() |
||||
|
{ |
||||
|
ObservableCollection<ColorItem> _standardColors = new ObservableCollection<ColorItem>(); |
||||
|
_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, "Geen")); |
||||
|
_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.Brown, "Brown")); |
||||
|
_standardColors.Add(new ColorItem(Colors.Purple, "Purple")); |
||||
|
return _standardColors; |
||||
|
} |
||||
|
|
||||
|
private static ObservableCollection<ColorItem> CreateAvailableColors() |
||||
|
{ |
||||
|
ObservableCollection<ColorItem> _standardColors = new ObservableCollection<ColorItem>(); |
||||
|
|
||||
|
PropertyInfo[] properties = typeof(Colors).GetProperties(BindingFlags.Static | BindingFlags.Public); |
||||
|
foreach (PropertyInfo info in properties) |
||||
|
{ |
||||
|
if (String.Compare(info.Name, "Transparent", false) != 0) |
||||
|
{ |
||||
|
Color c = (Color)info.GetValue(typeof(Colors), null); |
||||
|
var colorItem = new ColorItem(c, info.Name); |
||||
|
if (!_standardColors.Contains(colorItem)) |
||||
|
_standardColors.Add(colorItem); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return _standardColors; |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,186 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.Primitives |
||||
|
{ |
||||
|
public abstract class InputBase : Control |
||||
|
{ |
||||
|
#region Members
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Flags if the Text and Value properties are in the process of being sync'd
|
||||
|
/// </summary>
|
||||
|
private bool _isSyncingTextAndValueProperties; |
||||
|
private bool _isInitialized; |
||||
|
|
||||
|
#endregion //Members
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
public virtual object PreviousValue { get; internal set; } |
||||
|
|
||||
|
#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 FrameworkPropertyMetadata(default(String), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTextPropertyChanged)); |
||||
|
public string Text |
||||
|
{ |
||||
|
get { return (string)this.GetValue(TextProperty); } |
||||
|
set { this.SetValue(TextProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
InputBase input = (InputBase)d; |
||||
|
input.OnTextChanged((string)e.OldValue, (string)e.NewValue); |
||||
|
if (input._isInitialized) |
||||
|
input.SyncTextAndValueProperties(e.Property, e.NewValue); |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnTextChanged(string previousValue, string currentValue) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#endregion //Text
|
||||
|
|
||||
|
#region Value
|
||||
|
|
||||
|
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(object), typeof(InputBase), new FrameworkPropertyMetadata(default(object), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValuePropertyChanged, OnCoerceValuePropertyCallback)); |
||||
|
public virtual object Value |
||||
|
{ |
||||
|
get { return (object)GetValue(ValueProperty); } |
||||
|
set { SetValue(ValueProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
InputBase input = (InputBase)d; |
||||
|
|
||||
|
if (e.OldValue != e.NewValue) |
||||
|
{ |
||||
|
input.PreviousValue = e.OldValue; |
||||
|
input.OnValueChanged(e.OldValue, e.NewValue); |
||||
|
|
||||
|
if (input._isInitialized) |
||||
|
input.SyncTextAndValueProperties(e.Property, e.NewValue); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnValueChanged(object oldValue, object newValue) |
||||
|
{ |
||||
|
RoutedPropertyChangedEventArgs<object> args = new RoutedPropertyChangedEventArgs<object>(oldValue, newValue); |
||||
|
args.RoutedEvent = InputBase.ValueChangedEvent; |
||||
|
RaiseEvent(args); |
||||
|
} |
||||
|
|
||||
|
private static object OnCoerceValuePropertyCallback(DependencyObject d, object baseValue) |
||||
|
{ |
||||
|
InputBase inputBase = d as InputBase; |
||||
|
if (inputBase != null) |
||||
|
return inputBase.OnCoerceValue(baseValue); |
||||
|
else |
||||
|
return baseValue; |
||||
|
} |
||||
|
|
||||
|
protected virtual object OnCoerceValue(object value) |
||||
|
{ |
||||
|
return value; |
||||
|
} |
||||
|
|
||||
|
#endregion //Value
|
||||
|
|
||||
|
#region ValueType
|
||||
|
|
||||
|
public static readonly DependencyProperty ValueTypeProperty = DependencyProperty.Register("ValueType", typeof(Type), typeof(InputBase), new FrameworkPropertyMetadata(typeof(String), FrameworkPropertyMetadataOptions.None, new PropertyChangedCallback(OnValueTypePropertyChanged))); |
||||
|
public Type ValueType |
||||
|
{ |
||||
|
get { return (Type)GetValue(ValueTypeProperty); } |
||||
|
set { SetValue(ValueTypeProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnValueTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
InputBase input = (InputBase)d; |
||||
|
input.OnValueTypeChanged((Type)e.OldValue, (Type)e.NewValue); |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnValueTypeChanged(Type oldValue, Type newType) |
||||
|
{ |
||||
|
if (_isInitialized) |
||||
|
SyncTextAndValueProperties(TextProperty, Text); |
||||
|
} |
||||
|
|
||||
|
#endregion //ValueType
|
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
protected override void OnInitialized(EventArgs e) |
||||
|
{ |
||||
|
base.OnInitialized(e); |
||||
|
|
||||
|
if (!_isInitialized) |
||||
|
{ |
||||
|
_isInitialized = true; |
||||
|
SyncTextAndValueProperties(ValueProperty, Value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Events
|
||||
|
|
||||
|
public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<object>), typeof(InputBase)); |
||||
|
public event RoutedPropertyChangedEventHandler<object> ValueChanged |
||||
|
{ |
||||
|
add { AddHandler(ValueChangedEvent, value); } |
||||
|
remove { RemoveHandler(ValueChangedEvent, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Events
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
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) |
||||
|
{ |
||||
|
SetValue(InputBase.ValueProperty, ConvertTextToValue(newValue.ToString())); |
||||
|
} |
||||
|
|
||||
|
SetValue(InputBase.TextProperty, ConvertValueToText(newValue)); |
||||
|
|
||||
|
_isSyncingTextAndValueProperties = false; |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
|
||||
|
#region Abstract
|
||||
|
|
||||
|
protected abstract object ConvertTextToValue(string text); |
||||
|
|
||||
|
protected abstract string ConvertValueToText(object value); |
||||
|
|
||||
|
#endregion //Abstract
|
||||
|
} |
||||
|
} |
||||
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 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.
|
||||
|
/// </summary>
|
||||
|
internal class UIElementAdorner<TElement> |
||||
|
: Adorner |
||||
|
where TElement : UIElement |
||||
|
{ |
||||
|
#region Fields
|
||||
|
|
||||
|
TElement _child = null; |
||||
|
double _offsetLeft = 0; |
||||
|
double _offsetTop = 0; |
||||
|
|
||||
|
#endregion // Fields
|
||||
|
|
||||
|
#region Constructor
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Constructor.
|
||||
|
/// </summary>
|
||||
|
/// <param name="adornedElement">The element to which the adorner will be bound.</param>
|
||||
|
public UIElementAdorner(UIElement adornedElement) |
||||
|
: base(adornedElement) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
#endregion // Constructor
|
||||
|
|
||||
|
#region Public Interface
|
||||
|
|
||||
|
#region Child
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets/sets the child element hosted in the adorner.
|
||||
|
/// </summary>
|
||||
|
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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
/// <param name="transform"></param>
|
||||
|
/// <returns></returns>
|
||||
|
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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets/sets the horizontal offset of the adorner.
|
||||
|
/// </summary>
|
||||
|
public double OffsetLeft |
||||
|
{ |
||||
|
get { return _offsetLeft; } |
||||
|
set |
||||
|
{ |
||||
|
_offsetLeft = value; |
||||
|
UpdateLocation(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion // OffsetLeft
|
||||
|
|
||||
|
#region SetOffsets
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Updates the location of the adorner in one atomic operation.
|
||||
|
/// </summary>
|
||||
|
public void SetOffsets(double left, double top) |
||||
|
{ |
||||
|
_offsetLeft = left; |
||||
|
_offsetTop = top; |
||||
|
this.UpdateLocation(); |
||||
|
} |
||||
|
|
||||
|
#endregion // SetOffsets
|
||||
|
|
||||
|
#region OffsetTop
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets/sets the vertical offset of the adorner.
|
||||
|
/// </summary>
|
||||
|
public double OffsetTop |
||||
|
{ |
||||
|
get { return _offsetTop; } |
||||
|
set |
||||
|
{ |
||||
|
_offsetTop = value; |
||||
|
UpdateLocation(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion // OffsetTop
|
||||
|
|
||||
|
#endregion // Public Interface
|
||||
|
|
||||
|
#region Protected Overrides
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
/// <param name="constraint"></param>
|
||||
|
/// <returns></returns>
|
||||
|
protected override Size MeasureOverride(Size constraint) |
||||
|
{ |
||||
|
if (_child == null) |
||||
|
return base.MeasureOverride(constraint); |
||||
|
|
||||
|
_child.Measure(constraint); |
||||
|
return _child.DesiredSize; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
/// <param name="finalSize"></param>
|
||||
|
/// <returns></returns>
|
||||
|
protected override Size ArrangeOverride(Size finalSize) |
||||
|
{ |
||||
|
if (_child == null) |
||||
|
return base.ArrangeOverride(finalSize); |
||||
|
|
||||
|
_child.Arrange(new Rect(finalSize)); |
||||
|
return finalSize; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
protected override IEnumerator LogicalChildren |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
ArrayList list = new ArrayList(); |
||||
|
if (_child != null) |
||||
|
list.Add(_child); |
||||
|
return list.GetEnumerator(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
/// <param name="index"></param>
|
||||
|
/// <returns></returns>
|
||||
|
protected override Visual GetVisualChild(int index) |
||||
|
{ |
||||
|
return _child; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Override.
|
||||
|
/// </summary>
|
||||
|
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
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public enum DateTimeFormat |
||||
|
{ |
||||
|
FullDateTime, |
||||
|
LongDate, |
||||
|
LongTime, |
||||
|
MonthDay, |
||||
|
RFC1123, |
||||
|
ShortDate, |
||||
|
ShortTime, |
||||
|
SortableDateTime, |
||||
|
UniversalSortableDateTime, |
||||
|
YearMonth |
||||
|
} |
||||
|
} |
||||
@ -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; } |
||||
|
} |
||||
|
} |
||||
@ -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 |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,445 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Globalization; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public class DateTimeUpDown : UpDownBase |
||||
|
{ |
||||
|
#region Members
|
||||
|
|
||||
|
private List<DateTimeInfo> _dateTimeInfoList = new List<DateTimeInfo>(); |
||||
|
private DateTimeInfo _selectedDateTimeInfo; |
||||
|
private bool _fireSelectionChangedEvent = true; |
||||
|
|
||||
|
#endregion //Members
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
private DateTimeFormatInfo DateTimeFormatInfo { get; set; } |
||||
|
|
||||
|
#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) |
||||
|
{ |
||||
|
InitializeDateTimeInfoList(); |
||||
|
} |
||||
|
|
||||
|
#endregion //Format
|
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static DateTimeUpDown() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(DateTimeUpDown), new FrameworkPropertyMetadata(typeof(DateTimeUpDown))); |
||||
|
ValueTypeProperty.OverrideMetadata(typeof(DateTimeUpDown), new FrameworkPropertyMetadata(typeof(Nullable<DateTime>))); |
||||
|
} |
||||
|
|
||||
|
public DateTimeUpDown() |
||||
|
{ |
||||
|
DateTimeFormatInfo = DateTimeFormatInfo.GetInstance(CultureInfo.CurrentCulture); |
||||
|
InitializeDateTimeInfoList(); |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
TextBox.SelectionChanged += TextBox_SelectionChanged; |
||||
|
} |
||||
|
|
||||
|
protected override void OnPreviewKeyDown(KeyEventArgs e) |
||||
|
{ |
||||
|
if (e.Key == Key.Enter) |
||||
|
return; |
||||
|
|
||||
|
base.OnPreviewKeyDown(e); |
||||
|
} |
||||
|
|
||||
|
protected override void OnValueChanged(object oldValue, object 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
|
||||
|
ParseValueIntoDateTimeInfo(); |
||||
|
|
||||
|
base.OnValueChanged(oldValue, newValue); |
||||
|
} |
||||
|
|
||||
|
protected override object OnCoerceValue(object 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 base.OnCoerceValue(value); |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Event Hanlders
|
||||
|
|
||||
|
void TextBox_SelectionChanged(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
if (_fireSelectionChangedEvent) |
||||
|
SelectDateTimePart(); |
||||
|
else |
||||
|
_fireSelectionChangedEvent = true; |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Hanlders
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
#region Abstract
|
||||
|
|
||||
|
protected override void OnIncrement() |
||||
|
{ |
||||
|
UpdateDateTime(1); |
||||
|
} |
||||
|
|
||||
|
protected override void OnDecrement() |
||||
|
{ |
||||
|
UpdateDateTime(-1); |
||||
|
} |
||||
|
|
||||
|
protected override object ConvertTextToValue(string text) |
||||
|
{ |
||||
|
throw new NotImplementedException("ConvertTextToValue"); |
||||
|
} |
||||
|
|
||||
|
protected override string ConvertValueToText(object value) |
||||
|
{ |
||||
|
if (value == null) return string.Empty; |
||||
|
|
||||
|
DateTime? dt = DateTime.Parse(value.ToString(), CultureInfo.CurrentCulture); |
||||
|
|
||||
|
if (dt.HasValue) |
||||
|
return dt.Value.ToString(GetFormatString(Format), CultureInfo.CurrentCulture); |
||||
|
else |
||||
|
return string.Empty; |
||||
|
} |
||||
|
|
||||
|
#endregion //Abstract
|
||||
|
|
||||
|
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)).ToString() }; |
||||
|
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 SelectDateTimePart() |
||||
|
{ |
||||
|
_dateTimeInfoList.ForEach(info => |
||||
|
{ |
||||
|
if ((info.StartPosition <= TextBox.SelectionStart) && (TextBox.SelectionStart < (info.StartPosition + info.Length))) |
||||
|
{ |
||||
|
_fireSelectionChangedEvent = false; |
||||
|
TextBox.Select(info.StartPosition, info.Length); |
||||
|
_fireSelectionChangedEvent = true; |
||||
|
_selectedDateTimeInfo = info; |
||||
|
return; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
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; |
||||
|
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
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes static members of the <see cref="Magnifier"/> class.
|
||||
|
/// </summary>
|
||||
|
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
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,274 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Input; |
||||
|
using System.ComponentModel; |
||||
|
using Microsoft.Windows.Controls.Primitives; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
|
||||
|
public class MaskedTextBox : InputBase |
||||
|
{ |
||||
|
#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
|
||||
|
|
||||
|
#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; |
||||
|
} |
||||
|
|
||||
|
protected override object ConvertTextToValue(string text) |
||||
|
{ |
||||
|
object convertedValue = null; |
||||
|
|
||||
|
Type dataType = ValueType; |
||||
|
|
||||
|
string valueToConvert = MaskProvider.ToString(); |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
|
||||
|
protected override 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(); |
||||
|
} |
||||
|
|
||||
|
#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) |
||||
|
{ |
||||
|
base.OnPreviewKeyDown(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; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Handlers
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
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 //Methods
|
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,422 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Windows.Controls; |
||||
|
using System.Windows.Media; |
||||
|
using System.Windows.Controls.Primitives; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
[TemplateVisualState(Name = VisualStates.OK, GroupName = VisualStates.MessageBoxButtonsGroup)] |
||||
|
[TemplateVisualState(Name = VisualStates.OKCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
||||
|
[TemplateVisualState(Name = VisualStates.YesNo, GroupName = VisualStates.MessageBoxButtonsGroup)] |
||||
|
[TemplateVisualState(Name = VisualStates.YesNoCancel, GroupName = VisualStates.MessageBoxButtonsGroup)] |
||||
|
public class MessageBox : Control |
||||
|
{ |
||||
|
#region Private Members
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Tracks the MessageBoxButon value passed into the InitializeContainer method
|
||||
|
/// </summary>
|
||||
|
private MessageBoxButton _button = MessageBoxButton.OK; |
||||
|
|
||||
|
#endregion //Private Members
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static MessageBox() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageBox), new FrameworkPropertyMetadata(typeof(MessageBox))); |
||||
|
} |
||||
|
|
||||
|
internal MessageBox() |
||||
|
{ /*user cannot create instance */ } |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
#region Protected Properties
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A System.Windows.MessageBoxResult value that specifies which message box button was clicked by the user.
|
||||
|
/// </summary>
|
||||
|
protected MessageBoxResult MessageBoxResult = MessageBoxResult.None; |
||||
|
|
||||
|
protected Window Container { get; private set; } |
||||
|
protected Thumb DragWidget { get; private set; } |
||||
|
protected Button CloseButton { get; private set; } |
||||
|
|
||||
|
protected Button OkButton { get; private set; } |
||||
|
protected Button CancelButton { get; private set; } |
||||
|
protected Button YesButton { get; private set; } |
||||
|
protected Button NoButton { get; private set; } |
||||
|
|
||||
|
protected Button OkButton1 { get; private set; } |
||||
|
protected Button CancelButton1 { get; private set; } |
||||
|
protected Button YesButton1 { get; private set; } |
||||
|
protected Button NoButton1 { get; private set; } |
||||
|
|
||||
|
#endregion //Protected Properties
|
||||
|
|
||||
|
#region Dependency Properties
|
||||
|
|
||||
|
public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
||||
|
public string Caption |
||||
|
{ |
||||
|
get { return (string)GetValue(CaptionProperty); } |
||||
|
set { SetValue(CaptionProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty CaptionForegroundProperty = DependencyProperty.Register("CaptionForeground", typeof(Brush), typeof(MessageBox), new UIPropertyMetadata(null)); |
||||
|
public Brush CaptionForeground |
||||
|
{ |
||||
|
get { return (Brush)GetValue(CaptionForegroundProperty); } |
||||
|
set { SetValue(CaptionForegroundProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty CloseButtonStyleProperty = DependencyProperty.Register("CloseButtonStyle", typeof(Style), typeof(MessageBox), new PropertyMetadata(null)); |
||||
|
public Style CloseButtonStyle |
||||
|
{ |
||||
|
get { return (Style)GetValue(CloseButtonStyleProperty); } |
||||
|
set { SetValue(CloseButtonStyleProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(MessageBox), new UIPropertyMetadata(default(ImageSource))); |
||||
|
public ImageSource ImageSource |
||||
|
{ |
||||
|
get { return (ImageSource)GetValue(ImageSourceProperty); } |
||||
|
set { SetValue(ImageSourceProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MessageBox), new UIPropertyMetadata(String.Empty)); |
||||
|
public string Text |
||||
|
{ |
||||
|
get { return (string)GetValue(TextProperty); } |
||||
|
set { SetValue(TextProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty WindowBackgroundProperty = DependencyProperty.Register("WindowBackground", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); |
||||
|
public Brush WindowBackground |
||||
|
{ |
||||
|
get { return (Brush)GetValue(WindowBackgroundProperty); } |
||||
|
set { SetValue(WindowBackgroundProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty WindowBorderBrushProperty = DependencyProperty.Register("WindowBorderBrush", typeof(Brush), typeof(MessageBox), new PropertyMetadata(null)); |
||||
|
public Brush WindowBorderBrush |
||||
|
{ |
||||
|
get { return (Brush)GetValue(WindowBorderBrushProperty); } |
||||
|
set { SetValue(WindowBorderBrushProperty, value); } |
||||
|
} |
||||
|
|
||||
|
public static readonly DependencyProperty WindowOpacityProperty = DependencyProperty.Register("WindowOpacity", typeof(double), typeof(MessageBox), new PropertyMetadata(null)); |
||||
|
public double WindowOpacity |
||||
|
{ |
||||
|
get { return (double)GetValue(WindowOpacityProperty); } |
||||
|
set { SetValue(WindowOpacityProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion //Dependency Properties
|
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the OnApplyTemplate method.
|
||||
|
/// </summary>
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
|
||||
|
DragWidget = (Thumb)GetTemplateChild("PART_DragWidget"); |
||||
|
if (DragWidget != null) |
||||
|
DragWidget.DragDelta += (o, e) => ProcessMove(e); |
||||
|
|
||||
|
CloseButton = (Button)GetTemplateChild("PART_CloseButton"); |
||||
|
if (CloseButton != null) |
||||
|
CloseButton.Click += (o, e) => Close(); |
||||
|
|
||||
|
NoButton = (Button)GetTemplateChild("PART_NoButton"); |
||||
|
if (NoButton != null) |
||||
|
NoButton.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
NoButton1 = (Button)GetTemplateChild("PART_NoButton1"); |
||||
|
if (NoButton1 != null) |
||||
|
NoButton1.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
YesButton = (Button)GetTemplateChild("PART_YesButton"); |
||||
|
if (YesButton != null) |
||||
|
YesButton.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
YesButton1 = (Button)GetTemplateChild("PART_YesButton1"); |
||||
|
if (YesButton1 != null) |
||||
|
YesButton1.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
CancelButton = (Button)GetTemplateChild("PART_CancelButton"); |
||||
|
if (CancelButton != null) |
||||
|
CancelButton.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
CancelButton1 = (Button)GetTemplateChild("PART_CancelButton1"); |
||||
|
if (CancelButton1 != null) |
||||
|
CancelButton1.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
OkButton = (Button)GetTemplateChild("PART_OkButton"); |
||||
|
if (OkButton != null) |
||||
|
OkButton.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
OkButton1 = (Button)GetTemplateChild("PART_OkButton1"); |
||||
|
if (OkButton1 != null) |
||||
|
OkButton1.Click += (o, e) => Button_Click(o, e); |
||||
|
|
||||
|
ChangeVisualState(_button.ToString(), true); |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
#region Public Static
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Displays a message box that has a message and that returns a result.
|
||||
|
/// </summary>
|
||||
|
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
||||
|
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
|
public static MessageBoxResult Show(string messageText) |
||||
|
{ |
||||
|
return Show(messageText, string.Empty, MessageBoxButton.OK); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Displays a message box that has a message and title bar caption; and that returns a result.
|
||||
|
/// </summary>
|
||||
|
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
||||
|
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
|
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
|
public static MessageBoxResult Show(string messageText, string caption) |
||||
|
{ |
||||
|
return Show(messageText, caption, MessageBoxButton.OK); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Displays a message box that has a message and that returns a result.
|
||||
|
/// </summary>
|
||||
|
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
||||
|
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
|
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
|
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
|
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button) |
||||
|
{ |
||||
|
return ShowCore(messageText, caption, button, MessageBoxImage.None); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Displays a message box that has a message and that returns a result.
|
||||
|
/// </summary>
|
||||
|
/// <param name="messageText">A System.String that specifies the text to display.</param>
|
||||
|
/// <param name="caption">A System.String that specifies the title bar caption to display.</param>
|
||||
|
/// <param name="button">A System.Windows.MessageBoxButton value that specifies which button or buttons to display.</param>
|
||||
|
/// <param name="image"> A System.Windows.MessageBoxImage value that specifies the icon to display.</param>
|
||||
|
/// <returns>A System.Windows.MessageBoxResult value that specifies which message box button is clicked by the user.</returns>
|
||||
|
public static MessageBoxResult Show(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
||||
|
{ |
||||
|
return ShowCore(messageText, caption, button, icon); |
||||
|
} |
||||
|
|
||||
|
#endregion //Public Static
|
||||
|
|
||||
|
#region Private Static
|
||||
|
|
||||
|
private static MessageBoxResult ShowCore(string messageText, string caption, MessageBoxButton button, MessageBoxImage icon) |
||||
|
{ |
||||
|
MessageBox msgBox = new MessageBox(); |
||||
|
msgBox.InitializeMessageBox(messageText, caption, button, icon); |
||||
|
msgBox.Show(); |
||||
|
return msgBox.MessageBoxResult; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Resolves the owner Window of the MessageBox.
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
private static FrameworkElement ResolveOwner() |
||||
|
{ |
||||
|
FrameworkElement owner = null; |
||||
|
if (Application.Current != null) |
||||
|
{ |
||||
|
foreach (Window w in Application.Current.Windows) |
||||
|
{ |
||||
|
if (w.IsActive) |
||||
|
{ |
||||
|
owner = w; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return owner; |
||||
|
} |
||||
|
|
||||
|
#endregion //Private Static
|
||||
|
|
||||
|
#region Protected
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Shows the MessageBox
|
||||
|
/// </summary>
|
||||
|
protected void Show() |
||||
|
{ |
||||
|
Container.ShowDialog(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes the MessageBox.
|
||||
|
/// </summary>
|
||||
|
/// <param name="text">The text.</param>
|
||||
|
/// <param name="caption">The caption.</param>
|
||||
|
/// <param name="button">The button.</param>
|
||||
|
/// <param name="image">The image.</param>
|
||||
|
protected void InitializeMessageBox(string text, string caption, MessageBoxButton button, MessageBoxImage image) |
||||
|
{ |
||||
|
Text = text; |
||||
|
Caption = caption; |
||||
|
_button = button; |
||||
|
SetImageSource(image); |
||||
|
Container = CreateContainer(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Changes the control's visual state(s).
|
||||
|
/// </summary>
|
||||
|
/// <param name="name">name of the state</param>
|
||||
|
/// <param name="useTransitions">True if state transitions should be used.</param>
|
||||
|
protected void ChangeVisualState(string name, bool useTransitions) |
||||
|
{ |
||||
|
VisualStateManager.GoToState(this, name, useTransitions); |
||||
|
} |
||||
|
|
||||
|
#endregion //Protected
|
||||
|
|
||||
|
#region Private
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Sets the message image source.
|
||||
|
/// </summary>
|
||||
|
/// <param name="image">The image to show.</param>
|
||||
|
private void SetImageSource(MessageBoxImage image) |
||||
|
{ |
||||
|
String iconName = String.Empty; |
||||
|
|
||||
|
switch (image) |
||||
|
{ |
||||
|
case MessageBoxImage.Error: |
||||
|
{ |
||||
|
iconName = "Error48.png"; |
||||
|
break; |
||||
|
} |
||||
|
case MessageBoxImage.Information: |
||||
|
{ |
||||
|
iconName = "Information48.png"; |
||||
|
break; |
||||
|
} |
||||
|
case MessageBoxImage.Question: |
||||
|
{ |
||||
|
iconName = "Question48.png"; |
||||
|
break; |
||||
|
} |
||||
|
case MessageBoxImage.Warning: |
||||
|
{ |
||||
|
iconName = "Warning48.png"; |
||||
|
break; |
||||
|
} |
||||
|
case MessageBoxImage.None: |
||||
|
default: |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ImageSource = (ImageSource)new ImageSourceConverter().ConvertFromString(String.Format("pack://application:,,,/WPFToolkit.Extended;component/MessageBox/Icons/{0}", iconName)); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates the container which will host the MessageBox control.
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
private Window CreateContainer() |
||||
|
{ |
||||
|
var newWindow = new Window(); |
||||
|
newWindow.AllowsTransparency = true; |
||||
|
newWindow.Background = Brushes.Transparent; |
||||
|
newWindow.Content = this; |
||||
|
|
||||
|
var owner = ResolveOwner(); |
||||
|
if (owner != null) |
||||
|
newWindow.Owner = Window.GetWindow(owner); |
||||
|
|
||||
|
newWindow.ShowInTaskbar = false; |
||||
|
newWindow.SizeToContent = System.Windows.SizeToContent.WidthAndHeight; |
||||
|
newWindow.ResizeMode = System.Windows.ResizeMode.NoResize; |
||||
|
newWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; |
||||
|
newWindow.WindowStyle = System.Windows.WindowStyle.None; |
||||
|
return newWindow; |
||||
|
} |
||||
|
|
||||
|
#endregion //Private
|
||||
|
|
||||
|
#endregion //Methods
|
||||
|
|
||||
|
#region Event Handlers
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Processes the move of a drag operation on the header.
|
||||
|
/// </summary>
|
||||
|
/// <param name="e">The <see cref="System.Windows.Controls.Primitives.DragDeltaEventArgs"/> instance containing the event data.</param>
|
||||
|
private void ProcessMove(DragDeltaEventArgs e) |
||||
|
{ |
||||
|
Container.Left = Container.Left + e.HorizontalChange; |
||||
|
Container.Top = Container.Top + e.VerticalChange; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Sets the MessageBoxResult according to the button pressed and then closes the MessageBox.
|
||||
|
/// </summary>
|
||||
|
/// <param name="sender">The source of the event.</param>
|
||||
|
/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
|
||||
|
private void Button_Click(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
Button button = e.Source as Button; |
||||
|
switch (button.Name) |
||||
|
{ |
||||
|
case "PART_NoButton": |
||||
|
case "PART_NoButton1": |
||||
|
MessageBoxResult = MessageBoxResult.No; |
||||
|
break; |
||||
|
case "PART_YesButton": |
||||
|
case "PART_YesButton1": |
||||
|
MessageBoxResult = MessageBoxResult.Yes; |
||||
|
break; |
||||
|
case "PART_CancelButton": |
||||
|
case "PART_CancelButton1": |
||||
|
MessageBoxResult = MessageBoxResult.Cancel; |
||||
|
break; |
||||
|
case "PART_OkButton": |
||||
|
case "PART_OkButton1": |
||||
|
MessageBoxResult = MessageBoxResult.OK; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
Close(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Closes the MessageBox.
|
||||
|
/// </summary>
|
||||
|
private void Close() |
||||
|
{ |
||||
|
Container.Close(); |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Handlers
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
internal static partial class VisualStates |
||||
|
{ |
||||
|
public const string MessageBoxButtonsGroup = "MessageBoxButtonsGroup"; |
||||
|
|
||||
|
public const string OK = "OK"; |
||||
|
|
||||
|
public const string OKCancel = "OKCancel"; |
||||
|
|
||||
|
public const string YesNo = "YesNo"; |
||||
|
|
||||
|
public const string YesNoCancel = "YesNoCancel"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,297 @@ |
|||||
|
using System; |
||||
|
using System.Windows; |
||||
|
using System.Globalization; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public class NumericUpDown : UpDownBase |
||||
|
{ |
||||
|
#region Properties
|
||||
|
|
||||
|
#region Minimum
|
||||
|
|
||||
|
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum", typeof(double), typeof(NumericUpDown), new PropertyMetadata(Double.MinValue, OnMinimumPropertyChanged)); |
||||
|
public double Minimum |
||||
|
{ |
||||
|
get { return (double)GetValue(MinimumProperty); } |
||||
|
set { SetValue(MinimumProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnMinimumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
NumericUpDown nud = d as NumericUpDown; |
||||
|
nud.SetValidSpinDirection(); |
||||
|
} |
||||
|
|
||||
|
#endregion Minimum
|
||||
|
|
||||
|
#region Maximum
|
||||
|
|
||||
|
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum", typeof(double), typeof(NumericUpDown), new PropertyMetadata(Double.MaxValue, OnMaximumPropertyChanged)); |
||||
|
public double Maximum |
||||
|
{ |
||||
|
get { return (double)GetValue(MaximumProperty); } |
||||
|
set { SetValue(MaximumProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnMaximumPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
NumericUpDown nud = d as NumericUpDown; |
||||
|
nud.SetValidSpinDirection(); |
||||
|
} |
||||
|
|
||||
|
#endregion Maximum
|
||||
|
|
||||
|
#region Increment
|
||||
|
|
||||
|
public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment", typeof(double), typeof(NumericUpDown), new PropertyMetadata(1.0)); |
||||
|
public double Increment |
||||
|
{ |
||||
|
get { return (double)GetValue(IncrementProperty); } |
||||
|
set { SetValue(IncrementProperty, value); } |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
#region FormatString
|
||||
|
|
||||
|
public static readonly DependencyProperty StringFormatProperty = DependencyProperty.Register("FormatString", typeof(string), typeof(NumericUpDown), new PropertyMetadata("F0", OnStringFormatPropertyPropertyChanged)); |
||||
|
public string FormatString |
||||
|
{ |
||||
|
get { return (string)GetValue(StringFormatProperty); } |
||||
|
set { SetValue(StringFormatProperty, value); } |
||||
|
} |
||||
|
|
||||
|
private static void OnStringFormatPropertyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
|
{ |
||||
|
NumericUpDown nud = d as NumericUpDown; |
||||
|
nud.OnStringFormatChanged(e.OldValue.ToString(), e.NewValue.ToString()); |
||||
|
} |
||||
|
|
||||
|
protected virtual void OnStringFormatChanged(string oldValue, string newValue) |
||||
|
{ |
||||
|
SyncTextAndValueProperties(NumericUpDown.TextProperty, Value); |
||||
|
} |
||||
|
|
||||
|
#endregion //FormatString
|
||||
|
|
||||
|
#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
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
static NumericUpDown() |
||||
|
{ |
||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(typeof(NumericUpDown))); |
||||
|
ValueTypeProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(typeof(double))); |
||||
|
ValueProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(default(Double))); |
||||
|
} |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
SetValidSpinDirection(); |
||||
|
|
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected override void OnValueChanged(object oldValue, object newValue) |
||||
|
{ |
||||
|
SetValidSpinDirection(); |
||||
|
base.OnValueChanged(oldValue, newValue); |
||||
|
} |
||||
|
|
||||
|
protected override object OnCoerceValue(object value) |
||||
|
{ |
||||
|
if (value == null) return value; |
||||
|
|
||||
|
double val = Convert.ToDouble(value); |
||||
|
|
||||
|
if (val < Minimum) |
||||
|
{ |
||||
|
return Minimum; |
||||
|
} |
||||
|
else if (val > Maximum) |
||||
|
{ |
||||
|
return Maximum; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected override object ConvertTextToValue(string text) |
||||
|
{ |
||||
|
object result = null; |
||||
|
|
||||
|
NumberFormatInfo info = NumberFormatInfo.GetInstance(CultureInfo.CurrentCulture); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
result = FormatString.Contains("P") ? ParsePercent(text, ValueType, info) : ParseDataValue(text, ValueType, info); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
TextBox.Text = Text = ConvertValueToText(Value); |
||||
|
return Value; |
||||
|
} |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
protected override string ConvertValueToText(object value) |
||||
|
{ |
||||
|
return (Convert.ToDecimal(Value)).ToString(FormatString, CultureInfo.CurrentCulture); |
||||
|
} |
||||
|
|
||||
|
protected override void OnIncrement() |
||||
|
{ |
||||
|
double newValue = (double)(Convert.ToDecimal(Value) + (decimal)Increment); |
||||
|
Value = ValueType != typeof(Double) ? Convert.ChangeType(newValue, ValueType) : newValue; |
||||
|
} |
||||
|
|
||||
|
protected override void OnDecrement() |
||||
|
{ |
||||
|
double newValue = (double)(Convert.ToDecimal(Value) - (decimal)Increment); |
||||
|
Value = ValueType != typeof(Double) ? Convert.ChangeType(newValue, ValueType) : newValue; |
||||
|
} |
||||
|
|
||||
|
#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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Sets the valid spin direction based on current value, minimum and maximum.
|
||||
|
/// </summary>
|
||||
|
private void SetValidSpinDirection() |
||||
|
{ |
||||
|
ValidSpinDirections validDirections = ValidSpinDirections.None; |
||||
|
|
||||
|
if (Convert.ToDouble(Value) < Maximum) |
||||
|
{ |
||||
|
validDirections = validDirections | ValidSpinDirections.Increase; |
||||
|
} |
||||
|
|
||||
|
if (Convert.ToDouble(Value) > Minimum) |
||||
|
{ |
||||
|
validDirections = validDirections | ValidSpinDirections.Decrease; |
||||
|
} |
||||
|
|
||||
|
if (Spinner != null) |
||||
|
{ |
||||
|
Spinner.ValidSpinDirection = validDirections; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#region Parsing
|
||||
|
|
||||
|
private static object ParseDataValue(string text, Type dataType, NumberFormatInfo info) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (typeof(double) == dataType) |
||||
|
{ |
||||
|
return ParseDouble(text, info); |
||||
|
} |
||||
|
else if (typeof(float) == dataType) |
||||
|
{ |
||||
|
return ParseFloat(text, info); |
||||
|
} |
||||
|
else if (typeof(byte) == dataType || typeof(sbyte) == dataType || |
||||
|
typeof(short) == dataType || typeof(ushort) == dataType || typeof(Int16) == dataType || |
||||
|
typeof(int) == dataType || typeof(uint) == dataType || typeof(Int32) == dataType || |
||||
|
typeof(long) == dataType || typeof(ulong) == dataType || typeof(Int64) == dataType) |
||||
|
{ |
||||
|
return ParseWholeNumber(text, dataType, info); |
||||
|
} |
||||
|
else if (typeof(decimal) == dataType) |
||||
|
{ |
||||
|
return ParseDecimal(text, info); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
throw new ArgumentException("Type not supported"); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static double ParseDouble(string text, NumberFormatInfo info) |
||||
|
{ |
||||
|
return double.Parse(text, NumberStyles.Any, info); |
||||
|
} |
||||
|
|
||||
|
private static float ParseFloat(string text, NumberFormatInfo info) |
||||
|
{ |
||||
|
double result = double.Parse(text, NumberStyles.Any, info); |
||||
|
return (float)result; |
||||
|
} |
||||
|
|
||||
|
private static decimal ParseDecimal(string text, NumberFormatInfo info) |
||||
|
{ |
||||
|
return decimal.Parse(text, NumberStyles.Any, info); |
||||
|
} |
||||
|
|
||||
|
private static object ParseWholeNumber(string text, Type dataType, NumberFormatInfo info) |
||||
|
{ |
||||
|
decimal result = decimal.Parse(text, NumberStyles.Any, info); |
||||
|
return Convert.ChangeType(result, dataType, info); |
||||
|
} |
||||
|
|
||||
|
private static object ParsePercent(string text, Type dataType, NumberFormatInfo info) |
||||
|
{ |
||||
|
text = text.Replace(info.PercentSymbol, null); |
||||
|
|
||||
|
decimal result = decimal.Parse(text, NumberStyles.Any, info); |
||||
|
result = result / 100; |
||||
|
|
||||
|
return Convert.ChangeType(result, dataType, info); |
||||
|
} |
||||
|
|
||||
|
#endregion
|
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,59 @@ |
|||||
|
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)] |
||||
|
|
||||
|
//In order to begin building localizable applications, set
|
||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
|
//the line below to match the UICulture setting in the project file.
|
||||
|
|
||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
|
||||
|
|
||||
|
[assembly: ThemeInfo( |
||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// or application resource dictionaries)
|
||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// app, or any theme specific resource dictionaries)
|
||||
|
)] |
||||
|
|
||||
|
|
||||
|
// Version information for an assembly consists of the following four values:
|
||||
|
//
|
||||
|
// Major Version
|
||||
|
// Minor Version
|
||||
|
// Build Number
|
||||
|
// Revision
|
||||
|
//
|
||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
|
// by using the '*' as shown below:
|
||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
[assembly: AssemblyVersion("1.3.0.0")] |
||||
|
[assembly: AssemblyFileVersion("1.3.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")] |
||||
@ -0,0 +1,63 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.Properties { |
||||
|
using System; |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
|
/// </summary>
|
||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
|
// class via a tool like ResGen or Visual Studio.
|
||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
|
// with the /str option, or rebuild your VS project.
|
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] |
||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
internal class Resources { |
||||
|
|
||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||
|
|
||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||
|
|
||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||
|
internal Resources() { |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Resources.ResourceManager ResourceManager { |
||||
|
get { |
||||
|
if (object.ReferenceEquals(resourceMan, null)) { |
||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Windows.Controls.Properties.Resources", typeof(Resources).Assembly); |
||||
|
resourceMan = temp; |
||||
|
} |
||||
|
return resourceMan; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||
|
/// resource lookups using this strongly typed resource class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Globalization.CultureInfo Culture { |
||||
|
get { |
||||
|
return resourceCulture; |
||||
|
} |
||||
|
set { |
||||
|
resourceCulture = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<root> |
||||
|
<!-- |
||||
|
Microsoft ResX Schema |
||||
|
|
||||
|
Version 2.0 |
||||
|
|
||||
|
The primary goals of this format is to allow a simple XML format |
||||
|
that is mostly human readable. The generation and parsing of the |
||||
|
various data types are done through the TypeConverter classes |
||||
|
associated with the data types. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
... ado.net/XML headers & schema ... |
||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
|
<resheader name="version">2.0</resheader> |
||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
|
</data> |
||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
|
<comment>This is a comment</comment> |
||||
|
</data> |
||||
|
|
||||
|
There are any number of "resheader" rows that contain simple |
||||
|
name/value pairs. |
||||
|
|
||||
|
Each data row contains a name, and value. The row also contains a |
||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||
|
text/value conversion through the TypeConverter architecture. |
||||
|
Classes that don't support this are serialized and stored with the |
||||
|
mimetype set. |
||||
|
|
||||
|
The mimetype is used for serialized objects, and tells the |
||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||
|
|
||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
|
that the ResXResourceWriter will generate, however the reader can |
||||
|
read any of the formats listed below. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
|
value : The object must be serialized into a byte array |
||||
|
: using a System.ComponentModel.TypeConverter |
||||
|
: and then encoded with base64 encoding. |
||||
|
--> |
||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:choice maxOccurs="unbounded"> |
||||
|
<xsd:element name="metadata"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="assembly"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="data"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="resheader"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:choice> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:schema> |
||||
|
<resheader name="resmimetype"> |
||||
|
<value>text/microsoft-resx</value> |
||||
|
</resheader> |
||||
|
<resheader name="version"> |
||||
|
<value>2.0</value> |
||||
|
</resheader> |
||||
|
<resheader name="reader"> |
||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
<resheader name="writer"> |
||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
</root> |
||||
@ -0,0 +1,26 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:4.0.30319.1
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace Microsoft.Windows.Controls.Properties { |
||||
|
|
||||
|
|
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] |
||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
||||
|
|
||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
||||
|
|
||||
|
public static Settings Default { |
||||
|
get { |
||||
|
return defaultInstance; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version='1.0' encoding='utf-8'?> |
||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||
|
<Profiles> |
||||
|
<Profile Name="(Default)" /> |
||||
|
</Profiles> |
||||
|
<Settings /> |
||||
|
</SettingsFile> |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Documents; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public interface ITextFormatter |
||||
|
{ |
||||
|
string GetText(FlowDocument document); |
||||
|
void SetText(FlowDocument document, string text); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Documents; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Formats the RichTextBox text as plain text
|
||||
|
/// </summary>
|
||||
|
public class PlainTextFormatter : ITextFormatter |
||||
|
{ |
||||
|
public string GetText(FlowDocument document) |
||||
|
{ |
||||
|
return new TextRange(document.ContentStart, document.ContentEnd).Text; |
||||
|
} |
||||
|
|
||||
|
public void SetText(FlowDocument document, string text) |
||||
|
{ |
||||
|
new TextRange(document.ContentStart, document.ContentEnd).Text = text; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using System; |
||||
|
using System.Text; |
||||
|
using System.Windows.Documents; |
||||
|
using System.IO; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Formats the RichTextBox text as RTF
|
||||
|
/// </summary>
|
||||
|
public class RtfFormatter : ITextFormatter |
||||
|
{ |
||||
|
public string GetText(FlowDocument document) |
||||
|
{ |
||||
|
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
||||
|
using (MemoryStream ms = new MemoryStream()) |
||||
|
{ |
||||
|
tr.Save(ms, DataFormats.Rtf); |
||||
|
return ASCIIEncoding.Default.GetString(ms.ToArray()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void SetText(FlowDocument document, string text) |
||||
|
{ |
||||
|
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
||||
|
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) |
||||
|
{ |
||||
|
tr.Load(ms, DataFormats.Rtf); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using System; |
||||
|
using System.Text; |
||||
|
using System.IO; |
||||
|
using System.Windows.Documents; |
||||
|
using System.Windows; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Formats the RichTextBox text as Xaml
|
||||
|
/// </summary>
|
||||
|
public class XamlFormatter : ITextFormatter |
||||
|
{ |
||||
|
public string GetText(System.Windows.Documents.FlowDocument document) |
||||
|
{ |
||||
|
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
||||
|
using (MemoryStream ms = new MemoryStream()) |
||||
|
{ |
||||
|
tr.Save(ms, DataFormats.Xaml); |
||||
|
return ASCIIEncoding.Default.GetString(ms.ToArray()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void SetText(System.Windows.Documents.FlowDocument document, string text) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
TextRange tr = new TextRange(document.ContentStart, document.ContentEnd); |
||||
|
using (MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(text))) |
||||
|
{ |
||||
|
tr.Load(ms, DataFormats.Xaml); |
||||
|
} |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
throw new InvalidDataException("data provided is not in the correct Xaml format."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
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; |
||||
|
/// <summary>
|
||||
|
/// The ITextFormatter the is used to format the text of the RichTextBox.
|
||||
|
/// Deafult formatter is the RtfFormatter
|
||||
|
/// </summary>
|
||||
|
public ITextFormatter TextFormatter |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (_textFormatter == null) |
||||
|
_textFormatter = new RtfFormatter(); //default is rtf
|
||||
|
|
||||
|
return _textFormatter; |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
_textFormatter = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //TextFormatter
|
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
private void UpdateText() |
||||
|
{ |
||||
|
_textSetInternally = true; |
||||
|
|
||||
|
Text = TextFormatter.GetText(Document); |
||||
|
|
||||
|
_textSetInternally = false; |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
|
||||
|
#region Event Hanlders
|
||||
|
|
||||
|
private void RichTextBox_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
Binding binding = BindingOperations.GetBinding(this, TextProperty); |
||||
|
|
||||
|
if (binding != null) |
||||
|
{ |
||||
|
if (binding.UpdateSourceTrigger == UpdateSourceTrigger.Default || binding.UpdateSourceTrigger == UpdateSourceTrigger.LostFocus) |
||||
|
{ |
||||
|
PreviewLostKeyboardFocus += (o, ea) => UpdateText(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
TextChanged += (o, ea) => UpdateText(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Hanlders
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public interface IRichTextBoxFormatBar |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents the RichTextBox that will be the target for all text manipulations in the format bar.
|
||||
|
/// </summary>
|
||||
|
global::System.Windows.Controls.RichTextBox Target { get; set; } |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 175 B |
|
After Width: | Height: | Size: 209 B |
|
After Width: | Height: | Size: 172 B |
|
After Width: | Height: | Size: 374 B |
|
After Width: | Height: | Size: 183 B |
|
After Width: | Height: | Size: 169 B |
|
After Width: | Height: | Size: 186 B |
|
After Width: | Height: | Size: 269 B |
|
After Width: | Height: | Size: 181 B |
|
After Width: | Height: | Size: 374 B |
|
After Width: | Height: | Size: 197 B |
@ -0,0 +1,422 @@ |
|||||
|
<UserControl x:Class="Microsoft.Windows.Controls.RichTextBoxFormatBar" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls" |
||||
|
Background="Transparent" |
||||
|
IsTabStop="False" |
||||
|
x:Name="_window"> |
||||
|
<UserControl.Effect> |
||||
|
<DropShadowEffect BlurRadius="5" Opacity=".25" /> |
||||
|
</UserControl.Effect> |
||||
|
|
||||
|
<UserControl.Resources> |
||||
|
|
||||
|
<Style TargetType="{x:Type Separator}" BasedOn="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"/> |
||||
|
|
||||
|
<ControlTemplate x:Key="ThumbControlTemplate" TargetType="{x:Type Thumb}"> |
||||
|
<Border Background="Transparent" Cursor="Hand" ToolTip="Click to Drag"> |
||||
|
<StackPanel VerticalAlignment="Center" Width="75"> |
||||
|
<Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5" > |
||||
|
<Line.Stroke> |
||||
|
<SolidColorBrush Color="Gray" /> |
||||
|
</Line.Stroke> |
||||
|
</Line> |
||||
|
<Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5"> |
||||
|
<Line.Stroke> |
||||
|
<SolidColorBrush Color="Gray" /> |
||||
|
</Line.Stroke> |
||||
|
</Line> |
||||
|
<Line SnapsToDevicePixels="True" Stretch="Fill" StrokeDashArray="1,2" StrokeThickness="1" X1="0" X2="1" Margin=".5"> |
||||
|
<Line.Stroke> |
||||
|
<SolidColorBrush Color="Gray" /> |
||||
|
</Line.Stroke> |
||||
|
</Line> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</ControlTemplate> |
||||
|
|
||||
|
<SolidColorBrush x:Key="MouseOverBorderBrush" Color="#FFFFB700" /> |
||||
|
<LinearGradientBrush x:Key="MouseOverBackgroundBrush" StartPoint="0,0" EndPoint="0,1" > |
||||
|
<GradientStop Offset="0" Color="#FFFEFBF4" /> |
||||
|
<GradientStop Offset="0.19" Color="#FFFDE7CE" /> |
||||
|
<GradientStop Offset="0.39" Color="#FFFDDEB8" /> |
||||
|
<GradientStop Offset="0.39" Color="#FFFFCE6B" /> |
||||
|
<GradientStop Offset="0.79" Color="#FFFFDE9A" /> |
||||
|
<GradientStop Offset="1" Color="#FFFFEBAA" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<SolidColorBrush x:Key="CheckedBorderBrush" Color="#FFC29B29" /> |
||||
|
<LinearGradientBrush x:Key="CheckedBackgroundBrush" StartPoint="0,0" EndPoint="0,1" > |
||||
|
<GradientStop Offset="0" Color="#FFFFDCA0" /> |
||||
|
<GradientStop Offset="0.18" Color="#FFFFD692" /> |
||||
|
<GradientStop Offset="0.39" Color="#FFFFC45D" /> |
||||
|
<GradientStop Offset="1" Color="#FFFFD178" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<SolidColorBrush x:Key="PressedBorderBrush" Color="#FFC29B29" /> |
||||
|
<LinearGradientBrush x:Key="PressedBackgroundBrush" StartPoint="0,0" EndPoint="0,1" > |
||||
|
<GradientStop Offset="0" Color="#FFE3C085" /> |
||||
|
<GradientStop Offset="0.19" Color="#FFF4CC89" /> |
||||
|
<GradientStop Offset="0.36" Color="#FFF5C777" /> |
||||
|
<GradientStop Offset="0.36" Color="#FFF5BB56" /> |
||||
|
<GradientStop Offset="0.79" Color="#FFF4CE9A" /> |
||||
|
<GradientStop Offset="1" Color="#FFF3E28D" /> |
||||
|
</LinearGradientBrush> |
||||
|
|
||||
|
<Style x:Key="FormatBarToggleButtonStyle" TargetType="{x:Type ToggleButton}"> |
||||
|
<Setter Property="Background" Value="Transparent"/> |
||||
|
<Setter Property="BorderBrush" Value="Transparent"/> |
||||
|
<Setter Property="BorderThickness" Value="1"/> |
||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> |
||||
|
<Setter Property="Height" Value="22" /> |
||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
||||
|
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/> |
||||
|
<Setter Property="ToolTipService.ShowDuration" Value="20000"/> |
||||
|
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/> |
||||
|
<Setter Property="Template"> |
||||
|
<Setter.Value> |
||||
|
<ControlTemplate TargetType="{x:Type ToggleButton}"> |
||||
|
<Grid SnapsToDevicePixels="True"> |
||||
|
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2"/> |
||||
|
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2"> |
||||
|
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}"> |
||||
|
<StackPanel x:Name="StackPanel" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"> |
||||
|
<ContentPresenter x:Name="Content" Content="{TemplateBinding Content}" Margin="1" |
||||
|
RenderOptions.BitmapScalingMode="NearestNeighbor" |
||||
|
VerticalAlignment="Center" |
||||
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" /> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</Border> |
||||
|
</Grid> |
||||
|
<ControlTemplate.Triggers> |
||||
|
<Trigger Property="IsMouseOver" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource MouseOverBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource MouseOverBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsEnabled" Value="False"> |
||||
|
<Setter Property="Opacity" TargetName="Content" Value="0.5"/> |
||||
|
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsChecked" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource CheckedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource CheckedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#FFE7CBAD" Offset="0"/> |
||||
|
<GradientStop Color="#FFF7D7B5" Offset="0.1"/> |
||||
|
<GradientStop Color="#FFFFD38C" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFC75A" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFEFA5" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsPressed" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource PressedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource PressedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<MultiTrigger> |
||||
|
<MultiTrigger.Conditions> |
||||
|
<Condition Property="IsChecked" Value="True"/> |
||||
|
<Condition Property="IsMouseOver" Value="True"/> |
||||
|
</MultiTrigger.Conditions> |
||||
|
<Setter Property="Background" TargetName="MiddleBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0"/> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.69"/> |
||||
|
<GradientStop Color="#10FFFFFF" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</MultiTrigger> |
||||
|
</ControlTemplate.Triggers> |
||||
|
</ControlTemplate> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
|
||||
|
<Style x:Key="FontColorButtonStyle" TargetType="{x:Type ToggleButton}"> |
||||
|
<Setter Property="Background" Value="Transparent"/> |
||||
|
<Setter Property="BorderBrush" Value="Transparent"/> |
||||
|
<Setter Property="BorderThickness" Value="1"/> |
||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> |
||||
|
<Setter Property="Height" Value="22" /> |
||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
||||
|
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/> |
||||
|
<Setter Property="ToolTipService.ShowDuration" Value="20000"/> |
||||
|
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/> |
||||
|
<Setter Property="Template"> |
||||
|
<Setter.Value> |
||||
|
<ControlTemplate TargetType="{x:Type ToggleButton}"> |
||||
|
<Grid SnapsToDevicePixels="True"> |
||||
|
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> |
||||
|
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2"> |
||||
|
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}"> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="*"/> |
||||
|
<ColumnDefinition /> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<Grid> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/FontColorPicker16.png" Width="16" Height="16" /> |
||||
|
<Rectangle Grid.Row="1" Fill="{TemplateBinding Background}" Height="4" Margin="0,12,0,0" /> |
||||
|
</Grid> |
||||
|
|
||||
|
<Path Grid.Column="1" Width="7" Height="4" |
||||
|
Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" Fill="#FF000000"/> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</Border> |
||||
|
</Grid> |
||||
|
<ControlTemplate.Triggers> |
||||
|
<Trigger Property="IsMouseOver" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource MouseOverBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource MouseOverBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsEnabled" Value="False"> |
||||
|
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsChecked" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource CheckedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource CheckedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#FFE7CBAD" Offset="0"/> |
||||
|
<GradientStop Color="#FFF7D7B5" Offset="0.1"/> |
||||
|
<GradientStop Color="#FFFFD38C" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFC75A" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFEFA5" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsPressed" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource PressedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource PressedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<MultiTrigger> |
||||
|
<MultiTrigger.Conditions> |
||||
|
<Condition Property="IsChecked" Value="True"/> |
||||
|
<Condition Property="IsMouseOver" Value="True"/> |
||||
|
</MultiTrigger.Conditions> |
||||
|
<Setter Property="Background" TargetName="MiddleBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0"/> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.69"/> |
||||
|
<GradientStop Color="#10FFFFFF" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</MultiTrigger> |
||||
|
</ControlTemplate.Triggers> |
||||
|
</ControlTemplate> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
|
||||
|
<Style x:Key="FontBackgrounColorButtonStyle" TargetType="{x:Type ToggleButton}"> |
||||
|
<Setter Property="Background" Value="White"/> |
||||
|
<Setter Property="BorderBrush" Value="Transparent"/> |
||||
|
<Setter Property="BorderThickness" Value="1"/> |
||||
|
<Setter Property="FocusVisualStyle" Value="{x:Null}"/> |
||||
|
<Setter Property="Height" Value="22" /> |
||||
|
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
||||
|
<Setter Property="ToolTipService.InitialShowDelay" Value="900"/> |
||||
|
<Setter Property="ToolTipService.ShowDuration" Value="20000"/> |
||||
|
<Setter Property="ToolTipService.BetweenShowDelay" Value="0"/> |
||||
|
<Setter Property="Template"> |
||||
|
<Setter.Value> |
||||
|
<ControlTemplate TargetType="{x:Type ToggleButton}"> |
||||
|
<Grid SnapsToDevicePixels="True"> |
||||
|
<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2"/> |
||||
|
<Border x:Name="MiddleBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2"> |
||||
|
<Border x:Name="InnerBorder" BorderBrush="Transparent" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent" CornerRadius="2" Padding="{TemplateBinding Padding}"> |
||||
|
<Grid> |
||||
|
<Grid.ColumnDefinitions> |
||||
|
<ColumnDefinition Width="*"/> |
||||
|
<ColumnDefinition /> |
||||
|
</Grid.ColumnDefinitions> |
||||
|
|
||||
|
<Grid> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/TextHighlightColorPicker16.png" Width="16" Height="16" /> |
||||
|
<Rectangle Grid.Row="1" Fill="{TemplateBinding Background}" Height="4" Margin="0,12,0,0" /> |
||||
|
</Grid> |
||||
|
|
||||
|
<Path Grid.Column="1" Width="7" Height="4" |
||||
|
Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" Fill="#FF000000"/> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</Border> |
||||
|
</Grid> |
||||
|
<ControlTemplate.Triggers> |
||||
|
<Trigger Property="IsMouseOver" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource MouseOverBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource MouseOverBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="#80FFFFFF"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsEnabled" Value="False"> |
||||
|
<Setter Property="TextElement.Foreground" TargetName="OuterBorder" Value="#FF9E9E9E"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsChecked" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource CheckedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource CheckedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#FFE7CBAD" Offset="0"/> |
||||
|
<GradientStop Color="#FFF7D7B5" Offset="0.1"/> |
||||
|
<GradientStop Color="#FFFFD38C" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFC75A" Offset="0.36"/> |
||||
|
<GradientStop Color="#FFFFEFA5" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Trigger> |
||||
|
|
||||
|
<Trigger Property="IsPressed" Value="True"> |
||||
|
<Setter Property="Background" TargetName="OuterBorder" Value="{StaticResource PressedBackgroundBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="OuterBorder" Value="{StaticResource PressedBorderBrush}"/> |
||||
|
<Setter Property="BorderBrush" TargetName="InnerBorder" Value="Transparent"/> |
||||
|
</Trigger> |
||||
|
|
||||
|
<MultiTrigger> |
||||
|
<MultiTrigger.Conditions> |
||||
|
<Condition Property="IsChecked" Value="True"/> |
||||
|
<Condition Property="IsMouseOver" Value="True"/> |
||||
|
</MultiTrigger.Conditions> |
||||
|
<Setter Property="Background" TargetName="MiddleBorder"> |
||||
|
<Setter.Value> |
||||
|
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0"> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0"/> |
||||
|
<GradientStop Color="#40FFFEFE" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.39"/> |
||||
|
<GradientStop Color="#20FFCE68" Offset="0.69"/> |
||||
|
<GradientStop Color="#10FFFFFF" Offset="1"/> |
||||
|
</LinearGradientBrush> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</MultiTrigger> |
||||
|
</ControlTemplate.Triggers> |
||||
|
</ControlTemplate> |
||||
|
</Setter.Value> |
||||
|
</Setter> |
||||
|
</Style> |
||||
|
|
||||
|
</UserControl.Resources> |
||||
|
|
||||
|
<Border CornerRadius="3" BorderThickness="1" BorderBrush="Gray" Background="WhiteSmoke"> |
||||
|
<Grid Margin="5,0,5,5"> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition /> |
||||
|
<RowDefinition /> |
||||
|
</Grid.RowDefinitions> |
||||
|
|
||||
|
<Thumb x:Name="_dragWidget" Height="10" |
||||
|
Template="{StaticResource ThumbControlTemplate}" |
||||
|
DragDelta="DragWidget_DragDelta"/> |
||||
|
|
||||
|
<StackPanel Grid.Row="1"> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<ComboBox x:Name="_cmbFontFamilies" IsEditable="True" Width="100" |
||||
|
SelectionChanged="FontFamily_SelectionChanged" |
||||
|
ToolTip="Font Family"/> |
||||
|
|
||||
|
<ComboBox x:Name="_cmbFontSizes" IsEditable="True" Width="43" |
||||
|
SelectionChanged="FontSize_SelectionChanged" |
||||
|
ToolTip="Font Size"/> |
||||
|
|
||||
|
<Separator /> |
||||
|
|
||||
|
<ToggleButton x:Name="_btnBullets" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="EditingCommands.ToggleBullets" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
Click="Bullets_Clicked" |
||||
|
ToolTip="Bullets"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Bullets16.png" /> |
||||
|
</ToggleButton> |
||||
|
|
||||
|
<ToggleButton x:Name="_btnNumbers" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="EditingCommands.ToggleNumbering" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
Click="Numbers_Clicked" |
||||
|
ToolTip="Numbering"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Numbering16.png" /> |
||||
|
</ToggleButton> |
||||
|
|
||||
|
</StackPanel> |
||||
|
|
||||
|
<StackPanel Orientation="Horizontal" Margin="0,3,0,0"> |
||||
|
<ToggleButton x:Name="_btnBold" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Bold"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Bold16.png" /> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton x:Name="_btnItalic" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="{x:Static EditingCommands.ToggleItalic}" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Italic"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Italic16.png" /> |
||||
|
</ToggleButton> |
||||
|
<ToggleButton x:Name="_btnUnderline" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="{x:Static EditingCommands.ToggleUnderline}" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Underline"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/Underline16.png" /> |
||||
|
</ToggleButton> |
||||
|
|
||||
|
<Separator /> |
||||
|
|
||||
|
<RadioButton x:Name="_btnAlignLeft" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="{x:Static EditingCommands.AlignLeft}" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Align Left"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/LeftAlign16.png" /> |
||||
|
</RadioButton> |
||||
|
<RadioButton x:Name="_btnAlignCenter" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="{x:Static EditingCommands.AlignCenter}" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Align Center"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/CenterAlign16.png" /> |
||||
|
</RadioButton> |
||||
|
<RadioButton x:Name="_btnAlignRight" Style="{StaticResource FormatBarToggleButtonStyle}" |
||||
|
Command="{x:Static EditingCommands.AlignRight}" CommandTarget="{Binding ElementName=_window, Path=Target}" |
||||
|
ToolTip="Align Right"> |
||||
|
<Image Source="/WPFToolkit.Extended;component/RichTextBoxFormatBar/Images/RightAlign16.png" /> |
||||
|
</RadioButton> |
||||
|
|
||||
|
<Separator /> |
||||
|
|
||||
|
<extToolkit:ColorPicker x:Name="_cmbFontBackgroundColor" BorderThickness="0" |
||||
|
ButtonStyle="{StaticResource FontBackgrounColorButtonStyle}" |
||||
|
SelectedColorChanged="FontBackgroundColor_SelectedColorChanged" |
||||
|
ToolTip="Text Highlight Color"/> |
||||
|
|
||||
|
<extToolkit:ColorPicker x:Name="_cmbFontColor" BorderThickness="0" |
||||
|
ButtonStyle="{StaticResource FontColorButtonStyle}" |
||||
|
SelectedColorChanged="FontColor_SelectedColorChanged" |
||||
|
ToolTip="Font Color"/> |
||||
|
|
||||
|
</StackPanel> |
||||
|
|
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
</Border> |
||||
|
</UserControl> |
||||
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for RichTextBoxFormatBar.xaml
|
||||
|
/// </summary>
|
||||
|
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<Color> e) |
||||
|
{ |
||||
|
Color selectedColor = (Color)e.NewValue; |
||||
|
ApplyPropertyValueToSelectedText(TextElement.ForegroundProperty, new SolidColorBrush(selectedColor)); |
||||
|
} |
||||
|
|
||||
|
private void FontBackgroundColor_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> 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) ? Colors.White : ((SolidColorBrush)value).Color); |
||||
|
_cmbFontBackgroundColor.SelectedColor = currentColor; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Updates the visual state of the List styles, such as Numbers and Bullets.
|
||||
|
/// </summary>
|
||||
|
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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Checks to see if both selection lists are checked. (Bullets and Numbers)
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
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<Control> adorner = layer.GetAdorners(Target)[0] as UIElementAdorner<Control>; |
||||
|
adorner.SetOffsets(adorner.OffsetLeft + e.HorizontalChange, adorner.OffsetTop + e.VerticalChange); |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,197 @@ |
|||||
|
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<Control> _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.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; |
||||
|
} |
||||
|
|
||||
|
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
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Attaches a FormatBar to a RichtextBox
|
||||
|
/// </summary>
|
||||
|
/// <param name="richTextBox">The RichtextBox to attach to.</param>
|
||||
|
/// <param name="formatBar">The Formatbar to attach.</param>
|
||||
|
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<Control>(_richTextBox); |
||||
|
|
||||
|
formatBar.Target = _richTextBox; |
||||
|
_toolbar = formatBar; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Shows the FormatBar
|
||||
|
/// </summary>
|
||||
|
void ShowAdorner() |
||||
|
{ |
||||
|
if (_adorner.Visibility == Visibility.Visible) |
||||
|
return; |
||||
|
|
||||
|
VerifyAdornerLayer(); |
||||
|
|
||||
|
Control adorningEditor = _toolbar as Control; |
||||
|
_adorner.Child = adorningEditor; |
||||
|
_adorner.Visibility = Visibility.Visible; |
||||
|
|
||||
|
PositionFormatBar(adorningEditor); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Positions the FormatBar so that is does not go outside the bounds of the RichTextBox or covers the selected text
|
||||
|
/// </summary>
|
||||
|
/// <param name="adorningEditor"></param>
|
||||
|
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); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Ensures that the IRichTextFormatBar is in the adorner layer.
|
||||
|
/// </summary>
|
||||
|
/// <returns>True if the IRichTextFormatBar is in the adorner layer, else false.</returns>
|
||||
|
bool VerifyAdornerLayer() |
||||
|
{ |
||||
|
if (_adorner.Parent != null) |
||||
|
return true; |
||||
|
|
||||
|
AdornerLayer layer = AdornerLayer.GetAdornerLayer(_richTextBox); |
||||
|
if (layer == null) |
||||
|
return false; |
||||
|
|
||||
|
layer.Add(_adorner); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Hides the IRichTextFormatBar that is in the adornor layer.
|
||||
|
/// </summary>
|
||||
|
void HideAdorner() |
||||
|
{ |
||||
|
if (IsAdornerVisible) |
||||
|
{ |
||||
|
_adorner.Visibility = Visibility.Collapsed; |
||||
|
_adorner.Child = null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,162 @@ |
|||||
|
using System; |
||||
|
using System.Windows.Controls; |
||||
|
using Microsoft.Windows.Controls.Primitives; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
public abstract class UpDownBase : InputBase |
||||
|
{ |
||||
|
#region Members
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Name constant for Text template part.
|
||||
|
/// </summary>
|
||||
|
internal const string ElementTextName = "TextBox"; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Name constant for Spinner template part.
|
||||
|
/// </summary>
|
||||
|
internal const string ElementSpinnerName = "Spinner"; |
||||
|
|
||||
|
#endregion //Members
|
||||
|
|
||||
|
#region Properties
|
||||
|
|
||||
|
protected TextBox TextBox { get; private set; } |
||||
|
|
||||
|
private Spinner _spinner; |
||||
|
internal Spinner Spinner |
||||
|
{ |
||||
|
get { return _spinner; } |
||||
|
private set |
||||
|
{ |
||||
|
_spinner = value; |
||||
|
_spinner.Spin += OnSpinnerSpin; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Properties
|
||||
|
|
||||
|
#region Constructors
|
||||
|
|
||||
|
internal UpDownBase() { } |
||||
|
|
||||
|
#endregion //Constructors
|
||||
|
|
||||
|
#region Base Class Overrides
|
||||
|
|
||||
|
public override void OnApplyTemplate() |
||||
|
{ |
||||
|
base.OnApplyTemplate(); |
||||
|
|
||||
|
TextBox = GetTemplateChild(ElementTextName) as TextBox; |
||||
|
Spinner = GetTemplateChild(ElementSpinnerName) as Spinner; |
||||
|
} |
||||
|
|
||||
|
protected override void OnPreviewKeyDown(KeyEventArgs e) |
||||
|
{ |
||||
|
switch (e.Key) |
||||
|
{ |
||||
|
case Key.Up: |
||||
|
{ |
||||
|
DoIncrement(); |
||||
|
e.Handled = true; |
||||
|
break; |
||||
|
} |
||||
|
case Key.Down: |
||||
|
{ |
||||
|
DoDecrement(); |
||||
|
e.Handled = true; |
||||
|
break; |
||||
|
} |
||||
|
case Key.Enter: |
||||
|
{ |
||||
|
SyncTextAndValueProperties(UpDownBase.TextProperty, TextBox.Text); |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected override void OnMouseWheel(MouseWheelEventArgs e) |
||||
|
{ |
||||
|
base.OnMouseWheel(e); |
||||
|
|
||||
|
if (!e.Handled) |
||||
|
{ |
||||
|
if (e.Delta < 0) |
||||
|
{ |
||||
|
DoDecrement(); |
||||
|
} |
||||
|
else if (0 < e.Delta) |
||||
|
{ |
||||
|
DoIncrement(); |
||||
|
} |
||||
|
|
||||
|
e.Handled = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#endregion //Base Class Overrides
|
||||
|
|
||||
|
#region Event Handlers
|
||||
|
|
||||
|
private void OnSpinnerSpin(object sender, SpinEventArgs e) |
||||
|
{ |
||||
|
OnSpin(e); |
||||
|
} |
||||
|
|
||||
|
#endregion //Event Handlers
|
||||
|
|
||||
|
#region Methods
|
||||
|
|
||||
|
protected virtual void OnSpin(SpinEventArgs e) |
||||
|
{ |
||||
|
if (e == null) |
||||
|
throw new ArgumentNullException("e"); |
||||
|
|
||||
|
if (e.Direction == SpinDirection.Increase) |
||||
|
DoIncrement(); |
||||
|
else |
||||
|
DoDecrement(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Performs an increment if conditions allow it.
|
||||
|
/// </summary>
|
||||
|
private void DoDecrement() |
||||
|
{ |
||||
|
if (Spinner == null || (Spinner.ValidSpinDirection & ValidSpinDirections.Decrease) == ValidSpinDirections.Decrease) |
||||
|
{ |
||||
|
OnDecrement(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Performs a decrement if conditions allow it.
|
||||
|
/// </summary>
|
||||
|
private void DoIncrement() |
||||
|
{ |
||||
|
if (Spinner == null || (Spinner.ValidSpinDirection & ValidSpinDirections.Increase) == ValidSpinDirections.Increase) |
||||
|
{ |
||||
|
OnIncrement(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
#region Abstract
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Called by OnSpin when the spin direction is SpinDirection.Increase.
|
||||
|
/// </summary>
|
||||
|
protected abstract void OnIncrement(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Called by OnSpin when the spin direction is SpinDirection.Descrease.
|
||||
|
/// </summary>
|
||||
|
protected abstract void OnDecrement(); |
||||
|
|
||||
|
#endregion //Abstract
|
||||
|
|
||||
|
#endregion //Methods
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Microsoft.Windows.Controls |
||||
|
{ |
||||
|
internal static partial class VisualStates |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,174 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
|
<ProductVersion>8.0.30703</ProductVersion> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
<ProjectGuid>{72E591D6-8F83-4D8C-8F67-9C325E623234}</ProjectGuid> |
||||
|
<OutputType>library</OutputType> |
||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
|
<RootNamespace>Microsoft.Windows.Controls</RootNamespace> |
||||
|
<AssemblyName>WPFToolkit.Extended</AssemblyName> |
||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<SccProjectName>SAK</SccProjectName> |
||||
|
<SccLocalPath>SAK</SccLocalPath> |
||||
|
<SccAuxPath>SAK</SccAuxPath> |
||||
|
<SccProvider>SAK</SccProvider> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<Reference Include="System" /> |
||||
|
<Reference Include="System.Data" /> |
||||
|
<Reference Include="System.Xml" /> |
||||
|
<Reference Include="Microsoft.CSharp" /> |
||||
|
<Reference Include="System.Core" /> |
||||
|
<Reference Include="System.Xml.Linq" /> |
||||
|
<Reference Include="System.Data.DataSetExtensions" /> |
||||
|
<Reference Include="System.Xaml"> |
||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="WindowsBase" /> |
||||
|
<Reference Include="PresentationCore" /> |
||||
|
<Reference Include="PresentationFramework" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Page Include="RichTextBoxFormatBar\RichTextBoxFormatBar.xaml"> |
||||
|
<SubType>Designer</SubType> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
</Page> |
||||
|
<Page Include="Themes\Generic.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</Page> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="BusyIndicator\BusyIndicator.cs" /> |
||||
|
<Compile Include="ButtonSpinner\ButtonSpinner.cs" /> |
||||
|
<Compile Include="ChildWindow\ChildWindow.cs" /> |
||||
|
<Compile Include="ChildWindow\VisualStates.ChildWindow.cs" /> |
||||
|
<Compile Include="ChildWindow\WindowState.cs" /> |
||||
|
<Compile Include="ButtonSpinner\SpinDirection.cs" /> |
||||
|
<Compile Include="ButtonSpinner\SpinEventArgs.cs" /> |
||||
|
<Compile Include="ButtonSpinner\Spinner.cs" /> |
||||
|
<Compile Include="ButtonSpinner\ValidSpinDirections.cs" /> |
||||
|
<Compile Include="ColorPicker\ColorItem.cs" /> |
||||
|
<Compile Include="ColorPicker\ColorPicker.cs" /> |
||||
|
<Compile Include="Core\Converters\InverseBoolConverter.cs" /> |
||||
|
<Compile Include="DateTimeUpDown\DateTimeFormat.cs" /> |
||||
|
<Compile Include="DateTimeUpDown\DateTimeInfo.cs" /> |
||||
|
<Compile Include="DateTimeUpDown\DateTimePart.cs" /> |
||||
|
<Compile Include="DateTimeUpDown\DateTimeUpDown.cs" /> |
||||
|
<Compile Include="Magnifier\Converters\BorderThicknessToStrokeThicknessConverter.cs" /> |
||||
|
<Compile Include="Magnifier\Converters\RadiusConverter.cs" /> |
||||
|
<Compile Include="Magnifier\Magnifier.cs" /> |
||||
|
<Compile Include="Magnifier\MagnifierAdorner.cs" /> |
||||
|
<Compile Include="Magnifier\MagnifierManager.cs" /> |
||||
|
<Compile Include="Core\Primitives\InputBase.cs" /> |
||||
|
<Compile Include="MaskedTextBox\MaskedTextBox.cs" /> |
||||
|
<Compile Include="MessageBox\MessageBox.cs" /> |
||||
|
<Compile Include="NumericUpDown\NumericUpDown.cs" /> |
||||
|
<Compile Include="Properties\AssemblyInfo.cs"> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DesignTime>True</DesignTime> |
||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||
|
</Compile> |
||||
|
<Compile Include="BusyIndicator\VisualStates.BusyIndicator.cs" /> |
||||
|
<Compile Include="RichTextBoxFormatBar\IRichTextBoxFormatBar.cs" /> |
||||
|
<Compile Include="RichTextBoxFormatBar\RichTextBoxFormatBar.xaml.cs"> |
||||
|
<DependentUpon>RichTextBoxFormatBar.xaml</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="RichTextBoxFormatBar\RichTextBoxFormatBarManager.cs" /> |
||||
|
<Compile Include="Core\UIElementAdorner.cs" /> |
||||
|
<Compile Include="RichTextBox\Formatters\ITextFormatter.cs" /> |
||||
|
<Compile Include="RichTextBox\Formatters\PlainTextFormatter.cs" /> |
||||
|
<Compile Include="RichTextBox\Formatters\RtfFormatter.cs" /> |
||||
|
<Compile Include="RichTextBox\Formatters\XamlFormatter.cs" /> |
||||
|
<Compile Include="RichTextBox\RichTextBox.cs" /> |
||||
|
<Compile Include="UpDownBase\UpDownBase.cs" /> |
||||
|
<Compile Include="VisualStates.cs" /> |
||||
|
<Compile Include="MessageBox\VisualStates.MessageBox.cs" /> |
||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||
|
</EmbeddedResource> |
||||
|
<None Include="Properties\Settings.settings"> |
||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||
|
</None> |
||||
|
<AppDesigner Include="Properties\" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="MessageBox\Icons\Error48.png" /> |
||||
|
<Resource Include="MessageBox\Icons\Information48.png" /> |
||||
|
<Resource Include="MessageBox\Icons\Question48.png" /> |
||||
|
<Resource Include="MessageBox\Icons\Warning48.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\Bold16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\CenterAlign16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\Italic16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\JustifyAlign16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\LeftAlign16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\RightAlign16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\Underline16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\FontColorPicker16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\TextHighlightColorPicker16.png" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\Bullets16.png" /> |
||||
|
<Resource Include="RichTextBoxFormatBar\Images\Numbering16.png" /> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
|
Other similar extension points exist, see Microsoft.Common.targets. |
||||
|
<Target Name="BeforeBuild"> |
||||
|
</Target> |
||||
|
<Target Name="AfterBuild"> |
||||
|
</Target> |
||||
|
--> |
||||
|
</Project> |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
|
||||
|
Microsoft Visual Studio Solution File, Format Version 10.00 |
||||
|
# Visual Studio 2008 |
||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPFToolkit.Extended", "Src\WPFToolkit.Extended\WPFToolkit.Extended.csproj", "{72E591D6-8F83-4D8C-8F67-9C325E623234}" |
||||
|
EndProject |
||||
|
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 |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<Application x:Class="WPFToolkit.Extended.Examples.App" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
StartupUri="Window1.xaml"> |
||||
|
<Application.Resources> |
||||
|
|
||||
|
</Application.Resources> |
||||
|
</Application> |
||||
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for App.xaml
|
||||
|
/// </summary>
|
||||
|
public partial class App : Application |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -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
|
||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||
|
//the line below to match the UICulture setting in the project file.
|
||||
|
|
||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
|
||||
|
|
||||
|
[assembly: ThemeInfo( |
||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// or application resource dictionaries)
|
||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
|
//(used if a resource is not found in the page,
|
||||
|
// app, or any theme specific resource dictionaries)
|
||||
|
)] |
||||
|
|
||||
|
|
||||
|
// Version information for an assembly consists of the following four values:
|
||||
|
//
|
||||
|
// Major Version
|
||||
|
// Minor Version
|
||||
|
// Build Number
|
||||
|
// Revision
|
||||
|
//
|
||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
|
// by using the '*' as shown below:
|
||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
[assembly: AssemblyVersion("1.0.0.0")] |
||||
|
[assembly: AssemblyFileVersion("1.0.0.0")] |
||||
@ -0,0 +1,71 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:2.0.50727.4952
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace WPFToolkit.Extended.Examples.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
|
/// </summary>
|
||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
|
// class via a tool like ResGen or Visual Studio.
|
||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
|
// with the /str option, or rebuild your VS project.
|
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] |
||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
internal class Resources |
||||
|
{ |
||||
|
|
||||
|
private static global::System.Resources.ResourceManager resourceMan; |
||||
|
|
||||
|
private static global::System.Globalization.CultureInfo resourceCulture; |
||||
|
|
||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
||||
|
internal Resources() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Resources.ResourceManager ResourceManager |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if ((resourceMan == null)) |
||||
|
{ |
||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPFToolkit.Extended.Examples.Properties.Resources", typeof(Resources).Assembly); |
||||
|
resourceMan = temp; |
||||
|
} |
||||
|
return resourceMan; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||
|
/// resource lookups using this strongly typed resource class.
|
||||
|
/// </summary>
|
||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
||||
|
internal static global::System.Globalization.CultureInfo Culture |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return resourceCulture; |
||||
|
} |
||||
|
set |
||||
|
{ |
||||
|
resourceCulture = value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<root> |
||||
|
<!-- |
||||
|
Microsoft ResX Schema |
||||
|
|
||||
|
Version 2.0 |
||||
|
|
||||
|
The primary goals of this format is to allow a simple XML format |
||||
|
that is mostly human readable. The generation and parsing of the |
||||
|
various data types are done through the TypeConverter classes |
||||
|
associated with the data types. |
||||
|
|
||||
|
Example: |
||||
|
|
||||
|
... ado.net/XML headers & schema ... |
||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
|
<resheader name="version">2.0</resheader> |
||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
|
</data> |
||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
|
<comment>This is a comment</comment> |
||||
|
</data> |
||||
|
|
||||
|
There are any number of "resheader" rows that contain simple |
||||
|
name/value pairs. |
||||
|
|
||||
|
Each data row contains a name, and value. The row also contains a |
||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||
|
text/value conversion through the TypeConverter architecture. |
||||
|
Classes that don't support this are serialized and stored with the |
||||
|
mimetype set. |
||||
|
|
||||
|
The mimetype is used for serialized objects, and tells the |
||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||
|
|
||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
|
that the ResXResourceWriter will generate, however the reader can |
||||
|
read any of the formats listed below. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
|
value : The object must be serialized with |
||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
|
: and then encoded with base64 encoding. |
||||
|
|
||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
|
value : The object must be serialized into a byte array |
||||
|
: using a System.ComponentModel.TypeConverter |
||||
|
: and then encoded with base64 encoding. |
||||
|
--> |
||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:choice maxOccurs="unbounded"> |
||||
|
<xsd:element name="metadata"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="assembly"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="data"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
<xsd:element name="resheader"> |
||||
|
<xsd:complexType> |
||||
|
<xsd:sequence> |
||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
|
</xsd:sequence> |
||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:choice> |
||||
|
</xsd:complexType> |
||||
|
</xsd:element> |
||||
|
</xsd:schema> |
||||
|
<resheader name="resmimetype"> |
||||
|
<value>text/microsoft-resx</value> |
||||
|
</resheader> |
||||
|
<resheader name="version"> |
||||
|
<value>2.0</value> |
||||
|
</resheader> |
||||
|
<resheader name="reader"> |
||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
<resheader name="writer"> |
||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
|
</resheader> |
||||
|
</root> |
||||
@ -0,0 +1,30 @@ |
|||||
|
//------------------------------------------------------------------------------
|
||||
|
// <auto-generated>
|
||||
|
// This code was generated by a tool.
|
||||
|
// Runtime Version:2.0.50727.4952
|
||||
|
//
|
||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
|
// the code is regenerated.
|
||||
|
// </auto-generated>
|
||||
|
//------------------------------------------------------------------------------
|
||||
|
|
||||
|
namespace WPFToolkit.Extended.Examples.Properties |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] |
||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase |
||||
|
{ |
||||
|
|
||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
||||
|
|
||||
|
public static Settings Default |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
return defaultInstance; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version='1.0' encoding='utf-8'?> |
||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
||||
|
<Profiles> |
||||
|
<Profile Name="(Default)" /> |
||||
|
</Profiles> |
||||
|
<Settings /> |
||||
|
</SettingsFile> |
||||
@ -0,0 +1,113 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
|
<ProductVersion>9.0.30729</ProductVersion> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
<ProjectGuid>{747652D0-6AA6-4F96-99F7-0C834274FAB2}</ProjectGuid> |
||||
|
<OutputType>WinExe</OutputType> |
||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
|
<RootNamespace>WPFToolkit.Extended.Examples</RootNamespace> |
||||
|
<AssemblyName>WPFToolkit.Extended.Examples</AssemblyName> |
||||
|
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<SccProjectName>SAK</SccProjectName> |
||||
|
<SccLocalPath>SAK</SccLocalPath> |
||||
|
<SccAuxPath>SAK</SccAuxPath> |
||||
|
<SccProvider>SAK</SccProvider> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<Reference Include="System" /> |
||||
|
<Reference Include="System.Core"> |
||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="System.Xml.Linq"> |
||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="System.Data.DataSetExtensions"> |
||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
|
</Reference> |
||||
|
<Reference Include="System.Data" /> |
||||
|
<Reference Include="System.Xml" /> |
||||
|
<Reference Include="WindowsBase" /> |
||||
|
<Reference Include="PresentationCore" /> |
||||
|
<Reference Include="PresentationFramework" /> |
||||
|
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ApplicationDefinition Include="App.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</ApplicationDefinition> |
||||
|
<Page Include="Window1.xaml"> |
||||
|
<Generator>MSBuild:Compile</Generator> |
||||
|
<SubType>Designer</SubType> |
||||
|
</Page> |
||||
|
<Compile Include="App.xaml.cs"> |
||||
|
<DependentUpon>App.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Window1.xaml.cs"> |
||||
|
<DependentUpon>Window1.xaml</DependentUpon> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="Properties\AssemblyInfo.cs"> |
||||
|
<SubType>Code</SubType> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Resources.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DesignTime>True</DesignTime> |
||||
|
<DependentUpon>Resources.resx</DependentUpon> |
||||
|
</Compile> |
||||
|
<Compile Include="Properties\Settings.Designer.cs"> |
||||
|
<AutoGen>True</AutoGen> |
||||
|
<DependentUpon>Settings.settings</DependentUpon> |
||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
||||
|
</Compile> |
||||
|
<EmbeddedResource Include="Properties\Resources.resx"> |
||||
|
<Generator>ResXFileCodeGenerator</Generator> |
||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
||||
|
</EmbeddedResource> |
||||
|
<None Include="Properties\Settings.settings"> |
||||
|
<Generator>SettingsSingleFileGenerator</Generator> |
||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
||||
|
</None> |
||||
|
<AppDesigner Include="Properties\" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\WPFToolkit.Extended\WPFToolkit.Extended.csproj"> |
||||
|
<Project>{72E591D6-8F83-4D8C-8F67-9C325E623234}</Project> |
||||
|
<Name>WPFToolkit.Extended</Name> |
||||
|
</ProjectReference> |
||||
|
</ItemGroup> |
||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
|
Other similar extension points exist, see Microsoft.Common.targets. |
||||
|
<Target Name="BeforeBuild"> |
||||
|
</Target> |
||||
|
<Target Name="AfterBuild"> |
||||
|
</Target> |
||||
|
--> |
||||
|
</Project> |
||||
@ -0,0 +1,10 @@ |
|||||
|
"" |
||||
|
{ |
||||
|
"FILE_VERSION" = "9237" |
||||
|
"ENLISTMENT_CHOICE" = "NEVER" |
||||
|
"PROJECT_FILE_RELATIVE_PATH" = "" |
||||
|
"NUMBER_OF_EXCLUDED_FILES" = "0" |
||||
|
"ORIGINAL_PROJECT_FILE_PATH" = "" |
||||
|
"NUMBER_OF_NESTED_PROJECTS" = "0" |
||||
|
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
<Window x:Class="WPFToolkit.Extended.Examples.Window1" |
||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended" |
||||
|
Title="Window1" Height="300" Width="300"> |
||||
|
<Grid> |
||||
|
|
||||
|
</Grid> |
||||
|
</Window> |
||||
@ -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 |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Interaction logic for Window1.xaml
|
||||
|
/// </summary>
|
||||
|
public partial class Window1 : Window |
||||
|
{ |
||||
|
public Window1() |
||||
|
{ |
||||
|
InitializeComponent(); |
||||
|
Loaded += new RoutedEventHandler(Window1_Loaded); |
||||
|
} |
||||
|
|
||||
|
void Window1_Loaded(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
Microsoft.Windows.Controls.MessageBox.Show("MyStezt", "Test", MessageBoxButton.OKCancel, MessageBoxImage.Stop); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 3.2 KiB |