Example #1
0
        private void UpdateContent()
        {
            if (string.IsNullOrEmpty(Logging.LogFilePath))
            {
                return;
            }
            try
            {
                using (StreamReader reader = new StreamReader(new FileStream(Logging.LogFilePath,
                                                                             FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
                {
                    reader.BaseStream.Seek(lastOffset, SeekOrigin.Begin);

                    string line    = "";
                    bool   changed = false;
                    while ((line = reader.ReadLine()) != null)
                    {
                        changed = true;
                        LogTextBox.AppendText(line + Environment.NewLine);
                    }

                    if (changed)
                    {
                        LogTextBox.ScrollToCaret();
                    }

                    lastOffset = reader.BaseStream.Position;
                }
            }
            catch (FileNotFoundException)
            {
            }
        }
Example #2
0
        private void OnOBNewOrderReport(object sender, AxICETRADEAPILib._DICETRADEAPIEvents_OBNewOrderReportEvent e)
        {
            TRptData tmpRptData = new TRptData();

            tmpRptData.nIndex   = e.nDataIndex;
            tmpRptData.nType    = e.nDataType;
            tmpRptData.nGridNum = m_OBOrderRow;
            LogTextBox.AppendText("new\n");
            dataGridView3.Rows.Add();
            dataGridView3.Rows[m_OBOrderRow].Cells[0].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, FTR_ID);
            dataGridView3.Rows[m_OBOrderRow].Cells[1].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, FTR_MTH);
            dataGridView3.Rows[m_OBOrderRow].Cells[2].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, CALLPUT);
            dataGridView3.Rows[m_OBOrderRow].Cells[3].Value = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, STRIKE_PRICE) / 1000;
            dataGridView3.Rows[m_OBOrderRow].Cells[4].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ORDNO);
            tmpRptData.nOrderNo = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ORDNO);
            dataGridView3.Rows[m_OBOrderRow].Cells[5].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, BUYSELL);
            dataGridView3.Rows[m_OBOrderRow].Cells[6].Value  = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, OD_PRICE) / 1000;
            dataGridView3.Rows[m_OBOrderRow].Cells[7].Value  = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, OD_QTY);
            dataGridView3.Rows[m_OBOrderRow].Cells[8].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, OD_KEY);
            dataGridView3.Rows[m_OBOrderRow].Cells[9].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ERR_CODE);
            dataGridView3.Rows[m_OBOrderRow].Cells[10].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ERR_MSG);
            dataGridView3.Rows[m_OBOrderRow].Cells[11].Value = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, FORM_TYPE);

            m_OBOrderReport.Add(tmpRptData);
            m_OBOrderRow = m_OBOrderRow + 1;
        }
Example #3
0
        public void Recieve()
        {
            IPEndPoint from = new IPEndPoint(IPAddress.Any, 0);

            Thread.Sleep(1000); //Pozbycie się niewygodnych wyjątków

            while (true)
            {
                LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("RECIEVER> Waiting for data...\r\n")));

                try
                {
                    this.buffer = client_socket.Receive(ref from);
                }
                catch (Exception e)
                {
                    LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("RECIEVER> Socket error while recieving the message! " + e.ToString() + "\r\n")));
                }

                if (buffer.Length > 0)
                {
                    LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("SERVER> " + ByteToString(this.buffer) + "\r\n")));
                    ExecAndAck(); //Uzupełnienie pól klasy
                    LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("\n")));
                }
            }
        }
Example #4
0
 private void Log(string msg)
 {
     this.BeginInvoke((MethodInvoker) delegate
     {
         LogTextBox.AppendText("Client > " + msg + "\r\n");
     });
 }
Example #5
0
        private void OnConnectionTerminated(object sender, _IRDPSessionEvents_OnConnectionTerminatedEvent e)
        {//2308 == Presenter Ended Session
            //LogTextBox.Text += "Connection Terminated. Reason: " + e.discReason + Environment.NewLine;
            LogTextBox.AppendText("Connection Terminated. Reason: " + e.discReason + Environment.NewLine);
            //ControlButton.Enabled = false;
            //Close();


            ConnectButton.Enabled    = true;
            DisconnectButton.Enabled = false;
            ControlButton.Enabled    = false;


            NetManager propTest = new NetManager();

            //Thread netManager = new Thread(new ThreadStart(propTest.RunExample));

            //netManager.Start();


            propTest.netShutdown();


            //netManager.
        }
