Example #1
0
        private void ThreadExecute(object aThreadData)
        {
            if (InvokeRequired)
            {
                SetMessageCallback d = new SetMessageCallback(ThreadExecute);
                this.BeginInvoke(d, new object[] { aThreadData });
                //Thread.CurrentThread.Abort();
            }
            else
            {
                ThreadData aData = aThreadData as ThreadData;
                DataTable  __DGViewTableItems = aData.aTable;

                CustDGView.DataSource = __DGViewTableItems;
                CustDGView.Columns["Description"].HeaderText   = "Description";
                CustDGView.Columns["Description"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                CustDGView.Columns["UnitPrice"].AutoSizeMode   = DataGridViewAutoSizeColumnMode.AllCells;
                CustDGView.Columns["TaxLevel"].HeaderText      = "Tax Level %";
                CustDGView.Columns["TaxLevel"].AutoSizeMode    = DataGridViewAutoSizeColumnMode.AllCells;
                CustDGView.Columns["Quantity"].HeaderText      = "Quantity";
                CustDGView.Columns["Quantity"].AutoSizeMode    = DataGridViewAutoSizeColumnMode.AllCells;
                CustDGView.Columns["Total"].HeaderText         = "Total Price";
                CustDGView.Columns["Total"].AutoSizeMode       = DataGridViewAutoSizeColumnMode.Fill;
                CustDGView.ClearSelection();
                CustDGView.FirstDisplayedScrollingRowIndex = __DGViewTableItems.Rows.Count - 1;

                //Thread.CurrentThread.Abort();
            }
        }
Example #2
0
 /// <summary>
 /// Sets the message of the progress dialog
 /// </summary>
 /// <param name="message">The message.</param>
 public static void SetMessage(string message)
 {
     if (instance.InvokeRequired) //if another thread called this method
     {
         SetMessageCallback s = new SetMessageCallback(SetMessage);
         instance.Invoke(s, message);
     }
     else
     {
         instance.lblMessage.Text = message;
     }
 }
 private void AddNetworkInstance(string text)
 {
     if (this.lstNetworkInstances.InvokeRequired)
     {
         var d = new SetMessageCallback(AddNetworkInstance);
         this.BeginInvoke(d, new object[] { text });
     }
     else
     {
         this.lstNetworkInstances.Items.Add(text);
     }
 }
Example #4
0
 public void SetMessage(MessageWindow messageWindow, Commons.Message message)
 {
     if (messageWindow.InvokeRequired)
     {
         SetMessageCallback callback = new SetMessageCallback(messageWindow.RecievedNewMessage);
         messageWindow.Invoke(callback, message.Text, message.Sender.UserName);
     }
     else
     {
         messageWindow.RecievedNewMessage(message.Text, message.Sender.UserName);
     }
 }
Example #5
0
 private void setMessage(string message)
 {
     if (this.edOut.InvokeRequired)
     {
         SetMessageCallback d = new SetMessageCallback(setMessage);
         this.Invoke(d, new object[] { message });
     }
     else
     {
         this.edOut.Text = message + Environment.NewLine + this.edOut.Text;
     }
 }
 private void SetMessageText(RichTextBox rtb, string value)
 {
     if (rtb.InvokeRequired)
     {
         SetMessageCallback sc = new SetMessageCallback(SetMessageText);
         this.Invoke(sc, new object[] { rtb, value });
     }
     else
     {
         rtb.AppendText(value);
     }
 }
Example #7
0
 public void LogMessage(string msg)
 {
     if (txtResponse.InvokeRequired)
     {
         SetMessageCallback callback = new SetMessageCallback(LogMessage);
         Invoke(callback, new object[] { msg });
     }
     else
     {
         txtResponse.AppendText(msg);
         txtResponse.AppendText(Environment.NewLine);
     }
 }
Example #8
0
 private void ActivationChecking(object Data)
 {
     Security.V1.ActivationCheck.TrialCheck();/*Hackers Trick*/
     Application.DoEvents();
     this.FinishedActivation = true;
     if (InvokeRequired)
     {
         SetMessageCallback d = new SetMessageCallback(ActivationChecking);
         this.BeginInvoke(d, new object[] { Data });
     }
     else
     {
         Thread.Sleep(1000);
         this.Close();
     }
 }
Example #9
0
 public void SetMessage(string message, bool append)
 {
     // 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.labelMessage.InvokeRequired)
     {
         SetMessageCallback messageCallback = new SetMessageCallback(SetMessage);
         this.Invoke(messageCallback, new object[] { message, append });
     }
     else
     {
         if (append)
         {
             this.labelMessage.Text += "\n" + message;
         }
         else
         {
             this.labelMessage.Text = message;
         }
         this.progressBarMain.Value += 10;
     }
 }
Example #10
0
 /// <summary>
 /// Sets the message of the progress dialog
 /// </summary>
 /// <param name="message">The message.</param>
 public static void SetMessage(string message)
 {
     if (instance.InvokeRequired) //if another thread called this method
     {
         SetMessageCallback s = new SetMessageCallback(SetMessage);
         instance.Invoke(s, message);
     }
     else
     {
         instance.lblMessage.Text = message;
     }
 }
        public void SetMessage(string name, string log)
        {
            if (ReceivedCmd.InvokeRequired)
            {
                SetMessageCallback d = new SetMessageCallback(SetMessage);
                ReceivedCmd.Invoke(d, new object[] { name, log });  // invoking itself
            }
            else
            {
                if (log != "")
                {
                    string text = null;
                    text = DateTime.Now + log + Environment.NewLine;
                    ReceivedCmd.AppendText(text);
                    StoreText(text);
                }

                switch (name)
                {
                    case "TargetAlive" :

                        break;
                    case "TrainDetectionFinished":                          // Traindetection (because message train detection comes first and "trains on fiddle yard trackX true/false
                        if (Initialized == false)
                        {
                            LLed_Track1.BackColor = Color.Transparent;      // comes later, all tracks get the correct color.
                            LLed_Track1.Text = "                                   1";
                            LLed_Track2.BackColor = Color.Transparent;
                            LLed_Track2.Text = "                                   2";
                            LLed_Track3.BackColor = Color.Transparent;
                            LLed_Track3.Text = "                                   3";
                            LLed_Track4.BackColor = Color.Transparent;
                            LLed_Track4.Text = "                                   4";
                            LLed_Track5.BackColor = Color.Transparent;
                            LLed_Track5.Text = "                                   5";
                            LLed_Track6.BackColor = Color.Transparent;
                            LLed_Track6.Text = "                                   6";
                            LLed_Track7.BackColor = Color.Transparent;
                            LLed_Track7.Text = "                                   7";
                            LLed_Track8.BackColor = Color.Transparent;
                            LLed_Track8.Text = "                                   8";
                            LLed_Track9.BackColor = Color.Transparent;
                            LLed_Track9.Text = "                                   9";
                            LLed_Track10.BackColor = Color.Transparent;
                            LLed_Track10.Text = "                                  10";
                            LLed_Track11.BackColor = Color.Transparent;
                            LLed_Track11.Text = "                                  11";
                        }
                        Initialized = true;
                        break;

                    case "FiddleYardStopped":
                        Btn_Collect_TOP.Enabled = true;
                        manualModeToolStripMenuItem.Enabled = true;
                        Btn_Start_Fiddle_TOP.Enabled = true;
                        break;

                    default: break;
                }
            }
        }
        /*#--------------------------------------------------------------------------#*/
        /*  Description: SetMessage
         *
         *
         *
         *
         *  Input(s)   :
         *
         *  Output(s)  :
         *
         *  Returns    :
         *
         *  Pre.Cond.  :
         *
         *  Post.Cond. :
         *
         *  Notes      :
         */
        /*#--------------------------------------------------------------------------#*/
        private void SetMessage(string name, string log)
        {
            if (ReceivedCmd.InvokeRequired)
            {
                SetMessageCallback d = new SetMessageCallback(SetMessage);
                ReceivedCmd.Invoke(d, new object[] { name, log });  // invoking itself
            }
            else
            {
                if (log != "")
                {
                    FiddleYardFormLogging.StoreText(log);
                    string fmt = "000";
                    int m_Millisecond = DateTime.Now.Millisecond;
                    string m_text = DateTime.Now + ":" + m_Millisecond.ToString(fmt) + " " + log + " " + Environment.NewLine;
                    ReceivedCmd.AppendText(m_text);
                }

                switch (name)
                {
                    case "TrainDetectionFinished":                          // Traindetection (because message train detection comes first and "trains on fiddle yard trackX true/false
                        if (Initialized == false)
                        {
                            LLed_Track1.BackColor = Color.Transparent;      // comes later, all tracks get the correct color.
                            LLed_Track1.Text = "                                   1";
                            LLed_Track2.BackColor = Color.Transparent;
                            LLed_Track2.Text = "                                   2";
                            LLed_Track3.BackColor = Color.Transparent;
                            LLed_Track3.Text = "                                   3";
                            LLed_Track4.BackColor = Color.Transparent;
                            LLed_Track4.Text = "                                   4";
                            LLed_Track5.BackColor = Color.Transparent;
                            LLed_Track5.Text = "                                   5";
                            LLed_Track6.BackColor = Color.Transparent;
                            LLed_Track6.Text = "                                   6";
                            LLed_Track7.BackColor = Color.Transparent;
                            LLed_Track7.Text = "                                   7";
                            LLed_Track8.BackColor = Color.Transparent;
                            LLed_Track8.Text = "                                   8";
                            LLed_Track9.BackColor = Color.Transparent;
                            LLed_Track9.Text = "                                   9";
                            LLed_Track10.BackColor = Color.Transparent;
                            LLed_Track10.Text = "                                  10";
                            LLed_Track11.BackColor = Color.Transparent;
                            LLed_Track11.Text = "                                  11";
                        }
                        Initialized = true;
                        break;

                    case "CollectingTrainsEnabled":
                        Btn_Collect_TOP.Text = "Collect On";
                        break;

                    case "CollectingTrainsDisabled":
                        Btn_Collect_TOP.Text = "Collect Off";
                        break;

                    case "FiddleYardAutoModeIsStopped":
                        Btn_Start_Fiddle_TOP.Enabled = true;
                        Btn_Stop_Fiddle_TOP.Enabled = false;
                        manualModeToolStripMenuItem.Enabled = true;
                        break;

                    case "FiddleYardAutoModeStart":
                        Btn_Start_Fiddle_TOP.Enabled = false;
                        Btn_Stop_Fiddle_TOP.Enabled = true;
                        manualModeToolStripMenuItem.Enabled = false;
                        break;

                    case "FiddleYardReset":
                        Initialized = false;
                        // Next also force all track color to cyan including text becasue if a track is already false no update is executed on each track color.
                        LLed_Track1.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track1.Text = "                     Not Initialized";
                        LLed_Track2.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track2.Text = "                     Not Initialized";
                        LLed_Track3.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track3.Text = "                     Not Initialized";
                        LLed_Track4.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track4.Text = "                     Not Initialized";
                        LLed_Track5.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track5.Text = "                     Not Initialized";
                        LLed_Track6.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track6.Text = "                     Not Initialized";
                        LLed_Track7.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track7.Text = "                     Not Initialized";
                        LLed_Track8.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track8.Text = "                     Not Initialized";
                        LLed_Track9.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track9.Text = "                     Not Initialized";
                        LLed_Track10.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track10.Text = "                     Not Initialized";
                        LLed_Track11.BackColor = m_FYAppVar.TrackNotInitializedColor;;
                        LLed_Track11.Text = "                     Not Initialized";

                        PB_Tr1_Inline.Hide();
                        PB_Tr2_Inline.Hide();
                        PB_Tr3_Inline.Hide();
                        PB_Tr4_Inline.Hide();
                        PB_Tr5_Inline.Hide();
                        PB_Tr6_Inline.Hide();
                        PB_Tr7_Inline.Hide();
                        PB_Tr8_Inline.Hide();
                        PB_Tr9_Inline.Hide();
                        PB_Tr10_Inline.Hide();
                        PB_Tr11_Inline.Hide();

                        PB_Tr1_Train.Image = null;
                        PB_Tr2_Train.Image = null;
                        PB_Tr3_Train.Image = null;
                        PB_Tr4_Train.Image = null;
                        PB_Tr5_Train.Image = null;
                        PB_Tr6_Train.Image = null;
                        PB_Tr7_Train.Image = null;
                        PB_Tr8_Train.Image = null;
                        PB_Tr9_Train.Image = null;
                        PB_Tr10_Train.Image = null;
                        PB_Tr11_Train.Image = null;

                        PB_Tr1_Active.BackColor = LLed_Track1.BackColor;
                        PB_Tr1_Inline.BackColor = LLed_Track1.BackColor;
                        PB_Tr1_Train.BackColor = LLed_Track1.BackColor;

                        PB_Tr2_Active.BackColor = LLed_Track2.BackColor;
                        PB_Tr2_Inline.BackColor = LLed_Track2.BackColor;
                        PB_Tr2_Train.BackColor = LLed_Track2.BackColor;

                        PB_Tr3_Active.BackColor = LLed_Track3.BackColor;
                        PB_Tr3_Inline.BackColor = LLed_Track3.BackColor;
                        PB_Tr3_Train.BackColor = LLed_Track3.BackColor;

                        PB_Tr4_Active.BackColor = LLed_Track4.BackColor;
                        PB_Tr4_Inline.BackColor = LLed_Track4.BackColor;
                        PB_Tr4_Train.BackColor = LLed_Track4.BackColor;

                        PB_Tr5_Active.BackColor = LLed_Track5.BackColor;
                        PB_Tr5_Inline.BackColor = LLed_Track5.BackColor;
                        PB_Tr5_Train.BackColor = LLed_Track5.BackColor;

                        PB_Tr6_Active.BackColor = LLed_Track6.BackColor;
                        PB_Tr6_Inline.BackColor = LLed_Track6.BackColor;
                        PB_Tr6_Train.BackColor = LLed_Track6.BackColor;

                        PB_Tr7_Active.BackColor = LLed_Track7.BackColor;
                        PB_Tr7_Inline.BackColor = LLed_Track7.BackColor;
                        PB_Tr7_Train.BackColor = LLed_Track7.BackColor;

                        PB_Tr8_Active.BackColor = LLed_Track8.BackColor;
                        PB_Tr8_Inline.BackColor = LLed_Track8.BackColor;
                        PB_Tr8_Train.BackColor = LLed_Track8.BackColor;

                        PB_Tr9_Active.BackColor = LLed_Track9.BackColor;
                        PB_Tr9_Inline.BackColor = LLed_Track9.BackColor;
                        PB_Tr9_Train.BackColor = LLed_Track9.BackColor;

                        PB_Tr10_Active.BackColor = LLed_Track10.BackColor;
                        PB_Tr10_Inline.BackColor = LLed_Track10.BackColor;
                        PB_Tr10_Train.BackColor = LLed_Track10.BackColor;

                        PB_Tr11_Active.BackColor = LLed_Track11.BackColor;
                        PB_Tr11_Inline.BackColor = LLed_Track11.BackColor;
                        PB_Tr11_Train.BackColor = LLed_Track11.BackColor;

                        CheckWhichTrackInline();

                        Btn_Collect_TOP.Enabled = true;
                        Btn_Start_Fiddle_TOP.Enabled = true;
                        Btn_Stop_Fiddle_TOP.Enabled = false;
                        manualModeToolStripMenuItem.Enabled = true;
                        break;

                    default: break;
                }
            }
        }
Example #13
0
 // thread safe error messaging
 private void writeMessage(String text, bool severity)
 {
     if (this.lblError.InvokeRequired)
     {
         SetMessageCallback d = new SetMessageCallback (writeMessage);
         this.Invoke (d, new object[] { text, severity });
     }
     else
     {
         if (severity == true)
         {
             lblError.ForeColor = System.Drawing.Color.Red;
         }
         else
         {
             lblError.ForeColor = System.Drawing.Color.Gray;
         }
         lblError.Text = text;
         lblError.Refresh ();
     }
 }