Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / Primitives / CalendarButton.cs / 1305600 / CalendarButton.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
namespace System.Windows.Controls.Primitives
{
///
/// Represents a button control used in Calendar Control, which reacts to the Click event.
///
public sealed class CalendarButton : Button
{
///
/// Static constructor
///
static CalendarButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CalendarButton), new FrameworkPropertyMetadata(typeof(CalendarButton)));
}
///
/// Represents the CalendarButton that is used in Calendar Control.
///
public CalendarButton()
: base()
{
}
#region Public Properties
#region HasSelectedDays
internal static readonly DependencyPropertyKey HasSelectedDaysPropertyKey = DependencyProperty.RegisterReadOnly(
"HasSelectedDays",
typeof(bool),
typeof(CalendarButton),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnVisualStatePropertyChanged)));
///
/// Dependency property field for HasSelectedDays property
///
public static readonly DependencyProperty HasSelectedDaysProperty = HasSelectedDaysPropertyKey.DependencyProperty;
///
/// True if the CalendarButton represents a date range containing the display date
///
public bool HasSelectedDays
{
get { return (bool)GetValue(HasSelectedDaysProperty); }
internal set { SetValue(HasSelectedDaysPropertyKey, value); }
}
#endregion HasSelectedDays
#region IsInactive
internal static readonly DependencyPropertyKey IsInactivePropertyKey = DependencyProperty.RegisterReadOnly(
"IsInactive",
typeof(bool),
typeof(CalendarButton),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnVisualStatePropertyChanged)));
///
/// Dependency property field for IsInactive property
///
public static readonly DependencyProperty IsInactiveProperty = IsInactivePropertyKey.DependencyProperty;
///
/// True if the CalendarButton represents
/// a month that falls outside the current year
/// or
/// a year that falls outside the current decade
///
public bool IsInactive
{
get { return (bool)GetValue(IsInactiveProperty); }
internal set { SetValue(IsInactivePropertyKey, value); }
}
#endregion IsInactive
#endregion Public Properties
#region Internal Properties
internal Calendar Owner
{
get;
set;
}
#endregion Internal Properties
#region Public Methods
#endregion Public Methods
#region Protected Methods
///
/// Change to the correct visual state for the button.
///
///
/// true to use transitions when updating the visual state, false to
/// snap directly to the new visual state.
///
internal override void ChangeVisualState(bool useTransitions)
{
// Update the SelectionStates group
if (HasSelectedDays)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateUnselected, useTransitions);
}
// Update the ActiveStates group
if (!IsInactive)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateActive, VisualStates.StateInactive);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateInactive, useTransitions);
}
// Update the FocusStates group
if (IsKeyboardFocused)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonFocused, VisualStates.StateCalendarButtonUnfocused);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateCalendarButtonUnfocused, useTransitions);
}
base.ChangeVisualState(useTransitions);
}
///
/// Creates the automation peer for the DayButton.
///
///
protected override AutomationPeer OnCreateAutomationPeer()
{
return new CalendarButtonAutomationPeer(this);
}
#endregion Protected Methods
#region Internal Methods
internal void SetContentInternal(string value)
{
SetCurrentValueInternal(ContentControl.ContentProperty, value);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
namespace System.Windows.Controls.Primitives
{
///
/// Represents a button control used in Calendar Control, which reacts to the Click event.
///
public sealed class CalendarButton : Button
{
///
/// Static constructor
///
static CalendarButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CalendarButton), new FrameworkPropertyMetadata(typeof(CalendarButton)));
}
///
/// Represents the CalendarButton that is used in Calendar Control.
///
public CalendarButton()
: base()
{
}
#region Public Properties
#region HasSelectedDays
internal static readonly DependencyPropertyKey HasSelectedDaysPropertyKey = DependencyProperty.RegisterReadOnly(
"HasSelectedDays",
typeof(bool),
typeof(CalendarButton),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnVisualStatePropertyChanged)));
///
/// Dependency property field for HasSelectedDays property
///
public static readonly DependencyProperty HasSelectedDaysProperty = HasSelectedDaysPropertyKey.DependencyProperty;
///
/// True if the CalendarButton represents a date range containing the display date
///
public bool HasSelectedDays
{
get { return (bool)GetValue(HasSelectedDaysProperty); }
internal set { SetValue(HasSelectedDaysPropertyKey, value); }
}
#endregion HasSelectedDays
#region IsInactive
internal static readonly DependencyPropertyKey IsInactivePropertyKey = DependencyProperty.RegisterReadOnly(
"IsInactive",
typeof(bool),
typeof(CalendarButton),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnVisualStatePropertyChanged)));
///
/// Dependency property field for IsInactive property
///
public static readonly DependencyProperty IsInactiveProperty = IsInactivePropertyKey.DependencyProperty;
///
/// True if the CalendarButton represents
/// a month that falls outside the current year
/// or
/// a year that falls outside the current decade
///
public bool IsInactive
{
get { return (bool)GetValue(IsInactiveProperty); }
internal set { SetValue(IsInactivePropertyKey, value); }
}
#endregion IsInactive
#endregion Public Properties
#region Internal Properties
internal Calendar Owner
{
get;
set;
}
#endregion Internal Properties
#region Public Methods
#endregion Public Methods
#region Protected Methods
///
/// Change to the correct visual state for the button.
///
///
/// true to use transitions when updating the visual state, false to
/// snap directly to the new visual state.
///
internal override void ChangeVisualState(bool useTransitions)
{
// Update the SelectionStates group
if (HasSelectedDays)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateSelected, VisualStates.StateUnselected);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateUnselected, useTransitions);
}
// Update the ActiveStates group
if (!IsInactive)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateActive, VisualStates.StateInactive);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateInactive, useTransitions);
}
// Update the FocusStates group
if (IsKeyboardFocused)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateCalendarButtonFocused, VisualStates.StateCalendarButtonUnfocused);
}
else
{
VisualStateManager.GoToState(this, VisualStates.StateCalendarButtonUnfocused, useTransitions);
}
base.ChangeVisualState(useTransitions);
}
///
/// Creates the automation peer for the DayButton.
///
///
protected override AutomationPeer OnCreateAutomationPeer()
{
return new CalendarButtonAutomationPeer(this);
}
#endregion Protected Methods
#region Internal Methods
internal void SetContentInternal(string value)
{
SetCurrentValueInternal(ContentControl.ContentProperty, value);
}
#endregion
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NavigationWindowAutomationPeer.cs
- Hash.cs
- SafeFreeMibTable.cs
- QuaternionKeyFrameCollection.cs
- ToolStripItem.cs
- ObjectPersistData.cs
- DocumentViewerHelper.cs
- SessionSwitchEventArgs.cs
- UnsafeNativeMethods.cs
- ToggleButtonAutomationPeer.cs
- SqlBooleanizer.cs
- DesignerCalendarAdapter.cs
- WebPartAuthorizationEventArgs.cs
- MediaTimeline.cs
- XmlSchemaCollection.cs
- TransformerInfo.cs
- BidirectionalDictionary.cs
- SecUtil.cs
- SynchronizationContext.cs
- ZipIOCentralDirectoryBlock.cs
- DoubleAnimationUsingKeyFrames.cs
- SoundPlayer.cs
- InstanceDataCollectionCollection.cs
- BrowserTree.cs
- ColorAnimationBase.cs
- WpfSharedXamlSchemaContext.cs
- OciLobLocator.cs
- DictionarySectionHandler.cs
- PropertyExpression.cs
- RowType.cs
- LayoutTable.cs
- DragDeltaEventArgs.cs
- DecoderFallback.cs
- SystemColorTracker.cs
- ItemsControlAutomationPeer.cs
- HttpCookie.cs
- Pts.cs
- DesignerSerializationVisibilityAttribute.cs
- NodeInfo.cs
- ConfigurationStrings.cs
- ListViewHitTestInfo.cs
- ApplicationCommands.cs
- CodeDomExtensionMethods.cs
- EncodingNLS.cs
- FieldTemplateFactory.cs
- XmlDigitalSignatureProcessor.cs
- DataSourceView.cs
- CodeObject.cs
- CreateUserWizard.cs
- LightweightCodeGenerator.cs
- HttpSysSettings.cs
- EndpointFilterProvider.cs
- SafeNativeMethodsMilCoreApi.cs
- COM2Enum.cs
- TranslateTransform.cs
- DependencyPropertyAttribute.cs
- COM2ExtendedBrowsingHandler.cs
- HashHelper.cs
- WebEncodingValidator.cs
- Vector3DAnimation.cs
- XsdDateTime.cs
- TokenBasedSetEnumerator.cs
- HttpCapabilitiesEvaluator.cs
- DbConnectionPool.cs
- SupportingTokenBindingElement.cs
- COM2ExtendedUITypeEditor.cs
- MarshalByValueComponent.cs
- NumericExpr.cs
- DrawingGroupDrawingContext.cs
- PersianCalendar.cs
- StylusCollection.cs
- HttpCapabilitiesSectionHandler.cs
- InputReport.cs
- _PooledStream.cs
- Page.cs
- FunctionOverloadResolver.cs
- TextRangeEditTables.cs
- _ScatterGatherBuffers.cs
- NodeLabelEditEvent.cs
- ImageInfo.cs
- DataListCommandEventArgs.cs
- NumberAction.cs
- RoutedEventArgs.cs
- Parser.cs
- TheQuery.cs
- DataGridViewCellConverter.cs
- PaperSize.cs
- WebProxyScriptElement.cs
- ProofTokenCryptoHandle.cs
- InvalidDataException.cs
- ThreadStartException.cs
- FileChangesMonitor.cs
- DefaultEventAttribute.cs
- RedirectionProxy.cs
- Rect3D.cs
- RadialGradientBrush.cs
- WebPart.cs
- XPathScanner.cs
- StateBag.cs
- HwndPanningFeedback.cs