Example #1
0
 private void InfoListUpdate()
 {
     if (AppContext.PublishInfos.Count > 0)
     {
         PublishInfo[] infos = new PublishInfo[AppContext.PublishInfos.Count];
         AppContext.PublishInfos.CopyTo(infos);
         Array.Sort(infos);
         lock (AppConst.InfoListLocker)
         {
             infoListView.Items.Clear();
             foreach (PublishInfo info in infos)
             {
                 if (AppSetting.SYMBOLS.Contains(info.Symbol))
                 {
                     ListViewItem item = new ListViewItem(
                         new string[] { info.DateTime.ToString(), info.Type.ToString(), info.Content.ToString() }, 0);
                     infoListView.Items.Add(item);
                 }
             }
         }
     }
     else
     {
         infoListView.Items.Clear();
     }
 }
        public void AppendMsg(object obj)
        {
            PublishInfo   info = (PublishInfo)obj;
            StringBuilder sb   = new StringBuilder();
            string        msg  = info.Content;

            sb.Append(info.DateTime.ToShortDateString());
            sb.Append(SPACE);
            sb.Append(info.DateTime.ToLongTimeString());
            sb.Append(SPACE);
            sb.Append(info.Type);
            sb.Append(Environment.NewLine);
            sb.Append(AppUtil.GetSymbolChinese(info.Symbol.ToString()));
            sb.Append(SPACE);
            sb.Append(msg);
            if (!msg.EndsWith(EN_DOT) && !msg.EndsWith(CN_DOT))
            {
                sb.Append(CN_DOT);
            }
            sb.Append(Environment.NewLine);
            sb.Append(Environment.NewLine);
            Font fBold = new Font("Arial", 10, FontStyle.Regular);

            lock (richTextBoxInfo)
            {
                if (richTextBoxInfo.Lines.Length > MAX)
                {
                    richTextBoxInfo.Text = richTextBoxInfo.Text.Substring(richTextBoxInfo.Text.IndexOf(richTextBoxInfo.Lines[OFFSET]));
                    lastColor            = Color.DarkBlue;
                }
                richTextBoxInfo.Enabled = false;

                richTextBoxInfo.SelectionStart = richTextBoxInfo.Text.Length;
                richTextBoxInfo.SelectionFont  = fBold;
                if (lastColor == Color.Red)
                {
                    richTextBoxInfo.SelectionColor = Color.DarkBlue;
                    lastColor = Color.DarkBlue;
                }
                else
                {
                    richTextBoxInfo.SelectionColor = Color.Red;
                    lastColor = Color.Red;
                }
                richTextBoxInfo.SelectedText = sb.ToString();
                richTextBoxInfo.Enabled      = true;
            }
            Opacity = 100;
            Visible = true;
            Show();
        }
 private void InfoListUpdate()
 {
     if (AppContext.PublishInfos.Count > 0)
     {
         PublishInfo[] infos = new PublishInfo[AppContext.PublishInfos.Count];
         AppContext.PublishInfos.CopyTo(infos);
         Array.Sort(infos);
         lock (AppConst.InfoListLocker)
         {
             infoListView.Items.Clear();
             foreach (PublishInfo info in infos)
             {
                 if (AppSetting.SYMBOLS.Contains(info.Symbol))
                 {
                     ListViewItem item = new ListViewItem(
                       new string[] { info.DateTime.ToString(), info.Type.ToString(), info.Content.ToString() }, 0);
                     infoListView.Items.Add(item);
                 }
             }
         }
     }
     else
     {
         infoListView.Items.Clear();
     }
 }