public BarrageRenderer(Configurations conf)
 {
     stringFormat = new StringFormat();
     stringFormat.Alignment = StringAlignment.Center;
     stringFormat.LineAlignment = StringAlignment.Center;
     borderPen = new Pen(conf.GetRgbColor("Border-Color", Color.Black), conf.GetSingle("Border-Width", 2));
     borderPen.LineJoin = LineJoin.Round;
     borderPen.Alignment = PenAlignment.Outset;
     borderBrush = new SolidBrush(conf.GetRgbColor("Border-Color", Color.Black));
     fillBrush = new SolidBrush(conf.GetRgbColor("Fill-Color", Color.White));
     FontStyle fontStyle = FontStyle.Regular;
     if (conf.GetBoolean("Font-Bold", true))
         fontStyle |= FontStyle.Bold;
     if (conf.GetBoolean("Font-Italic", false))
         fontStyle |= FontStyle.Italic;
     Font = new Font(conf.GetString("Font-Family", "黑体"),
         conf.GetSingle("Font-Size", 30), fontStyle, GraphicsUnit.Pixel);
     HorizontalMargin = conf.GetInt("Horizontal-Margin", 5);
     BarrageHeight = conf.GetInt("Height", 40);
     BlurRadius = conf.GetInt("Blur-Radius", 2);
     Transparency = conf.GetSingle("Transparency", 1.0f);
     ShadowX = conf.GetInt("Shadow-XOffset", 1);
     ShadowY = conf.GetInt("Shadow-YOffset", 1);
 }
        public SubtitleManager(BarrageWindow parent, Rectangle rect, Configurations subtitleConf)
        {
            FontStyle fontStyle = FontStyle.Regular;
            if (subtitleConf.GetBoolean("Font-Bold", true))
                fontStyle |= FontStyle.Bold;
            if (subtitleConf.GetBoolean("Font-Italic", false))
                fontStyle |= FontStyle.Italic;
            Font = new Font(subtitleConf.GetString("Font-Family", "黑体"),
                subtitleConf.GetSingle("Font-Size", 30), fontStyle, GraphicsUnit.Pixel);
            Padding = subtitleConf.GetInt("Padding", 10);
            FillColor = subtitleConf.GetRgbColor("Fill-Color", Color.White);
            BorderColor = subtitleConf.GetRgbColor("Border-Color", Color.Black);
            BorderWidth = subtitleConf.GetSingle("Border-Width", 1.0f);

            current = -1;
            groups = new List<SubtitleGroup>();
            int n;
            var lycFiles = from pair in subtitleConf
                           where pair.Key.StartsWith("Lyc-File")
                            && Int32.TryParse(pair.Key.Substring("Lyc-File".Length), out n)
                           select new { Index = Int32.Parse(pair.Key.Substring("Lyc-File".Length)) - 1,
                               FileName = pair.Value };
            foreach (var lycFile in lycFiles.OrderBy(l => l.Index))
            {
                try
                {
                    groups.Add(new SubtitleGroup(this, new LyricFile(lycFile.FileName)));
                    Core.Debugger.Log("lyc loaded: " + lycFile.FileName);
                }
                catch (Exception exc)
                {
                    Core.Debugger.Log("lyc file load failed: " + lycFile.FileName + " (" + exc.Message + ")");
                }
            }
            if (groups.Count >= 0)
                current = 0;

            stopwatch = new Stopwatch();
            this.Rect = Rectangle.FromLTRB(rect.Left + Padding, rect.Top + Padding,
                rect.Right - Padding, rect.Bottom - Padding);

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("Start-Key", Keys.Control | Keys.Alt | Keys.D1),
                k =>
                {
                    if (StartSubtitle())
                        parent.ShowNotice("字幕开始");
                    return true;
                }
            );

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("End-Key", Keys.Control | Keys.Alt | Keys.D2),
                k =>
                {
                    if (StopSubtitle())
                        parent.ShowNotice("字幕停止");
                    return true;
                }
            );

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("Prev-Key", Keys.Control | Keys.Alt | Keys.PageUp),
                k =>
                {
                    PrevSubtitle();
                    return true;
                }
            );

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("Next-Key", Keys.Control | Keys.Alt | Keys.PageDown),
                k =>
                {
                    NextSubtitle();
                    return true;
                }
            );

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("Prev-Lrc", Keys.Control | Keys.Alt | Keys.D3),
                k =>
                {
                    if (PrevGroup())
                        parent.ShowNotice("字幕:" + CurrentGroup.Title);
                    return true;
                }
            );

            GlobalKeyHook.Instance.SetProcessor(
                subtitleConf.GetKeys("Next-Lrc", Keys.Control | Keys.Alt | Keys.D4),
                k =>
                {
                    if (NextGroup())
                        parent.ShowNotice("字幕:" + CurrentGroup.Title);
                    return true;
                }
            );
        }