Exemple #1
0
 /// <summary>
 /// Permits to update Login / logout btn
 /// </summary>
 /// <param name="connectionState"></param>
 private void UpdateLoginButton(string connectionState)
 {
     // We can update this compoent only if we are in the from thread
     if (tbLogin.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(UpdateLoginButton);
         this.Invoke(d, new object[] { connectionState });
     }
     else
     {
         if (connectionState == Rainbow.Model.ConnectionState.Connected)
         {
             tbLogin.Enabled        = tbPassword.Enabled = true;
             btnLoginLogout.Enabled = true;
             btnLoginLogout.Text    = "Logout";
         }
         else if (connectionState == Rainbow.Model.ConnectionState.Disconnected)
         {
             tbLogin.Enabled        = tbPassword.Enabled = true;
             btnLoginLogout.Enabled = true;
             btnLoginLogout.Text    = "Login";
         }
         else if (connectionState == Rainbow.Model.ConnectionState.Connecting)
         {
             tbLogin.Enabled        = tbPassword.Enabled = false;
             btnLoginLogout.Enabled = false;
             btnLoginLogout.Text    = "Connecting";
         }
     }
 }
Exemple #2
0
        //The 'RecieveStreamingNumbersMsg' method is being called back by the server in order to send (push) messages to the client
        public void RecieveStreamingNumbersMsg(string streamingNumbersMsg)
        {
            /* The 'RecieveStreamingNumbersMsg' method provides a pattern for making thread-safe calls on a Windows Forms control.
             *
             * If the calling thread is different from the thread that created the listBox control, this method creates
             * a StringArgReturningVoidDelegate and calls itself asynchronously using the Invoke method.
             *
             * If the calling thread is the same as the thread that created the TextBox control, the Text property is set directly. */

            // Check if invoke is required
            if (this.listBox1.InvokeRequired)
            {
                // Create a delegate for the invoke
                StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(RecieveStreamingNumbersMsg);
                // Control.Invoke: Executes the specified delegate on the thread that owns the control's underlying window handle.
                this.listBox1.Invoke(d, new object[] { streamingNumbersMsg });
            }
            else
            {
                // Add random numbers, time, and date message to the list box
                listBox1.Items.Add(streamingNumbersMsg);
                // Enables automatic scrolling down to bottom of the listbox
                listBox1.TopIndex = listBox1.Items.Count - 1;
            }
        }
        private string GetExtensionvalue()
        {
            string text = "null";

            try
            {
                if (this.Extensionvalue.InvokeRequired)
                {
                    StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(GetExtensionvalue);
                    Extensionvalue.Invoke(new MethodInvoker(delegate { text = Extensionvalue.Text; }));

                    return(text);
                }
                else
                {
                    return(text);
                }
            }
            catch (Exception ex)
            {
                GC.Collect();
                GC.WaitForPendingFinalizers();
                MessageBox.Show(ex.ToString());

                return(this.Extensionvalue.Text);
            }
            // 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.
        }
 private void ShowmIss()
 {
     if (this.dataGridView1.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(ShowmIss);
         this.Invoke(d, new object[] {});
     }
     else
     {
         this.dataGridView1.Rows.Clear();
         foreach (Issue issue in _model.getMyIssues().issues)
         {
             this.dataGridView1.Rows.Add(issue.ID, issue.Project.Name,
                                         issue.Status.Name,
                                         issue.Priority.Name,
                                         issue.Author.Name,
                                         issue.Assigned_to.Name,
                                         issue.Subject,
                                         issue.Description,
                                         issue.Start_date,
                                         issue.Done_ratio,
                                         issue.Created_on,
                                         issue.Updated_on);
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Función que actualiza la gráfica
        /// </summary>
        private void UpdateChart()
        {
            try
            {
                if (this.chartVar.InvokeRequired)
                {
                    //Para evitar concurrencia se llama a un delegado puesto que los datos se han obtenido en otro hilo
                    StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(UpdateChart);
                    this.Invoke(d, new object[] { });
                }
                else
                {
                    //Se recogen los valores de las variables seleccionadas
                    _sqlTime.Clear();
                    _sqlTime = _db_services.GetTime(_proyect, _chartAmount);
                    foreach (Variable v in _variables.Where(p => p.Type != EnumVarType.String))
                    {
                        _sqlData.Add(_db_services.GetVarValue(_proyect, v, _chartAmount));
                        if (_sqlTime.Count() == _sqlData.Last().Select(p => p.Value).ToList().Count())
                        {
                            chartVar.Series[v.Name].Points.Clear();
                            chartVar.Series[v.Name].Points.DataBindXY(_sqlTime, _sqlData.Last().Select(p => Double.Parse(p.Value)).ToList());
                        }
                    }

                    chartVar.Update();
                }
            }
            catch (Exception ex)
            {
                _exMg.HandleException(ex);
            }
        }
Exemple #6
0
        private void openOrCreateFile(Byte[] b, string[] s)
        {
            /*
             * MemoryStream stream = new MemoryStream(b);
             * StreamReader reader = new StreamReader(stream);
             *
             * using (reader)
             * {
             *  string line;
             *  while (reader.Peek() >= 0)
             *  {
             *      try
             *      {
             *          line = reader.ReadLine();
             *          NetworkInfoLabel.Text = NetworkInfoLabel.Text + line;
             *      }
             *      catch (Exception)
             *      {}
             *  }
             * } */

            for (int i = 0; i < s.Length; i++)
            {
                if (networkInfoTextBox1.InvokeRequired)
                {
                    StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(openOrCreateFile);
                    string[] arr = { s[i] + "\n" };
                    Invoke(d, new object[] { b, arr });
                }
                else
                {
                    networkInfoTextBox1.Text = networkInfoTextBox1.Text + s[i] + "\n";
                }
            }
        }
Exemple #7
0
        public void UpdateWindowSettings()
        {
            // Is it the worker thread?
            if (this.InvokeRequired)
            {
                StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(UpdateWindowSettings);
                // Request the UI thread.
                this.Invoke(d);
            }
            else
            {
                //Is it the UI thread?

                // Change the window name.
                this.Text = rsTools.GetGameTitle();
                Rectangle rect = rsTools.GetScreenSize();

                // Adjust the client area. (for removing the scrollbar)
                this.ClientSize    = new Size(rect.Width, rect.Height);
                browser.ClientSize = new Size(rect.Width, rect.Height);

                // Set the window position in the display.
                this.CenterToScreen();
                // The focus can get only in an UI thread, not worker thread (it's very strict.)
                rsTools.Focus();

                // Check the platform.
                EvaluateScript(browser, @"Utils.isCef = function() { 
                    return true; 
                };");
            }
        }
Exemple #8
0
 /// <summary>
 /// Método que actualiza la columna del dataGrid que contiene los valores actuales que recibe de la placa
 /// </summary>
 /// <param name="rows">Proyecto que guarda todas las variables con su último valor</param>
 private void FillDataGridView(Proyect rows)
 {
     try
     {
         if (this.dgvProVars.InvokeRequired)
         {
             //Para evitar concurrencia se llama a un delegado puesto que los datos se han obtenido en otro hilo
             StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(FillDataGridView);
             this.Invoke(d, new object[] { rows });
         }
         else
         {
             for (int j = 0; j < dgvProVars.Rows.Count; j++)
             {
                 for (int i = 0; i < rows.Variables.Count; i++)
                 {
                     if (dgvProVars[0, j].Value.ToString() == rows.Variables[i].Name)
                     {
                         dgvProVars[1, j].Value = rows.Variables[i].Value;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         _exMg.HandleException(ex);
     }
 }
Exemple #9
0
        private void MsgIn(string text)
        {
            // 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 (statusStrip.InvokeRequired)
            {
                StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(MsgIn);
                Invoke(d, new object[] { text });
            }
            else
            {
                statusLabel.Text = text.Trim();
                if (text.Contains("OK") || text.Contains("HOMED"))
                {
                    InMotion(false);
                    timer.Enabled = false;

                    if (text.Contains("HOMED"))
                    {
                        btnHome.BackColor = Color.LawnGreen;
                    }
                }
            }
        }
Exemple #10
0
 private void SetText(string text, MessageType type)
 {
     // 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.logtxt.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetText);
         this.Invoke(d, new object[] { text, type });
     }
     else
     {
         this.logtxt.SelectionStart = this.logtxt.TextLength > 0 ? this.logtxt.TextLength : 0;
         if (type == MessageType.Success)
         {
             this.logtxt.SelectionColor = Color.Green;
         }
         else if (type == MessageType.Information)
         {
             this.logtxt.SelectionColor = Color.White;
         }
         else
         {
             this.logtxt.SelectionColor = Color.Red;
         }
         text = text + System.Environment.NewLine;
         this.logtxt.AppendText(text);
     }
 }
Exemple #11
0
        private void SetLogText(string text)
        {
            // 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.richTextBoxMessagesLog.InvokeRequired)
            {
                StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetLogText);
                this.Invoke(d, new object[] { text });
            }
            else
            {
                if (text.Contains("Process Complete"))
                {
                    this.richTextBoxMessagesLog.SelectionColor = Color.Green;
                }
                else if (text.Contains("Exeception"))
                {
                    this.richTextBoxMessagesLog.SelectionColor = Color.Red;
                }
                else
                {
                    this.richTextBoxMessagesLog.SelectionColor = Color.Black;
                }

                this.richTextBoxMessagesLog.AppendText(text);

                this.richTextBoxMessagesLog.AppendText("\n");
                this.richTextBoxMessagesLog.ScrollToCaret();
            }
        }
Exemple #12
0
        public void WriteLine(int i, string text, bool Line)
        {
            // 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.
            System.Windows.Forms.Control theTextBox = this.Dashboard.Controls.Find(textBoxPrefix + i, false)[0];
            string InputText = text + ((Line) ? System.Environment.NewLine : "");

            if (theTextBox.InvokeRequired)
            {
                StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(WriteLine);
                theTextBox.Invoke(d, new object[] { i, text, Line });
            }
            else
            {
                if (!Line)
                {
                    try
                    {
                        ((TextBox)theTextBox).Text = ((TextBox)theTextBox).Text.Remove(((TextBox)theTextBox).Text.LastIndexOf(Environment.NewLine));
                        ((TextBox)theTextBox).AppendText(Environment.NewLine);
                    }
                    catch (ArgumentOutOfRangeException)
                    {}
                }

                ((TextBox)theTextBox).AppendText(InputText);
                //((TextBox)theTextBox).SelectionStart = theTextBox.Text.Length;
            }
        }
Exemple #13
0
 protected override void OnRestore(Stream stream)
 {
     _windowsDash = Dashboard.dash;
     _appendText  = new StringArgReturningVoidDelegate(_windowsDash.Output_box().AppendText);
     _getText     = new VoidArgReturningStringDelegate(_windowsDash.getText);
     if (_text != null)
     {
         _windowsDash.Output_box().Invoke(_appendText, _text);
     }
 }
Exemple #14
0
 internal void writeMemoryUsage(string memory)
 {
     if (this.lbMemoryUsageValue.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeMemoryUsage);
         this.Invoke(d, new object[] { memory });
     }
     else
     {
         this.lbMemoryUsageValue.Text = memory;
     }
 }
Exemple #15
0
 internal void writeCpuUsage(string cpu)
 {
     if (this.lbCPUUsageValue.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeCpuUsage);
         this.Invoke(d, new object[] { cpu });
     }
     else
     {
         this.lbCPUUsageValue.Text = cpu;
     }
 }
Exemple #16
0
 private void CustomSetTextLabel(string text)
 {
     if (lblState.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(CustomSetTextLabel);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         lblState.Text = text;
     }
 }
Exemple #17
0
 private void SetText(string text, Control obj)
 {
     if (obj.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetText);
         Invoke(d, new object[] { text, obj });
     }
     else
     {
         obj.Text = text;
     }
 }
Exemple #18
0
 private void CustomSetText(string text)
 {
     if (txtState.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(CustomSetText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         txtState.Text += text + Environment.NewLine;
     }
 }
Exemple #19
0
 internal void writeOSInformation(string osInfor)
 {
     if (this.tbOSInformationValue.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeOSInformation);
         this.Invoke(d, new object[] { osInfor });
     }
     else
     {
         this.tbOSInformationValue.Text = osInfor;
     }
 }
Exemple #20
0
 internal void writeDebug(string log)
 {
     if (this.mTextboxContent.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeDebug);
         this.Invoke(d, new object[] { log });
     }
     else
     {
         this.mTextboxContent.Text = log;
     }
 }
Exemple #21
0
 internal void writeWatchdogProcessName(string processName)
 {
     if (this.lbWatchdogProcessName.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeWatchdogProcessName);
         this.Invoke(d, new object[] { processName });
     }
     else
     {
         this.lbWatchdogProcessName.Text = processName;
     }
 }
