private void ShootDanMu(string text, OutlinedDanMu danmu, int entrynum, int speed)
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
     {
         dmp.Shoot(text, danmu, entrynum, speed);
     }));
 }
        /// <summary>
        /// 显示弹幕
        /// </summary>
        /// <param name="text"></param>
        private void ShowDanMu(string text)
        {
            int entryNum = Int32.Parse(EntryNumSlider.Value.ToString().Trim());
            int speed    = Int32.Parse(SpeedSlider.Value.ToString().Trim());

            OutlinedDanMu DanMu = new OutlinedDanMu(text);

            DanMu.FontSize   = Int32.Parse(FontSizeBox.Text.Trim());
            DanMu.FontFamily = new FontFamily(FontStyleBox.Text.Trim());

            Random RandomNum_First = new Random((int)DateTime.Now.Ticks);

            System.Threading.Thread.Sleep(RandomNum_First.Next(50));
            Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);

            if (CustomColorBtn.IsChecked == true && ColorPickerBox.Text != "")
            {
                string color = ColorPickerBox.Text.Trim();

                color      = color.Substring(color.LastIndexOf(" "));
                DanMu.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
            }
            else
            {
                //随机颜色
                int int_Red   = RandomNum_First.Next(256);
                int int_Green = RandomNum_Sencond.Next(256);
                int int_Blue  = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
                int_Blue   = (int_Blue > 255) ? 255 : int_Blue;
                DanMu.Fill = new SolidColorBrush(Color.FromRgb((byte)int_Red, (byte)int_Green, (byte)int_Blue));
            }

            ShootDanMu(text, DanMu, entryNum, speed);
        }
Exemple #3
0
        public void Shoot(string text, OutlinedDanMu danmu, int entrynum, int speed)
        {
            if (dm == null)
            {
                dm = new DanMuManager(DanMuGrid, enableShadowEffect);
            }

            dm.Shoot(text, danmu, entrynum, speed);
        }