1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Automation
7 using System.Collections.Generic;
8 using System.Diagnostics;
9 using System.Globalization;
12 using System.Windows.Automation;
13 using System.Windows.Automation.Peers;
14 using System.Windows.Automation.Provider;
15 using System.Windows.Controls;
16 using System.Windows.Media;
18 using System.Activities.Presentation.PropertyEditing;
19 using System.Activities.Presentation;
21 using System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.PropertyInspector;
22 using System.Activities.Presentation.Internal.PropertyEditing.Model;
23 using System.Activities.Presentation.Internal.PropertyEditing.Selection;
24 using System.Activities.Presentation.Internal.Properties;
27 // AutomationPeer for CategoryList class
29 internal class CategoryListAutomationPeer : ItemsControlAutomationPeer, IAutomationFocusChangedEventSource
32 private CategoryList _control;
34 private List<AutomationPeer> _children;
39 // <param name="owner">Contained CategoryList</param>
40 public CategoryListAutomationPeer(CategoryList owner)
45 throw FxTrace.Exception.ArgumentNull("owner");
49 _children = new List<AutomationPeer>();
52 protected override ItemAutomationPeer CreateItemAutomationPeer(object item)
55 ItemAutomationPeer peer = CategoryContainerAutomationPeer.CreateItemAutomationPeer(
56 item as ModelCategoryEntry,
57 _control.ItemContainerGenerator.ContainerFromItem(item) as CiderCategoryContainer,
60 //Add each item to the children's list
66 protected override string GetClassNameCore()
68 return typeof(ItemsControl).Name;
71 protected override string GetNameCore()
73 return Resources.PropertyEditing_CategoryList;
76 // We use the ItemStatus to convey read-only property selection status
77 protected override string GetItemStatusCore()
79 FrameworkElement selection = _control.Selection;
82 if (selection != null)
84 ISelectionStop selectionStop = PropertySelection.GetSelectionStop(selection);
85 status = selectionStop == null ? null : selectionStop.Description;
89 status = string.Format(
90 CultureInfo.CurrentCulture,
91 Resources.PropertyEditing_SelectionStatus_Unknown,
92 selection.GetType().Name);
97 status = Resources.PropertyEditing_SelectionStatus_Empty;
103 // IAutomationFocusChangedEventSource Members
104 public void UnloadEventHook()
106 if (_children != null)
108 foreach (AutomationPeer peer in _children)
110 IAutomationFocusChangedEventSource unhookEventPeer = peer as IAutomationFocusChangedEventSource;
111 if (unhookEventPeer != null)
113 unhookEventPeer.UnloadEventHook();