/// <summary>
        /// テロップ追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void TelopAddButton_Click(object sender, EventArgs e)
        {
            var nr = new OnePointTelop();

            nr.ID = OnePointTelopTable.Default.Table.Any() ?
                OnePointTelopTable.Default.Table.Max(x => x.ID) + 1 :
                1;
            nr.guid = Guid.NewGuid();
            nr.Title = Translate.Get("NewTelop");
            nr.DisplayTime = 3;
            nr.FontColor = Settings.Default.FontColor.ToHTML();
            nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
            nr.FontFamily = Settings.Default.Font.Name;
            nr.FontSize = Settings.Default.Font.Size;
            nr.FontStyle = (int)Settings.Default.Font.Style;
            nr.BackgroundColor = Settings.Default.BackgroundColor.ToHTML();
            nr.Left = 10.0d;
            nr.Top = 10.0d;
            nr.JobFilter = string.Empty;
            nr.ZoneFilter = string.Empty;
            nr.TimersMustRunningForStart = new Guid[0];
            nr.TimersMustStoppingForStart = new Guid[0];

            // 現在選択しているノードの情報を一部コピーする
            if (this.TelopTreeView.SelectedNode != null)
            {
                var baseRow = this.TelopTreeView.SelectedNode.Tag != null ?
                    this.TelopTreeView.SelectedNode.Tag as OnePointTelop :
                    this.TelopTreeView.SelectedNode.Nodes[0].Tag as OnePointTelop;

                if (baseRow != null)
                {
                    nr.Title = baseRow.Title + " New";
                    nr.Message = baseRow.Message;
                    nr.Keyword = baseRow.Keyword;
                    nr.KeywordToHide = baseRow.KeywordToHide;
                    nr.RegexEnabled = baseRow.RegexEnabled;
                    nr.Delay = baseRow.Delay;
                    nr.DisplayTime = baseRow.DisplayTime;
                    nr.AddMessageEnabled = baseRow.AddMessageEnabled;
                    nr.ProgressBarEnabled = baseRow.ProgressBarEnabled;
                    nr.FontColor = baseRow.FontColor;
                    nr.FontOutlineColor = baseRow.FontOutlineColor;
                    nr.FontFamily = baseRow.FontFamily;
                    nr.FontSize = baseRow.FontSize;
                    nr.FontStyle = baseRow.FontStyle;
                    nr.Font = baseRow.Font;
                    nr.BackgroundColor = baseRow.BackgroundColor;
                    nr.BackgroundAlpha = baseRow.BackgroundAlpha;
                    nr.Left = baseRow.Left;
                    nr.Top = baseRow.Top;
                    nr.JobFilter = baseRow.JobFilter;
                    nr.ZoneFilter = baseRow.ZoneFilter;
                    nr.TimersMustRunningForStart = baseRow.TimersMustRunningForStart;
                    nr.TimersMustStoppingForStart = baseRow.TimersMustStoppingForStart;
                }
            }

            nr.MatchDateTime = DateTime.MinValue;
            nr.Enabled = true;
            nr.Regex = null;
            nr.RegexPattern = string.Empty;
            nr.RegexToHide = null;
            nr.RegexPatternToHide = string.Empty;

            OnePointTelopTable.Default.Table.Add(nr);

            OnePointTelopTable.Default.ClearReplacedKeywords();
            OnePointTelopTable.Default.Save();

            // 新しいノードを生成する
            var node = new TreeNode(nr.Title)
            {
                Tag = nr,
                ToolTipText = nr.Message,
                Checked = nr.Enabled
            };

            this.TelopTreeView.Nodes.Add(node);
            this.TelopTreeView.SelectedNode = node;

            // ジョブ限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectJobButton.ForeColor = nr.JobFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // ゾーン限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectZoneButton.ForeColor = nr.ZoneFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSetConditionButton.ForeColor =
                (nr.TimersMustRunningForStart.Length != 0 || nr.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;

            // 標準のスペルタイマーへ変更を反映する
            SpellTimerCore.Default.applyToNormalSpellTimer();
        }
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource"></param>
        private void ShowTelopDetail(
            OnePointTelop dataSource)
        {
            var src = dataSource;
            if (src == null)
            {
                this.TelopDetailGroupBox.Visible = false;
                return;
            }

            this.TelopDetailGroupBox.Visible = true;

            this.TelopTitleTextBox.Text = src.Title;
            this.TelopMessageTextBox.Text = src.Message;
            this.TelopKeywordTextBox.Text = src.Keyword;
            this.TelopKeywordToHideTextBox.Text = src.KeywordToHide;
            this.TelopRegexEnabledCheckBox.Checked = src.RegexEnabled;
            this.TelopDelayNumericUpDown.Value = src.Delay;
            this.DisplayTimeNumericUpDown.Value = src.DisplayTime;
            this.EnabledAddMessageCheckBox.Checked = src.AddMessageEnabled;
            this.TelopProgressBarEnabledCheckBox.Checked = src.ProgressBarEnabled;

            this.TelopVisualSetting.FontColor = src.FontColor.FromHTML();
            this.TelopVisualSetting.FontOutlineColor = src.FontOutlineColor.FromHTML();
            this.TelopVisualSetting.FontColor = src.FontColor.FromHTML();
            this.TelopVisualSetting.SetFontInfo(src.Font);
            this.TelopVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                Settings.Default.BackgroundColor :
                Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.TelopVisualSetting.RefreshSampleImage();

            var left = (int)src.Left;
            var top = (int)src.Top;

            double x, y;
            OnePointTelopController.GettLocation(
                src.ID,
                out x,
                out y);

            if (x != 0)
            {
                left = (int)x;
            }

            if (y != 0)
            {
                top = (int)y;
            }

            this.TelopLeftNumericUpDown.Value = left;
            this.TelopLeftNumericUpDown.Tag = left;
            this.TelopTopNumericUpDown.Value = top;
            this.TelopTopNumericUpDown.Tag = top;

            this.TelopMatchSoundComboBox.SelectedValue = src.MatchSound;
            this.TelopMatchTTSTextBox.Text = src.MatchTextToSpeak;

            this.TelopDelaySoundComboBox.SelectedValue = src.DelaySound;
            this.TelopDelayTTSTextBox.Text = src.DelayTextToSpeak;

            // データソースをタグに突っ込んでおく
            this.TelopDetailGroupBox.Tag = src;

            // ジョブ限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectJobButton.ForeColor = src.JobFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // ゾーン限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectZoneButton.ForeColor = src.ZoneFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSetConditionButton.ForeColor =
                (src.TimersMustRunningForStart.Length != 0 || src.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;
        }
        /// <summary>
        /// テロップ追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void TelopAddButton_Click(object sender, EventArgs e)
        {
            var nr = new OnePointTelop();

            this.EditTickersTableBlock(() =>
            {
                nr.ID = OnePointTelopTable.Default.Table.Any() ?
                        OnePointTelopTable.Default.Table.Max(x => x.ID) + 1 :
                        1;
                nr.guid             = Guid.NewGuid();
                nr.Title            = Translate.Get("NewTelop");
                nr.DisplayTime      = 3;
                nr.FontColor        = Settings.Default.FontColor.ToHTML();
                nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
                nr.FontFamily       = Settings.Default.Font.Name;
                nr.FontSize         = Settings.Default.Font.Size;
                nr.FontStyle        = (int)Settings.Default.Font.Style;
                nr.BackgroundColor  = Settings.Default.BackgroundColor.ToHTML();
                nr.Left             = 10.0d;
                nr.Top        = 10.0d;
                nr.JobFilter  = string.Empty;
                nr.ZoneFilter = string.Empty;
                nr.TimersMustRunningForStart  = new Guid[0];
                nr.TimersMustStoppingForStart = new Guid[0];

                // 現在選択しているノードの情報を一部コピーする
                if (this.TelopTreeView.SelectedNode != null)
                {
                    var baseRow = this.TelopTreeView.SelectedNode.Tag != null ?
                                  this.TelopTreeView.SelectedNode.Tag as OnePointTelop :
                                  this.TelopTreeView.SelectedNode.Nodes[0].Tag as OnePointTelop;

                    if (baseRow != null)
                    {
                        nr.Title              = baseRow.Title + " New";
                        nr.Message            = baseRow.Message;
                        nr.Keyword            = baseRow.Keyword;
                        nr.KeywordToHide      = baseRow.KeywordToHide;
                        nr.RegexEnabled       = baseRow.RegexEnabled;
                        nr.Delay              = baseRow.Delay;
                        nr.DisplayTime        = baseRow.DisplayTime;
                        nr.AddMessageEnabled  = baseRow.AddMessageEnabled;
                        nr.ProgressBarEnabled = baseRow.ProgressBarEnabled;
                        nr.FontColor          = baseRow.FontColor;
                        nr.FontOutlineColor   = baseRow.FontOutlineColor;
                        nr.FontFamily         = baseRow.FontFamily;
                        nr.FontSize           = baseRow.FontSize;
                        nr.FontStyle          = baseRow.FontStyle;
                        nr.Font                       = baseRow.Font;
                        nr.BackgroundColor            = baseRow.BackgroundColor;
                        nr.BackgroundAlpha            = baseRow.BackgroundAlpha;
                        nr.Left                       = baseRow.Left;
                        nr.Top                        = baseRow.Top;
                        nr.JobFilter                  = baseRow.JobFilter;
                        nr.ZoneFilter                 = baseRow.ZoneFilter;
                        nr.TimersMustRunningForStart  = baseRow.TimersMustRunningForStart;
                        nr.TimersMustStoppingForStart = baseRow.TimersMustStoppingForStart;
                    }
                }

                nr.MatchDateTime      = DateTime.MinValue;
                nr.Enabled            = true;
                nr.Regex              = null;
                nr.RegexPattern       = string.Empty;
                nr.RegexToHide        = null;
                nr.RegexPatternToHide = string.Empty;

                OnePointTelopTable.Default.Table.Add(nr);

                OnePointTelopTable.Default.ClearReplacedKeywords();
                OnePointTelopTable.Default.Save();
            });

            // 新しいノードを生成する
            var node = new TreeNode(nr.Title)
            {
                Tag         = nr,
                ToolTipText = nr.Message,
                Checked     = nr.Enabled
            };

            this.TelopTreeView.Nodes.Add(node);
            this.TelopTreeView.SelectedNode = node;

            // ジョブ限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectJobButton.ForeColor = nr.JobFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // ゾーン限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectZoneButton.ForeColor = nr.ZoneFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSetConditionButton.ForeColor =
                (nr.TimersMustRunningForStart.Length != 0 || nr.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;

            // 標準のスペルタイマーへ変更を反映する
            SpellTimerCore.Default.ApplyToNormalSpellTimer();
        }
        /// <summary>
        /// ACT標準のスペルタイマーの設定を追加・更新する(テロップ用)
        /// </summary>
        /// <param name="spellTimer">元になるテロップ</param>
        /// <param name="forceHide">強制非表示か?</param>
        public void updateNormalSpellTimerForTelop(OnePointTelop telop, bool forceHide)
        {
            if (!Settings.Default.EnabledNotifyNormalSpellTimer)
            {
                return;
            }

            var prefix = Settings.Default.NotifyNormalSpellTimerPrefix;
            var spellName = prefix + "telop_" + telop.Title;
            var categoryName = prefix + "telops";

            var timerData = new TimerData(spellName, categoryName);
            timerData.TimerValue = forceHide ? 1 : (int)(telop.DisplayTime + telop.Delay);
            timerData.RemoveValue = forceHide ? -timerData.TimerValue : 0;
            timerData.WarningValue = (int)telop.DisplayTime;
            timerData.OnlyMasterTicks = telop.AddMessageEnabled ? false : true;
            timerData.Tooltip = telop.MessageReplaced;

            timerData.Panel1Display = false;
            timerData.Panel2Display = false;

            timerData.WarningSoundData = "none"; // disable warning sound

            // initialize other parameters
            timerData.RestrictToMe = false;
            timerData.AbsoluteTiming = false;
            timerData.RestrictToCategory = false;

            ActGlobals.oFormSpellTimers.AddEditTimerDef(timerData);
        }
Example #5
0
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource"></param>
        private void ShowTelopDetail(
            OnePointTelop dataSource)
        {
            var src = dataSource;

            if (src == null)
            {
                this.TelopDetailGroupBox.Visible = false;
                return;
            }

            this.TelopDetailGroupBox.Visible = true;

            this.TelopTitleTextBox.Text                  = src.Title;
            this.TelopMessageTextBox.Text                = src.Message;
            this.TelopKeywordTextBox.Text                = src.Keyword;
            this.TelopKeywordToHideTextBox.Text          = src.KeywordToHide;
            this.TelopRegexEnabledCheckBox.Checked       = src.RegexEnabled;
            this.TelopDelayNumericUpDown.Value           = src.Delay;
            this.DisplayTimeNumericUpDown.Value          = src.DisplayTime;
            this.EnabledAddMessageCheckBox.Checked       = src.AddMessageEnabled;
            this.TelopProgressBarEnabledCheckBox.Checked = src.ProgressBarEnabled;

            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.FontOutlineColor = src.FontOutlineColor.FromHTML();
            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.TextFont         = new Font(
                src.FontFamily,
                src.FontSize,
                (FontStyle)src.FontStyle);
            this.TelopVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.TelopVisualSetting.RefreshSampleImage();

            var left = (int)src.Left;
            var top  = (int)src.Top;

            double x, y;

            OnePointTelopController.GettLocation(
                src.ID,
                out x,
                out y);

            if (x != 0)
            {
                left = (int)x;
            }

            if (y != 0)
            {
                top = (int)y;
            }

            this.TelopLeftNumericUpDown.Value = left;
            this.TelopLeftNumericUpDown.Tag   = left;
            this.TelopTopNumericUpDown.Value  = top;
            this.TelopTopNumericUpDown.Tag    = top;

            this.TelopMatchSoundComboBox.SelectedValue = src.MatchSound;
            this.TelopMatchTTSTextBox.Text             = src.MatchTextToSpeak;

            this.TelopDelaySoundComboBox.SelectedValue = src.DelaySound;
            this.TelopDelayTTSTextBox.Text             = src.DelayTextToSpeak;

            // データソースをタグに突っ込んでおく
            this.TelopDetailGroupBox.Tag = src;
        }
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource"></param>
        private void ShowTelopDetail(
            OnePointTelop dataSource)
        {
            var src = dataSource;

            if (src == null)
            {
                this.TelopDetailGroupBox.Visible = false;
                return;
            }

            this.TelopDetailGroupBox.Visible = true;

            this.TelopTitleTextBox.Text                  = src.Title;
            this.TelopMessageTextBox.Text                = src.Message;
            this.TelopKeywordTextBox.Text                = src.Keyword;
            this.TelopKeywordToHideTextBox.Text          = src.KeywordToHide;
            this.TelopRegexEnabledCheckBox.Checked       = src.RegexEnabled;
            this.TelopDelayNumericUpDown.Value           = src.Delay;
            this.DisplayTimeNumericUpDown.Value          = src.DisplayTime;
            this.EnabledAddMessageCheckBox.Checked       = src.AddMessageEnabled;
            this.TelopProgressBarEnabledCheckBox.Checked = src.ProgressBarEnabled;

            this.TelopVisualSetting.FontColor        = src.FontColor.FromHTML();
            this.TelopVisualSetting.FontOutlineColor = src.FontOutlineColor.FromHTML();
            this.TelopVisualSetting.SetFontInfo(src.Font);
            this.TelopVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.TelopVisualSetting.RefreshSampleImage();

            var left = (int)src.Left;
            var top  = (int)src.Top;

            double x, y;

            OnePointTelopController.GettLocation(
                src.ID,
                out x,
                out y);

            if (x != 0)
            {
                left = (int)x;
            }

            if (y != 0)
            {
                top = (int)y;
            }

            this.TelopLeftNumericUpDown.Value = left;
            this.TelopLeftNumericUpDown.Tag   = left;
            this.TelopTopNumericUpDown.Value  = top;
            this.TelopTopNumericUpDown.Tag    = top;

            this.TelopMatchSoundComboBox.SelectedValue = src.MatchSound;
            this.TelopMatchTTSTextBox.Text             = src.MatchTextToSpeak;

            this.TelopDelaySoundComboBox.SelectedValue = src.DelaySound;
            this.TelopDelayTTSTextBox.Text             = src.DelayTextToSpeak;

            // データソースをタグに突っ込んでおく
            this.TelopDetailGroupBox.Tag = src;

            // ジョブ限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectJobButton.ForeColor = src.JobFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // ゾーン限定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSelectZoneButton.ForeColor = src.ZoneFilter != string.Empty ? Color.Blue : Button.DefaultForeColor;

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.TelopSetConditionButton.ForeColor =
                (src.TimersMustRunningForStart.Length != 0 || src.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;
        }
Example #7
0
        /// <summary>
        /// ログ1行1テロップに対して判定する
        /// </summary>
        /// <param name="telop">テロップ</param>
        /// <param name="log">ログ</param>
        public void MatchCore(
            OnePointTelop telop,
            string log)
        {
            var matched = false;

            var regex       = telop.Regex;
            var regexToHide = telop.RegexToHide;

            // マッチング計測開始
            telop.StartMatching();

            // 開始条件を確認する
            if (ConditionUtility.CheckConditionsForTelop(telop))
            {
                // 通常マッチ
                if (regex == null)
                {
                    var keyword = telop.KeywordReplaced;
                    if (!string.IsNullOrWhiteSpace(keyword))
                    {
                        if (log.Contains(keyword, StringComparison.OrdinalIgnoreCase))
                        {
                            var messageReplaced = ConditionUtility.GetReplacedMessage(telop);

                            // PC名を置換する
                            messageReplaced = FFXIVPlugin.Instance.ReplacePartyMemberName(messageReplaced);

                            if (!telop.AddMessageEnabled)
                            {
                                telop.MessageReplaced = messageReplaced;
                            }
                            else
                            {
                                telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                         messageReplaced :
                                                         Environment.NewLine + messageReplaced;
                            }

                            telop.ForceHide     = false;
                            telop.Delayed       = false;
                            telop.MatchedLog    = log;
                            telop.MatchDateTime = DateTime.Now;

                            // マッチング計測終了
                            telop.EndMatching();

                            SoundController.Instance.Play(telop.MatchSound);
                            SoundController.Instance.Play(telop.MatchTextToSpeak);

                            // DISCORDに通知する?
                            if (telop.NotifyToDiscord)
                            {
                                DiscordBridge.Instance.SendMessageDelegate?.Invoke(messageReplaced);
                            }

                            matched = true;
                        }
                    }
                }

                // 正規表現マッチ
                else
                {
                    var match = regex.Match(log);
                    if (match.Success)
                    {
                        var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                        messageReplaced = match.Result(messageReplaced);

                        // PC名を置換する
                        messageReplaced = FFXIVPlugin.Instance.ReplacePartyMemberName(messageReplaced);

                        if (!telop.AddMessageEnabled)
                        {
                            telop.MessageReplaced = messageReplaced;
                        }
                        else
                        {
                            telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                                     messageReplaced :
                                                     Environment.NewLine + messageReplaced;
                        }

                        telop.ForceHide     = false;
                        telop.Delayed       = false;
                        telop.MatchedLog    = log;
                        telop.MatchDateTime = DateTime.Now;

                        // マッチング計測終了
                        telop.EndMatching();

                        SoundController.Instance.Play(telop.MatchSound);
                        if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                        {
                            var tts = match.Result(telop.MatchTextToSpeak);
                            SoundController.Instance.Play(tts);
                        }

                        // DISCORDに通知する?
                        if (telop.NotifyToDiscord)
                        {
                            DiscordBridge.Instance.SendMessageDelegate?.Invoke(messageReplaced);
                        }

                        matched = true;
                    }
                }
            }

            if (matched)
            {
                // ディレイサウンドをスタートさせる
                telop.StartDelayedSoundTimer();

                SpellsController.Instance.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                SpellsController.Instance.NotifyNormalSpellTimerForTelop(telop.Title);

                return;
            }

            // 通常マッチ(強制非表示)
            if (regexToHide == null)
            {
                var keyword = telop.KeywordToHideReplaced;
                if (!string.IsNullOrWhiteSpace(keyword))
                {
                    if (log.Contains(keyword, StringComparison.OrdinalIgnoreCase))
                    {
                        telop.ForceHide = true;
                        matched         = true;
                    }
                }
            }

            // 正規表現マッチ(強制非表示)
            else
            {
                if (regexToHide.IsMatch(log))
                {
                    telop.ForceHide = true;
                    matched         = true;
                }
            }

            if (matched)
            {
                SpellsController.Instance.UpdateNormalSpellTimerForTelop(telop, telop.ForceHide);
                SpellsController.Instance.NotifyNormalSpellTimerForTelop(telop.Title);
            }
        }
Example #8
0
        /// <summary>
        /// テロップ追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void TelopAddButton_Click(object sender, EventArgs e)
        {
            var nr = new OnePointTelop();

            nr.ID = OnePointTelopTable.Default.Table.Any() ?
                    OnePointTelopTable.Default.Table.Max(x => x.ID) + 1 :
                    1;
            nr.Title            = Translate.Get("NewTelop");
            nr.DisplayTime      = 3;
            nr.FontColor        = Settings.Default.FontColor.ToHTML();
            nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
            nr.FontFamily       = Settings.Default.Font.Name;
            nr.FontSize         = Settings.Default.Font.Size;
            nr.FontStyle        = (int)Settings.Default.Font.Style;
            nr.BackgroundColor  = Settings.Default.BackgroundColor.ToHTML();
            nr.Left             = 10.0d;
            nr.Top       = 10.0d;
            nr.JobFilter = string.Empty;

            // 現在選択しているノードの情報を一部コピーする
            if (this.TelopTreeView.SelectedNode != null)
            {
                var baseRow = this.TelopTreeView.SelectedNode.Tag != null ?
                              this.TelopTreeView.SelectedNode.Tag as OnePointTelop :
                              this.TelopTreeView.SelectedNode.Nodes[0].Tag as OnePointTelop;

                if (baseRow != null)
                {
                    nr.Title              = baseRow.Title + " New";
                    nr.Message            = baseRow.Message;
                    nr.Keyword            = baseRow.Keyword;
                    nr.KeywordToHide      = baseRow.KeywordToHide;
                    nr.RegexEnabled       = baseRow.RegexEnabled;
                    nr.Delay              = baseRow.Delay;
                    nr.DisplayTime        = baseRow.DisplayTime;
                    nr.AddMessageEnabled  = baseRow.AddMessageEnabled;
                    nr.ProgressBarEnabled = baseRow.ProgressBarEnabled;
                    nr.FontColor          = baseRow.FontColor;
                    nr.FontOutlineColor   = baseRow.FontOutlineColor;
                    nr.FontFamily         = baseRow.FontFamily;
                    nr.FontSize           = baseRow.FontSize;
                    nr.FontStyle          = baseRow.FontStyle;
                    nr.BackgroundColor    = baseRow.BackgroundColor;
                    nr.BackgroundAlpha    = baseRow.BackgroundAlpha;
                    nr.Left      = baseRow.Left;
                    nr.Top       = baseRow.Top;
                    nr.JobFilter = baseRow.JobFilter;
                }
            }

            nr.MatchDateTime      = DateTime.MinValue;
            nr.Enabled            = true;
            nr.Regex              = null;
            nr.RegexPattern       = string.Empty;
            nr.RegexToHide        = null;
            nr.RegexPatternToHide = string.Empty;

            OnePointTelopTable.Default.Table.Add(nr);

            OnePointTelopTable.Default.Save();

            // 新しいノードを生成する
            var node = new TreeNode(nr.Title)
            {
                Tag         = nr,
                ToolTipText = nr.Message,
                Checked     = nr.Enabled
            };

            this.TelopTreeView.Nodes.Add(node);
            this.TelopTreeView.SelectedNode = node;
        }
        /// <summary>
        /// Windowをリフレッシュする
        /// </summary>
        /// <param name="telop">テロップ</param>
        public static void RefreshTelopWindows(
            OnePointTelop[] telops)
        {
            foreach (var telop in telops)
            {
                var w = telopWindowList.ContainsKey(telop.ID) ? telopWindowList[telop.ID] : null;
                if (w == null)
                {
                    w = new OnePointTelopWindow()
                    {
                        Title = "OnePointTelop - " + telop.Title,
                        DataSource = telop
                    };

                    if (Settings.Default.ClickThroughEnabled)
                    {
                        w.ToTransparentWindow();
                    }

                    w.Opacity = 0;
                    w.Topmost = false;
                    w.Show();

                    telopWindowList.Add(telop.ID, w);
                }

                // telopの位置を保存する
                if (DateTime.Now.Second == 0)
                {
                    telop.Left = w.Left;
                    telop.Top = w.Top;
                    OnePointTelopTable.Default.Save();
                }

                if (Settings.Default.OverlayVisible &&
                    Settings.Default.TelopAlwaysVisible)
                {
                    // ドラッグ中じゃない?
                    if (!w.IsDragging)
                    {
                        w.Refresh();
                        w.ShowOverlay();
                    }

                    continue;
                }

                if (telop.MatchDateTime > DateTime.MinValue)
                {
                    var start = telop.MatchDateTime.AddSeconds(telop.Delay);
                    var end = telop.MatchDateTime.AddSeconds(telop.Delay + telop.DisplayTime);

                    if (start <= DateTime.Now && DateTime.Now <= end)
                    {
                        w.Refresh();
                        w.ShowOverlay();
                    }
                    else
                    {
                        w.HideOverlay();

                        if (DateTime.Now > end)
                        {
                            telop.MatchDateTime = DateTime.MinValue;
                            telop.MessageReplaced = string.Empty;
                        }
                    }

                    if (telop.ForceHide)
                    {
                        w.HideOverlay();
                        telop.MatchDateTime = DateTime.MinValue;
                        telop.MessageReplaced = string.Empty;
                    }
                }
                else
                {
                    w.HideOverlay();
                    telop.MessageReplaced = string.Empty;
                }
            }
        }
        /// <summary>
        /// ログとマッチングする
        /// </summary>
        /// <param name="telops">Telops</param>
        /// <param name="logLines">ログ行</param>
        public static void Match(
            OnePointTelop[] telops,
            string[] logLines)
        {
            foreach (var log in logLines)
            {
                foreach (var telop in telops)
                {
                    var matched = false;

                    var regex = telop.Regex;
                    var regexToHide = telop.RegexToHide;

                    // 開始条件を確認する
                    if (ConditionUtility.CheckConditionsForTelop(telop))
                    {
                        // 通常マッチ
                        if (regex == null)
                        {
                            var keyword = telop.KeywordReplaced;
                            if (!string.IsNullOrWhiteSpace(keyword))
                            {
                                if (log.ToUpper().Contains(
                                    keyword.ToUpper()))
                                {
                                    var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                    if (!telop.AddMessageEnabled)
                                    {
                                        telop.MessageReplaced = messageReplaced;
                                    }
                                    else
                                    {
                                        telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                            messageReplaced :
                                            Environment.NewLine + messageReplaced;
                                    }

                                    telop.MatchDateTime = DateTime.Now;
                                    telop.Delayed = false;
                                    telop.MatchedLog = log;
                                    telop.ForceHide = false;

                                    SoundController.Default.Play(telop.MatchSound);
                                    SoundController.Default.Play(telop.MatchTextToSpeak);

                                    matched = true;
                                }
                            }
                        }

                        // 正規表現マッチ
                        if (regex != null)
                        {
                            var match = regex.Match(log);
                            if (match.Success)
                            {
                                var messageReplaced = ConditionUtility.GetReplacedMessage(telop);
                                if (!telop.AddMessageEnabled)
                                {
                                    telop.MessageReplaced = match.Result(messageReplaced);
                                }
                                else
                                {
                                    telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                        match.Result(messageReplaced) :
                                        Environment.NewLine + match.Result(messageReplaced);
                                }

                                telop.MatchDateTime = DateTime.Now;
                                telop.Delayed = false;
                                telop.MatchedLog = log;
                                telop.ForceHide = false;

                                SoundController.Default.Play(telop.MatchSound);
                                if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                                {
                                    var tts = match.Result(telop.MatchTextToSpeak);
                                    SoundController.Default.Play(tts);
                                }

                                matched = true;
                            }
                        }
                    }

                    if (matched)
                    {
                        SpellTimerCore.Default.updateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.notifyNormalSpellTimerForTelop(telop.Title);
                        continue;
                    }

                    // 通常マッチ(強制非表示)
                    if (regexToHide == null)
                    {
                        var keyword = telop.KeywordToHideReplaced;
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                keyword.ToUpper()))
                            {
                                telop.ForceHide = true;
                                matched = true;
                            }
                        }
                    }

                    // 正規表現マッチ(強制非表示)
                    if (regexToHide != null)
                    {
                        if (regexToHide.IsMatch(log))
                        {
                            telop.ForceHide = true;
                            matched = true;
                        }
                    }

                    if (matched)
                    {
                        SpellTimerCore.Default.updateNormalSpellTimerForTelop(telop, telop.ForceHide);
                        SpellTimerCore.Default.notifyNormalSpellTimerForTelop(telop.Title);
                    }
                }   // end loop telops
            }

            // スペルの更新とサウンド処理を行う
            foreach (var telop in telops)
            {
                var regex = telop.Regex;

                // ディレイ時間が経過した?
                if (!telop.Delayed &&
                    telop.MatchDateTime > DateTime.MinValue &&
                    telop.Delay > 0)
                {
                    var delayed = telop.MatchDateTime.AddSeconds(telop.Delay);
                    if (DateTime.Now >= delayed)
                    {
                        telop.Delayed = true;
                        SoundController.Default.Play(telop.DelaySound);
                        var tts = regex != null && !string.IsNullOrWhiteSpace(telop.DelayTextToSpeak) ?
                            regex.Replace(telop.MatchedLog, telop.DelayTextToSpeak) :
                            telop.DelayTextToSpeak;
                        SoundController.Default.Play(tts);
                    }
                }
            }
#if false
            Parallel.ForEach(telops, (telop) =>
            {
            }); // end loop telops
#endif
        }
        /// <summary>
        /// 不要になったWindowを閉じる
        /// </summary>
        /// <param name="telops">Telops</param>
        public static void GarbageWindows(
            OnePointTelop[] telops)
        {
            // 不要になったWindowを閉じる
            var removeWindowList = new List<OnePointTelopWindow>();
            foreach (var window in telopWindowList.Values)
            {
                if (!telops.Any(x => x.ID == window.DataSource.ID))
                {
                    removeWindowList.Add(window);
                }
            }

            foreach (var window in removeWindowList)
            {
                ActInvoker.Invoke(() =>
                {
                    window.DataSource.Left = window.Left;
                    window.DataSource.Top = window.Top;
                    window.Close();
                });

                telopWindowList.Remove(window.DataSource.ID);
            }
        }
        /// <summary>
        /// ログとマッチングする
        /// </summary>
        /// <param name="telops">Telops</param>
        /// <param name="logLines">ログ行</param>
        public static void Match(
            OnePointTelop[] telops,
            string[] logLines)
        {
            Parallel.ForEach(telops, (telop) =>
            {
                var regex = telop.Regex;
                var regexToHide = telop.RegexToHide;

                foreach (var log in logLines)
                {
                    // 通常マッチ
                    if (regex == null)
                    {
                        var keyword = telop.KeywordReplaced;
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                keyword.ToUpper()))
                            {
                                if (!telop.AddMessageEnabled)
                                {
                                    telop.MessageReplaced = telop.Message;
                                }
                                else
                                {
                                    telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                        telop.Message :
                                        Environment.NewLine + telop.Message;
                                }

                                telop.MatchDateTime = DateTime.Now;
                                telop.Delayed = false;
                                telop.MatchedLog = log;
                                telop.ForceHide = false;

                                SoundController.Default.Play(telop.MatchSound);
                                SoundController.Default.Play(telop.MatchTextToSpeak);

                                continue;
                            }
                        }
                    }

                    // 正規表現マッチ
                    if (regex != null)
                    {
                        var match = regex.Match(log);
                        if (match.Success)
                        {
                            if (!telop.AddMessageEnabled)
                            {
                                telop.MessageReplaced = match.Result(telop.Message);
                            }
                            else
                            {
                                telop.MessageReplaced += string.IsNullOrWhiteSpace(telop.MessageReplaced) ?
                                    match.Result(telop.Message) :
                                    Environment.NewLine + match.Result(telop.Message);
                            }

                            telop.MatchDateTime = DateTime.Now;
                            telop.Delayed = false;
                            telop.MatchedLog = log;
                            telop.ForceHide = false;

                            SoundController.Default.Play(telop.MatchSound);
                            if (!string.IsNullOrWhiteSpace(telop.MatchTextToSpeak))
                            {
                                var tts = match.Result(telop.MatchTextToSpeak);
                                SoundController.Default.Play(tts);
                            }

                            continue;
                        }
                    }

                    // 通常マッチ(強制非表示)
                    if (regexToHide == null)
                    {
                        var keyword = telop.KeywordToHideReplaced;
                        if (!string.IsNullOrWhiteSpace(keyword))
                        {
                            if (log.ToUpper().Contains(
                                keyword.ToUpper()))
                            {
                                telop.ForceHide = true;
                                continue;
                            }
                        }
                    }

                    // 正規表現マッチ(強制非表示)
                    if (regexToHide != null)
                    {
                        if (regexToHide.IsMatch(log))
                        {
                            telop.ForceHide = true;
                            continue;
                        }
                    }
                }   // end loop logLines

                // ディレイ時間が経過した?
                if (!telop.Delayed &&
                    telop.MatchDateTime > DateTime.MinValue &&
                    telop.Delay > 0)
                {
                    var delayed = telop.MatchDateTime.AddSeconds(telop.Delay);
                    if (DateTime.Now >= delayed)
                    {
                        telop.Delayed = true;
                        SoundController.Default.Play(telop.DelaySound);
                        var tts = regex != null && !string.IsNullOrWhiteSpace(telop.DelayTextToSpeak) ?
                            regex.Replace(telop.MatchedLog, telop.DelayTextToSpeak) :
                            telop.DelayTextToSpeak;
                        SoundController.Default.Play(tts);
                    }
                }
            }); // end loop telops
        }
        /// <summary>
        /// テロップ追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void TelopAddButton_Click(object sender, EventArgs e)
        {
            var nr = new OnePointTelop();

            nr.ID = OnePointTelopTable.Default.Table.Any() ?
                OnePointTelopTable.Default.Table.Max(x => x.ID) + 1 :
                1;
            nr.Title = Translate.Get("NewTelop");
            nr.DisplayTime = 3;
            nr.FontColor = Settings.Default.FontColor.ToHTML();
            nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
            nr.FontFamily = Settings.Default.Font.Name;
            nr.FontSize = Settings.Default.Font.Size;
            nr.FontStyle = (int)Settings.Default.Font.Style;
            nr.BackgroundColor = Settings.Default.BackgroundColor.ToHTML();
            nr.Left = 10.0d;
            nr.Top = 10.0d;
            nr.JobFilter = string.Empty;
            nr.ZoneFilter = string.Empty;

            // 現在選択しているノードの情報を一部コピーする
            if (this.TelopTreeView.SelectedNode != null)
            {
                var baseRow = this.TelopTreeView.SelectedNode.Tag != null ?
                    this.TelopTreeView.SelectedNode.Tag as OnePointTelop :
                    this.TelopTreeView.SelectedNode.Nodes[0].Tag as OnePointTelop;

                if (baseRow != null)
                {
                    nr.Title = baseRow.Title + " New";
                    nr.Message = baseRow.Message;
                    nr.Keyword = baseRow.Keyword;
                    nr.KeywordToHide = baseRow.KeywordToHide;
                    nr.RegexEnabled = baseRow.RegexEnabled;
                    nr.Delay = baseRow.Delay;
                    nr.DisplayTime = baseRow.DisplayTime;
                    nr.AddMessageEnabled = baseRow.AddMessageEnabled;
                    nr.ProgressBarEnabled = baseRow.ProgressBarEnabled;
                    nr.FontColor = baseRow.FontColor;
                    nr.FontOutlineColor = baseRow.FontOutlineColor;
                    nr.FontFamily = baseRow.FontFamily;
                    nr.FontSize = baseRow.FontSize;
                    nr.FontStyle = baseRow.FontStyle;
                    nr.Font = baseRow.Font;
                    nr.BackgroundColor = baseRow.BackgroundColor;
                    nr.BackgroundAlpha = baseRow.BackgroundAlpha;
                    nr.Left = baseRow.Left;
                    nr.Top = baseRow.Top;
                    nr.JobFilter = baseRow.JobFilter;
                    nr.ZoneFilter = baseRow.ZoneFilter;
                }
            }

            nr.MatchDateTime = DateTime.MinValue;
            nr.Enabled = true;
            nr.Regex = null;
            nr.RegexPattern = string.Empty;
            nr.RegexToHide = null;
            nr.RegexPatternToHide = string.Empty;

            OnePointTelopTable.Default.Table.Add(nr);

            OnePointTelopTable.Default.ClearReplacedKeywords();
            OnePointTelopTable.Default.Save();

            // 新しいノードを生成する
            var node = new TreeNode(nr.Title)
            {
                Tag = nr,
                ToolTipText = nr.Message,
                Checked = nr.Enabled
            };

            this.TelopTreeView.Nodes.Add(node);
            this.TelopTreeView.SelectedNode = node;
        }