Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Automation / Peers / ToggleButtonAutomationPeer.cs / 1305600 / ToggleButtonAutomationPeer.cs
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Windows;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interop;
using System.Windows.Media;
using MS.Internal;
using MS.Win32;
namespace System.Windows.Automation.Peers
{
///
public class ToggleButtonAutomationPeer : ButtonBaseAutomationPeer, IToggleProvider
{
///
public ToggleButtonAutomationPeer(ToggleButton owner): base(owner)
{}
///
override protected string GetClassNameCore()
{
return "Button";
}
///
override protected AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Button;
}
///
override public object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Toggle)
{
return this;
}
else
{
return base.GetPattern(patternInterface);
}
}
void IToggleProvider.Toggle()
{
if(!IsEnabled())
throw new ElementNotEnabledException();
ToggleButton owner = (ToggleButton)Owner;
owner.OnToggle();
}
ToggleState IToggleProvider.ToggleState
{
get
{
ToggleButton owner = (ToggleButton)Owner;
return ConvertToToggleState(owner.IsChecked);
}
}
//
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
internal virtual void RaiseToggleStatePropertyChangedEvent(bool? oldValue, bool? newValue)
{
if (oldValue != newValue)
{
RaisePropertyChangedEvent(TogglePatternIdentifiers.ToggleStateProperty, ConvertToToggleState(oldValue), ConvertToToggleState(newValue));
}
}
private static ToggleState ConvertToToggleState(bool? value)
{
switch (value)
{
case (true): return ToggleState.On;
case (false): return ToggleState.Off;
default: return ToggleState.Indeterminate;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Windows;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Interop;
using System.Windows.Media;
using MS.Internal;
using MS.Win32;
namespace System.Windows.Automation.Peers
{
///
public class ToggleButtonAutomationPeer : ButtonBaseAutomationPeer, IToggleProvider
{
///
public ToggleButtonAutomationPeer(ToggleButton owner): base(owner)
{}
///
override protected string GetClassNameCore()
{
return "Button";
}
///
override protected AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.Button;
}
///
override public object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Toggle)
{
return this;
}
else
{
return base.GetPattern(patternInterface);
}
}
void IToggleProvider.Toggle()
{
if(!IsEnabled())
throw new ElementNotEnabledException();
ToggleButton owner = (ToggleButton)Owner;
owner.OnToggle();
}
ToggleState IToggleProvider.ToggleState
{
get
{
ToggleButton owner = (ToggleButton)Owner;
return ConvertToToggleState(owner.IsChecked);
}
}
//
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
internal virtual void RaiseToggleStatePropertyChangedEvent(bool? oldValue, bool? newValue)
{
if (oldValue != newValue)
{
RaisePropertyChangedEvent(TogglePatternIdentifiers.ToggleStateProperty, ConvertToToggleState(oldValue), ConvertToToggleState(newValue));
}
}
private static ToggleState ConvertToToggleState(bool? value)
{
switch (value)
{
case (true): return ToggleState.On;
case (false): return ToggleState.Off;
default: return ToggleState.Indeterminate;
}
}
}
}
// 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
- Group.cs
- BmpBitmapDecoder.cs
- FixedSOMGroup.cs
- IgnoreSectionHandler.cs
- BitmapEditor.cs
- XsdValidatingReader.cs
- SocketInformation.cs
- SqlXmlStorage.cs
- SingleStorage.cs
- EncoderFallback.cs
- DependentList.cs
- SqlHelper.cs
- Semaphore.cs
- MissingSatelliteAssemblyException.cs
- PropertyChangeTracker.cs
- WebAdminConfigurationHelper.cs
- VoiceSynthesis.cs
- ActivityCodeDomSerializer.cs
- UInt32Storage.cs
- IRCollection.cs
- SQLDoubleStorage.cs
- NavigationPropertyEmitter.cs
- WSHttpBindingBase.cs
- WindowsRegion.cs
- MetaTableHelper.cs
- ChtmlFormAdapter.cs
- CookieParameter.cs
- LocatorManager.cs
- SessionPageStatePersister.cs
- SerializationUtility.cs
- KnownTypesHelper.cs
- XmlResolver.cs
- XsltException.cs
- UriTemplateClientFormatter.cs
- WebPartDescriptionCollection.cs
- SerializationObjectManager.cs
- SequenceRangeCollection.cs
- FragmentQuery.cs
- XamlValidatingReader.cs
- TextParagraph.cs
- login.cs
- DrawingCollection.cs
- NetPeerTcpBindingCollectionElement.cs
- BinarySecretKeyIdentifierClause.cs
- DataGridViewColumn.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- RegexCompilationInfo.cs
- Label.cs
- keycontainerpermission.cs
- ToolTipService.cs
- AmbientLight.cs
- SafeViewOfFileHandle.cs
- WmlPanelAdapter.cs
- FrameworkElement.cs
- PrimitiveDataContract.cs
- ModelPropertyCollectionImpl.cs
- HttpConfigurationContext.cs
- DbMetaDataCollectionNames.cs
- XhtmlBasicLinkAdapter.cs
- DomainUpDown.cs
- Substitution.cs
- TimelineGroup.cs
- XmlComplianceUtil.cs
- DelegateSerializationHolder.cs
- mediaeventshelper.cs
- DragEvent.cs
- BitmapEffectGeneralTransform.cs
- ProcessModuleCollection.cs
- ExpanderAutomationPeer.cs
- GridPatternIdentifiers.cs
- ToolStripMenuItem.cs
- FontNamesConverter.cs
- FormsAuthentication.cs
- PriorityRange.cs
- WebPartTransformerCollection.cs
- Solver.cs
- MergeExecutor.cs
- XD.cs
- WindowsScrollBar.cs
- XmlObjectSerializerWriteContext.cs
- DefaultBinder.cs
- TlsnegoTokenProvider.cs
- SoapServerProtocol.cs
- RelationHandler.cs
- PropertyState.cs
- XmlCountingReader.cs
- DecoderNLS.cs
- CalendarData.cs
- HtmlTableRowCollection.cs
- Brush.cs
- ValueQuery.cs
- FormViewDeletedEventArgs.cs
- Bezier.cs
- StoreAnnotationsMap.cs
- COM2ColorConverter.cs
- ThousandthOfEmRealDoubles.cs
- QilParameter.cs
- EventListener.cs
- FlowDocumentPaginator.cs
- MenuItemStyleCollectionEditor.cs