Example #6
0
        private void InitContent()
        {
            if (string.IsNullOrEmpty(Logging.LogFilePath))
            {
                return;
            }
            using (StreamReader reader = new StreamReader(new FileStream(Logging.LogFilePath,
                                                                         FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
            {
                if (reader.BaseStream.Length > BACK_OFFSET)
                {
                    reader.BaseStream.Seek(-BACK_OFFSET, SeekOrigin.End);
                    reader.ReadLine();
                }

                string line = "";
                while ((line = reader.ReadLine()) != null)
                {
                    LogTextBox.AppendText(line + Environment.NewLine);
                }

                LogTextBox.ScrollToCaret();

                lastOffset = reader.BaseStream.Position;
            }
        }
Example #7
0
        /// <summary>
        /// Update the status label at the bottom of the form
        /// </summary>
        private void timer_Tick(object sender, EventArgs e)
        {
            StatisticsToolStripStatusLabel.Text = string.Concat("Performance: CPU: ", OS.CpuUsage.NextValue().ToString("0.0"), "%",
                                                                " Ram: ", OS.TotalPhysicalMemoryUsed, " Mb");

            if (_logging == null)
            {
                return;
            }

            LogEntry log;

            while (_logging.Logs.TryDequeue(out log))
            {
                switch (log.MessageType)
                {
                case LogType.Debug:
                    LogTextBox.AppendText(log.ToString(), Color.Black);
                    break;

                default:
                case LogType.Trace:
                    LogTextBox.AppendText(log.ToString(), Color.Black);
                    break;

                case LogType.Error:
                    LogTextBox.AppendText(log.ToString(), Color.DarkRed);
                    break;
                }
            }
        }
Example #8
0
        private void OnError(object sender, _IRDPSessionEvents_OnErrorEvent e)
        {
            int ErrorCode = (int)e.errorInfo;

            //LogTextBox.Text += ("Error 0x" + ErrorCode.ToString("X") + Environment.NewLine);
            LogTextBox.AppendText("Error 0x" + ErrorCode.ToString("X") + Environment.NewLine);
        }
Example #9
0
        private void StopButton_Click(object sender, EventArgs e)
        {
            StartButton.Enabled = true;
            StopButton.Enabled  = false;

            try
            {
                MessagesClass propTest = new MessagesClass();
                propTest.netShutdown();
                m_pRdpSession.Close();
                //LogTextBox.Text += "Presentation Stopped." + Environment.NewLine;
                LogTextBox.AppendText("Presentation Stopped." + Environment.NewLine);
                Marshal.ReleaseComObject(m_pRdpSession);
                m_pRdpSession = null;
            }
            catch (Exception ex)
            {
                //LogTextBox.Text += "Error occured while stopping presentation. Error: " + ex.ToString();
                LogTextBox.AppendText("Error occured while stopping presentation. Error: " + ex.ToString() + Environment.NewLine);

                StartButton.Enabled = false;
                StopButton.Enabled  = false;
                checkBox1.Enabled   = false;

                LogTextBox.AppendText("Please exit the program." + Environment.NewLine);
            }
        }
 private void AppendLog(string text)
 {
     if (this.Disposing || this.IsDisposed)
     {
         return;
     }
     if (LogTextBox.InvokeRequired)
     {
         LogTextBox.Invoke(new EventHandler((s, e) =>
         {
             lock (LogTextBox)
             {
                 LogTextBox.AppendText(text);
             }
             LogTextBox.ScrollToCaret();
         }), this, null);
     }
     else
     {
         lock (LogTextBox)
         {
             LogTextBox.AppendText(text);
         }
         LogTextBox.ScrollToCaret();
     }
 }
 public void Log(string text)
 {
     Dispatcher.BeginInvoke(new System.Threading.ThreadStart(delegate {
         LogTextBox.AppendText(DateTime.Now + " :: " + text + "\n");
         LogTextBox.ScrollToEnd();
     }));
 }
Example #12
0
 private void AppendLog(string message)
 {
     Dispatcher.Invoke(() =>
     {
         LogTextBox.AppendText($"{message}{Environment.NewLine}");
     });
 }
        private void VelocidadProduccionTrackBar_Scroll(object sender, EventArgs e)
        {
            string Mensaje = string.Empty;

            if (VelocidadProduccionTrackBar.Value == 1)
            {
                Mensaje          = "La velocidad es";
                IntervaloTiempo  = 10;
                incremento       = VelocidadProduccionTrackBar.Value;
                OnTimer.Interval = 100;
            }
            else if (VelocidadProduccionTrackBar.Value == 10)
            {
                Mensaje          = "La velocidad es";
                IntervaloTiempo  = 0;
                OnTimer.Interval = 1;
                incremento       = 10;
            }
            else if (VelocidadProduccionTrackBar.Value > CorreaVelocidadValue)
            {
                Mensaje           = "Se Aumento la velocidad a ";
                IntervaloTiempo  -= 1;
                OnTimer.Interval -= 10;
                incremento        = VelocidadProduccionTrackBar.Value;
            }
            else if (CorreaVelocidadValue > VelocidadProduccionTrackBar.Value)
            {
                Mensaje           = "Se Disminuyo la velocidad a";
                IntervaloTiempo  += 1;
                OnTimer.Interval += 10;
                incremento        = VelocidadProduccionTrackBar.Value;
            }
            LogTextBox.AppendText($"{System.Environment.NewLine}{Mensaje} {incremento.ToString()}");
            VelocidadCorreaLabel.Text = incremento.ToString();
        }
        public void AsignarEmbutido(bool EvualuarExpresion = false, bool MarcarNoServible = false)
        {
            embutido = new Embutidos
            {
                Longitud            = LongitudEmbutidoRandom(),
                LongitudAprensadora = LongitudAprensadoraRandom(),
                Tipo = Tipo.Servible
            };
            embutido.AsignarWidthEmbutido();
            embutido.AsignarWidthAprensadora();

            if (EvualuarExpresion)
            {
                if ((float)embutido.LongitudAprensadora != (float)embutido.Longitud)
                {
                    embutido.Tipo = Tipo.NoServible;
                }
            }
            if (MarcarNoServible)
            {
                embutido.Tipo = Tipo.NoServible;
            }

            Lista.Add(embutido);
            string Servible = embutido.Tipo == Tipo.NoServible ? "Que no es servible" : "";

            LogTextBox.AppendText($"{System.Environment.NewLine}Se agrego un embutido {embutido.Longitud.ToString()} {Servible}");
            LogTextBox.AppendText($"{System.Environment.NewLine}La Aprensadora es {embutido.LongitudAprensadora.ToString()}");
        }
Example #15
0
        private void OnOBChangeOrderReport(object sender, AxICETRADEAPILib._DICETRADEAPIEvents_OBChgOrderReportEvent e)
        {
            int Row;

            LogTextBox.AppendText("chg\n");
            foreach (TRptData tmpRptData in m_OBOrderReport)
            {
                if ((tmpRptData.nIndex == e.nDataIndex) && (tmpRptData.nType == e.nDataType))
                {
                    Row = tmpRptData.nGridNum;
                    dataGridView3.Rows[Row].Cells[0].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, FTR_ID);
                    dataGridView3.Rows[Row].Cells[1].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, FTR_MTH);
                    dataGridView3.Rows[Row].Cells[2].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, CALLPUT);
                    dataGridView3.Rows[Row].Cells[3].Value  = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, STRIKE_PRICE) / 1000;
                    dataGridView3.Rows[Row].Cells[4].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ORDNO);
                    dataGridView3.Rows[Row].Cells[5].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, BUYSELL);
                    dataGridView3.Rows[Row].Cells[6].Value  = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, OD_PRICE) / 1000;
                    dataGridView3.Rows[Row].Cells[7].Value  = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, OD_QTY);
                    dataGridView3.Rows[Row].Cells[8].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, OD_KEY);
                    dataGridView3.Rows[Row].Cells[9].Value  = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ERR_CODE);
                    dataGridView3.Rows[Row].Cells[10].Value = tradeApi.GetOBReportString(e.nDataType, e.nDataIndex, ERR_MSG);
                    dataGridView3.Rows[Row].Cells[11].Value = tradeApi.GetOBReportValue(e.nDataType, e.nDataIndex, FORM_TYPE);
                    break;
                }
            }
        }
 private void buttonSaveSettings_Click(object sender, EventArgs e)
 {
     Properties.Settings.Default.Accumulations = (int)numericAccumulations.Value;
     Properties.Settings.Default.Temperature   = (int)numericTemp.Value;
     Properties.Settings.Default.Save();
     LogTextBox.AppendText("SETTINGS: saved\r\n");
 }