Exemple #22
0
 internal void writeWatchdogProcessStatus(string processStatus)
 {
     if (this.lbProcessStatusValue.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeWatchdogProcessStatus);
         this.Invoke(d, new object[] { processStatus });
     }
     else
     {
         this.lbProcessStatusValue.Text = processStatus;
     }
 }
Exemple #23
0
 internal void writeUseSerialPort(string serialPort)
 {
     if (this.tbSerialPort.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeUseSerialPort);
         this.Invoke(d, new object[] { serialPort });
     }
     else
     {
         this.tbSerialPort.Text = serialPort;
     }
 }
Exemple #24
0
 private void SetText(Label label, string text)
 {
     if (label.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetText);
         this.Invoke(d, new object[] { label, text });
     }
     else
     {
         label.Text = text;
     }
 }
Exemple #25
0
 internal void writeProcessList(string processList)
 {
     if (this.tbProcessList.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeProcessList);
         this.Invoke(d, new object[] { processList });
     }
     else
     {
         this.tbProcessList.Text = processList;
     }
 }
Exemple #26
0
 public void AddLineTemperature(string line)
 {
     if (GatewayText.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(AddLineTemperature);
         this.Invoke(d, new object[] { line });
     }
     else
     {
         this.TemperatureText.Text += line;
     }
 }
Exemple #27
0
 internal void writeUpdateDate(string date)
 {
     if (this.lbProcessUpdate.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(writeUpdateDate);
         this.Invoke(d, new object[] { date });
     }
     else
     {
         this.lbProcessUpdate.Text = date;
     }
 }
Exemple #28
0
 public void AppendTextBox(string msg)
 {
     if (this.Console.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(AppendTextBox);
         this.Invoke(d, new object[] { msg });
     }
     else
     {
         this.Console.Text += msg;
     }
 }
 public void SetText(string text)
 {
     if (this.textBox1.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(SetText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.textBox1.Items.Add(text);
     }
 }
 private void setEmailText(string text)
 {
     if (this.lblEmail.InvokeRequired)
     {
         StringArgReturningVoidDelegate d = new StringArgReturningVoidDelegate(setEmailText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.lblEmail.Text = text;
     }
 }