Example #1
0
        private String GetText()
        {
            String message = "";

            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.richTextBox1.InvokeRequired)
            {
                GetTextCallback d = new GetTextCallback(GetText);
                try
                {
                    message = (String)this.Invoke(d, new object[] { });
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                message = this.richTextBox1.Text;
            }
            return(message);
        }
Example #2
0
        /// <summary>
        /// Reads line after keyword and until newline character.
        /// </summary>
        /// <param name="keyword">Where reading should start</param>
        /// <returns>Returns line that has been read.</returns>
        public String ReadLine(string keyword)
        {
            String text = String.Empty;

            if (TheTextBox.InvokeRequired)
            {
                // It's on a different thread, so use Invoke:
                lock (m_LockObject) {
                    GetTextCallback ourDelegate = new GetTextCallback(getText);
                    text = (String)TheTextBox.Invoke(ourDelegate, new object[] { TheTextBox });
                }
            }
            else
            {
                lock (m_LockObject) {
                    text = TheTextBox.Text;
                }
            }
            if ((text.LastIndexOf("\n") - text.LastIndexOf(keyword) - keyword.Length > 0) && text.LastIndexOf(keyword) > -1)
            {
                return(text.Substring(text.LastIndexOf(keyword) + keyword.Length, text.LastIndexOf("\n") - text.LastIndexOf(keyword) - keyword.Length));
            }
            else
            {
                return(String.Empty);
            }
        }
Example #3
0
 private string GetText()
 {
     if (this.TxtInput.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         try
         {
             return(this.Invoke(d).ToString());
         }
         catch
         {
             return("");
         }
     }
     else
     {
         try
         {
             string txt = TxtInput.Text;
             TxtInput.Text = "";
             return(txt);
         }
         catch
         {
             return("");
         }
     }
 }
Example #4
0
 private string GetText()
 {
     if (cmbDir.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         return((string)this.Invoke(d));
     }
     else
     {
         return(cmbDir.Text);
     }
 }
Example #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public string GetTextControl(Control c)
 {
     if (c.InvokeRequired)
     {
         var d = new GetTextCallback(GetTextControl);
         return(c.Invoke(d, new object[] { c }).ToString());
     }
     else
     {
         return(c.Text);
     }
 }
Example #6
0
 public string GetText(int itemsNum, int subItemsNum)
 {
     if (this.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         return((string)this.Invoke(d, new object[] { itemsNum, subItemsNum }));
     }
     else
     {
         return(this.Items[itemsNum].SubItems[subItemsNum].Text);
     }
 }
Example #7
0
 public string GetText()
 {
     if (this.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         return((string)this.Invoke(d, new object[] { }));
     }
     else
     {
         return(this.Text);
     }
 }
Example #8
0
 // funkcija za ocitavanje textBox polja textUserData
 private string readTextUserData()
 {
     if (textUserData.InvokeRequired)
     {
         GetTextCallback d    = new GetTextCallback(readTextUserData);
         string          temp = (string)Invoke(d);
         return(temp);
     }
     else
     {
         return(textUserData.Text);
     }
 }
Example #9
0
 // funkcija za ocitavanje textBox polja textIdManager
 private string readIdManager()
 {
     if (textIdManager.InvokeRequired)
     {
         GetTextCallback d    = new GetTextCallback(readIdManager);
         string          temp = (string)Invoke(d);
         return(temp);
     }
     else
     {
         return(textIdManager.Text);
     }
 }
Example #10
0
 // funkcija za ocitavanje textBox polja textPassword
 private string readTextPassword()
 {
     if (textPassword.InvokeRequired)
     {
         GetTextCallback d    = new GetTextCallback(readTextPassword);
         string          temp = (string)Invoke(d);
         return(temp);
     }
     else
     {
         return(textPassword.Text);
     }
 }
Example #11
0
 // funkcija za ocitavanje textBox polja textIpAddress
 private string readIpAddress()
 {
     if (textIpAddress.InvokeRequired)
     {
         GetTextCallback d    = new GetTextCallback(readIpAddress);
         string          temp = (string)Invoke(d);
         return(temp);
     }
     else
     {
         return(textIpAddress.Text);
     }
 }
Example #12
0
 private string GetText(int i)
 {
     string text = "";
     if (this.lvUpdateList.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         text = this.Invoke(d, new object[] { i }).ToString();
     }
     else
     {
         text = lvUpdateList.Items[i].Text;
     }
     return text;
 }
