Beispiel #1
0
        private void DGV_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            try{
                if (DGV.InvokeRequired)
                {
                    DGV.Invoke(new On_DataPaintdDelegate(DGV_RowPrePaint), sender, e);
                    return;
                }

                if (DGV.Rows[e.RowIndex].Cells["Buy_SellIndicator"].Value.ToString() == "BUY")
                {
                    //  DGV.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
                    DGV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Blue;
                }
                else
                {
                    //  DGV.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Blue;
                    DGV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Trade Book -  Funtion Name-  toolStripButton1_Click  " + ex.Message);
            }
        }
        private void OnReceive(IAsyncResult asyncResult)
        {
            if (started == true)
            {
                uint readlength = BitConverter.ToUInt16(Byteswap(bytedata, 2), 0);
                sourceport      = BitConverter.ToUInt16(Byteswap(bytedata, 22), 0);
                destinationport = BitConverter.ToUInt16(Byteswap(bytedata, 24), 0);

                if (bytedata[9] == 6)
                {
                    typez = "TCP";
                }
                else if (bytedata[9] == 17)
                {
                    typez = "UDP";
                }
                else
                {
                    typez = "???";
                }

                ipfrom = new IPAddress(BitConverter.ToUInt32(bytedata, 12));
                ipto   = new IPAddress(BitConverter.ToUInt32(bytedata, 16));

                if (ipfrom.Equals(myip) == true || ipto.Equals(myip) == true)
                {
                    if (FilterIP == false || (FilterIP == true && (FilterIPAddress.Equals(ipfrom) || FilterIPAddress.Equals(ipto))))
                    {
                        stringz = "";
                        for (uint i = 26; i < readlength; i++)
                        {
                            if (Char.IsLetterOrDigit(Convert.ToChar(bytedata[i])) == true)
                            {
                                stringz = stringz + Convert.ToChar(bytedata[i]);
                            }
                            else
                            {
                                stringz = stringz + "";
                            }
                        }
                        DGV.Invoke(new MethodInvoker(DGVUpdate));
                    }
                }
            }

            socketz.BeginReceive(bytedata, 0, bytedata.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
        }
 private void DGV_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
 {
     try
     {
         DGV.PerformLayout();
         if (DGV.InvokeRequired)
         {
             DGV.Invoke(new On_DataPaintdDelegate(DGV_RowPrePaint), sender, e);
             return;
         }
         if (Convert.ToString(DGV.Rows[e.RowIndex].Cells["Symbol"].Value) == "Total")
         {
             //  DGV.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
             DGV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #4
0
        /// <summary>
        /// Обработка и проверка на интервал
        /// </summary>
        /// <param name="table"></param>
        private async void SqlWorker_EventTableHandler(DataTable table)
        {
            DateTime curRow, nextRow;

            for (int i = 0; i < table.Rows.Count - 1; i++)
            {
                curRow  = (DateTime)table.Rows[i][3];
                nextRow = (DateTime)table.Rows[i + 1][3];

                var q = nextRow - curRow;

                if (q > interval)
                {
                    string[] arr = new string[]
                    {
                        table.Rows[i][0].ToString(),
                        table.Rows[i][1].ToString(),
                        table.Rows[i][2].ToString(),
                        table.Rows[i][3].ToString(),
                        nextRow.ToString("dd/MM/yyyy HH:mm:ss")
                    };
                    myTable.Rows.Add(arr);
                }
            }

            if (myTable.Rows.Count > 0)
            {
                try
                {
                    await Task.Run(new Action(() =>
                    {
                        DGV.Invoke(actUpdTable, myTable);
                    }), _token);
                }
                catch (TaskCanceledException)
                {
                }
            }
        }
Beispiel #5
0
 private void DGV_RowPrePaint_1(object sender, DataGridViewRowPrePaintEventArgs e)
 {
     try
     {
         DGV.PerformLayout();
         if (DGV.InvokeRequired)
         {
             DGV.Invoke(new On_DataPaintdDelegate(DGV_RowPrePaint_1), sender, e);
             return;
         }
         if (Convert.ToDouble(DGV.Rows[e.RowIndex].Cells["ACTUALPRICE"].Value) < 0)
         {
             //  DGV.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Red;
             DGV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Blue;
         }
         else
         {
             DGV.Rows[e.RowIndex].DefaultCellStyle.ForeColor = Color.Red;
         }
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #6
0
        private void OnReceive(IAsyncResult asyncresult)
        {
            try
            {
                lock (_syncObject)
                {
                    int  nReceived  = _mainSocket.EndReceive(asyncresult);
                    bool showPacket = false;

                    IpV4Header ipHeader = new IpV4Header(_recvData, nReceived);
                    // If this is a packet to / from me and not from myself then...
                    if ((ipHeader.SourceAddress.Equals(_selectedIP) == true |
                         ipHeader.DestinationAddress.Equals(_selectedIP) == true) &
                        ipHeader.DestinationAddress.Equals(ipHeader.SourceAddress) == false)
                    {
                        if (_performIPFilter == false |
                            (_performIPFilter == true & (_filterIP.Equals(ipHeader.SourceAddress) | _filterIP.Equals(ipHeader.DestinationAddress))))
                        {
                            //all
                            if (_selectedProtocol == 0 || _selectedProtocol == 3)
                            {
                                showPacket = true;
                            }
                            else if ((_selectedProtocol == 2 || _selectedProtocol == 5) && ipHeader.ProtocolType == Protocol.TCP) //TCP
                            {
                                showPacket = true;
                            }
                            else if ((_selectedProtocol == 1 || _selectedProtocol == 4) && ipHeader.ProtocolType == Protocol.UDP) //UDP
                            {
                                showPacket = true;
                            }
                        }
                    }
                    else
                    {
                        if (_performIPFilter == false | (_performIPFilter == true & (_filterIP.Equals(ipHeader.SourceAddress) | _filterIP.Equals(ipHeader.DestinationAddress))))
                        {
                            if (_selectedProtocol == 3)
                            {
                                showPacket = true;
                            }
                            else if (_selectedProtocol == 5 && ipHeader.ProtocolType == Protocol.TCP) //TCP
                            {
                                showPacket = true;
                            }
                            else if (_selectedProtocol == 4 && ipHeader.ProtocolType == Protocol.UDP) //UDP
                            {
                                showPacket = true;
                            }
                        }
                    }

                    if (showPacket)
                    {
                        var displayPacket = GetDisplayPacket(ipHeader);
                        DGV.Invoke(_dgvUpdateHandler, displayPacket);
                    }

                    if (_showPacketinGrid == true)
                    {
                        // Restart the Receiving
                        BeginReceive();
                    }
                }
            }
            catch (Exception)
            {
            }
        }