public void StartBarrager() { started = true; int exStyle = ApiHelper.GetWindowLong(Handle, ApiHelper.GWL_EXSTYLE); ApiHelper.SetWindowLong(Handle, ApiHelper.GWL_EXSTYLE, exStyle | ApiHelper.WS_EX_TRANSPARENT); // 隐藏弹幕快捷键。 GlobalKeyHook.Instance.SetProcessor(hideKey, k => { barrageManager.Visible = !barrageManager.Visible; ShowNotice(barrageManager.Visible ? "弹幕显示" : "弹幕隐藏"); return true; }); // 实例化弹幕源。 inputs = new List<CommentInput>(); foreach (KeyValuePair<string, string> keyValue in confs["Input"]) { try { Assembly assembly = Assembly.LoadFrom(keyValue.Value); foreach (Type type in assembly.GetTypes()) { if (type.Name.Equals(keyValue.Key)) { CommentInput input = (CommentInput)Activator.CreateInstance(type); input.Initialize(confs[keyValue.Key]); input.Comment += (sender, ce) => barrageManager.AddBarrage(ce.Comment); Debugger.Log("弹幕源: " + input.GetType().FullName); inputs.Add(input); } } } catch (Exception exc) { Debugger.Exception(exc); } } barrageManager = new BarrageManager(this, ClientSize, confs["Appearance"], confs["Action"]); subtitleManager = new SubtitleManager(this, ClientRectangle, confs["Subtitle"]); stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); frameTimer = new Timer(); frameTimer.Interval = 30; frameTimer.Tick += new EventHandler(frameTimer_Tick); frameTimer.Start(); }
/// <summary> /// 初始化BarrageLine类的新实例。 /// </summary> /// <param name="parent">管理此BarrageLine的BarrageManager。</param> public BarrageLine(BarrageManager parent) { this.parent = parent; queue = new Queue<Barrage>(); }