Exemplo n.º 1
0
        /// <summary>
        ///     Waits for the specified text to appear at the specified location.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="timeoutMS"></param>
        /// <returns></returns>
        public bool WaitForText(int x, int y, string text, int timeoutMS)
        {
            if (currentConnection == null)
            {
                throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection",
                                          null);
            }
            var start = DateTime.Now.Ticks;

            //bool ok = false;
            if (Config.AlwaysRefreshWhenWaiting)
            {
                lock (this)
                {
                    DisposeOfCurrentScreenXML();
                    currentScreenXML = null;
                }
            }
            do
            {
                if (CurrentScreenXML != null)
                {
                    var screenText = CurrentScreenXML.GetText(x, y, text.Length);
                    if (screenText == text)
                    {
                        if (Audit != null)
                        {
                            Audit.WriteLine("WaitForText('" + text + "') Found!");
                        }
                        return(true);
                    }
                }
                //
                if (timeoutMS == 0)
                {
                    if (Audit != null)
                    {
                        Audit.WriteLine("WaitForText('" + text + "') Not found");
                    }
                    return(false);
                }
                //
                Thread.Sleep(100);
                if (Config.AlwaysRefreshWhenWaiting)
                {
                    lock (this)
                    {
                        DisposeOfCurrentScreenXML();
                        currentScreenXML = null;
                    }
                }
                Refresh(true, 1000);
            } while ((DateTime.Now.Ticks - start) / 10000 < timeoutMS);
            //
            if (Audit != null)
            {
                Audit.WriteLine("WaitForText('" + text + "') Timed out");
            }
            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Wait for some text to appear at the specified location
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="text"></param>
        /// <param name="timeoutMS"></param>
        /// <returns></returns>
        public bool WaitForText(int x, int y, string text, int timeoutMS)
        {
            if (currentConnection == null)
            {
                throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null);
            }
            long start = DateTime.Now.Ticks;

            //bool ok = false;
            if (Config.AlwaysRefreshWhenWaiting)
            {
                lock (this)
                {
                    this._currentScreenXML = null;
                }
            }
            do
            {
                if (CurrentScreenXML != null)
                {
                    string screenText = CurrentScreenXML.GetText(x, y, text.Length);
                    if (screenText == text)
                    {
                        return(true);
                    }
                }
                //
                if (timeoutMS == 0)
                {
                    return(false);
                }
                //
                System.Threading.Thread.Sleep(100);
                if (Config.AlwaysRefreshWhenWaiting)
                {
                    lock (this)
                    {
                        this._currentScreenXML = null;
                    }
                }
                Refresh(true, 1000);
            }while (((DateTime.Now.Ticks - start) / 10000) < timeoutMS);
            //
            return(false);
        }
Exemplo n.º 3
0
 /// <summary>
 ///     Retrieves text at the specified location on the screen
 /// </summary>
 /// <param name="x">Column</param>
 /// <param name="y">Row</param>
 /// <param name="length">Length of the text to be returned</param>
 /// <returns></returns>
 public string GetText(int x, int y, int length)
 {
     return(CurrentScreenXML.GetText(x, y, length));
 }