Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Framework / System / Windows / Automation / Peers / ToggleButtonAutomationPeer.cs / 1 / 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;
return null;
}
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;
return null;
}
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
- XamlFigureLengthSerializer.cs
- _SslSessionsCache.cs
- DataGridRowDetailsEventArgs.cs
- PassportPrincipal.cs
- EllipseGeometry.cs
- CodeMemberField.cs
- ZipIORawDataFileBlock.cs
- TabletCollection.cs
- MaskInputRejectedEventArgs.cs
- GuidTagList.cs
- HtmlTextBoxAdapter.cs
- _StreamFramer.cs
- StaticExtension.cs
- ValidatedControlConverter.cs
- BooleanStorage.cs
- LoadWorkflowByKeyAsyncResult.cs
- NullableBoolConverter.cs
- HttpCachePolicyElement.cs
- ListViewItem.cs
- PTProvider.cs
- AsymmetricKeyExchangeDeformatter.cs
- EnumValAlphaComparer.cs
- X509AsymmetricSecurityKey.cs
- EvidenceBase.cs
- ParsedAttributeCollection.cs
- HyperLinkStyle.cs
- DEREncoding.cs
- SettingsPropertyValue.cs
- Missing.cs
- _TransmitFileOverlappedAsyncResult.cs
- ValueTypeFixupInfo.cs
- ZipIOLocalFileHeader.cs
- LineUtil.cs
- FileLogRecordEnumerator.cs
- WsdlBuildProvider.cs
- ProjectionPruner.cs
- PingOptions.cs
- ThicknessConverter.cs
- TextRangeAdaptor.cs
- DBSqlParserColumnCollection.cs
- ControllableStoryboardAction.cs
- TextEditorContextMenu.cs
- JapaneseLunisolarCalendar.cs
- PackUriHelper.cs
- EditingCoordinator.cs
- NameValueCollection.cs
- MailMessage.cs
- FormsAuthentication.cs
- NGCSerializerAsync.cs
- PriorityBindingExpression.cs
- LicenseException.cs
- RangeBaseAutomationPeer.cs
- FixedSOMElement.cs
- MachineKey.cs
- bindurihelper.cs
- CoreChannel.cs
- TextEditorDragDrop.cs
- HtmlToClrEventProxy.cs
- MenuItemCollection.cs
- LoadWorkflowCommand.cs
- DiagnosticTrace.cs
- PrincipalPermission.cs
- StartFileNameEditor.cs
- FocusManager.cs
- clipboard.cs
- ReadWriteObjectLock.cs
- formatter.cs
- EntityModelSchemaGenerator.cs
- SchemaImporter.cs
- TemplateControlCodeDomTreeGenerator.cs
- Adorner.cs
- Brush.cs
- TypedTableGenerator.cs
- DataGridViewCellLinkedList.cs
- _LocalDataStore.cs
- ServiceDescriptionImporter.cs
- JsonClassDataContract.cs
- DefaultTraceListener.cs
- WebPartsSection.cs
- SqlDataRecord.cs
- ServiceContractAttribute.cs
- JavaScriptObjectDeserializer.cs
- CompiledELinqQueryState.cs
- Schema.cs
- FixedSOMElement.cs
- VectorConverter.cs
- HtmlElementCollection.cs
- NodeFunctions.cs
- StylusEditingBehavior.cs
- HttpHandlerActionCollection.cs
- MenuBase.cs
- ContextMenuAutomationPeer.cs
- LogStore.cs
- XmlSiteMapProvider.cs
- XmlHelper.cs
- InteropBitmapSource.cs
- AttributeProviderAttribute.cs
- InkPresenter.cs
- CustomAttributeFormatException.cs
- AstNode.cs