public void SimpleSearch(string queryString, WaitingType waitingType) { _selenium.Open("/books/"); _selenium.Type("css=.search-input-html", queryString); _selenium.ClickAndWait("css=.search-button", waitingType); }
/// <summary> /// Производит нажатие мышкой на указанном элементе и дожидается загрузки страницы /// </summary> /// <param name="locator">XPath путь до элемента</param> /// <param name="waitingType">Тип ожидания</param> public void ClickAndWait(string locator, WaitingType waitingType) { switch (waitingType) { case WaitingType.None: Click(locator); break; case WaitingType.Ajax: Click(locator); WaitForCondition( "!selenium.browserbot.getCurrentWindow().Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()", Timeout); IsDocumentObsolete = true; break; case WaitingType.PageLoad: Click(locator); WaitForPageToLoad(Timeout); SuppressAllAlerts(); IsDocumentObsolete = true; break; case WaitingType.SmallTimeout: Click(locator); Thread.Sleep(500); break; default: throw new ArgumentOutOfRangeException("waitingType"); } }
private void OnDependencyAssetReady() { if (IsResourceLoading(m_Task.ResourceInfo.ResourceName.Name)) { m_WaitingType = WaitingType.WaitForResource; return; } ResourceObject resourceObject = m_ResourcePool.Spawn(m_Task.ResourceInfo.ResourceName.Name); if (resourceObject != null) { OnResourceObjectReady(resourceObject); return; } m_LoadingResource = true; s_LoadingResourceNames.Add(m_Task.ResourceInfo.ResourceName.Name); string fullPath = Utility.Path.GetCombinePath(m_Task.ResourceInfo.StorageInReadOnly ? m_ReadOnlyPath : m_ReadWritePath, Utility.Path.GetResourceNameWithSuffix(m_Task.ResourceInfo.ResourceName.FullName)); if (m_Task.ResourceInfo.LoadType == LoadType.LoadFromFile) { m_Helper.ReadFile(fullPath); } else { m_Helper.ReadBytes(fullPath, (int)m_Task.ResourceInfo.LoadType); } }
/// <summary> /// 初始化加载资源代理的新实例。 /// </summary> /// <param name="loadResourceAgentHelper">加载资源代理辅助器。</param> /// <param name="resourceHelper">资源辅助器。</param> /// <param name="resourceLoader">加载资源器。</param> /// <param name="readOnlyPath">资源只读区路径。</param> /// <param name="readWritePath">资源读写区路径。</param> /// <param name="decryptResourceCallback">解密资源回调函数。</param> public LoadResourceAgent(ILoadResourceAgentHelper loadResourceAgentHelper, IResourceHelper resourceHelper, ResourceLoader resourceLoader, string readOnlyPath, string readWritePath, DecryptResourceCallback decryptResourceCallback) { if (loadResourceAgentHelper == null) { throw new GameFrameworkException("Load resource agent helper is invalid."); } if (resourceHelper == null) { throw new GameFrameworkException("Resource helper is invalid."); } if (resourceLoader == null) { throw new GameFrameworkException("Resource loader is invalid."); } if (decryptResourceCallback == null) { throw new GameFrameworkException("Decrypt resource callback is invalid."); } m_Helper = loadResourceAgentHelper; m_ResourceHelper = resourceHelper; m_ResourceLoader = resourceLoader; m_ReadOnlyPath = readOnlyPath; m_ReadWritePath = readWritePath; m_DecryptResourceCallback = decryptResourceCallback; m_LoadingDependencyAssetNames = new LinkedList <string>(); m_Task = null; m_WaitingType = WaitingType.None; m_LoadingAsset = false; m_LoadingResource = false; }
/// <summary> /// 重置加载资源代理。 /// </summary> public void Reset() { m_Helper.Reset(); m_LoadingDependencyAssetNames.Clear(); m_Task = null; m_WaitingType = WaitingType.None; m_LoadingAsset = false; m_LoadingResource = false; }
public void AdvSearch(string name, string author, string publisher, string startYear, string endYear, WaitingType waitingType) { _selenium.Open("/search/advanced/"); AddSearchCondition("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_tbName", name, 1); AddSearchCondition("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_tbAuthor", author, 1); AddSearchCondition("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_tbPublisher", publisher, 1); AddSearchCondition("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_ddlPublishedFrom", startYear, 2); AddSearchCondition("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_ddlPublishedTo", endYear, 2); _selenium.ClickAndWait("ctl00_ctl00_ctl00_PageView_PageView_phDefault_SearchAdvancedControl_btnAdvancedSearch", waitingType); }
public WaitingForm(SqlData sqlDataFrom, SqlData sqlDataTo) { InitializeComponent(); waitingType = WaitingType.CopyDataBaseData; this.sqlDataFrom = sqlDataFrom; this.sqlDataTo = sqlDataTo; bitmap = new Bitmap(this.Width, this.Height); image = MyFilm.Properties.Resources.waiting; ImageAnimator.Animate(image, this.OnImageAnimate); }
public WaitingForm(WaitingType type) { InitializeComponent(); LockWatingThread = new object(); ReadyEvent = new ManualResetEvent(false); this.type = type; if (type == WaitingType.None) { //button1.Visible = false; //progressBar1.Width = 530; } bCancelled = false; }
public bool Execute(WaitingProcFunc func, string Title, WaitingType type, string ConfirmPrompt) { Func = func; form = new WaitingForm(type); form.ConfirmPrompt = ConfirmPrompt; form.Text = Title; WaitingThread = new Thread(new ThreadStart(Waiting)); WaitingThread.Name = "等待执行线程"; WaitingThread.Start(); form.ShowDialog(); return(!form.bCancelled); }
/// <summary> /// Производит нажатие кнопки на указанном элементе и дожидается загрузки страницы /// </summary> /// <param name="locator">XPath путь до элемента</param> /// <param name="keySequence">ASCII код кнопки</param> /// <param name="waitingType">Тип ожидания</param> public void KeyDownAndWait(string locator, string keySequence, WaitingType waitingType) { switch (waitingType) { case WaitingType.PageLoad: KeyDown(locator, keySequence); WaitForPageToLoad(Timeout); IsDocumentObsolete = true; break; default: throw new NotImplementedException(); } }
///// <summary> ///// Возвращает значение элемента по указанному xpath адресу ///// </summary> ///// <param name="xPath">XPath путь до искомого элемента</param> ///// <returns>Строковое значение элемента</returns> //public new string GetValue(string xPath) //{ // var node = Document.DocumentNode.SelectSingleNode(xPath); // return node.InnerText; //} /// <summary> /// Выбирает указанное значение в указанном списке выбора и дожидается загрузки страницы /// </summary> /// <param name="selectLocator">XPath путь до списка выбора</param> /// <param name="optionLocator">XPath путь до выбираемого значения</param> /// <param name="waitingType">Тип ожидания</param> public void SelectAndWait(string selectLocator, string optionLocator, WaitingType waitingType) { Select(selectLocator, optionLocator); switch (waitingType) { case WaitingType.PageLoad: WaitForPageToLoad(Timeout); IsDocumentObsolete = true; break; default: throw new NotImplementedException(); } }
public WaitingForm( ThreadWebDataCaptureCallback threadCallback, SqlData sqlData, String crawlURL) { InitializeComponent(); waitingType = WaitingType.RealOrFake4KWebDataCapture; bitmap = new Bitmap(this.Width, this.Height); image = MyFilm.Properties.Resources.waiting; ImageAnimator.Animate(image, this.OnImageAnimate); this.webDataCapture = new RealOrFake4KWebDataCapture( threadCallback, SetFinish, sqlData, crawlURL); }
/// <summary> /// 初始化加载资源代理的新实例。 /// </summary> /// <param name="loadResourceAgentHelper">加载资源代理辅助器。</param> /// <param name="resourceHelper">资源辅助器。</param> /// <param name="assetPool">资源对象池。</param> /// <param name="resourcePool">资源对象池。</param> /// <param name="resourceLoader">加载资源器。</param> /// <param name="readOnlyPath">资源只读区路径。</param> /// <param name="readWritePath">资源读写区路径。</param> /// <param name="decryptResourceCallback">解密资源回调函数。</param> public LoadResourceAgent(ILoadResourceAgentHelper loadResourceAgentHelper, IResourceHelper resourceHelper, IObjectPool <AssetObject> assetPool, IObjectPool <ResourceObject> resourcePool, ResourceLoader resourceLoader, string readOnlyPath, string readWritePath, DecryptResourceCallback decryptResourceCallback) { if (loadResourceAgentHelper == null) { throw new System.Exception("Load resource agent helper is invalid."); } if (resourceHelper == null) { throw new System.Exception("Resource helper is invalid."); } if (assetPool == null) { throw new System.Exception("Asset pool is invalid."); } if (resourcePool == null) { throw new System.Exception("Resource pool is invalid."); } if (resourceLoader == null) { throw new System.Exception("Resource loader is invalid."); } if (decryptResourceCallback == null) { throw new System.Exception("Decrypt resource callback is invalid."); } m_Helper = loadResourceAgentHelper; m_ResourceHelper = resourceHelper; m_AssetPool = assetPool; m_ResourcePool = resourcePool; m_ResourceLoader = resourceLoader; m_ReadOnlyPath = readOnlyPath; m_ReadWritePath = readWritePath; m_DecryptResourceCallback = decryptResourceCallback; m_LoadingDependencyAssetNames = new LinkedList <string>(); m_Task = null; m_WaitingType = WaitingType.None; m_LoadingAsset = false; m_LoadingResource = false; }
/// <summary> /// 开始处理加载资源任务。 /// </summary> /// <param name="task">要处理的加载资源任务。</param> public void Start(LoadResourceTaskBase task) { if (task == null) { throw new AshException("Task is invalid."); } m_Task = task; m_Task.StartTime = DateTime.Now; if (IsAssetLoading(m_Task.AssetName)) { m_WaitingType = WaitingType.WaitForAsset; return; } TryLoadAsset(); }
public bool Execute(WaitingProcFunc func, string Title, WaitingType type, string ConfirmPrompt) { Func = func; form = new WaitingForm(type); form.ConfirmPrompt = ConfirmPrompt; form.Text = Title; form.progressBar1.Minimum = MinProgress; form.progressBar1.Maximum = MaxProgress; WaitingThread = new Thread(new ThreadStart(Waitting)); WaitingThread.Name = "等待执行线程"; WaitingThread.Start(); if (owner == null) { form.ShowDialog(); } else { form.ShowDialog(owner); } return(!form.bCancelled); }
private static bool IsLoading(string name, WaitingType wt) { string bundleName = string.Empty; if (wt == WaitingType.Asset) { var bundleInfo = GetAssetInfo(name); bundleName = bundleInfo.BundleName; } else { bundleName = name; } for (int i = 0; i < LoadingList.Count; i++) { if (LoadingList[i].BundleName.Equals(bundleName)) { return(true); } } return(false); }
private void TryLoadAsset() { if (!m_Task.IsScene) { AssetObject assetObject = m_AssetPool.Spawn(m_Task.AssetName); if (assetObject != null) { OnAssetObjectReady(assetObject); return; } } m_LoadingAsset = true; s_LoadingAssetNames.Add(m_Task.AssetName); foreach (string dependencyAssetName in m_Task.GetDependencyAssetNames()) { if (!m_AssetPool.CanSpawn(dependencyAssetName)) { if (!IsAssetLoading(dependencyAssetName)) { OnError(LoadResourceStatus.DependencyError, string.Format("Can not find dependency asset object named '{0}'.", dependencyAssetName)); return; } m_LoadingDependencyAssetNames.AddLast(dependencyAssetName); } } if (m_LoadingDependencyAssetNames.Count > 0) { m_WaitingType = WaitingType.WaitForDependencyAsset; return; } OnDependencyAssetReady(); }
/// <summary> /// 加载资源代理轮询。 /// </summary> /// <param name="elapseSeconds">逻辑流逝时间,以秒为单位。</param> /// <param name="realElapseSeconds">真实流逝时间,以秒为单位。</param> public void Update(float elapseSeconds, float realElapseSeconds) { if (m_WaitingType == WaitingType.None) { return; } if (m_WaitingType == WaitingType.WaitForAsset) { if (IsAssetLoading(m_Task.AssetName)) { return; } m_WaitingType = WaitingType.None; AssetObject assetObject = m_AssetPool.Spawn(m_Task.AssetName); if (assetObject == null) { TryLoadAsset(); return; } OnAssetObjectReady(assetObject); return; } if (m_WaitingType == WaitingType.WaitForDependencyAsset) { LinkedListNode <string> current = m_LoadingDependencyAssetNames.First; while (current != null) { if (!IsAssetLoading(current.Value)) { LinkedListNode <string> next = current.Next; if (!m_AssetPool.CanSpawn(current.Value)) { OnError(LoadResourceStatus.DependencyError, string.Format("Can not find dependency asset object named '{0}'.", current.Value)); return; } m_LoadingDependencyAssetNames.Remove(current); current = next; continue; } current = current.Next; } if (m_LoadingDependencyAssetNames.Count > 0) { return; } m_WaitingType = WaitingType.None; OnDependencyAssetReady(); return; } if (m_WaitingType == WaitingType.WaitForResource) { if (IsResourceLoading(m_Task.ResourceInfo.ResourceName.Name)) { return; } ResourceObject resourceObject = m_ResourcePool.Spawn(m_Task.ResourceInfo.ResourceName.Name); if (resourceObject == null) { OnError(LoadResourceStatus.DependencyError, string.Format("Can not find resource object named '{0}'.", m_Task.ResourceInfo.ResourceName.Name)); return; } m_WaitingType = WaitingType.None; OnResourceObjectReady(resourceObject); return; } }
void Update() { if (m_WaitingType == WaitingType.None) { return; } if (m_WaitingType == WaitingType.WaitForAsset) { if (IsAssetLoading(m_Task.AssetName)) { return; } m_WaitingType = WaitingType.None; AssetObject assetObject = m_AssetPool.Spawn(m_Task.AssetName); if (assetObject == null) { TryLoadAsset(); return; } OnAssetObjectReady(); return; } if (m_WaitingType == WaitingType.WaitForDependencyAsset) { LinkedListNode<string> current = m_LoadingDependencyAssetName.First; while (current != null) { if (!IsAssetLoading(current.Value)) { LinkedListNode<string> next = current.Next; if (!m_AssetPool.CanSpawn(current.Value)) { OnError(LoadResourceStatus.DependencyError); return; } m_LoadingDependencyAssetNames.Remove(current); current = next; continue; } } if (m_LoadingDependencyAssetNames.Count > 0) { return; } m_WaitingType = WaitingType.None; OnDependencyAssetReady(); return; } if (m_WaitingType == WaitingType.WaitForResource) { if (IsResourceLoading(m_Task.ResourceInfo) { return; } ResourceObject resourceObject = ResourcePool.Spawn(m_Task.ResourceInfo); if (resourceObject == null) { OnError(LoadResourceStatus.DependencyError); return; } m_WaitingType = WaitingType.None; OnResourceObjectReady(resourceObject); return; } }
/// <summary> /// Draw the Dialog Line /// </summary> /// <param name="_startPos">Starting position of the rect within the line will be drawn</param> /// <param name="_lineDescriptor">Line Descriptor</param> /// <param name="_removeAction">Action called when the Dialog Line is removed</param> /// <param name="_isLastPoint">Does this Dialog Line has to draw an out point</param> /// <param name="_pointIcon">Icon of the out point</param> /// <param name="_pointStyle"> Style of the point /// <param name="_onOutLineSelected">Action called when the out point of this line is selected</param> /// <param name="_otherSets">The other sets in the current Dialog</param> /// <returns>Height used to draw the dialog Line</returns> public float Draw(Vector2 _startPos, string _lineDescriptor, Action <DialogueLine> _removeAction, DialogSetType _dialogSetType, bool _isLastPoint, GUIContent _pointIcon, GUIStyle _pointStyle, Action <DialogueLine> _onOutLineSelected, List <DialogueSet> _otherSets, List <DialogueCondition> _otherConditions, List <CharacterColorSettings> _colorSettings) { if (m_ids == null) { InitEditor(_lineDescriptor); } if (m_content == string.Empty && m_key != string.Empty) { Script _luaScript = new Script(); _luaScript.DoString(_lineDescriptor); DynValue _content = _luaScript.Globals.Get(m_key).Table.Get("Text_En_en"); m_content = _content.String; } Rect _r = new Rect(_startPos.x, _startPos.y, DialogueNode.POPUP_HEIGHT, DialogueNode.POPUP_HEIGHT); if (GUI.Button(_r, "-")) { _removeAction.Invoke(this); return(_r.y); } _r = new Rect(_r.position.x + DialogueNode.POPUP_HEIGHT, _r.position.y, DialogueNode.CONTENT_WIDTH - DialogueNode.POPUP_HEIGHT, DialogueNode.POPUP_HEIGHT); Color _originalColor = GUI.backgroundColor; if (_colorSettings != null && m_key != string.Empty && _colorSettings.Any(s => s.CharacterIdentifier == m_key.Substring(0, 2))) { GUI.backgroundColor = _colorSettings.Where(s => s.CharacterIdentifier == m_key.Substring(0, 2)).First().CharacterColor; } m_nextIndex = EditorGUI.Popup(_r, "Line ID", m_index, m_ids); GUI.backgroundColor = _originalColor; if (m_nextIndex != m_index) { m_index = m_nextIndex; m_key = m_ids[m_index]; Script _luaScript = new Script(); _luaScript.DoString(_lineDescriptor); DynValue _content = _luaScript.Globals.Get(m_key).Table.Get("Text_En_en"); m_content = _content.String; } _r.y += DialogueNode.POPUP_HEIGHT; // -- Draw the dialog line content -- // _r = new Rect(_startPos.x, _r.position.y, DialogueNode.CONTENT_WIDTH, DialogueNode.BASIC_CONTENT_HEIGHT); GUI.TextArea(_r, m_content); _r.y += DialogueNode.BASIC_CONTENT_HEIGHT; _r = new Rect(_startPos.x, _r.position.y, DialogueNode.CONTENT_WIDTH, DialogueNode.POPUP_HEIGHT); m_initalWaitingTime = EditorGUI.Slider(_r, new GUIContent("Inital Waiting Time (s): ", "Used if there is no audioclip linked to this line"), m_initalWaitingTime, 0, 10); _r.y += DialogueNode.POPUP_HEIGHT; EditorGUI.BeginDisabledGroup(_dialogSetType == DialogSetType.PlayerAnswer); // -- Draw the Dialog Line Waiting Type -- // _r = new Rect(_startPos.x, _r.position.y, DialogueNode.CONTENT_WIDTH, DialogueNode.POPUP_HEIGHT); m_waitingType = (WaitingType)EditorGUI.EnumPopup(_r, "Extra Waiting Type: ", m_waitingType); _r.y += DialogueNode.POPUP_HEIGHT; EditorGUI.BeginDisabledGroup(m_waitingType != WaitingType.WaitForTime); // -- Draw the Dialog Waiting Time Value -- // _r = new Rect(_startPos.x, _r.position.y, DialogueNode.CONTENT_WIDTH, DialogueNode.POPUP_HEIGHT); m_extraWaitingTime = EditorGUI.Slider(_r, new GUIContent("Extra Waiting Time (s): ", "Duration to wait after the end of the inital waiting time"), m_extraWaitingTime, 0, 10); EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); _r.y += DialogueNode.POPUP_HEIGHT; _r.y += DialogueNode.SPACE_HEIGHT / 2; Color _c = GUI.color; GUI.color = Color.black; _r = new Rect(_startPos.x, _r.position.y, DialogueNode.CONTENT_WIDTH, .5f); GUI.Box(_r, ""); GUI.color = _c; _r.y += DialogueNode.SPACE_HEIGHT / 2; m_pointRect = new Rect(_startPos.x + DialogueNode.CONTENT_WIDTH - 2, (_startPos.y + _r.y) / 2, 38, 38); if (_isLastPoint || _dialogSetType == DialogSetType.PlayerAnswer) { if (m_linkedToken != -1) { Rect _linkedRect = Rect.zero; if (_otherSets.Any(s => s.NodeToken == m_linkedToken)) { _linkedRect = _otherSets.Where(p => p.NodeToken == m_linkedToken).First().InPointRect; } else if (_otherConditions.Any(c => c.NodeToken == m_linkedToken)) { _linkedRect = _otherConditions.Where(p => p.NodeToken == m_linkedToken).First().InPointRect; } else { m_linkedToken = -1; } if (_linkedRect != Rect.zero) { Handles.DrawBezier(m_pointRect.center, _linkedRect.center, m_pointRect.center + Vector2.right * 100.0f, _linkedRect.center + Vector2.left * 100.0f, Color.white, null, 2.0f); Handles.color = Color.white; if (Handles.Button((m_pointRect.center + _linkedRect.center) * 0.5f, Quaternion.identity, 4, 8, Handles.RectangleHandleCap)) { m_linkedToken = -1; } } } if (GUI.Button(m_pointRect, _pointIcon, _pointStyle)) { _onOutLineSelected?.Invoke(this); } } return(_r.y); }