示例#1
0
 /// <summary>
 /// 重绘前景方法
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="clipRect">裁剪区域</param>
 public override void OnPaintBackground(CPaint paint, RECT clipRect)
 {
     base.OnPaintBackground(paint, clipRect);
     lock (m_barrages)
     {
         int barragesSize = m_barrages.Count;
         for (int i = 0; i < barragesSize; i++)
         {
             Barrage brg  = m_barrages[i];
             FONT    font = brg.Font;
             RECT    rect = brg.Rect;
             String  str  = brg.Text;
             SIZE    size = paint.TextSize(str, font);
             rect.right  = rect.left + size.cx;
             rect.bottom = rect.top + size.cy;
             brg.Rect    = rect;
             long color = brg.Color;
             int  mode  = brg.Mode;
             if (mode == 1)
             {
                 int a = 0, r = 0, g = 0, b = 0;
                 COLOR.ToARGB(null, color, ref a, ref r, ref g, ref b);
                 a     = a * brg.Tick / 400;
                 color = COLOR.ARGB(a, r, g, b);
             }
             paint.DrawText(str, color, font, rect);
         }
     }
 }
示例#2
0
 /// <summary>
 /// 秒表方法
 /// </summary>
 /// <param name="timerID">秒表ID</param>
 public override void OnTimer(int timerID)
 {
     base.OnTimer(timerID);
     if (m_timerID == timerID)
     {
         bool paint = false;
         lock (m_barrages)
         {
             int barragesSize = m_barrages.Count;
             if (barragesSize > 0)
             {
                 int width = Width, height = Height;
                 for (int i = 0; i < barragesSize; i++)
                 {
                     Barrage brg  = m_barrages[i];
                     int     mode = brg.Mode;
                     if (mode == 0)
                     {
                         if (brg.Rect.right < 0)
                         {
                             m_barrages.Remove(brg);
                             i--;
                             barragesSize--;
                         }
                         else
                         {
                             brg.Calculate();
                         }
                         paint = true;
                     }
                     else if (mode == 1)
                     {
                         int tick = brg.Tick;
                         tick--;
                         if (tick <= 0)
                         {
                             m_barrages.Remove(brg);
                             i--;
                             barragesSize--;
                         }
                         else
                         {
                             brg.Tick = tick;
                         }
                         if (tick % 20 == 0)
                         {
                             paint = true;
                         }
                     }
                 }
             }
         }
         if (paint)
         {
             Invalidate();
         }
     }
 }
示例#3
0
        /// <summary>
        /// 提示
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>结果</returns>
        public double Alert(CVariable var)
        {
            BarrageDiv barrageDiv = m_chart.BarrageDiv;
            Barrage    barrage    = new Barrage();

            barrage.Text = m_indicator.GetText(var.m_parameters[0]);
            barrage.Mode = 1;
            barrageDiv.AddBarrage(barrage);
            return(1);
        }
示例#4
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage        message = (CMessage)args;
            List <ChatData> datas   = new List <ChatData>();

            ChatService.GetChatDatas(datas, message.m_body, message.m_bodyLength);
            int    size     = datas.Count;
            String chatInfo = "";

            for (int i = 0; i < size; i++)
            {
                chatInfo = datas[i].m_text;
                Barrage brg = new Barrage();
                brg.Text = chatInfo;
                m_chart.BarrageDiv.AddBarrage(brg);
            }
            datas.Clear();
        }
示例#5
0
        /// <summary>
        /// 启动弹幕
        /// </summary>
        /// <param name="barrage">弹幕参数</param>
        public void AddBarrage(Barrage barrage)
        {
            barrage.Color = m_sysColors[m_tick % 6];
            int width = Width, height = Height;

            if (width < 100)
            {
                width = 100;
            }
            if (height < 100)
            {
                height = 100;
            }
            int mode = barrage.Mode;

            if (mode == 0)
            {
                barrage.Rect = new RECT(width, m_rd.Next(0, height), width, 0);
            }
            else
            {
                int left = 0, top = 0;
                if (width > 200)
                {
                    left = m_rd.Next(0, width - 200);
                }
                if (height > 200)
                {
                    top = m_rd.Next(0, height - 200);
                }
                barrage.Rect = new RECT(left, top, left, 0);
            }
            lock (m_barrages)
            {
                m_barrages.Add(barrage);
            }
            m_tick++;
        }