Exemplo n.º 1
0
        /// <summary>
        /// 提示
        /// </summary>
        /// <param name="var">变量</param>
        /// <returns>结果</returns>
        public double ADDBARRAGE(CVariable var)
        {
            String text = "";
            int    len  = var.m_parameters.Length;

            for (int i = 0; i < len; i++)
            {
                text += m_indicator.getText(var.m_parameters[i]);
            }
            BarrageDiv barrageDiv = (m_xml as MainFrame).findControl("divBarrage") as BarrageDiv;
            Barrage    barrage    = new Barrage();

            barrage.Text = text;
            barrage.Mode = 0;
            barrageDiv.addBarrage(barrage);
            return(1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintBackground(FCPaint paint, FCRect clipRect)
        {
            base.onPaintBackground(paint, clipRect);
            int width = Width, height = Height;

            lock (m_barrages) {
                int barragesSize = m_barrages.Count;
                for (int i = 0; i < barragesSize; i++)
                {
                    Barrage brg  = m_barrages[i];
                    FCFont  font = brg.Font;
                    FCRect  rect = brg.Rect;
                    String  str  = brg.Text;
                    FCSize  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;
                        FCColor.toArgb(null, color, ref a, ref r, ref g, ref b);
                        a     = a * brg.Tick / 400;
                        color = FCColor.argb(a, r, g, b);
                    }
                    paint.drawText(str, color, font, rect);
                }
            }
            if (m_progress > 0)
            {
                int    tWidth    = 500;
                int    tHeight   = 60;
                int    showWidth = m_progress * 500 / 100;
                FCRect pRect     = new FCRect((width - tWidth) / 2, (height - tHeight) / 2, (width + tWidth) / 2, (height + tHeight) / 2);
                paint.fillRect(FCColor.argb(255, 0, 0), pRect);
                FCRect pRect2 = new FCRect((width - tWidth) / 2, (height - tHeight) / 2, (width - tWidth) / 2 + showWidth, (height + tHeight) / 2);
                paint.fillRect(FCColor.argb(255, 255, 0), pRect2);
                paint.drawRect(FCColor.argb(255, 255, 255), 1, 0, pRect);
                FCFont pFont = new FCFont("微软雅黑", 20, true, false, false);
                FCSize pSize = paint.textSize(m_progressText, pFont);
                FCDraw.drawText(paint, m_progressText, FCColor.argb(0, 0, 0), pFont, (width - pSize.cx) / 2, (height - pSize.cy) / 2);
            }
        }
Exemplo n.º 3
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 FCRect(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 FCRect(left, top, left, 0);
            }
            lock (m_barrages)
            {
                m_barrages.Add(barrage);
            }
            m_tick++;
        }
Exemplo n.º 4
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 (m_mainFrame != null)
             {
                 m_mainFrame.onTimer();
             }
         }
         if (paint)
         {
             invalidate();
         }
     }
 }