Example #17
0
        public void StartConnect(string password)
        {
            string ConnectionString = ReadFromFile();

            while (IsFileEmpty("inv.xml") == true)
            {
                //wait
            }

            if (ConnectionString != null)
            {
                try
                {
                    //pRdpViewer.OnAttendeeConnected += new _IRDPSessionEvents_OnAttendeeConnectedEventHandler(OnAttendeeConnected);
                    //pRdpViewer.OnAttendeeDisconnected += new _IRDPSessionEvents_OnAttendeeDisconnectedEventHandler(OnAttendeeDisconnected);
                    //pRdpViewer.OnAttendeeUpdate += new _IRDPSessionEvents_OnAttendeeUpdateEvent(OnAttendeeUpdate);
                    //pRdpViewer.Connect(ConnectionString, "Viewer1", "");
                    pRdpViewer.Connect(ConnectionString, Environment.MachineName, password);
                }
                catch (Exception ex)
                {
                    //LogTextBox.Text += ("Error in Connecting. Error Info: " + ex.ToString() + Environment.NewLine);
                    LogTextBox.AppendText("Error in Connecting. Error Info: " + ex.ToString() + Environment.NewLine);

                    LogTextBox.AppendText(ConnectionString + Environment.MachineName + password + Environment.NewLine);

                    NetManager propTest = new NetManager();
                    propTest.netShutdown();
                }
            }
        }
        private void AndorCCDTestApp_Load(object sender, EventArgs e)
        {
            // Initialize Window
            buttonAbort.Enabled = false;
            buttonPause.Enabled = false;
            buttonSave.Enabled  = false;

            LogTextBox.Text = "Initializing...\r\n";

            if (andor.numCameras == 1)
            {
                cameraConnected          = true;
                groupBoxReadMode.Enabled = cameraConnected;
                groupBoxSettings.Enabled = cameraConnected;
                groupBoxTemp.Enabled     = cameraConnected;
                LogTextBox.AppendText("ANDOR: Camera connected. \r\n");
                LogTextBox.AppendText("ANDOR: SN " + andor.Serial.ToString() + "\r\n");
                cameraConnected = true;
                InitWindow();
                LogTextBox.Text += "Ready.\r\n";
            }
            if (andor.numCameras == 0)
            {
                cameraConnected          = false;
                groupBoxReadMode.Enabled = cameraConnected;
                groupBoxSettings.Enabled = cameraConnected;
                groupBoxTemp.Enabled     = cameraConnected;
                LogTextBox.Text         += "ANDOR: NO camera connected. \r\n";
            }
        }
