Esempio n. 1
0
        /// <summary>
        /// Opens a dialog to open a format file
        /// </summary>
        private void OpenFormat()
        {
            UpdateTextBox.Invoke();
            if (!Format.OverwriteConfirmation())
            {
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog
            {
                Title  = "Open format file",
                Filter = "JSON Files (*.json)|*.json"
            };

            if (ofd.ShowDialog() != true)
            {
                return;
            }

            VM_HeaderNode newFormat = new VM_HeaderNode(this, ofd.FileName);

            if (newFormat.FormatFilePath != ofd.FileName)
            {
                return;
            }
            Format = newFormat;
            ResetMessage();
        }
Esempio n. 2
0
 /// <summary>
 /// Performs an Undo. If a textbox is focused, the binding will be updated
 /// </summary>
 private void Redo()
 {
     UpdateTextBox.Invoke();
     if (Format.Tracker.Redo())
     {
         SetMessage("Performed Redo!");
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Creates a new format file
 /// </summary>
 private void NewFormat()
 {
     UpdateTextBox.Invoke();
     if (!Format.OverwriteConfirmation())
     {
         return;
     }
     Format = new VM_HeaderNode(this);
     ResetMessage();
 }
Esempio n. 4
0
        //扫码成功时的回调函数
        int decodeCallBackStr(IntPtr str, int length)
        {
            //得到解码结果字符串
            string        result = Marshal.PtrToStringAnsi(str);
            UpdateTextBox utb    = new UpdateTextBox(InputTextBox);

            BeginInvoke(utb, result);

            return(0);
        }
Esempio n. 5
0
 // Function for handling text updates
 private void SetResponseText(TextBox textBox, string text)
 {
     if (textBox.InvokeRequired)
     {
         UpdateTextBox updateTextBoxes = new UpdateTextBox(SetResponseText);
         Invoke(updateTextBoxes, new object[] { textBox, text });
     }
     else
     {
         textBox.Text = text;
     }
 }
Esempio n. 6
0
 public void Start(UpdateTextBox updateText)
 {
     this.updateTextBox   = updateText;
     this.th              = new Thread(new ThreadStart(this.Excute));
     this.th.IsBackground = true;
     this.th.SetApartmentState(ApartmentState.STA);
     while (this.th.IsAlive)
     {
         Thread.Sleep(50);
     }
     Log.WriteLog("Workth Start");
     this.th.Start();
 }
Esempio n. 7
0
 public frmBackup()
 {
     log.Info("Entry");
     InitializeComponent();
     //this.conf = new ConfigManager(conf);
     this.conf  = ConfigManager.GetInstance();
     this.Text += String.Format(" {0} -> {1}\\{2}.zip", this.conf.BackupSettings.source,
                                this.conf.BackupSettings.destination, Helper.Placeholder.replace(this.conf.BackupSettings.schema, this.conf.BackupSettings.source));
     updateFileProgress = UpdateProgress;
     updateStatusCount  = UpdatelblStatusCount;
     updateFile         = UpdatelblActualFile;
     updateTextBox      = UpdatetbHistory;
     log.Info("Exit");
 }
Esempio n. 8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //delegate to update from from data recieved method
            _updateLabel          = new UpdateLabel(Update_Label);
            _updateTextBox        = new UpdateTextBox(Update_Textbox);
            _DelegateDataReceived = new DelegateDataReceived(DataReceived);
            _threadStressTest     = null;
            //_DelegateStressTest = new DelegateStressTest(StressTest);

            kickoffRead = delegate
            {
                try
                {
                    this.serialPort1.BaseStream.BeginRead(_serialReadBuffer, 0, _serialReadBuffer.Length, delegate(IAsyncResult ar)
                    {
                        try
                        {
                            if (serialPort1.IsOpen)
                            {
                                int actualLength = serialPort1.BaseStream.EndRead(ar);
                                byte[] received  = new byte[actualLength];
                                Buffer.BlockCopy(_serialReadBuffer, 0, received, 0, actualLength);
                                if (actualLength > 0)
                                {
                                    DataReceived(received);
                                }
                            }
                            kickoffRead();
                        }
                        catch (Exception ie)//ie for internql exceeption
                        {
                            MessageBox.Show(ie.Message, "Serial issue");
                        }
                    }, null);
                }
                catch (IOException exc)
                {
                    if (serialPort1.IsOpen)
                    {
                        serialPort1.Close();
                    }
                }
            };

            NewFile();
        }
Esempio n. 9
0
 /// <summary>
 /// Saves the current data into a new file
 /// </summary>
 private void SaveFileAs()
 {
     UpdateTextBox.Invoke();
     if (Properties.Settings.Default.DevMode)
     {
         if (Format.SaveFormat(true))
         {
             SetMessage("Format Saved!");
         }
     }
     else
     {
         if (Format.SaveContent(true))
         {
             SetMessage("Content Saved!");
         }
     }
 }
Esempio n. 10
0
        private void btnReceive_Click(object sender, EventArgs e)
        {
            var thread = new Thread(t => {
                UpdateTextBox textbox = UpdateDataTextBox;
                WhatsApp wa           = new WhatsApp(txbName.Text, txbPhone.Text, txbPass.Text, true);
                wa.OnConnectSuccess  += () =>
                {
                    if (txbStatus.InvokeRequired)
                    {
                        Invoke(textbox, txbStatus, "Connected...");
                    }
                    wa.OnLoginSuccess += (phone, data) =>
                    {
                    };
                };
            });

            thread.Start();
        }
 private void UpdateTextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     UpdateTextBox.Clear();
 }
Esempio n. 12
0
 //Thread safe call on the TextBox
 //If the calling thread is different from the thread that created
 //the TextBox control, this method creates a callback and calls itself
 //asynchronously using the Invole method
 //
 //If the calling thread is the same as the the one that created the control
 //it updates the data directly
 private void ClustersTextUpdate(string value)
 {
     // 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.clustersNum.InvokeRequired)
     {
         UpdateTextBox d = new UpdateTextBox(ClustersTextUpdate);
         this.Invoke(d, new object[] { value });
     }
     else
     {
         this.clustersNum.Text = value;
     }
 }
Esempio n. 13
0
 private void send()
 {
     try
     {
         WhatsUserManager manager = new WhatsUserManager();
         user = manager.CreateUser(textBox5MyMobile.Text, textBox4Name.Text);
         var thread = new Thread(t =>
         {
             UpdateTextBox textbox = UpdateDataTextBox;
             wa = new WhatsApp(textBox5MyMobile.Text, textBox6Password.Text, textBox4Name.Text, true);
             wa.OnConnectSuccess += () =>
             {
                 if (textBox3Status.InvokeRequired)
                 {
                     Invoke(textbox, textBox3Status, "Connected...");
                 }
                 wa.OnLoginSuccess += (phone, data) =>
                 {
                     if (textBox3Status.InvokeRequired)
                     {
                         Invoke(textbox, textBox3Status, "\r\nLogin success!");
                     }
                     while (wa != null)
                     {
                         wa.PollMessages();
                         Thread.Sleep(200);
                         continue;
                     }
                 };
                 wa.OnGetMessage += (node, from, id, name, message, receipt_sent) =>
                 {
                     if (textBox3Status.InvokeRequired)
                     {
                         Invoke(textbox, textBox3Status, string.Format("\r\n{0}:{1}", name, message));
                     }
                 };
                 wa.OnLoginFailed += (data) =>
                 {
                     if (textBox3Status.InvokeRequired)
                     {
                         Invoke(textbox, textBox3Status, string.Format("\r\nLogin failed:{0}", data));
                     }
                 };
                 wa.Login();
             };
             wa.OnConnectFailed += (ex) =>
             {
                 if (textBox3Status.InvokeRequired)
                 {
                     Invoke(textbox, textBox3Status, string.Format("\r\nConnect failed: {0}", ex.StackTrace));
                 }
             };
             wa.Connect();
         })
         {
             IsBackground = true
         };
         thread.Start();
     }
     catch (Exception ex) { MessageBox.Show("Connection failed. Check input data, remove polish letters, to telephone number add prefix 48" + ex); }
 }
Esempio n. 14
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            WhatsUserManager Manage = new WhatsUserManager();

            USER = Manage.CreateUser(TextBox5.Text, TextBox6.Text);
            var thread = new Thread(testc =>
            {
                UpdateTextBox textbox = UpdateDataTextBox;
                WA = new Whatsapp(TextBox5.Text, TextBox6.Text, TextBox4.Text, true);
                WA.OnConnectSuccess += () =>
                {
                    if (TextBox3.InvokeRequired)
                    {
                        Invoke(textbox, TextBox3, "Connected....");
                    }
                    WA.OnLoginSuccess += (phone, data) =>
                    {
                        if (TextBox3.InvokeRequired)
                        {
                            invoke(textbox, TextBox3, "\r\nLogin Success....");
                        }
                        while (WA != null)
                        {
                            WA = PollMessage();
                            Thread.Sleep(200);
                            continue;
                        }
                    };
                    WA.OnGetMessage += (node, from, id, name, message, receipt_send) =>
                    {
                        if (TextBox3.InvokeRequired)
                        {
                            invoke(textbox, TextBox3, string.Format("\r\n{0}:{1}", name, message));
                        }
                    };
                    WA.OnLoginFailed += (data) =>
                    {
                        if (TextBox3.InvokeRequired)
                        {
                            invoke(textbox, TextBox3, string.Format("\r\nConnect failed: {0}", data));
                        }
                    };
                    WA.Login();
                };
                WA.OnConnectFailed += (ex) =>
                {
                    if (TextBox3.InvokeRequired)
                    {
                        invoke(textbox, TextBox3, string.Format("\r\nConnection Failed {0}", ex.StactTrace));
                    }
                };



                WA.Connect();
            })
            {
                IsBackground = true
            };

            thread.Start();
        }