Beispiel #1
0
        void fFocuser_OnHandshakeEvent(object sender, EventArgs e)
        {
            switch (fFocuser.DeviceType)
            {
            case FDEV.FD_FOCUSER:
                LogBox.AppendText("Focuser connected.\n");
                break;

            case FDEV.FD_MOUNTER:
                LogBox.AppendText("Mounter is attached! Please, re-connect Focuser!\n");
                btnDisconnect_Click(this, new EventArgs());
                break;

            case FDEV.FD_GROWER:
                LogBox.AppendText("Grower is attached! Please, re-connect Focuser!\n");
                btnDisconnect_Click(this, new EventArgs());
                break;

            default:
                LogBox.AppendText("Unknown device is attached! Please, re-connect Focuser!\n");
                btnDisconnect_Click(this, new EventArgs());
                break;
            }
            ;
        }
Beispiel #2
0
        private void UpdateLog(string str)
        {
            var sb = $@"{DateTime.Now}	{str}{Environment.NewLine}";

            LogBox.Invoke(new Action(() => { LogBox.AppendText(sb); }));
            UpdateLogFile(sb);
        }
Beispiel #3
0
 public void Log(string Msg)
 {
     Invoke(new Action(delegate()
     {
         LogBox.AppendText(Msg + Environment.NewLine);
     }));
 }
Beispiel #4
0
        private void DeleteFiles()
        {
            ProgressBar.Maximum = ToBeDeleted.Count;
            ProgressBar.Step    = 1;
            ProgressBar.Value   = 0;

            foreach (string file in ToBeDeleted)
            {
                if (!File.Exists(file))
                {
                    continue;
                }

                // File exists
                try
                {
                    File.Delete(file);
                    LogBox.AppendText(file + " has been deleted." + Environment.NewLine);
                }
                catch (UnauthorizedAccessException)
                {
                    MessageBox.Show($@"Please close {Path.GetFileName(file)} before trying to delete it!");
                    LogBox.AppendText(@Path.GetFileName(file) + " has not been deleted." + Environment.NewLine);
                }
                finally
                {
                    ProgressBar.Increment(1);
                }
            }

            MessageBox.Show(@"The deletion has been completed.");
            ProgressBar.Value = ProgressBar.Maximum;
        }
Beispiel #5
0
        private void ExposureList_TextChanged(object sender, EventArgs e)
        {
            byte[] buffer = new byte[1];

            switch (ExposureList.Text)
            {
            case "-5":
                buffer[0] = 0x40;
                break;

            case "-4":
                buffer[0] = 0x41;
                break;

            case "-3":
                buffer[0] = 0x42;
                break;

            case "-2":
                buffer[0] = 0x43;
                break;

            case "-1":
                buffer[0] = 0x44;
                break;

            case "0":
                buffer[0] = 0x45;
                break;

            case "1":
                buffer[0] = 0x46;
                break;

            case "2":
                buffer[0] = 0x47;
                break;

            case "3":
                buffer[0] = 0x48;
                break;

            case "4":
                buffer[0] = 0x49;
                break;

            case "5":
                buffer[0] = 0x4A;
                break;
            }

            try
            {
                portUsed.Write(buffer, 0, 1);
            }
            catch (Exception ex)
            {
                LogBox.AppendText(ex.Message + "\n");
            }
        }
Beispiel #6
0
        public void AddToLog(string text)
        {
            string line = String.Format(@"{0} {1}{2}", System.DateTime.Now.ToString(), text, Environment.NewLine);

            LogBox.BeginInvoke(
                ((Action)(() => LogBox.AppendText(line))));
        }
Beispiel #7
0
        private void RefreshView()
        {
            LogBox.Clear();

            UPnP.Log.LockReading(() =>
            {
                foreach (Tuple <UpnpLogType, string> item in UPnP.Log)
                {
                    LogBox.SelectionStart  = LogBox.Text.Length;
                    LogBox.SelectionLength = 0;

                    switch (item.Param1)
                    {
                    case UpnpLogType.In:
                        LogBox.SelectionColor = Color.Blue;
                        break;

                    case UpnpLogType.Out:
                        LogBox.SelectionColor = Color.Red;
                        break;

                    case UpnpLogType.Other:
                        LogBox.SelectionColor = Color.Black;
                        break;

                    case UpnpLogType.Error:
                        LogBox.SelectionColor = Color.Orange;
                        break;
                    }

                    LogBox.AppendText(item.Param2 + "\n\n");
                }
            });
        }
Beispiel #8
0
 /// <summary>
 /// 로그 대화상자에 메시지를 출력
 /// </summary>
 /// <param name="Msg">출력할 메시지</param>
 public void Log(string Msg)
 {
     Dispatcher.BeginInvoke((Action) delegate
     {
         LogBox.AppendText(DateTime.Now + " | " + Msg + "\n");
     });
 }