Example #19
0
        private void OnConnectionEstablished(object sender, EventArgs e)
        {
            //LogTextBox.Text += "Connection Established" + Environment.NewLine;
            LogTextBox.AppendText("Connection Established" + Environment.NewLine);

            //ControlButton is kinda glitchy
            ControlButton.Enabled = true;
            ConnectButton.Enabled = false;

            viewerWidth();

            //pRdpViewer.RequestControl(RDPCOMAPILib.CTRL_LEVEL.CTRL_LEVEL_VIEW);



            NetworkComms.AppendGlobalIncomingPacketHandler <string>("CtrlLvl", HandleIncomingCtrlLvlPacket);

            GetCtrlLvl();

            //pRdpViewer.RequestControl(RDPCOMAPILib.CTRL_LEVEL.CTRL_LEVEL_VIEW);

            //Thread.Sleep(10000);
            //pRdpViewer.Size = new Size(1280, 720);
            //Form2 newMDIChild = new Form2();
            // Set the Parent Form of the Child window.
            //newMDIChild.MdiParent = this;
            // Display the new form.
            //newMDIChild.Show();
        }
Example #20
0
        // ----------------------------------------------------------------------------------------------------------------------------
        // WRITE LINE TO LOG TEXTBOX - THREADSAFE
        //
        private void LogWriteTextBox(DateTime dateTime, string messageString, string fileName = null)
        {
            try
            {
                if (LogTextBox.InvokeRequired)
                {
                    EventClass.EventHandler d = new EventClass.EventHandler(LogWriteTextBox);
                    LogTextBox.Invoke(d, new object[] { dateTime, messageString, fileName });
                    return;
                }

                // CLEAR SOME LINES FROM THE TOP OF THE LOG
                if (LogTextBox.Text.Length > 30000)
                {
                    LogTextBox.Text = LogTextBox.Text.Substring(10000);
                }

                // ADD LINE AND SCROLL TO END
                LogTextBox.AppendText(messageString + "\r\n");

                if (bScroll)
                {
                    //LogTextBox.CaretIndex = LogTextBox.Text.Length;
                    //LogTextBox.ScrollToEnd();
                }
            }

            catch (Exception ex)
            {
                //LogWriteTextBox(DateTime.Now, DateTime.Now.ToString("0:MM/dd/yy hh:mm:ss.fff tt") + "     EXCEPTION: " + ex.Message);
                LogWriteFile(DateTime.Now, DateTime.Now.ToString("0:MM/dd/yy hh:mm:ss.fff tt") + "     EXCEPTION: " + ex.Message);
            }
        }