Example #13
0
 /// <summary>
 /// Get text property of various controls
 /// </summary>
 /// <param name="form">The calling form</param>
 /// <param name="ctrl"></param>
 public static string GetText(Form form, Control ctrl)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (ctrl.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(GetText);
         return((string)form.Invoke(d, new object[] { form, ctrl }));
     }
     else
     {
         return(ctrl.Text);
     }
 }
Example #14
0
        private string getText()
        {
            string ret = "";

            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (this.richTextBox_received.InvokeRequired)
            {
                GetTextCallback d = new GetTextCallback(getText);
                ret = (string)this.Invoke(d);
            }
            else
            {
                ret = this.richTextBox_received.Text;
            }
            return(ret);
        }
Example #15
0
 // funkcija za ocitavanje textBox polja textIdManager
 private string readIdManager()
 {
     if (textIdManager.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(readIdManager);
         string temp = (string)Invoke(d);
         return temp;
     }
     else
     {
         return textIdManager.Text;
     }
 }
Example #16
0
 // funkcija za ocitavanje textBox polja textPassword
 private string readTextPassword()
 {
     if (textPassword.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(readTextPassword);
         string temp = (string)Invoke(d);
         return temp;
     }
     else
     {
         return textPassword.Text;
     }
 }
Example #17
0
        // 経度を取得する
        private string GetRandomGPSLat()
        {
            if (this.txtGpsLat.InvokeRequired)
            {
                GetTextCallback c = new GetTextCallback(GetRandomGPSLat);
                return (string)Invoke(c);
            }
            else
            {
                string lat;
                if (chkDebug.Checked)
                {
                    DateTime now = DateTime.Now;
                    if (debugPrevTime != new DateTime(2000, 1, 1))
                    {
                        // 角度を10度の範囲で変化
                        debugDir = (debugDir + (rnd.Next(20) - 10) + 360D) % 360D;
                        Double radian = debugDir * (Math.PI / 180);

                        TimeSpan ts = now - debugPrevTime;
                        // 移動距離
                        Double dist = (0.00005 + rnd.NextDouble() / 1000) * (ts.TotalMilliseconds / 1000);
                        debugLon += Math.Cos(Math.PI / 180 * 90 - radian) * dist;
                        debugLat += Math.Sin(Math.PI / 180 * 90 - radian) * dist;
                    }
                    txtGpsLat.Text = lat = Math.Round(debugLat, 6).ToString();
                    txtGpsLon.Text = Math.Round(debugLon, 6).ToString();
                    txtGpsDirection.Text = Math.Round(debugDir, 6).ToString();
                    debugPrevTime = now;
                }
                else
                {
                    lat = txtGpsLat.Text;
                }
                return lat;
            }
        }
Example #18
0
 private string GetRadius()
 {
     if (this.cbRadius.InvokeRequired)
     {
         GetTextCallback c = new GetTextCallback(GetRadius);
         return (string)Invoke(c);
     }
     else
     {
         return cbRadius.Text;
     }
 }
Example #19
0
 // 経度を取得する
 private string GetGPSLon()
 {
     if (this.txtGpsLon.InvokeRequired)
     {
         GetTextCallback c = new GetTextCallback(GetGPSLon);
         return (string)Invoke(c);
     }
     else
     {
         return txtGpsLon.Text;
     }
 }
Example #20
0
 // funkcija za ocitavanje textBox polja textIpAddress
 private string readIpAddress()
 {
     if (textIpAddress.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(readIpAddress);
         string temp = (string)Invoke(d);
         return temp;
     }
     else
     {
         return textIpAddress.Text;
     }
 }
Example #21
0
 // funkcija za ocitavanje textBox polja textUsername
 private string readTextUsername()
 {
     if (textUsername.InvokeRequired)
     {
         GetTextCallback d = new GetTextCallback(readTextUsername);
         string temp = (string)Invoke(d);
         return temp;
     }
     else
     {
         return textUsername.Text;
     }
 }
 /// <summary>
 /// Gets the text for asynchronous calls in a thread safe manner.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <returns></returns>
 protected string GetTextSafe(Control control)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (control.InvokeRequired)
     {
         GetTextCallback d =
             new GetTextCallback(GetTextSafe);
         string text = (string) Invoke(d, new object[] {control});
         return text;
     }
     else
     {
         return control.Text;
     }
 }