Beispiel #9
0
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x0312)
            {
                int id = m.WParam.ToInt32();
                switch (id)
                {
                case 0:
                    this.Activate();
                    LogBox.AppendText("Hotkey #1 - Pressed\r\n");
                    break;

                case 1:
                    this.Activate();
                    LogBox.AppendText("Hotkey #2 - Pressed\r\n");
                    break;

                case 2:
                    this.Activate();
                    LogBox.AppendText("Hotkey #3 - Pressed\r\n");
                    break;

                case 3:
                    this.Activate();
                    LogBox.AppendText("Hotkey #4 - Pressed\r\n");
                    break;
                }
            }
        }
Beispiel #10
0
 private void DisplayTableButton_Click(object sender, EventArgs e)
 {
     DataView.Columns.Clear();
     try
     {
         if (MPLSFIBButton.Checked)
         {
             SetupMPLSFIBDataGridView();
         }
         else if (IPFIBButton.Checked)
         {
             SetupIPFIBDataGridView();
         }
         else if (NHLFEButton.Checked)
         {
             SetupNHLFEDataGridView();
         }
         else if (FTNButton.Checked)
         {
             SetupFTNDataGridView();
         }
         else if (ILMButton.Checked)
         {
             SetupDataILMGridView();
         }
     }
     catch (Exception ex)
     {
         LogBox.AppendText(Logger.Log(ex.Message, LogType.ERROR));
     }
 }
Beispiel #11
0
 private void UpdateData(string Message)
 {
     if (LogBox.InvokeRequired)
     {
         ReceiveMessageCallBack DataCallBack = new ReceiveMessageCallBack(UpdateData);
         try
         {
             this.Invoke(DataCallBack, new Object[] { Message });
         }
         catch (ObjectDisposedException)
         {
             return;
         }
     }
     else
     {
         try
         {
             LogBox.AppendText(DateTime.Now.ToString("HH:mm:ss.ffff") + ": " + Message + Environment.NewLine);
             LogBox.SelectionStart = LogBox.TextLength;
             LogBox.ScrollToCaret();
         }
         catch (ObjectDisposedException)
         {
             return;
         }
     }
 }
Beispiel #12
0
 private void Refresher_Tick(object sender, EventArgs e)
 {
     while (router.messageQueue.Count > 0)
     {
         LogBox.AppendText(router.messageQueue.Dequeue());
     }
 }
Beispiel #13
0
 private void Log(string text)
 {
     LogBox.Invoke((MethodInvoker) delegate
     {
         LogBox.AppendText(text + "\n");
     });
 }
Beispiel #14
0
 private void PrintLog(String log)
 {
     if (this.LogBox.InvokeRequired)
     {
         printDelegate printInvoke = new printDelegate(PrintLog);
         this.LogBox.Invoke(printInvoke, log);
     }
     else
     {
         log = Regex.Replace(String.Format("{0}|{1}\n", DateTime.Now.ToString("hh:mm:ss.fff"), log), @"[\r\n]+", "\r\n");
         this.LogBox.AppendText(log);
         byte[] LogByte = this.SerialPort.Encoding.GetBytes(log);
         if (this.CheckBox_SaveLog.Checked)
         {
             using (FileStream SaveFileWrite = new FileStream(@SavePath, FileMode.Append))
             {
                 SaveFileWrite.Write(LogByte, 0, LogByte.Length);
             }
         }
         if (LogBox.Lines.Length > 100)
         {
             int    index     = LogBox.Text.IndexOf("\n");
             String newString = LogBox.Text.Remove(0, index + 2);
             LogBox.Clear();
             LogBox.AppendText(newString);
         }
     }
 }
Beispiel #15
0
        private void SendMessage()
        {
            string caption = "ChatForm Error!";
            // если не нужно отправлять, а просто вывести на экран
            // вдруг приватное сообщение отправлено самому себе
            string user = null;
            string msg  = "";

            if (msgInputField.Text.IndexOf('@') == 0)
            {
                int pos = msgInputField.Text.IndexOf(' ');
                if (pos == -1)
                {
                    string alertMsg = "Вы пытаетесь отправить сообщение, однако ничего не ввели" + Environment.NewLine
                                      + "@NICK MESSAGE";
                    MessageBox.Show(alertMsg, caption);
                    return;
                }
                if (pos < 2)
                {
                    string alertMsg = "Вы пытаетесь отправить сообщение, однако не выбрали получателя" + Environment.NewLine
                                      + "@NICK MESSAGE";
                    MessageBox.Show(alertMsg, caption);
                    return;
                }

                user = msgInputField.Text.Substring(1, pos - 1);
                msg  = msgInputField.Text.Substring(pos + 1);
                if (msg == "")
                {
                    string alertMsg = "Вы пытаетесь отправить сообщение, однако ничего не ввели" + Environment.NewLine
                                      + "@NICK MESSAGE";
                    MessageBox.Show(alertMsg, caption);
                    return;
                }
                if (user.Equals(username))
                {
                    LogBox.AppendText(msgInputField.Text + Environment.NewLine);
                    msgInputField.Text = "";
                    return;
                }
            }
            else
            {
                //TODO: FIX
                LogBox.AppendText(msgInputField.Text + Environment.NewLine);
                msgInputField.Text = "";
                return;
            }
            msgInputField.Text = "";

            DataController.UserMessage newMsg = new DataController.UserMessage(msg, getLogin.login, user);

            this.dataController.WriteQueue.Enqueue(newMsg);
            //if(newMsg.To != getLogin.login)
            //{
            //    AddMessage(newMsg);
            //}
        }