Example #21
0
 public void WrongMessage()
 {
     LogTextBox.Invoke(new Action(() => LogTextBox.AppendText("RECIEVER> Server has sent a bad message!\r\n")));
     TimeLeft.Invoke(new Action(() => TimeLeft.Text   = ""));
     SessionID.Invoke(new Action(() => SessionID.Text = ""));
     SetReadyToSend(false);
 }
Example #22
0
        private void ReadLog()
        {
            var newLogFile = Logging.LogFile;

            if (newLogFile != _currentLogFile)
            {
                _currentOffset      = 0;
                _currentLogFile     = newLogFile;
                _currentLogFileName = Logging.LogFileName;
            }

            try
            {
                if (!File.Exists(newLogFile))
                {
                    Title = $@"{this.GetWindowStringValue(@"Title")}";
                    return;
                }
                using var reader = new StreamReader(new FileStream(newLogFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
                if (_currentOffset == 0)
                {
                    var maxSize = reader.BaseStream.Length;
                    if (maxSize > MaxReadSize)
                    {
                        reader.BaseStream.Seek(-MaxReadSize, SeekOrigin.End);
                        reader.ReadLine();
                    }
                }
                else
                {
                    reader.BaseStream.Seek(_currentOffset, SeekOrigin.Begin);
                }

                var txt = reader.ReadToEnd();
                if (!string.IsNullOrEmpty(txt))
                {
                    LogTextBox.AppendText(txt);

                    if (LogTextBox.SelectionStart == 0 || LogTextBox.IsScrolledToEnd())
                    {
                        LogTextBox.ScrollToEnd();
                    }
                    else
                    {
                        LogTextBox.ScrollToLine(LogTextBox.GetLineIndexFromCharacterIndex(LogTextBox.SelectionStart));
                    }
                }

                _currentOffset = reader.BaseStream.Position;
            }
            catch (FileNotFoundException)
            {
            }
            catch (ArgumentNullException)
            {
            }

            Title = $@"{this.GetWindowStringValue(@"Title")} {_currentLogFileName}";
        }
        private async void buttonSetTemp_Click(object sender, EventArgs e)
        {
            OnTaskStarted(e);
            LogTextBox.AppendText("ANDOR: Temp set " + numericTemp.Value.ToString() + " deg\r\n");
            await UpdateTemperature();

            OnTaskFinished(e);
        }
 public void Log(string text)
 {
     Dispatcher.Invoke(() =>
     {
         LogTextBox.AppendText(DateTime.Now + " :: " + text + "\n");
         LogTextBox.ScrollToEnd();
     });
 }
Example #25
0
 public void WriteToOutput(string message)
 {
     Dispatcher.Invoke(() =>
     {
         LogTextBox.AppendText(message + "\n");
         LogTextBox.ScrollToEnd();
     });
 }
Example #26
0
 private void Write(string text, Color color)
 {
     LogTextBox.Focus();
     LogTextBox.SelectionLength = 0;
     LogTextBox.SelectionColor  = color;
     LogTextBox.AppendText(text + "\n");
     LogTextBox.Refresh();
 }
Example #27
0
        private void RestoreLogs()
        {
            foreach (var log in LogList)
            {
                LogTextBox.AppendText(log + Environment.NewLine);
            }

            LogTextBox.ScrollToEnd();
        }
Example #28
0
        void OnAttendeeDisconnected(object pDisconnectInfo)
        {
            IRDPSRAPIAttendeeDisconnectInfo pDiscInfo = pDisconnectInfo as IRDPSRAPIAttendeeDisconnectInfo;

            textBox2.AppendText(Environment.NewLine);
            textBox1.AppendText(Environment.NewLine + "Disconnected");
            //LogTextBox.Text += ("Attendee Disconnected: " + pDiscInfo.Attendee.RemoteName + Environment.NewLine);
            LogTextBox.AppendText("Attendee Disconnected: " + pDiscInfo.Attendee.RemoteName + Environment.NewLine);
        }
Example #29
0
        private void MessagePump_Tick(object sender, EventArgs e)
        {
            string message;

            while ((message = LogQueue.Get()) != null)
            {
                LogTextBox.AppendText(message + Environment.NewLine);
            }
        }
Example #30
0
        private void Metrics_Form_Load(object sender, EventArgs e)
        {
            IList <string> logs = Metrics.GetSessionLogs();

            foreach (string log in logs)
            {
                LogTextBox.AppendText(log + "\r\n");
            }
        }