Mono.UIAutomation.Winforms.ComboBoxProvider.ComboBoxListBoxProvider.GetItemPropertyValue C# (CSharp) Method

GetItemPropertyValue() public method

public GetItemPropertyValue ( ListItemProvider item, int propertyId ) : object
item ListItemProvider
propertyId int
return object
			public override object GetItemPropertyValue (ListItemProvider item,
			                                             int propertyId)
			{
				if (propertyId == AutomationElementIdentifiers.NameProperty.Id)
					return comboboxControl.GetItemText (item.ObjectItem);

				int topItem = -1;
				if (ListBoxControl != null)
					topItem = ListBoxControl.UIATopItem;

				if (ContainsItem (item) == false)
					return null;
				else if (propertyId == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id)
					return comboboxControl.Focused && item.Index == comboboxControl.SelectedIndex;
				else if (propertyId == AutomationElementIdentifiers.BoundingRectangleProperty.Id) {
					//FIXME: We need to improve this
					int index = item.Index;
					System.Drawing.Rectangle rectangle = System.Drawing.Rectangle.Empty;
					System.Drawing.Rectangle bounds = System.Drawing.Rectangle.Empty;

					if (ListBoxControl == null)
						bounds = comboboxControl.Bounds;
					else
						bounds = ListBoxControl.Bounds;

					int itemHeight = comboboxControl.GetItemHeight (0);// TODO: always true?
					rectangle.Height = comboboxControl.GetItemHeight (index);
					rectangle.Width = bounds.Width;
					rectangle.X = bounds.X;
					rectangle.Y = bounds.Y + (index * itemHeight) - (topItem * itemHeight);// decreaseY;

					if (ListBoxControl == null)
						return Helper.GetControlScreenBounds (rectangle, comboboxControl);
					else
						return Helper.GetControlScreenBounds (rectangle, ListBoxControl);
				} else if (propertyId == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
					if (comboboxControl.SelectedIndex == item.Index)
						return false;
					
					if (topItem == -1 || !ListBoxControl.Visible)
						return !(comboboxControl.SelectedIndex == item.Index);

					int lastItem = ListBoxControl.UIALastItem;				
					if ((item.Index >= topItem && item.Index < lastItem) 
					    || (item.Index == lastItem && comboboxControl.Items.Count == lastItem + 1))
						return false;
					else
						return true;
				} else
					return null;
			}