/// <summary>
        /// Create a property bag based on RecorderSetting changes.
        /// </summary>
        /// <param name="cfg"></param>
        /// <returns></returns>
        private static IDictionary <string, string> GetPropertyBag(RecorderSetting cfg)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("Scope", cfg.ListenScope.ToString());

            if (cfg.IsListeningFocusChangedEvent)
            {
                dic.Add(EventType.UIA_AutomationFocusChangedEventId.ToString(CultureInfo.InvariantCulture), EventType.GetInstance().GetNameById(EventType.UIA_AutomationFocusChangedEventId));
            }

            foreach (var e in cfg.Events)
            {
                if (e.IsRecorded)
                {
                    dic.Add(e.Id.ToString(CultureInfo.InvariantCulture), e.Name);
                }
            }

            foreach (var p in cfg.Properties)
            {
                if (p.IsRecorded)
                {
                    dic.Add(p.Id.ToString(CultureInfo.InvariantCulture), p.Name);
                }
            }

            return(dic);
        }
        /// <summary>
        /// Set the checked state based on id and type
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="val"></param>
        private void SetChecked(RecorderSetting setting, int id, RecordEntityType type, bool val, string name = null)
        {
            int change = val ? 1 : -1;

            if (type == RecordEntityType.Event)
            {
                if (id == EventType.UIA_AutomationFocusChangedEventId)
                {
                    setting.IsListeningFocusChangedEvent = val;
                }
                else
                {
                    setting.Events.Where(e => e.Id == id).First().CheckedCount += change;
                }
            }
            else
            {
                if (setting.Properties.Where(e => e.Id == id).Count() > 0)
                {
                    setting.Properties.Where(e => e.Id == id).First().CheckedCount += change;
                }
                else
                {
                    setting.Properties.Add(new RecordEntitySetting()
                    {
                        Type         = RecordEntityType.Property,
                        Id           = id,
                        Name         = name,
                        IsCustom     = true,
                        IsRecorded   = false,
                        CheckedCount = 1
                    });
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="config"></param>
 /// <param name="ec"></param>
 /// <param name="listener"></param>
 private ListenAction(RecorderSetting config, ElementContext ec, HandleUIAutomationEventMessage listener)
 {
     this.Id               = Guid.NewGuid();
     this.Config           = config;
     this.ElementContext   = ec;
     this.EventListener    = new EventListenerFactory(ec.Element, config.ListenScope);
     this.EventRecords     = new List <IA11yEventMessage>();
     this.ExternalListener = listener;
 }
Beispiel #4
0
        /// <summary>
        /// Create new Instance of ListenAction
        /// </summary>
        /// <param name="config"></param>
        /// <param name="ecId"></param>
        /// <param name="listener"></param>
        /// <returns></returns>
        public static Guid CreateInstance(RecorderSetting config, Guid ecId, HandleUIAutomationEventMessage listener)
        {
            var ec = DataManager.GetDefaultInstance().GetElementContext(ecId);
            var la = new ListenAction(config, ec, listener);

            sListenActions.Add(la.Id, la);

            return(la.Id);
        }
Beispiel #5
0
 /// <summary>
 /// Generate list of event ids to listen to from recorder setting
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 private static IEnumerable<int> GenerateEventIds(RecorderSetting config)
 {
     var eventIds = from c in config.Events
                    where config.IsListeningAllEvents || c.CheckedCount > 0
                    select c.Id;
     if (config.IsListeningFocusChangedEvent)
     {
         eventIds = eventIds.Append(EventType.UIA_AutomationFocusChangedEventId);
     }
     return eventIds;
 }
Beispiel #6
0
 /// <summary>
 /// Generate list of property ids to listen to from recorder setting
 /// </summary>
 /// <param name="config"></param>
 /// <returns></returns>
 private static IEnumerable <int> GeneratePropertyIds(RecorderSetting config)
 {
     return(from c in config.Properties
            where config.IsListeningAllEvents || c.CheckedCount > 0
            select c.Id);
 }