private void libInit(initCompleteHandler initCompleted) { //FormattedText ft = new FormattedText("OhMyDanmaku", CultureInfo.GetCultureInfo("zh-cn"), FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), danmaku_FontSize, Brushes.Black); // Create a test danmaku to calculate row OutlinedTextBlock _testDanmaku = new OutlinedTextBlock(); _testDanmaku.Text = "OhMyDanmaku"; _testDanmaku.FontFamily = (FontFamily) new FontFamilyConverter().ConvertFromString("Microsoft YaHei"); _testDanmaku.Name = "uni_testheight"; _testDanmaku.FontSize = danmaku_FontSize; _testDanmaku.FontWeight = FontWeights.Bold; _testDanmaku.Loaded += delegate(object o, RoutedEventArgs e) { calcRow(system_RenderCanvas.Height, _testDanmaku.Name, _testDanmaku.ActualHeight); if (system_enableAPCS) { preventCoverInit(initCompleted); } else { initCompleted(); } }; system_RenderCanvas.Children.Add(_testDanmaku); system_RenderCanvas.RegisterName(_testDanmaku.Name, _testDanmaku); }
//2.[初始化part-3]-通过向canvas中添加一个FontSize大小的弹幕来获取在canvas中显示时的真是尺寸 private void libInit(initCompleteHandler initCompleted) { BarrageUIBlock _testBarrage = new BarrageUIBlock(); _testBarrage.Text = "Hello,World!"; _testBarrage.FontFamily = (FontFamily) new FontFamilyConverter().ConvertFromString("Microsoft YaHei"); _testBarrage.Name = "uni_testforheight"; _testBarrage.FontSize = barrage_FontSize; _testBarrage.FontWeight = FontWeights.Bold; _testBarrage.Loaded += delegate(object sender, RoutedEventArgs e) { calcRow(system_RenderCanvas.Height, _testBarrage.Name, _testBarrage.ActualHeight); if (system_enableAPCS) { preventBarrageCover(initCompleted); } else { initCompleted(); } }; system_RenderCanvas.Children.Add(_testBarrage); system_RenderCanvas.RegisterName(_testBarrage.Name, _testBarrage); }
/// <summary> /// wpfDanmakulib initialization Entry point /// </summary> /// <param name="wpfCanvas">A WPF Canvas for containing danmakus</param> /// <param name="random">Use your own random seed or leave it null</param> /// <param name="final">Call a method when wpfDanmakulib initialization completed or leave it null</param> /// <param name="Duration">Danmaku stay duration (ms)</param> /// <param name="FontSize">Danmaku font size</param> /// <param name="Shadow">Danmaku Shadow Effect visibility</param> /// <param name="ColorR">Danmaku color red value (0-255)</param> /// <param name="ColorG">Danmaku color green value (0-255)</param> /// <param name="ColorB">Danmaku color blue value (0-255)</param> /// <param name="enableAPCS">APCS(Auto Prevent Cover System) is used for maintaining a row slot status list for solving danmaku occlusion issue. Disable APCS can save few system resource.</param> public wpfDanmakulib(Canvas wpfCanvas, Random random = null, bool enableAPCS = true, initCompleteHandler final = null, int Duration = 9000, int FontSize = 30, bool Shadow = true, byte ColorR = 255, byte ColorG = 255, byte ColorB = 255) { system_RenderCanvas = wpfCanvas; if (random != null) { ra = random; } else { ra = new Random(); } system_enableAPCS = enableAPCS; danmaku_Duration = Duration; danmaku_FontSize = FontSize; danmaku_EnableShadow = Shadow; danmaku_colorR = ColorR; danmaku_colorG = ColorG; danmaku_colorB = ColorB; libInit(final); }
private ArrayList idleRows; //空闲的行号 #endregion #region 逻辑处理函数-构造函数流程 //1.[初始化part-1、part-2]-构造函数 public wpfBarragelib(Canvas canvas, Random random = null, bool enableAPCS = true, initCompleteHandler final = null, int Duration = 10000, int FontSize = 40, bool Shadow = true, byte ColorR = 255, byte ColorG = 255, byte ColorB = 255) { system_RenderCanvas = canvas; if (random == null) { ra = new Random(); } else { ra = random; } system_enableAPCS = enableAPCS; barrage_Duration = Duration; barrage_FontSize = FontSize; barrage_EnableShadow = Shadow; barrage_colorR = ColorR; barrage_colorG = ColorG; barrage_colorB = ColorB; libInit(final); }
//4.避免弹幕在canvas中重叠机制 private void preventBarrageCover(initCompleteHandler initCompleted) { _rowList = new bool[_maxRow]; idleRows = new ArrayList(); initCompleted(); }
/// <summary> /// wpfDanmakulib initialization Entry point /// </summary> /// <param name="wpfCanvas">A WPF Canvas for containing danmakus</param> /// <param name="random">Use your own random seed or leave it null</param> /// <param name="final">Call a method when wpfDanmakulib initialization completed or leave it null</param> /// <param name="Duration">Danmaku stay duration (ms)</param> /// <param name="FontSize">Danmaku font size</param> /// <param name="Shadow">Danmaku Shadow Effect visibility</param> /// <param name="ColorR">Danmaku color red value (0-255)</param> /// <param name="ColorG">Danmaku color green value (0-255)</param> /// <param name="ColorB">Danmaku color blue value (0-255)</param> /// <param name="enableAPCS">APCS(Auto Prevent Cover System) is used for maintaining a row slot status list for solving danmaku occlusion issue. Disable APCS can save few system resource.</param> public wpfDanmakulib(Canvas wpfCanvas, Random random = null, bool enableAPCS = true, initCompleteHandler final = null, int Duration = 9000, int FontSize = 30, bool Shadow = true, byte ColorR = 255, byte ColorG = 255, byte ColorB = 255) { system_RenderCanvas = wpfCanvas; if (random != null) { ra = random; } else { ra = new Random(); } system_enableAPCS = enableAPCS; danmaku_Duration = Duration; danmaku_FontSize = FontSize; danmaku_EnableShadow = Shadow; danmaku_colorR = ColorR; danmaku_colorG = ColorG; danmaku_colorB = ColorB; libInit(final); }
private void preventCoverInit(initCompleteHandler initCompleted) { _rowList = new bool[_maxRow]; //init a row list for recording row status idleRows = new ArrayList(); initCompleted(); }
private void preventCoverInit(initCompleteHandler initCompleted) { _rowList = new bool[_maxRow]; //init a row list for recording row status idleRows = new ArrayList(); initCompleted(); }
private void libInit(initCompleteHandler initCompleted) { //FormattedText ft = new FormattedText("OhMyDanmaku", CultureInfo.GetCultureInfo("zh-cn"), FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), danmaku_FontSize, Brushes.Black); // Create a test danmaku to calculate row OutlinedTextBlock _testDanmaku = new OutlinedTextBlock(); _testDanmaku.Text = "OhMyDanmaku"; _testDanmaku.FontFamily = (FontFamily)new FontFamilyConverter().ConvertFromString("Microsoft YaHei"); _testDanmaku.Name = "uni_testheight"; _testDanmaku.FontSize = danmaku_FontSize; _testDanmaku.FontWeight = FontWeights.Bold; _testDanmaku.Loaded += delegate(object o, RoutedEventArgs e) { calcRow(system_RenderCanvas.Height, _testDanmaku.Name, _testDanmaku.ActualHeight); if (system_enableAPCS) { preventCoverInit(initCompleted); } else { initCompleted(); } }; system_RenderCanvas.Children.Add(_testDanmaku); system_RenderCanvas.RegisterName(_testDanmaku.Name, _testDanmaku); }