import	clr
clr.AddReference("Ans.UI")
clr.AddReference("Ans.TestingAddin.Base")
import	Ansys.UI
import	Ansys.TestingAddin.Base
import	System
import	re
import	Testing

class	ValueUnit:
	def	__init__(self,	lValue,	lUnit):
		self.Value	=	lValue
		self.Unit	=	lUnit
	
class	UITestQueries:

	def Debugging(self, Argument=None):
		Testing.Debugging(Argument)
	
	def	DumpHtml(self,	fileName=None):
		"""
		Usage:	UIQueries.DumpHtml()
			This	function	generates	an	xml	file	of	the	given	webpage
		Arguments:
			fileName	-	The	name	of 	the	output	file
		Returns:
			None
		Example:
			UIQueries.DumpHtml(fileName="C:\mainPage.html")
		Notes:
		"""
		
		Testing.DumpHtml(fileName)
	
	def ShowPropertyInspector(self):
		Testing.ShowPropertyInspector()

	def	QueryHtmlElement(self,	SelectorQuery=None, Attribute=None):
		"""
		Usage:	UIQueries.QueryHtmlElement()
			This	function	queries	the WebBrowser	for	element(s)	matching	the	given	CSS	Selector	Query
		Arguments:
			SelectorQuery	-	CSS	selector	used	to	search	for	elements
			Attribute	-	The	attribute	whos	value	to	return
		Returns:
			The	specified	attribute's	value	as	a	string
		Example:
			UIQueries.QueryHtmlElement("div<class='text invalid'><innertext='[[DataManager]] 2'>", "data-bind")
		Notes:
			Attribute	values	must	be	enclose	in	single	quotes
		"""
		
		Result = Testing.QueryHtmlElement(SelectorQuery,	Attribute)
		return Result
		
	def SetHtmlElement(self,	SelectorQuery=None,	Attribute=None,	Value=None):
		"""
		Usage: UIQueries.SetHtmlElement()
			This	function	queries	the	WebBrowser	for element(s)	matching	the	give	CSS	Selector	Query
			and	sets	the	Attribute	of	the	found	element(s)	to	Value
		Arguments:
			SelectorQuery	-	CSS	selector	used	to	search	for	elements
			Attribute	-	The	attribute	to	set
			Value	-	The	value	to	set	the	Attribute	to
		Returns:
			None
		Example:
			UIQueries.SetHtmlElement("div<class='text invalid'><innertext='[[DataManager]] 2'>", "data-bind", "someNewValue")
		Notes:
			Attribute	values	must	be	enclose	in	single	quotes
		"""
		
		Result = Testing.SetHtmlElement(SelectorQuery,	Attribute,	Value)
		print Result
		
	def	QueryOutlineProperty(self,	UniqueID=None):
		Result = Testing.QueryOutlineProperty(UniqueID)
		return Result
	
	def	QueryDropdownValue(self,	UniqueID=None):
		Result = Testing.QueryDropdownValue(UniqueID)
		return Result
	
	def	QueryDropdownOptions(self,	UniqueID=None):
		Result = Testing.QueryDropdownOptions(UniqueID)
		return Result
	
	def	QueryTextboxDisplayValue(self,	UniqueID=None):
		Result = Testing.QueryTextboxDisplayValue(UniqueID)
		return Result
	
	def	QueryTextboxEditableValue(self,	UniqueID=None):
		Result = Testing.QueryTextboxEditableValue(UniqueID)
		return Result
	
	def SetOutlineProperty(self,	UniqueID=None,	Value=None):
		Result = Testing.SetOutlineProperty(UniqueID,	Value)
		print Result
	
	def	GetParameterByDP(self,	DesignPoint=None,	ParameterName=None):
		"""
		Usage:	UIQueries.GetParameterByDP()
		This	function	gets	the	Value	and	Unit	from	the	Design	Point	Window	Table
		Arguments:
			DesignPoint:	0	for	current	DP	for	other	DP	respective	DP	#
			ParameterName:	Paramter	Name	String	as	displayed	in	the	Table
		Returns:
			The	Value	and	Unit	of	the	specified	Parameter
		Example:	
			parmValue	=	UIQueries.GetParameterByDP(
						DesignPoint=1,ParameterName='P2	-	Pressure	Magnitude').Value
			parmUnit	=	UIQueries.GetParameterByDP(
						DesignPoint=1,ParameterName='P2	-	Pressure	Magnitude').Unit
		Notes:	Typically	used	in	getting	Value	and	Unit	from	Design	Point	Table	window"""
				
		tabData	=	Testing.GetUIViewContents(ViewName="TabularDataView")
		ParamCol	=	tabData[1].index(ParameterName)
		DPRow	=	DesignPoint+3
		UnitRow	=	2
		MyValue	=	tabData[DPRow][ParamCol]
		s	=	MyValue.find("[")
		if	s	>	-1:
			value	=	float(MyValue[:(s-1)])
			unit	=	MyValue[(s+1):].replace("]",	"")
		else:
			value	=	float(MyValue)
			unit	=	''
		result	=	ValueUnit(value,unit)
		return	result

	def	ActivateWorkspace(self,	WorkspaceName=None):
		"""
		Usage:	UIQueries.ActivateWorkspace()
		This	function	activates	the	specified	Workspace
		Arguments:
			WorkspaceName:	Can	be	any	of	the	following:
							"Schematic"	
							"Components"	
		Returns:
			None
		Example:	
			UIQueries.ActivateWorkspace(WorkspaceName="Schematic")
			UIQueries.ActivateWorkspace(WorkspaceName="Components")
		Notes:	Typically	used	to	activate	a	Workspace	before	calling	further	UIQueries	on	that	Workspace"""


		UIManager	=	Ansys.UI.UIManager.Instance
		Workspace	=	UIManager.GetActiveWorkspace()
		Workspace.ActivateWorkspace(WorkspaceName)

	def _isNonParameterColumn(self, name):
		'''Returns true if the supplied name is one of the known 
columns that don't refer to a parameter.'''
		# Strip [] in case we're running with 
		# ANSYS_FRAMEWORK_DEVELOPMENT set and there
		# are missing translations.
		name = name.replace('[','').replace(']','')
		return name in ('Name',	'Exported',	'Export', 'Retained', 'Retain', 'Retain (Beta)', 'Retained Data', 'Retained Data (Beta)', 'Note')
		
	def _quantityStringToTwoElementList(self, quantityString):
		valueAndUnit	=	[]	
		s	=	quantityString.find("[")
		if	s	>	-1:
			valueAndUnit.append(float(quantityString[:(s-1)]))
			valueAndUnit.append(quantityString[(s+1):].replace("]",	""))
		else:
			valueAndUnit.append(float(quantityString))
			valueAndUnit.append('')
		return valueAndUnit
	
	def	GetDPData(self):
		DPData	=	{}
		UIQueries.SelectCell("Parameters")
		UIQueries.ActivateWorkspace(WorkspaceName="Components")
		DPData	=	Testing.GetUIViewContents("TabularDataView")
		for	j	in	range(len(DPData)):
			if	j	not	in	[0,1,2,len(DPData)-1]:
				for	i	in	range(len(DPData[j])):
					if	not self._isNonParameterColumn(DPData[1][i]):
						DPData[j][i]	=	self._quantityStringToTwoElementList(DPData[j][i])
		return	DPData

	def	SelectCell(self,	SystemName=None,	CellName=None):
		"""
		Usage:	UIQueries.SelectCell()
		This	function	selects	a	particular	cell	in	the	project	schematic
		Arguments:
			SystemName	-	System	Name
			CellName	-	Cell	Name		
		Returns:
			None
		Example:	
			UIQueries.SelectCell(SystemName="SMD",	CellName="Parameters")
			UIQueries.SelectCell(SystemName="Parameters	Set",	CellName="None")
		Notes:	See	also	UIQueries.ActivateWorkspace()"""
		
		UIManager	=	Ansys.UI.UIManager.Instance
		workSpace	=	UIManager.GetActiveWorkspace()
		psView	=	workSpace.GetView("ProjectSchematic")
		diagram	=	psView.Control
		systemBlocks	=	diagram.Blocks
		
		system	=	None
		cell	=	None
		for	systemBlock	in	systemBlocks:
			if	systemBlock	!=	None:
				if	systemBlock.Text	==	SystemName:
					system	=	systemBlock					
					break
		if	systemBlock.Text	== "Parameter Set":			
			systemBlock.Select()
			workSpace.ActivateWorkspace("Schematic")
			return
		elif	not	system:
			print	"Unable	to	find	system",	SystemName
			return
			
		for	cell	in	system.Cells:
			if	cell	!=	None:
				if	cell.Text	==	CellName:
					cell.Select()					
					if	cell.Text	==	"Parameters":
						workSpace.ActivateWorkspace("Schematic")
					else:
						workSpace.ActivateWorkspace("Schematic")
					break
		if	not	cell:
			print	"Unable	to	find	cell",	cellName
		return							

	def GetContextMenuEntries(self, includeSubmenus = False):
		"""
		Usage: UIQueries.GetContextMenuEntries()
		
		This function returns the names, and a little information, about the entries
		that would be visible were a context menu to be popped up with the current
		selection."""
		cmm = Ansys.UI.UIManager.Instance.ContextMenuManager
		activeView = Ansys.UI.UIManager.Instance.GetActiveWorkspace().ActiveView
		guiEntities = cmm.GetApplicableGuiEntitiesWrappedForPython(None, activeView, None)
		
		return self._getMenuInfoForVisibleGuiEntities(guiEntities, includeSubmenus)
	
	def _getMenuInfoForVisibleGuiEntities(self, entities, includeSubentities = True):
		menuEntries = {}
		for guiEntity in entities:
			if not guiEntity.Visible:
				continue
			
			entry = {}

			name  = guiEntity.DisplayText
			if not name:
				name = guiEntity.EntityName
			if not name:
				# if it has no name at all, it's probably a separator
				continue
			name = name.replace("&","")
			
			entry["Enabled"] = guiEntity.Enabled
			#entry["Visible"] = guiEntity.Visible
			entry["Checkable"] = guiEntity.Checkable
			if guiEntity.Checkable:
				entry["Checked"] = guiEntity.Checked
			
			items = guiEntity.GuiEntityList
			if items:
				if includeSubentities:
					entry["Items"] = self._getMenuInfoForVisibleGuiEntities(items)
				else:
					entry["Items"] = True

			menuEntries[name] = entry
				
		return menuEntries
	
	def GetVisibleMenuItems(self):
		"""
		Usage: UIQueries.GetVisibleMenuItems()
		
		This function returns the names, and a little information, about the entries
		on the main menu."""
		activeView = Ansys.UI.UIManager.Instance.GetActiveWorkspace().ActiveView
		Ansys.UI.UIManager.Instance.MenuManager.Refresh(activeView)
		return self._getMenuInfoForVisibleGuiEntities(Ansys.UI.UIManager.Instance.MenuManager.GetMenuEntitiesWrappedForPython())

	def	GetUIParameterValues(self,DesignPoint):
		"""
		Usage:	UIQueries.GetUIParameterValues()
		This	function	returns	the	value/unit	of	all	parameters	for	a	specified	design	point
		Arguments:
			Design	Point	
			-	Equal	to	"0"	for	the	"Current	DP"
			-	Equal	to	"N"	for	"DP	N"		
		Returns:
			The	value	and	unit	of	all	parameters	for	the	design	point	specified
		Examples:	
			UIQueries.GetUIParameterValues(0)
			UIQueries.GetUIParameterValues(3)
		Notes:	See	also	UIQueries.ActivateWorkspace()"""

		UIQueries.ActivateWorkspace(WorkspaceName="Schematic")
		UIQueries.SelectCell(SystemName="Parameter	Set",	CellName=	"None")

		ParameterValues	=	{}
		TabData	=	Testing.GetUIViewContents(ViewName="TabularDataView")
		DPRow	=	DesignPoint+3
		UnitRow	=	2
		for	i	in	range(len(TabData[1])):
			Value	=	[]	
			if	not self._isNonParameterColumn(TabData[1][i]):
				ParameterValues[TabData[1][i]] = self._quantityStringToTwoElementList(TabData[DPRow][i])

		return	ParameterValues
		
	def	GetActiveWorkspace(self):
		"""
		Utility	method	used	for	minimizing	disruption	to	UI	tests	that
		were	invoking	ActivateView	and	ActivateWorkspace	from	UIManager
		"""	
		workspace	=	Workspace()
		return	workspace
		
	#start	new	UI	method	definitions
	
	def	SelectCellByRow(self,	SystemName=None,	Row=None):
		"""
		Usage:	UIQueries.SelectCellByRow()
		This	function	selects	a	particular	cell	in	the	project	schematic
		Arguments:
			SystemName	-	System	Name	
			Row	-	The	cell's	row	index
		Returns:
			None
		Example:	
			UIQueries.SelectCellByRow(SystemName="EngData",	1)
		Notes:	See	also	UIQueries.ActivateWorkspace()"""
		
		Testing.SelectCellByRow(SystemName,	Row)
		return
	
	def	SelectGridViewCellByName(self,	ViewName=None,	CellText=None):
		"""
		Usage:	UIQueries.SelectGridViewCell()
		This	function	selects	a	particular	cell	in	the	project	schematic
		Arguments:
			ViewName	-	View	Name
			CellText	-	The	Cell's	Display	Text
		Returns:
			None
		Example:	
			UIQueries.SelectGridViewCellCell(ViewName="Data",	CellText="File")
		Notes:	See	also	UIQueries.ActivateWorkspace()"""
		
		Testing.SelectGridViewCellByName(ViewName,	CellText)
		return	
	
	def	GetView(self,	ViewName=None):
		"""
		Usage:	UIQueries.GetView()
		This	function	obtains	a	specific	view	from	the	current	workspace
		Arguments:
		Returns:
			The	view
		Example:	
		Notes:	Typically	used	to	activate	a	Workspace	before	calling	further	UIQueries	on	that	Workspace"""


		UIManager	=	Ansys.UI.UIManager.Instance
		Workspace	=	UIManager.GetActiveWorkspace()
		View	=	None
		View	=	Workspace.GetView(ViewName)
		return	View	
	
	def	RefreshUI(self):
		"""
		Usage:	UITestingQueries.RefreshUI()
		Initiates	a	UI	refresh
		ActivateViewForUIQueries	command
		Arguments:
			None
		Returns:
			None
		Example:
			UITestingQueries.RefreshUI()
		Notes:
			None"""
		
		Testing.RefreshUI()
		return
	
	def	SetGridViewCellValue(self,	ViewName=None,	Row=None,	Col=None,	NewCellValue=None):
		"""
		Usage:	UITestingQueries.SelectViewGridCell()
		Set	a	View's	GridCell	value	based	upon	its	row/col
		coordinates	within	the	View's	GridView.
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
			NewCellValue	-	the	new	value	to	set	the	Cell	to
		Returns:
			None
		Example:
			UITestingQueries.SetViewGridCellValue("Data",	1,	1,	"Testing")
		Notes:
			None"""
		
		Testing.SetGridViewCellValue(ViewName,	Row,	Col,	NewCellValue)
		return
		
	def	SelectGridViewCellByIndex(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UITestingQueries.SelectViewGridCell()
		Select	a	View's	GridCell	based	upon	its	row/col
		coordinates	within	the	View's	GridView.
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			The	GridViewCell	(Ansys.UI.Toolkit)	object	representing	the	UI	Cell
		Example:
			UITestingQueries.SelectViewGridCell("Data",	1,	1)
		Notes:
			None"""
		
		Testing.SelectGridViewCellByIndex(ViewName,	Row,	Col)		
		return
		
	def	GetGridViewCellText(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UITestingQueries.SelectViewGridCell()
		Obtain	a	View's	GridCell	UI	Text	based	upon	its	row/col
		coordinates	within	the	View's	GridView.
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			The	GridViewCell's	UI	Text	string
		Example:
			UITestingQueries.GetViewGridCellText("Data",	1,	1)
		Notes:
			None"""

		CellText	=	Testing.GetGridViewCellText(ViewName,	Row,	Col)
		return	CellText
		
	def	DoesFileExistInFilesView(self,	FileName=None):
		"""
		Usage:	UITestingQueries.DoesFileExistInFilesView("FileName.Extension")
		Checks	if	the	supplied	file	exists	in	the	UI	Files	View
		Arguments:
			FileName	-	The	name	of	the	file	to	check
		Returns:
			True	if	the	file	exists	in	the	View,	false	otherwise.
		Example:
			UITestingQueries.DoesFileExistInFilesView("TST.inp")
		Notes:
			None"""

		Exists	=	Testing.DoesFileExistInFilesView(FileName)
		return	Exists
		
	def	GetGridViewCellOptions(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UIQueries.SelectViewGridCell()
		Obtains	an	array	of	a	View's	GridCell	UI	Options	(if	available).
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			The	GridViewDropDownCell's	UI	string	options
		Example:
			UIQueries.GetViewGridCellOptions("Data",	1,	1)
		Notes:
			None"""

		CellOptions	=	Testing.GetGridViewCellOptions(ViewName,	Row,	Col)
		return	CellOptions
		
	def	GetGridViewCellState(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UIQueries.GetViewGridCellState()
				Acquires	a	View's	GridViewCell's	CellState	field.
				This	will	be	set	to	one	of	the	following	states:
				-UpToDate
				-OutOfDate
				-Unfulfilled
				-NeverSolved
				-OutOfDateInput
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			The	Cell's	CellState	field.
		Example:
			testCellState	=	UIQueries.GetViewGridCellState("Data",	1,	1)
		Notes:
			None."""
		
		cellState	=	Testing.GetGridViewCellState(ViewName,	Row,	Col)
		return	cellState
		
	def	IsGridViewCellUpToDate(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UIQueries.IsViewGridCellUpToDate()
				Queries	whether	the	cell	in	question	is	Up-to-date.
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			A	bool	value	indicating	true	if	cell	is	up	to	date,	false	otherwise.
		Example:
			cellUpToDate	=	UIQueries.IsViewGridCellUpToDate("Data",	1,	1)
		Notes:
			None."""
		cellUpToDate	=	Testing.IsGridViewCellUpToDate(ViewName,	Row,	Col)
		return	cellUpToDate
		
	def	GetAvailableViewNames(self):
		"""
		Usage:	UIQueries.PrintAvailableViewNames()
		prints	the	names	of	all	Views	contained	in	the	active	workspace.
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			List	of	view	names.
		Example:
			UIQueries.GetViewGridCellOptions("Data",	1,	1)
		Notes:
			None"""
			
		ViewNames	=	Testing.GetAvailableViewNames()
		return	ViewNames
		
	def	ExpandGridViewRowGroup(self,	ViewName=None,	Row=None):
		"""
		Usage:	UIQueries.ExpandViewGridRowGroup()
		Expand	a	View's	GridCellGroup	based	upon	the	row	of
		the	group's	parent
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
		Returns:
			None
		Example:
			UIQueries.ExpandViewGridRowGroup("Property",	1)
		Notes:
			GridViewRows	start	at	ONE	and	NOT	zero"""

		Testing.ExpandGridViewRowGroup(ViewName,	Row)
		return

	def	CollapseGridViewRowGroup(self,	ViewName=None,	Row=None):
		"""
		Usage:	UIQueries.ExpandViewGridRowGroup()
		Collapse	a	View's	GridCellGroup	based	upon	the	row	of
		the	group's	parent
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
		Returns:
			None
		Example:
			UIQueries.CollapseGridViewRowGroup("Property",	1)
		Notes:
			None"""

		Testing.CollapseGridViewRowGroup(ViewName,	Row)
		return
		
	def	CollapseAllGridViewRowGroups(self,	ViewName=None):
		"""
		Usage:	UIQueries.CollapseAllGridViewRowGroups()
		Collapse	all	row	groups	in	a	given	view
		Arguments:
			ViewName	=	the	name	of	the	view	that	contains	the	rows
		Returns:
			None
		Example:
			UIQueries.CollapseAllGridViewRowGroups("Property")
		Notes:
			None"""
		
		Testing.CollapseAllGridViewRowGroups(ViewName)
		return
	
	def	ExpandAllGridViewRowGroups(self,	ViewName=None):
		"""
		Usage:	UIQueries.ExpandAllGridViewRowGroups()
		Expand	all	row	groups	in	a	given	view
		Arguments:
			ViewName	=	the	name	of	the	view	that	contains	the	rows
		Returns:
			None
		Example:
			UIQueries.ExpandAllGridViewRowGroups("Property")
		Notes:
			None"""
		
		Testing.ExpandAllGridViewRowGroups(ViewName)
		return
	
	def	ExpandToolboxGroup(self,	GroupName=None):
		"""
		"""
		
		Testing.ExpandToolboxGroup(GroupName)
		return
		
	def	CollapseToolboxGroup(self,	GroupName=None):
		"""
		"""
		
		Testing.CollapseToolboxGroup(GroupName)
		return
		
	def	IsToolboxEntryEnabled(self,	GroupName=None,	EntryName=None):
		"""
		"""
			
		isEnabled	=	Testing.IsToolboxEntryEnabled(GroupName,	EntryName)
		return	isEnabled
		
	def	SelectToolboxEntry(self,	GroupName=None,	EntryName=None):
		"""
		"""
		
		Testing.SelectToolboxEntry(GroupName,	EntryName)
		return
		
	def	AddEntryFromToolbox(self,	GroupName=None,	EntryName=None):
		"""
		"""
		
		Testing.AddEntryFromToolbox(GroupName,	EntryName)
		return

	def	GetUIText(self,	ViewName=None,	Row=None,	Col=None):
		"""
		Usage:	UIQueries.GetUIText()
		This	helper	function	returns	the	text	of	the	selected	cell	(based	on	its	Row/Col)	from	the	selected	view
		Arguments:
			ViewName	-	The	name	of	the	view	the	contains	the	cell
			Row	-	The	Cell's	row	number
			Col	-	The	Cell's	column	number
		Returns:
			The	text	contained	in	the	cell
		Example:	
			UIQueries.GetUIText("Messages",1,1)"""

		success	=	False
		text	=	""
		while(not(success)):		
			try:
				text	=	UIQueries.GetGridViewCellText(ViewName,	Row,	Col)
				success	=	True
			except:
				if	text	==	None:
					success	=	True
				else:
					success	=	False			
		return	text
	
	def	IsMessagePresent(self,	Message=None):
		"""
		Usage:	UIQueries.IsMessagePresent()
		Checks	the	messages	window	in	the	project	schematic	to	see	if	the	message	is	present
		Arguments:
			Message	-	The	messsage	that	will	be	checked	for	in	the	messages	view
		Returns:
			True	if	the	message	is	present,	False	otherwise
		Example:	
			UIQueries.IsMessagePresent("Method(s)	bound	to	command	EngData.WriteMixtures	which	has	an	optional	primary	reference	argument.")"""
		uiManager	=	Ansys.UI.UIManager.Instance
		test	=	uiManager.GetActiveWorkspace()
		count	=	1
		temp	=	UIQueries.GetUIText("Messages",count,1)
		while	temp	!=	None:
			if	temp	==	Message:
				return	True
			count	=	count	+	1
			temp	=	UIQueries.GetUIText("Messages",count,1)
		return	False

	#end	new	UI	method	definitions

if	__name__	==	'__main__':
	UIQueries	=	UITestQueries()
	


class	Workspace():
		
	def	ActivateView(self,	ViewName):
		"""
		Utility	method	to	call	C#	that	wraps	activate	view	with	Invoke	operation
		for	the	purpose	of	forcing	a	refresh
		"""
		Testing.ActivateViewForUIQueries(ViewName)
		
	def	DeactivateView(self,	ViewName):
		"""
		Utility	method	to	call	C#	that	wraps	de-activate	view	with	Invoke	operation
		for	the	purpose	of	forcing	a	refresh
		"""
		Testing.DeactivateViewForUIQueries(ViewName)		
	
	def	ActivateWorkspace(self,	WorkspaceName):	
		"""
		Utility	method	to	call	C#	that	wraps	activate	workspace	with	Invoke	operation
		for	the	purpose	of	forcing	a	refresh
		"""	
		Testing.ActivateWorkspaceForUIQueries(WorkspaceName)