Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / WindowsListViewItemStartMenu.cs / 1305600 / WindowsListViewItemStartMenu.cs
//----------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
//
// Description: Win32 ListView Item proxy for the Start Menu.
// The Start Menu has a special use of ListViews. The items in the
// list are treated like menuitems. To expose this special behavor
// data from MSAA is need. The Shell team has implemented a special
// IAccessible to support the Sart Menu.
//
// History:
// 2005/01/25 - [....] - Created
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.Windows;
using Accessibility;
using MS.Win32;
namespace MS.Internal.AutomationProxies
{
// This class will only change a couple of aspects of a ListViewItem. So derive from the ListViewItem to
// retain the majority of the ListView item functionality.
internal class ListViewItemStartMenu : ListViewItem
{
// -----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
internal ListViewItemStartMenu(IntPtr hwnd, ProxyFragment parent, int item, IAccessible acc)
: base (hwnd, parent, item)
{
// The items are zero based, i.e. the first listview item is item 0. The
// zero item in MSAA is self, so need to add one to the item to get the
// correct Accessible child.
AccessibleRole role = Accessible.GetRole(acc, item + 1);
// Normal Listview items should be of control type listitem. But
// the Listview items in the Start Menu act like menuitems. Get the Role
// from IAccessible interface implemented by the Shell team and set the
// control type.
if (role == AccessibleRole.MenuItem)
{
_cControlType = ControlType.MenuItem;
}
else
{
System.Diagnostics.Debug.Assert(false, "The listview item on the Start Menu has an unexpected IAccessible role!");
}
}
#endregion Constructos
//------------------------------------------------------
//
// Patterns Implementation
//
//-----------------------------------------------------
#region ProxySimple Interface
// Returns a pattern interface if supported.
internal override object GetPatternProvider(AutomationPattern iid)
{
// Treate these listview items as menuitems and only support Invoke or Expand/Collapse patterns.
// Invoke Pattern needs to be supported when the item has no children. When the item does have
// children it needs to support ExpandCollapse Pattern.
if (iid == InvokePattern.Pattern)
{
return this;
}
//
return null;
}
// Process all the Logical and Raw Element Properties
internal override object GetElementProperty(AutomationProperty idProp)
{
// Normal Listview items do not have a concept of an AccessKey. But
// the Listview items in the Start Menu does. This information is
// in the IAccessible interface implemented by the Shell team.
if (idProp == AutomationElement.AccessKeyProperty)
{
// The IAccessible should be valid here since it is the cached value in ProxySimple.
System.Diagnostics.Debug.Assert(AccessibleObject != null, "Failed to get a valid IAccessible!");
try
{
string key = AccessibleObject.get_accKeyboardShortcut(_item + 1);
if (!string.IsNullOrEmpty(key))
{
return ST.Get(STID.KeyAlt) + "+" + key;
}
}
catch (Exception e)
{
if (Misc.IsCriticalException(e))
{
throw;
}
}
}
else if (idProp == AutomationElement.HasKeyboardFocusProperty)
{
return IsFocused();
}
return base.GetElementProperty(idProp);
}
#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.
//
//
//
// Description: Win32 ListView Item proxy for the Start Menu.
// The Start Menu has a special use of ListViews. The items in the
// list are treated like menuitems. To expose this special behavor
// data from MSAA is need. The Shell team has implemented a special
// IAccessible to support the Sart Menu.
//
// History:
// 2005/01/25 - [....] - Created
//
//---------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.Windows;
using Accessibility;
using MS.Win32;
namespace MS.Internal.AutomationProxies
{
// This class will only change a couple of aspects of a ListViewItem. So derive from the ListViewItem to
// retain the majority of the ListView item functionality.
internal class ListViewItemStartMenu : ListViewItem
{
// -----------------------------------------------------
//
// Constructors
//
//-----------------------------------------------------
#region Constructors
internal ListViewItemStartMenu(IntPtr hwnd, ProxyFragment parent, int item, IAccessible acc)
: base (hwnd, parent, item)
{
// The items are zero based, i.e. the first listview item is item 0. The
// zero item in MSAA is self, so need to add one to the item to get the
// correct Accessible child.
AccessibleRole role = Accessible.GetRole(acc, item + 1);
// Normal Listview items should be of control type listitem. But
// the Listview items in the Start Menu act like menuitems. Get the Role
// from IAccessible interface implemented by the Shell team and set the
// control type.
if (role == AccessibleRole.MenuItem)
{
_cControlType = ControlType.MenuItem;
}
else
{
System.Diagnostics.Debug.Assert(false, "The listview item on the Start Menu has an unexpected IAccessible role!");
}
}
#endregion Constructos
//------------------------------------------------------
//
// Patterns Implementation
//
//-----------------------------------------------------
#region ProxySimple Interface
// Returns a pattern interface if supported.
internal override object GetPatternProvider(AutomationPattern iid)
{
// Treate these listview items as menuitems and only support Invoke or Expand/Collapse patterns.
// Invoke Pattern needs to be supported when the item has no children. When the item does have
// children it needs to support ExpandCollapse Pattern.
if (iid == InvokePattern.Pattern)
{
return this;
}
//
return null;
}
// Process all the Logical and Raw Element Properties
internal override object GetElementProperty(AutomationProperty idProp)
{
// Normal Listview items do not have a concept of an AccessKey. But
// the Listview items in the Start Menu does. This information is
// in the IAccessible interface implemented by the Shell team.
if (idProp == AutomationElement.AccessKeyProperty)
{
// The IAccessible should be valid here since it is the cached value in ProxySimple.
System.Diagnostics.Debug.Assert(AccessibleObject != null, "Failed to get a valid IAccessible!");
try
{
string key = AccessibleObject.get_accKeyboardShortcut(_item + 1);
if (!string.IsNullOrEmpty(key))
{
return ST.Get(STID.KeyAlt) + "+" + key;
}
}
catch (Exception e)
{
if (Misc.IsCriticalException(e))
{
throw;
}
}
}
else if (idProp == AutomationElement.HasKeyboardFocusProperty)
{
return IsFocused();
}
return base.GetElementProperty(idProp);
}
#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
- EntityDataSourceChangingEventArgs.cs
- MatrixValueSerializer.cs
- WebMessageBodyStyleHelper.cs
- ContentFileHelper.cs
- ThreadStaticAttribute.cs
- StylusOverProperty.cs
- SchemaMapping.cs
- Base64Decoder.cs
- SizeLimitedCache.cs
- MediaScriptCommandRoutedEventArgs.cs
- HttpCapabilitiesBase.cs
- PowerStatus.cs
- RuntimeIdentifierPropertyAttribute.cs
- EdmItemError.cs
- RemoteX509Token.cs
- UrlPath.cs
- ProfileEventArgs.cs
- SpeakCompletedEventArgs.cs
- EraserBehavior.cs
- TriggerBase.cs
- SqlBulkCopy.cs
- XhtmlConformanceSection.cs
- AutoCompleteStringCollection.cs
- RelatedPropertyManager.cs
- QilUnary.cs
- RemotingException.cs
- ReadOnlyKeyedCollection.cs
- TextElementEnumerator.cs
- OletxResourceManager.cs
- ClosableStream.cs
- SqlTriggerContext.cs
- ResourceSet.cs
- BinaryReader.cs
- CodeActivityMetadata.cs
- PenThreadWorker.cs
- DirectoryInfo.cs
- ProviderCommandInfoUtils.cs
- BaseResourcesBuildProvider.cs
- IncrementalCompileAnalyzer.cs
- SqlTypeConverter.cs
- MobileErrorInfo.cs
- BindStream.cs
- Sql8ExpressionRewriter.cs
- Block.cs
- SvcMapFileLoader.cs
- WebPartDisplayModeCollection.cs
- ParallelSeparator.xaml.cs
- SerializationInfo.cs
- PropertyEmitter.cs
- XmlSchemaAll.cs
- ServerValidateEventArgs.cs
- Page.cs
- StatusBarDrawItemEvent.cs
- ListParagraph.cs
- AnyReturnReader.cs
- ShapingEngine.cs
- NameValuePermission.cs
- ContainerFilterService.cs
- PtsPage.cs
- MaskedTextProvider.cs
- FileUtil.cs
- ObjectSecurityT.cs
- XmlEncoding.cs
- RowToFieldTransformer.cs
- oledbmetadatacolumnnames.cs
- ItemList.cs
- _Semaphore.cs
- StringToken.cs
- ExpandSegmentCollection.cs
- HtmlTableCellCollection.cs
- PropertyMappingExceptionEventArgs.cs
- HttpWebResponse.cs
- XmlAnyAttributeAttribute.cs
- FlowDocumentFormatter.cs
- RecordConverter.cs
- MiniLockedBorderGlyph.cs
- MatrixStack.cs
- RepeaterItemCollection.cs
- DockPatternIdentifiers.cs
- ConfigErrorGlyph.cs
- BitmapPalette.cs
- Thumb.cs
- DbgUtil.cs
- XmlSchemaAppInfo.cs
- InputLanguage.cs
- OleDbRowUpdatedEvent.cs
- JsonSerializer.cs
- MsmqTransportSecurityElement.cs
- GeneralTransformGroup.cs
- WebPartDisplayModeCollection.cs
- HttpServerVarsCollection.cs
- MLangCodePageEncoding.cs
- RestHandler.cs
- SiteMapDataSource.cs
- PeerToPeerException.cs
- HTTPNotFoundHandler.cs
- EnumBuilder.cs
- CharAnimationUsingKeyFrames.cs
- _SafeNetHandles.cs
- SqlMultiplexer.cs