Declaration of the pattern schema, with all of the information UIA needs about this property.
Inheritance: ManagedUiaCustomizationCore.CustomPatternSchemaBase
Beispiel #1
0
        public TriColorProvider(TriColorControl control)
        {
            _control = control;

            // Populate static properties
            //
            AddStaticProperty(UIA_PropertyIds.UIA_ControlTypePropertyId, UIA_ControlTypeIds.UIA_CustomControlTypeId);
            AddStaticProperty(UIA_PropertyIds.UIA_LocalizedControlTypePropertyId, "tri-color picker");
            AddStaticProperty(UIA_PropertyIds.UIA_ProviderDescriptionPropertyId, "UIASamples: Tri-Color Provider");
            AddStaticProperty(UIA_PropertyIds.UIA_HelpTextPropertyId,
                              "This is a color picker for a choice of three colors.  Use Up and Down arrows to move the selection between the colors.");
            // The WinForm name for this control makes a good Automation ID.
            AddStaticProperty(UIA_PropertyIds.UIA_AutomationIdPropertyId, _control.Name);
            AddStaticProperty(UIA_PropertyIds.UIA_IsKeyboardFocusablePropertyId, true);
            AddStaticProperty(UIA_PropertyIds.UIA_IsControlElementPropertyId, true);
            AddStaticProperty(UIA_PropertyIds.UIA_IsContentElementPropertyId, true);

            // Some properties are provided for me already by HWND provider
            // NativeWindowHandle, ProcessId, FrameworkId, IsEnabled, HasKeyboardFocus

            // Register for custom property
            ReadyStateSchema.GetInstance().Register();

            // Register for custom pattern
            ColorSchema.GetInstance().Register();

            // TEST: Register for test schema
            TestSchema.GetInstance().Register();
        }
Beispiel #2
0
        public override object GetPatternProvider(int patternId)
        {
            // We just respond with ourself for the patterns we support.
            if (patternId == UIA_PatternIds.UIA_ValuePatternId ||
                patternId == UIA_PatternIds.UIA_SelectionPatternId ||
                patternId == ColorSchema.GetInstance().PatternId)
            {
                return(this);
            }

            // TEST: Respond with a test schema object on request
            if (patternId == TestSchema.GetInstance().PatternId)
            {
                return(new TestPatternProvider(this));
            }

            return(base.GetPatternProvider(patternId));
        }
        public void Dispatch(object pTarget, uint index, UIAutomationParameter[] pParams, uint cParams)
        {
            // Parse the provider and parameter list
            var provider  = (IColorProvider)pTarget;
            var paramList = new UiaParameterListHelper(pParams);

            // Dispatch the method/property calls
            if (index == ColorSchema.GetInstance().ValueAsColorProperty.Index)
            {
                paramList[0] = provider.ValueAsColor;
            }
            else if (index == ColorSchema.GetInstance().SetValueAsColorMethod.Index)
            {
                provider.SetValueAsColor((int)paramList[0]);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
 public void SetValueAsColor(int value)
 {
     CallMethod(ColorSchema.GetInstance().SetValueAsColorMethod, value);
 }