public TriColorFragmentProvider(TriColorControl control, IRawElementProviderFragmentRoot root, TriColorValue value) : base((IRawElementProviderFragment)root /* parent */, root /* fragmentRoot */) { _control = control; _value = value; // Populate static properties // // In a production app, Name should be localized AddStaticProperty(UIA_PropertyIds.UIA_NamePropertyId, _value.ToString()); AddStaticProperty(UIA_PropertyIds.UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_CustomControlTypeId); // In a production app, LocalizedControlType should be localized AddStaticProperty(UIA_PropertyIds.UIA_LocalizedControlTypePropertyId, "tri-color item"); AddStaticProperty(UIA_PropertyIds.UIA_ProviderDescriptionPropertyId, "UIASamples: Tri-Color Fragment Provider"); AddStaticProperty(UIA_PropertyIds.UIA_AutomationIdPropertyId, _value.ToString()); AddStaticProperty(UIA_PropertyIds.UIA_IsKeyboardFocusablePropertyId, false); AddStaticProperty(UIA_PropertyIds.UIA_IsControlElementPropertyId, true); AddStaticProperty(UIA_PropertyIds.UIA_IsContentElementPropertyId, false); }
public TriColorFragmentProvider(TriColorControl control, IRawElementProviderFragmentRoot root, TriColorValue value) : base((IRawElementProviderFragment) root /* parent */, root /* fragmentRoot */) { _control = control; _value = value; // Populate static properties // // In a production app, Name should be localized AddStaticProperty(UIA_PropertyIds.UIA_NamePropertyId, _value.ToString()); AddStaticProperty(UIA_PropertyIds.UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_CustomControlTypeId); // In a production app, LocalizedControlType should be localized AddStaticProperty(UIA_PropertyIds.UIA_LocalizedControlTypePropertyId, "tri-color item"); AddStaticProperty(UIA_PropertyIds.UIA_ProviderDescriptionPropertyId, "UIASamples: Tri-Color Fragment Provider"); AddStaticProperty(UIA_PropertyIds.UIA_AutomationIdPropertyId, _value.ToString()); AddStaticProperty(UIA_PropertyIds.UIA_IsKeyboardFocusablePropertyId, false); AddStaticProperty(UIA_PropertyIds.UIA_IsControlElementPropertyId, true); AddStaticProperty(UIA_PropertyIds.UIA_IsContentElementPropertyId, false); }
// Raise appropriate events for the value changing public void RaiseEventsForNewValue(TriColorValue oldValue, TriColorValue newValue) { // Since we support Value pattern, raise a PropertyChanged(Value) event // Values are represented as strings. NativeMethods.UiaRaiseAutomationPropertyChangedEvent(this, UIA_PropertyIds.UIA_ValueValuePropertyId, oldValue.ToString(), newValue.ToString()); // Since we support Selection pattern, raise a SelectionChanged event. // Since a top-level AutomationEvent exists for this event, we raise it, // rather than raising PropertyChanged(Selection) NativeMethods.UiaRaiseAutomationEvent( this, UIA_EventIds.UIA_SelectionItem_ElementSelectedEventId); }