public ScreenItem(UIItem uiItem, IScrollBars scrollBars) { this.uiItem = uiItem; if (scrollBars == null || scrollBars.Vertical == null) return; verticalScroll = scrollBars.Vertical; }
private ToolTip GetToolTip(UIItem uiItem, ActionListener actionListener) { mouse.Click(uiItem.Bounds.Center()); actionListener.ActionPerformed(Action.WindowMessage); Thread.Sleep(CoreAppXmlConfiguration.Instance.TooltipWaitTime); return ToolTip.GetFrom(uiItem.Bounds.Center()); }
public void OnUIClose(UIItem item) { if (!m_toRemoveList.Contains(item)) { m_toRemoveList.Add(item); } TryShowItem(); TryReleaseCache(); }
// When game started, assign the image to the UIItem, find the selected item public void Awake() { spriteImage = GetComponent <Image>(); UpdateItem(null); selectedItem = GameObject.Find("SelectedItem").GetComponent <UIItem>(); tooltip = GameObject.Find("Tooltip").GetComponent <Tooltip>(); equipped = GameObject.Find("Equipped Master Panel").GetComponent <Equipped>(); click = GameObject.Find("Click Sound").GetComponent <AudioSource>(); player = GameObject.Find("Player").GetComponent <PlayerMovement>(); }
public void Awake() { for (int i = 0; i < slotPanel.transform.childCount; i++) { UIItem uiItem = slotPanel.transform.GetChild(i).GetComponent <UIItem>(); uiItems.Add(uiItem); } UpdateSelectedItem(0); }
public override void OnItemClick(UIItem item) { base.OnItemClick(item); if (item.HasName("BtnRestart")) { mRunner.Restart(); SetVisibility(false); } }
internal bool WaitUtilDisplayed(UIItem UI, int iWait) { int iTemp = this.iGlobalWait; this.iGlobalWait = iWait; bool bResult = WaitUtilDisplayed(UI); this.iGlobalWait = iTemp; return(bResult); }
public ScreenItem(UIItem uiItem, IScrollBars scrollBars) { this.uiItem = uiItem; if (scrollBars == null || scrollBars.Vertical == null) { return; } verticalScroll = scrollBars.Vertical; }
private void setIntListener(UIItem item = null) { int key = item.Key; if (!dicSignals.ContainsKey(key)) { dicSignals.Add(key, item); } AddEventHandler(key, pkt => { dicSignals[key].ValueFloatGet = pkt.getPacketInt(); }); }
public static Table GetFastTable(this UIItem item, string id, int searchDepth = 3) { var element = item.GetElement(SearchCriteria.ByAutomationId(id).AndControlType(ControlType.Table)); if (element == null) { return(null); } return(new FastTable(element, new NullActionListener())); }
private static UIItem Find(UIItem item, string name, int maxDepth) { AutomationElement element = Find(item.AutomationElement, name, maxDepth); if (element == null) { return(null); } return((UIItem)_factory.Create(element, item.ActionListener)); }
private void Set_DiscreteIO(string description, ObservableCollection <UIItem> observableCollection, int key) { UIItem uiItem = new UIItem("", key) { Description = description }; _dicDiscreteIO[key] = uiItem; observableCollection.Add(uiItem); }
public void RefreshItemNumByClientData(int itemNum) { if (m_tranIcon != null) { if (itemNum > 0) { UIItem.AttachParent(m_tranIcon, m_useItemData.itemid, (uint)itemNum); } } }
/// <summary> /// Get a DataGridRow based on SearchCriteria /// </summary> /// <param name="searchCriteria">UIItem identification conditions</param> /// <param name="friendlyName">Friendly name for DataGridRow</param> /// <param name="scope">Scope of search</param> /// <param name="timeout">Timeout value for search (milliseconds)</param> /// <returns>Matching DataGridRow</returns> public static QADataGridRow Get( SearchCriteria searchCriteria, string friendlyName, UIItem scope = null, int timeout = 0) { var dataGridRow = FindUIItem(searchCriteria, scope, timeout); return(new QADataGridRow(dataGridRow, friendlyName)); }
public void ScrollUpWithHotKeys() { UIItem.Focus(); Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.PAGEDOWN); Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.PAGEUP); while (UIItem.ScrollBars.Vertical.IsNotMinimum) { Desktop.Instance.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.PAGEUP); } }
public void DropItem(UIItem selectedItem) { if (selectedItem != null && selectedItem.item != null) { // Remover da lusta de character chacacterItems.Remove(selectedItem.item); // Setar item igual a null no slot do inventário selectedItem.UpdateItem(null); } }
void InitOldPet(uint petID) { m_uPetOldThisID = petID; petDataManager.AddInhertPet((int)PetInheritPos.Old, petID); IPet pet = petDataManager.GetPetByThisID(petID); if (pet != null) { uint baseID = pet.PetBaseID; m_uOldPetBaseID = baseID; PetDataBase pdb = GameTableManager.Instance.GetTableItem <PetDataBase>(baseID); if (pdb != null) { m_label_Old_name.text = petDataManager.GetPetName(pet); //DataManager.Manager<UIManager>().SetSpriteDynamicIcon(m_sprite_Old_icon, pdb.icon); UIManager.GetTextureAsyn(pdb.icon, ref m_inheritOldIconAsynSeed, () => { if (null != m__Old_icon) { m__Old_icon.mainTexture = null; } }, m__Old_icon, false); string bgSpriteName = ItemDefine.GetItemFangBorderIconByItemID(pdb.ItemID); //DataManager.Manager<UIManager>().SetSpriteDynamicIcon(m_sprite_OldIconBox, bgSpriteName); UIManager.GetAtlasAsyn(bgSpriteName, ref m_inheritOldQuaAsynSeed, () => { if (null != m_sprite_OldIconBox) { m_sprite_OldIconBox.atlas = null; } }, m_sprite_OldIconBox, false); int oldLv = pet.GetProp((int)CreatureProp.Level); m_label_Old_level_Before.text = oldLv.ToString(); m_label_Old_level_After.text = "0"; m_label_Old_skill_Before.text = pet.GetPetSkillList().Count.ToString(); m_label_Old_skill_After.text = "0"; m_label_Old_xiuwei_Before.text = pet.GetProp((int)PetProp.YinHunLevel).ToString(); m_label_Old_xiuwei_After.text = "0"; PetInHeritDataBase idb = GetInHeritData(m_uNewPetBaseID); if (idb != null) { UIItem.AttachParent(m_sprite_ChuanChengCommon_icon_di.transform, idb.costItem, 0, InheritGetWayCallBack); ItemDataBase db = GameTableManager.Instance.GetTableItem <ItemDataBase>(idb.costItem); if (db != null) { m_label_ChuanChengCommon_name.text = db.itemName; } m_label_ChuanChengCommon_number.text = "0/0"; } m_btn_btn_Old_delete.gameObject.SetActive(true); } } }
void ShowItemList(uint itemBaseId) { List <BaseItem> itemdataList = new List <BaseItem>(); List <BaseItem> itemdataList1 = DataManager.Manager <ItemManager>().GetItemByBaseId(itemBaseId, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN); itemdataList.AddRange(itemdataList1); table.ItemDataBase itemdb = GameTableManager.Instance.GetTableItem <table.ItemDataBase>(itemBaseId); if (itemdb != null && itemdb.EqualsId != 0) { List <BaseItem> itemdataList2 = DataManager.Manager <ItemManager>().GetItemByBaseId(itemdb.EqualsId, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN); itemdataList.AddRange(itemdataList2); } if (itemdataList.Count <= 0) { Engine.Utility.Log.Error("背包没有道具{0}", itemBaseId); } int count = m_lstUIItem.Count; while (count > 0) { m_lstUIItem[0].Release(); m_lstUIItem.RemoveAt(0); count = m_lstUIItem.Count; } m_lstUIItem.Clear(); for (int i = 0; i < itemdataList.Count; i++) { UIItem uiitem = DataManager.Manager <UIManager>().GetUICommonItem(itemBaseId, itemdataList[i].Num, itemdataList[i].QWThisID, OnSelectItem); uiitem.Attach(m_grid_root.transform); if (uiitem.GetGrid <UIItemCommonGrid>().GetComponent <UIDragScrollView>() == null) { uiitem.GetGrid <UIItemCommonGrid>().gameObject.AddComponent <UIDragScrollView>(); } //int x = (i % 3) * 85; //int y = -(i / 3) * 85; //uiitem.SetPosition(true, new Vector3(x, y, 0)); m_lstUIItem.Add(uiitem); } if (m_grid_root != null) { m_grid_root.Reposition(); } if (itemdataList.Count > 0) { OnSelectItem(m_lstUIItem[0].GetGrid <UIItemCommonGrid>()); } }
public void AddItem(ItemData item, UIItem uiItem = null) { if (uiItem) { UpdateSlot(uiItems.FindIndex(i => i == uiItem), item); } else { UpdateSlot(uiItems.FindIndex(i => i.item == null), item); } }
private void InitializeSlots(int size) { uiItems.Clear(); for (int i = 0; i < size; i++) { GameObject slotInstance = Instantiate(slotPrefab, Vector3.zero, Quaternion.identity, slotPanel); UIItem uiitem = slotInstance.GetComponentInChildren <UIItem>(); uiitem.slot = i; uiItems.Add(i, uiitem); } }
void ClickItem(short evt, UIItem item) { bagItem = item.item; itemNum = item.ItemNum; if (!gameObject.activeSelf) { gameObject.SetActive(true); } // GameObject.Find("BagMenubg").transform.position= item.transform.position; gameObject.transform.GetChild(0).position = item.transform.position; }
internal bool IsDisplayedByIndex(UIItem uIItem, int LoadIDIndex) { try { return(true); } catch { return(false); } }
/// <summary> /// Write the action (that was invoked) to output /// </summary> /// <param name="action">Name of action</param> protected void ReportAction(string action) { Report.Output( Report.Level.Action, Resources.UIItemActionMsg, action, FriendlyName, UIItem.PrimaryIdentification, UIItem.Name, UIItem.GetType().BaseType.ToString()); }
public static void xtDoDefaultAction(this UIItem item) { patt_LegacyIAccessible = Retry.For(() => ((LegacyIAccessiblePattern)item.AutomationElement.GetCurrentPattern(LegacyIAccessiblePattern.Pattern)), TimeSpan.FromSeconds(10)); try { patt_LegacyIAccessible.DoDefaultAction(); } catch (System.Runtime.InteropServices.COMException e) { } }
public void RefreshUI() { string itemName = "Item_"; #region leftui for (int i = 1; i < 4; i++) { Transform item = m_widget_ItemContent.transform.Find(itemName + i.ToString()); if (item != null) { Transform bg = item.Find("bg_" + i.ToString()); UIEventListener.Get(bg.gameObject).onClick = OnSelectItem; CompassDataBase db = compassList[i - 1]; if (db != null) { uint itemID = db.dwID; ItemDataBase idb = GameTableManager.Instance.GetTableItem <ItemDataBase>(itemID); if (idb != null) { int count = DataManager.Manager <ItemManager>().GetItemNumByBaseId(itemID); Transform icon = item.Find("icon"); if (icon != null) { UIItem.AttachParent(icon, itemID, (uint)count); } Transform name = item.Find("name"); if (name != null) { UILabel label = name.GetComponent <UILabel>(); if (label != null) { label.text = idb.itemName; } } Transform des = item.Find("description"); if (des != null) { UILabel label = des.GetComponent <UILabel>(); if (label != null) { label.text = idb.description; } } } } } } #endregion ShowStoneUIByData(homeDM.StoneID, homeDM.ComPassID, homeDM.GainStoneNum); ShowBtn(); RefreshMineState(); }
private bool VerifyColumn(UIItem column, string columnName) { if (column.GetText() == columnName) { return(true); } else { return(false); } }
private void CheckMagazineStorage(Magazine m) { UIItem uIItem = m.UIItem; StorageWindow sw = m.UIItem.StorageWindow; StorageSlot ss = (StorageSlot)m.UIItem.Slot; if (sw && ss && uIItem) { sw.DeSlot(ss, uIItem); } }
public virtual void DragVertically(UIItem uiItem, int distance) { Location = uiItem.Location; double currentXLocation = Location.X; double currentYLocation = Location.Y; HoldForDrag(); ActionPerformed(uiItem); Location = new Point(currentXLocation, currentYLocation + distance); LeftUp(); }
public string VerifyAlerts() { //to do: add condition or entity types UIItem AlertElement = null; UIItem AlertTextElement = null; try { switch (_Data.InvoiceStatus) { case "Awaiting Approval": AlertElement = _ChargesTab.AwaitingApprovalAlert; AlertTextElement = _ChargesTab.AwaitingApprovalText; break; case "In Process": AlertElement = _ChargesTab.InProcessAlert; AlertTextElement = _ChargesTab.InProcessText; break; case "Partial Payment": AlertElement = _ChargesTab.PartialPaymentAlert; AlertTextElement = _ChargesTab.PartialPaymentText; break; case "Paid": AlertElement = _ChargesTab.PaidAlert; AlertTextElement = _ChargesTab.PaidText; break; } Thread.Sleep(Constants.Wait_Medium); Assert.IsTrue(AlertElement.WaitUntilDisplayed()); if (AlertTextElement.GetText() == _Data.AlertText) { try { _LoadDetailsPage.ChargesTab_Factoring.Click(); _LoadDetailsPage.TopTab_Factoring.Click(); } catch { } return("VerifyAlertsSuccess"); } else { return("VerifyAlertsFailed"); } } catch { return("VerifyAlertsFailed"); } }
public virtual void DragVertically(MouseButton mouseButton, UIItem uiItem, int distance) { Location = uiItem.Bounds.Center(); var currentXLocation = Location.X; var currentYLocation = Location.Y; MouseButtonDown(mouseButton); ActionPerformed(uiItem); Location = new Point(currentXLocation, currentYLocation + distance); MouseButtonUp(mouseButton); }
public virtual void DragHorizontally(UIItem uiItem, int distance) { Location = uiItem.Bounds.Center(); double currentXLocation = Location.X; double currentYLocation = Location.Y; HoldForDrag(); ActionPerformed(uiItem); Location = new Point(currentXLocation + distance, currentYLocation); LeftUp(); }
public void buildUI() { skillTreeUI = new SkillTreeUI(); choiceUI = new ChoiceUI(skillDefinitionLoader.getAllWays(), way => { player.pickWay(way); showSkillTreeUI(player); }); skillTreeInterface = new UserInterface(); skillTreeInterface.SetState(skillTreeUI); currentUI = skillTreeUI; }
public virtual void ClickOutsideToolTip(UIItem uiItem, ActionListener actionListener) { actionListener.ActionPerforming(uiItem); ToolTip toolTip = GetToolTip(uiItem, actionListener); if (toolTip == null) mouse.Click(uiItem.Bounds.Center(), actionListener); else { logger.Debug("Found tooltip Clicking outside tooltip bounds"); mouse.Click(toolTip.LeftOutside(uiItem.Bounds), actionListener); } }
public virtual void RightClickOutsideToolTip(UIItem uiItem, ActionListener actionListener) { actionListener.ActionPerforming(uiItem); ToolTip toolTip = GetToolTip(uiItem, actionListener); if (toolTip == null) { //Because mouse has already been moved mouse.RightClickHere(actionListener); } else { logger.Debug("Found tooltip RightClicking outside tooltip bounds"); mouse.RightClick(toolTip.LeftOutside(uiItem.Bounds), actionListener); } }
protected void WaitUntilEnabled(UIItem element, string message = "", int maxDuration = 60) { int maxWait = (maxDuration * 1000); int retryInterval = 500; while (maxWait > 0) { if (element.Enabled) { return; } Thread.Sleep(retryInterval); maxWait -= retryInterval; } throw new AssertionException((message.Trim().Length > 0) ? message : element.Name); }
bool trySell(UIItem uitem, bool stack) { PraeItem pitem = uitem._item; int amount = (stack) ? System.Math.Min(pitem.amount, pitem.stackSize) : 1; float itemWeight = pitem.weightSingle * amount; // money constraint of shop if (!_seller.money.CanPay(uitem._item.value)) { Debug.Log("Shop has insufficient money!"); return false; } _seller.AddBoughtItem(new PraeItem(pitem, amount)); uitem._item.amount -= amount; uitem.Set(uitem._item); // update labels if (uitem._item.amount <= 0) { selectedUIItem.ResetColor(); selectedUIItem = null; // deselect item // NOTE: this is by far not the most efficient way of doing this - but whats the point in optimising shops anyway _buyer.RemoveItem(page * 10 + uitem.id); calcPagedItems(); if (page > maxPage) page = maxPage; SetUpPage(page); } // gain _seller.money.Pay(uitem._item.value); _buyer.money.Add(uitem._item.value); UIbuyerMoney.Set(_buyer.G, _buyer.K, _buyer.T); return true; }
bool tryBuy(UIItem uitem, bool stack) { PraeItem pitem = uitem._item; int amount = (stack) ? System.Math.Min(pitem.amount, pitem.stackSize) : 1; float itemWeight = pitem.weightSingle * amount; // weight constraint if (_buyer.weight + itemWeight > _buyer.maxWeight) { Debug.Log("Cannot add item: inventory weight constraint violated!"); return false; } // money constraint if (!_buyer.money.CanPay(uitem._item.value)) { Debug.Log("Insufficient money!"); return false; } // it can fit based on size int rest = _buyer.AddItem(new PraeItem(pitem, amount), true, false); Debug.Assert(rest == 0, "Adding item to inventory was unsuccessful!"); uitem._item.amount -= (amount - rest); uitem.Set(uitem._item); // update labels if (uitem._item.amount <= 0) { selectedUIItem.ResetColor(); selectedUIItem = null; // deselect item // NOTE: this is by far not the most efficient way of doing this - but whats the point in optimising shops anyway if (userMode == EShopMode.buy) _seller.RemoveItem(page * 10 + uitem.id); else if (userMode == EShopMode.rebuy) _seller.RemoveBoughtItem(page * 10 + uitem.id); else Debug.LogError("Cannot buy item in wrong mode: " + userMode); calcPagedItems(); // refresh PagedItems if (page > maxPage) page = maxPage; SetUpPage(page); // update UI } // pay _buyer.money.Pay(uitem._item.value); _seller.money.Add(uitem._item.value); UIbuyerMoney.Set(_buyer.G, _buyer.K, _buyer.T); return true; }
void LateUpdate() { // handle mouse over animation // remove visual changes for buttons (except items) if (selectedModeButton != null) selectedModeButton.butImage.color = selectedModeButton.selectedColor; if (mouseOverModeButton != null && mouseOverModeButton != selectedModeButton) mouseOverModeButton.butImage.color = mouseOverModeButton.origColor; mouseOverModeButton = null; // remove visual changes for items if (selectedUIItem != null) selectedUIItem.Set(mouseSelectColor); if (mouseoverUIItem != null && mouseoverUIItem != selectedUIItem) mouseoverUIItem.ResetColor(); mouseoverUIItem = null; if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)gameObject.transform, Input.mousePosition)) // ShopUI rect { if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)panelItems.transform, Input.mousePosition)) // PanelItems rect { for (int i = 0; i < UIItems.Length; ++i) { if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)UIItems[i]._itemElem.transform, Input.mousePosition)) // items { // mouse is within item rect if (Input.GetMouseButton(0)) { if (UIItems[i]._hasItem && UIItems[i]._item.amount > 0) { /* item was clicked on with left mouse button => selected */ if (selectedUIItem != UIItems[i] && selectedUIItem != null) selectedUIItem.ResetColor(); // a different item was selected previously selectedUIItem = UIItems[i]; selectedUIItem.Set(mouseSelectColor); } } else { /* mouse is only hovering over the item */ // restore old visual for the previously highlighted item if (mouseoverUIItem != null && mouseoverUIItem != UIItems[i] && mouseoverUIItem != selectedUIItem) // mouse hovers over a new item mouseoverUIItem.ResetColor(); else if (selectedUIItem != null && mouseoverUIItem == selectedUIItem) // the previous item could still be selected selectedUIItem.Set(mouseSelectColor); // set colors for new hover item mouseoverUIItem = UIItems[i]; UIItems[i].Set((selectedUIItem == mouseoverUIItem) ? mouseSelectOverColor : mouseOverColor); break; } } } } else if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)panelTop.transform, Input.mousePosition)) // top bar rect { UIButton oldSelectButton = selectedModeButton; if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)buttonClose.button.transform, Input.mousePosition)) { if (Input.GetMouseButton(0)) currendManager.EndInteraction(); // end of shopping else if (selectedModeButton == buttonClose) selectedModeButton.butImage.color = selectedModeButton.selectedOverColor; else mouseOverModeButton = buttonClose; } else if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)buttonSelectBuy.button.transform, Input.mousePosition)) { if (Input.GetMouseButton(0)) ChangeModeTo(EShopMode.buy); else if (selectedModeButton == buttonSelectBuy) selectedModeButton.butImage.color = selectedModeButton.selectedOverColor; else mouseOverModeButton = buttonSelectBuy; } else if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)buttonSell.button.transform, Input.mousePosition)) { if (Input.GetMouseButton(0)) ChangeModeTo(EShopMode.sell); else if (selectedModeButton == buttonSell) selectedModeButton.butImage.color = selectedModeButton.selectedOverColor; else mouseOverModeButton = buttonSell; } else if (RectTransformUtility.RectangleContainsScreenPoint((RectTransform)buttonRebuy.button.transform, Input.mousePosition)) { if (Input.GetMouseButton(0)) ChangeModeTo(EShopMode.rebuy); else if (selectedModeButton == buttonRebuy) selectedModeButton.butImage.color = selectedModeButton.selectedOverColor; else mouseOverModeButton = buttonRebuy; } if (mouseOverModeButton != null) mouseOverModeButton.butImage.color = mouseOverModeButton.mouseOvercolor; // apply visual changes if (selectedModeButton != oldSelectButton ) { oldSelectButton.butImage.color = selectedModeButton.origColor; selectedModeButton.butImage.color = selectedModeButton.selectedOverColor; } } } }
public virtual bool IsEditable(UIItem uiItem) { return editableControls.All(t => t.IsInstanceOfType(uiItem)); }
public SettingsWindow(Application application, Window whiteWindow, UIItem settingsControl) : base(application, whiteWindow) { this.settingsControl = settingsControl; }
public AutomationElement GetChildElement(UIItem element, Condition condition) { AutomationElement childElement = element.AutomationElement.FindFirst(TreeScope.Descendants, condition); return childElement; }
public void ActionPerforming(UIItem uiItem) { Control.ActionPerforming(uiItem); }
public virtual void DragVertically(UIItem uiItem, int distance) { DragVertically(MouseButton.Left, uiItem, distance); }
public static void LogPatterns(UIItem uiItem) { LogPatterns(uiItem.AutomationElement); }
public virtual void SetValueOn(UIItem uiItem) { object value = fieldInfo.GetValue(entity); if (null != value) uiItem.SetValue(value); }
//TODO: Need to remove when [Ignore] tests are cleaned up private static bool IsWatchListWindowCollapsed(UIItem item) { return !item.Visible; }
public static IUIItem GetControl(AppProcess process, MappedItem window, MappedItem control, AppManager appManager) { Process wProcess = Process.GetProcessesByName(process.Name).First(); Application application = Application.Attach(wProcess); Window appWindow = null; if (control.Type == "pane") { } /*IEnumerable<string> enumerable = application.GetWindows().Select(w => w.Title); IEnumerable<string> list2 = application.GetWindows().Select(w => w.AutomationElement.Current.Name); */ List<string> windowTitles2 = GetWindowsForProcess(process.Name); if (!window.Name.IsNullOrEmpty()) appWindow = application.GetWindow(SearchCriteria.ByAutomationId(window.Name), InitializeOption.NoCache); else { for (int i = 0; i < 5; i++) { List<string> windowTitles = GetWindowsForProcess(process.Name); string windowName = window.Text; string closestTitle = windowTitles[0]; decimal toleranceLevel = windowName.Length * 0.7m; foreach (string windowTitle in windowTitles) { int num1 = LevenshteinDistance.GetToleranceLevel(windowTitle, windowName); if (num1 < toleranceLevel) { toleranceLevel = num1; closestTitle = windowTitle; } } try { List<Window> windows = application.GetWindows(); appWindow = application.GetWindows().FirstOrDefault(w => w.AutomationElement.Current.Name.Equals(closestTitle)); if (appWindow == null) { List<IntPtr> handles = EnumerateProcessWindowHandles(wProcess.Id).ToList(); Dictionary<string, IntPtr> windowHandleDict = new Dictionary<string, IntPtr>(); StringBuilder builder = new StringBuilder(1024); foreach (IntPtr myIntPtr in handles) { GetWindowText(myIntPtr, builder, 1024); string windowTitle = builder.ToString(); windowHandleDict[windowTitle] = myIntPtr; } AutomationElement element = AutomationElement.FromHandle(windowHandleDict[closestTitle]); appWindow = new Win32Window(element, WindowFactory.Desktop, InitializeOption.NoCache, new NullWindowSession()); } break; } catch (Exception ex) { } } } BringWindowToFront(appWindow.AutomationElement.Current.NativeWindowHandle); if (control == null || control.Type == "window" || control.Equals(window)) return appWindow; Stack<MappedItem> mappedItemTree = new Stack<MappedItem>(); MappedItem currentMappedItem = control; if (window == null) { } while (currentMappedItem != window) { mappedItemTree.Push(currentMappedItem); currentMappedItem = appManager.GetMappedItem(currentMappedItem.ParentId); } IUIItem currentControl = appWindow; AutomationElement elemn; while (mappedItemTree.Count > 0) { MappedItem currentMappedItemControl = mappedItemTree.Pop(); if (!currentMappedItemControl.Name.IsNullOrEmpty()) { AutomationElement element = currentControl.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, currentMappedItemControl.Name)); //AutomationElement element = currentControl.GetElement(SearchCriteria.ByAutomationId(currentMappedItemControl.Name)); currentControl = new UIItem(element, new NullActionListener()); continue; } if (!string.IsNullOrEmpty(currentMappedItemControl.Text)) { currentControl = new UIItem(currentControl.GetElement(SearchCriteria.ByText(currentMappedItemControl.Text)), new NullActionListener()); continue; } } return currentControl; }
public void Awake() { Constants.ShopUI = gameObject; Text TG = null; Text TK = null; Text TT = null; // get important item elements UIItems = new UIItem[numElemsPerPage]; HashSet<string> addedList = new HashSet<string>(); int i = 0; foreach (Component g in gameObject.GetComponentsInChildren<Component>()) { if (g.name.StartsWith("ItemElem") && !addedList.Contains(g.name)) { UIItems[i] = new UIItem(g); UIItems[i].id = i; addedList.Add(g.name); ++i; } else if (g.name.Equals("MoneyLabel")) { foreach (Text t in g.GetComponentsInChildren<Text>()) { if (t.name.Equals("Text_G")) TG = t; else if (t.name.Equals("Text_K")) TK = t; else if (t.name.Equals("Text_T")) TT = t; else Debug.Log("MoneyLabel contained unexpected text objects? " + t.name); } break; } else if (g.name.Equals("PanelTop")) panelTop = g; else if (g.name.Equals("PanelItems")) panelItems = g; else if (g.name.Equals("PanelPageSetter")) panelPageSetter = g; else if (g.name.Equals("PanelBottom")) panelBottom = g; else if (g.name.Equals("ButtonClose")) buttonClose = new UIButton(g, mouseOverColor, mouseSelectColor, mouseSelectOverColor); else if (g.name.Equals("ButtonSelectBuy")) buttonSelectBuy = new UIButton(g, mouseOverColor, mouseSelectColor, mouseSelectOverColor); else if (g.name.Equals("ButtonSelectSell")) buttonSell = new UIButton(g, mouseOverColor, mouseSelectColor, mouseSelectOverColor); else if (g.name.Equals("ButtonSelectRebuy")) buttonRebuy = new UIButton(g, mouseOverColor, mouseSelectColor, mouseSelectOverColor); else if (g.name.Equals("TextPage")) textPage = g.GetComponent<Text>(); else if (g.name.Equals("ButtonPageLeft")) { g.GetComponent<Button>().onClick.RemoveAllListeners(); g.GetComponent<Button>().onClick.AddListener(() => { if (page - 1 >= 0) SetUpPage(--page); }); } else if (g.name.Equals("ButtonPageRight")) { g.GetComponent<Button>().onClick.RemoveAllListeners(); g.GetComponent<Button>().onClick.AddListener(() => { if (page + 1 < maxPage) SetUpPage(++page); }); } else if (g.name.Equals("ButtonBuy")) { buttonBuy = g.GetComponent<Button>(); g.GetComponent<Button>().onClick.RemoveAllListeners(); // the buttons are found multiple times in the list of child components g.GetComponent<Button>().onClick.AddListener(() => { switch(userMode) { case EShopMode.buy: if (selectedUIItem != null) // an item icon can only be selected if a valid item is presend if (Input.GetKey(KeyCode.LeftControl)) tryBuy(selectedUIItem, true); else tryBuy(selectedUIItem, false); break; case EShopMode.sell: if (selectedUIItem != null) if (Input.GetKey(KeyCode.LeftControl)) trySell(selectedUIItem, true); else trySell(selectedUIItem, false); break; case EShopMode.rebuy: if (selectedUIItem != null) if (Input.GetKey(KeyCode.LeftControl)) tryBuy(selectedUIItem, true); else tryBuy(selectedUIItem, false); break; default: throw new System.NotImplementedException(); } //TODO: apply amount selection screen during leftshift-click! }); } } UIbuyerMoney = new UICurrency(TG, TK, TT); }
public virtual void ActionPerforming(UIItem uiItem) { }
protected override string FieldName(UIItem item) { return item.Name; }
/// <summary> /// Raises the reset award event. /// </summary> /// <param name="award">Award.</param> IEnumerator OnResetAward(UIItem item, DialogAward award) { yield return new WaitForEndOfFrame(); item.Icon = award.Icon; item.Count = award.Count; item.ID = award.ID; }
public virtual void Drop(UIItem uiItem) { Mouse.DragAndDrop(uiItem, IconsList); }
public override void ActionPerforming(UIItem uiItem) { if (uiItem is Table) return; new ScreenItem(uiItem, ScrollBars).MakeVisible(this); }
public ToggleableItem(UIItem uiItem) : base(uiItem.AutomationElement, uiItem.ActionListener) { }
public virtual void DragVertically(UIItem uiItem, int distance) { Location = uiItem.Bounds.Center(); double currentXLocation = Location.X; double currentYLocation = Location.Y; HoldForDrag(); ActionPerformed(uiItem); Location = new Point(currentXLocation, currentYLocation + distance); LeftUp(); }
public static void LogProperties(UIItem uiItem) { LogProperties(uiItem.AutomationElement); }
public override void ActionPerforming(UIItem uiItem) { throw new NotImplementedException(); }
public override void ActionPerforming(UIItem uiItem) { var screenItem = new ScreenItem(uiItem, ScrollBars); screenItem.MakeVisible(this); }
public virtual void DragHorizontally(UIItem uiItem, int distance) { DragHorizontally(MouseButton.Left, uiItem, distance); }