Beispiel #16
0
        public void Log(string message)
        {
            //LogBox.AppendText("\n[" + DateTime.Now.ToString("HH:mm") + "]" + message);
            LogBox.AppendText("\n" + message);
            LogBox.ScrollToEnd();

            //WriteTextSafe(message);
        }
Beispiel #17
0
 private void LogEventHandler(string logline)
 {
     ss_log.LogEntry(logline);
     LogBox.AppendText(logline + "\r\n");
     this.Show();
     System.Windows.Forms.Application.DoEvents();
     return;
 }
Beispiel #18
0
 void LogMessage(string message)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         LogBox.AppendText(message + "\n");
         LogBox.ScrollToEnd();
     }));
 }
Beispiel #19
0
        public void Log(string message)
        {
            var    dt   = DateTime.Now;
            string time = "[" + dt.ToString("HH:mm:ss") + "]: ";

            LogBox.AppendText(time + message + System.Environment.NewLine);
            LogBox.ScrollToCaret();
        }
Beispiel #20
0
        private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (sender is Bond)

            {
                LogBox.AppendText($"Bond {(sender as Bond).Path} property {e.PropertyName} changed.\n");
            }
        }
Beispiel #21
0
 private void AppendLog(string text)
 {
     Console.WriteLine(text);
     Dispatcher.Invoke(() =>
     {
         LogBox.AppendText(text + "\n");
         LogBox.ScrollToEnd();
     });
 }
Beispiel #22
0
        //{0, 1, 2, 3, 4, 5, 6, 14};

        private void ClosePort()
        {
            if (Port.IsOpen == true)
            {
                Port.Close();
                LogBox.AppendText("Закрыт порт " + Port.PortName + '\n');
                comPortStatus.Text = "Закрыт";
            }
        }
Beispiel #23
0
        void fFocuser_OnDebugMsgEvent(object sender, EventArgs e)
        {
            string s = "";

            while (fFocuser.GetDebugMsg(out s))
            {
                LogBox.AppendText("Debug msg: " + s + "\r\n");
            }
        }
Beispiel #24
0
 private void QuitExcelButton_Click(object sender, EventArgs e)
 {
     Application.DisplayAlerts = false;
     Application.Quit();
     Application.Dispose();
     Application = null;
     LogBox.AppendText("Application Has Been Disposed." + Environment.NewLine);
     SetupUI();
 }
Beispiel #25
0
 private void PortSpeedBox_SelectedValueChanged(object sender, EventArgs e)
 {
     if (Port.BaudRate != (int)PortSpeedBox.SelectedItem)
     {
         ClosePort();
         Port.BaudRate = (int)PortSpeedBox.SelectedItem;
         LogBox.AppendText("Скорость порта изменена на " + Port.BaudRate.ToString() + " бод\n");
     }
     LogBox.ScrollToCaret();
 }
Beispiel #26
0
 private void PortNameBox_SelectedValueChanged(object sender, EventArgs e)
 {
     if (Port.PortName != PortNameBox.Text)
     {
         ClosePort();
         Port.PortName = PortNameBox.Text;
         LogBox.AppendText("Имя последовательного порта изменено на " + Port.PortName + '\n');
     }
     LogBox.ScrollToCaret();
 }
Beispiel #27
0
 private void OpenPort()
 {
     if (Port.IsOpen != true)
     {
         Port.Open();
         LogBox.AppendText("Открыт порт " + Port.PortName + '\n');
         comPortStatus.Text = "Открыт";
         Port.DiscardInBuffer();
     }
 }
Beispiel #28
0
        public void WriteLine
        (
            string format, params object[] args
        )
        {
            string text = string.Format(format, args) + Environment.NewLine;

            LogBox.AppendText(text);
            LogBox.ScrollToEnd();
        }
Beispiel #29
0
 private void Log(string text)
 {
     if (this.InvokeRequired)
     {
         this.Invoke((MethodInvoker) delegate() { Log(text); });
     }
     else
     {
         LogBox.AppendText(text + Environment.NewLine);
     }
 }
 public void AppendLog(string log)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         if (AutoScrollChk.IsChecked == true)
         {
             LogBox.ScrollToEnd();
         }
         LogBox.AppendText(log + "\r\n");
     }));
 }