Exemplo n.º 1
0
        /// <summary>
        /// instanceが不要になっていたらコレクションから除去する
        /// </summary>
        /// <param name="instance">インスタンス</param>
        public static void TryRemoveInstance(
            SpellTimer instance)
        {
            var ttl = Settings.Default.TimeOfHideSpell + 30;

            lock (instance)
            {
                if (instance.CompleteScheduledTime != DateTime.MinValue &&
                    (DateTime.Now - instance.CompleteScheduledTime).TotalSeconds >= ttl)
                {
                    // ガーベージタイマを止める
                    instance.StopGarbageInstanceTimer();

                    SpellTimer o;
                    instanceSpells.TryRemove(instance.SpellTitleReplaced, out o);

                    // スペルコレクション本体から除去する
                    lock (lockObject)
                    {
                        table.Remove(instance);
                    }

                    instance.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// ACT標準のスペルタイマーの設定を追加・更新する
        /// </summary>
        /// <param name="spellTimer">元になるスペルタイマー</param>
        /// <param name="useRecastTime">リキャスト時間にRecastの値を使うか。falseの場合はCompleteScheduledTimeから計算される</param>
        public void updateNormalSpellTimer(SpellTimer spellTimer, bool useRecastTime)
        {
            if (!Settings.Default.EnabledNotifyNormalSpellTimer)
            {
                return;
            }

            var prefix       = Settings.Default.NotifyNormalSpellTimerPrefix;
            var spellName    = prefix + "spell_" + spellTimer.SpellTitle;
            var categoryName = prefix + spellTimer.Panel;
            var recastTime   = useRecastTime ? spellTimer.RecastTime : (spellTimer.CompleteScheduledTime - DateTime.Now).TotalSeconds;

            var timerData = new TimerData(spellName, categoryName);

            timerData.TimerValue      = (int)recastTime;
            timerData.RemoveValue     = (int)-Settings.Default.TimeOfHideSpell;
            timerData.WarningValue    = 0;
            timerData.OnlyMasterTicks = true;
            timerData.Tooltip         = spellTimer.SpellTitleReplaced;

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

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

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

            ActGlobals.oFormSpellTimers.AddEditTimerDef(timerData);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 指定したスペルをコレクションから除去する
 /// </summary>
 /// <param name="spell">除去するスペル</param>
 public static void RemoveSpell(
     SpellTimer spell)
 {
     lock (lockObject)
     {
         table.Remove(spell);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// ACT標準のスペルタイマーに通知する
        /// </summary>
        /// <param name="spellTimer">通知先に対応するスペルタイマー</param>
        public void notifyNormalSpellTimer(SpellTimer spellTimer)
        {
            if (!Settings.Default.EnabledNotifyNormalSpellTimer)
            {
                return;
            }

            var prefix    = Settings.Default.NotifyNormalSpellTimerPrefix;
            var spellName = prefix + "spell_" + spellTimer.SpellTitle;

            ActGlobals.oFormSpellTimers.NotifySpell("attacker", spellName, false, "victim", false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            lock (SpellTimerTable.Table)
            {
                var nr = new SpellTimer();

                nr.ID = SpellTimerTable.Table.Any() ?
                        SpellTimerTable.Table.Max(x => x.ID) + 1 :
                        1;
                nr.guid                       = Guid.NewGuid();
                nr.Panel                      = "General";
                nr.SpellTitle                 = "New Spell";
                nr.SpellIcon                  = string.Empty;
                nr.SpellIconSize              = 24;
                nr.ProgressBarVisible         = true;
                nr.FontColor                  = Settings.Default.FontColor.ToHTML();
                nr.FontOutlineColor           = Settings.Default.FontOutlineColor.ToHTML();
                nr.BarColor                   = Settings.Default.ProgressBarColor.ToHTML();
                nr.BarOutlineColor            = Settings.Default.ProgressBarOutlineColor.ToHTML();
                nr.FontFamily                 = Settings.Default.Font.Name;
                nr.FontSize                   = Settings.Default.Font.Size;
                nr.FontStyle                  = (int)Settings.Default.Font.Style;
                nr.BarWidth                   = Settings.Default.ProgressBarSize.Width;
                nr.BarHeight                  = Settings.Default.ProgressBarSize.Height;
                nr.BackgroundColor            = Settings.Default.BackgroundColor.ToHTML();
                nr.JobFilter                  = string.Empty;
                nr.ZoneFilter                 = string.Empty;
                nr.TimersMustRunningForStart  = new Guid[0];
                nr.TimersMustStoppingForStart = new Guid[0];

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

                    if (baseRow != null)
                    {
                        nr.Panel                          = baseRow.Panel;
                        nr.SpellTitle                     = baseRow.SpellTitle + " New";
                        nr.SpellIcon                      = baseRow.SpellIcon;
                        nr.SpellIconSize                  = baseRow.SpellIconSize;
                        nr.Keyword                        = baseRow.Keyword;
                        nr.RegexEnabled                   = baseRow.RegexEnabled;
                        nr.RecastTime                     = baseRow.RecastTime;
                        nr.KeywordForExtend1              = baseRow.KeywordForExtend1;
                        nr.RecastTimeExtending1           = baseRow.RecastTimeExtending1;
                        nr.KeywordForExtend2              = baseRow.KeywordForExtend2;
                        nr.RecastTimeExtending2           = baseRow.RecastTimeExtending2;
                        nr.ExtendBeyondOriginalRecastTime = baseRow.ExtendBeyondOriginalRecastTime;
                        nr.UpperLimitOfExtension          = baseRow.UpperLimitOfExtension;
                        nr.RepeatEnabled                  = baseRow.RepeatEnabled;
                        nr.ProgressBarVisible             = baseRow.ProgressBarVisible;
                        nr.IsReverse                      = baseRow.IsReverse;
                        nr.FontColor                      = baseRow.FontColor;
                        nr.FontOutlineColor               = baseRow.FontOutlineColor;
                        nr.BarColor                       = baseRow.BarColor;
                        nr.BarOutlineColor                = baseRow.BarOutlineColor;
                        nr.DontHide                       = baseRow.DontHide;
                        nr.HideSpellName                  = baseRow.HideSpellName;
                        nr.OverlapRecastTime              = baseRow.OverlapRecastTime;
                        nr.ReduceIconBrightness           = baseRow.ReduceIconBrightness;
                        nr.FontFamily                     = baseRow.FontFamily;
                        nr.FontSize                       = baseRow.FontSize;
                        nr.FontStyle                      = baseRow.FontStyle;
                        nr.Font                       = baseRow.Font;
                        nr.BarWidth                   = baseRow.BarWidth;
                        nr.BarHeight                  = baseRow.BarHeight;
                        nr.BackgroundColor            = baseRow.BackgroundColor;
                        nr.BackgroundAlpha            = baseRow.BackgroundAlpha;
                        nr.JobFilter                  = baseRow.JobFilter;
                        nr.ZoneFilter                 = baseRow.ZoneFilter;
                        nr.TimersMustRunningForStart  = baseRow.TimersMustRunningForStart;
                        nr.TimersMustStoppingForStart = baseRow.TimersMustStoppingForStart;
                        nr.ToInstance                 = baseRow.ToInstance;
                    }
                }

                nr.MatchDateTime = DateTime.MinValue;
                nr.UpdateDone    = false;
                nr.Enabled       = true;
                nr.DisplayNo     = SpellTimerTable.Table.Any() ?
                                   SpellTimerTable.Table.Max(x => x.DisplayNo) + 1 :
                                   50;
                nr.Regex        = null;
                nr.RegexPattern = string.Empty;
                SpellTimerTable.Table.Add(nr);

                SpellTimerTable.ClearReplacedKeywords();
                SpellTimerTable.RemoveAllInstanceSpells();
                SpellTimerTable.Save();

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

                // 親ノードがあれば追加する
                foreach (TreeNode item in this.SpellTimerTreeView.Nodes)
                {
                    if (item.Text == nr.Panel)
                    {
                        item.Nodes.Add(node);
                        this.SpellTimerTreeView.SelectedNode = node;
                        break;
                    }
                }

                // 親ノードがなかった
                if (this.SpellTimerTreeView.SelectedNode != node)
                {
                    var parentNode = new TreeNode(nr.Panel, new TreeNode[] { node })
                    {
                        Checked = true
                    };

                    this.SpellTimerTreeView.Nodes.Add(parentNode);
                    this.SpellTimerTreeView.SelectedNode = node;
                }

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

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

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

            // 標準のスペルタイマーへ変更を反映する
            SpellTimerCore.Default.applyToNormalSpellTimer();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource">データソース</param>
        private void ShowDetail(
            SpellTimer dataSource)
        {
            var src = dataSource;

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

            this.DetailGroupBox.Visible = true;

            this.PanelNameTextBox.Text           = src.Panel;
            this.SpellTitleTextBox.Text          = src.SpellTitle;
            this.SpellIconComboBox.SelectedValue = src.SpellIcon;
            this.SpellIconSizeUpDown.Value       = src.SpellIconSize;
            this.DisplayNoNumericUpDown.Value    = src.DisplayNo;
            this.KeywordTextBox.Text             = src.Keyword;
            this.RegexEnabledCheckBox.Checked    = src.RegexEnabled;
            this.RecastTimeNumericUpDown.Value   = src.RecastTime;
            this.RepeatCheckBox.Checked          = src.RepeatEnabled;
            this.ShowProgressBarCheckBox.Checked = src.ProgressBarVisible;

            this.KeywordToExpand1TextBox.Text                   = src.KeywordForExtend1;
            this.ExpandSecounds1NumericUpDown.Value             = src.RecastTimeExtending1;
            this.KeywordToExpand2TextBox.Text                   = src.KeywordForExtend2;
            this.ExpandSecounds2NumericUpDown.Value             = src.RecastTimeExtending2;
            this.ExtendBeyondOriginalRecastTimeCheckBox.Checked = src.ExtendBeyondOriginalRecastTime;
            this.UpperLimitOfExtensionNumericUpDown.Value       = src.UpperLimitOfExtension;

            this.MatchSoundComboBox.SelectedValue = src.MatchSound;
            this.MatchTextToSpeakTextBox.Text     = src.MatchTextToSpeak;

            this.OverSoundComboBox.SelectedValue = src.OverSound;
            this.OverTextToSpeakTextBox.Text     = src.OverTextToSpeak;
            this.OverTimeNumericUpDown.Value     = src.OverTime;

            this.BeforeSoundComboBox.SelectedValue = src.BeforeSound;
            this.BeforeTextToSpeakTextBox.Text     = src.BeforeTextToSpeak;
            this.BeforeTimeNumericUpDown.Value     = src.BeforeTime;

            this.TimeupSoundComboBox.SelectedValue = src.TimeupSound;
            this.TimeupTextToSpeakTextBox.Text     = src.TimeupTextToSpeak;

            this.IsReverseCheckBox.Checked            = src.IsReverse;
            this.DontHideCheckBox.Checked             = src.DontHide;
            this.HideSpellNameCheckBox.Checked        = src.HideSpellName;
            this.OverlapRecastTimeCheckBox.Checked    = src.OverlapRecastTime;
            this.ReduceIconBrightnessCheckBox.Checked = src.ReduceIconBrightness;
            this.ToInstanceCheckBox.Checked           = src.ToInstance;

            this.SpellVisualSetting.SetFontInfo(src.Font);
            this.SpellVisualSetting.BarColor = string.IsNullOrWhiteSpace(src.BarColor) ?
                                               Settings.Default.ProgressBarColor :
                                               src.BarColor.FromHTML();
            this.SpellVisualSetting.BarOutlineColor = string.IsNullOrWhiteSpace(src.BarOutlineColor) ?
                                                      Settings.Default.ProgressBarOutlineColor :
                                                      src.BarOutlineColor.FromHTML();
            this.SpellVisualSetting.FontColor = string.IsNullOrWhiteSpace(src.FontColor) ?
                                                Settings.Default.FontColor :
                                                src.FontColor.FromHTML();
            this.SpellVisualSetting.FontOutlineColor = string.IsNullOrWhiteSpace(src.FontOutlineColor) ?
                                                       Settings.Default.FontOutlineColor :
                                                       src.FontOutlineColor.FromHTML();
            this.SpellVisualSetting.BarSize         = new Size(src.BarWidth, src.BarHeight);
            this.SpellVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.SpellVisualSetting.SpellIcon         = src.SpellIcon;
            this.SpellVisualSetting.SpellIconSize     = src.SpellIconSize;
            this.SpellVisualSetting.HideSpellName     = src.HideSpellName;
            this.SpellVisualSetting.OverlapRecastTime = src.OverlapRecastTime;

            this.SpellVisualSetting.RefreshSampleImage();

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

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

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

            // 条件設定ボタンの色を変える(未設定:黒、設定有:青)
            this.SetConditionButton.ForeColor =
                (src.TimersMustRunningForStart.Length != 0 || src.TimersMustStoppingForStart.Length != 0) ?
                Color.Blue :
                Button.DefaultForeColor;
        }
        /// <summary>
        /// スペルパネルWindowを更新する
        /// </summary>
        /// <param name="spells">
        /// 対象のスペル</param>
        private void RefreshSpellPanelWindows(
            SpellTimer[] spells)
        {
            var spellsGroupByPanel =
                from s in spells
                group s by s.Panel.Trim();

            foreach (var panel in spellsGroupByPanel)
            {
                var f = panel.First();

                var w = this.SpellTimerPanels
                    .Where(x => x.PanelName == f.Panel)
                    .FirstOrDefault();

                if (w == null)
                {
                    w = new SpellTimerListWindow()
                    {
                        Title = "SpecialSpellTimer - " + f.Panel,
                        PanelName = f.Panel,
                    };

                    this.SpellTimerPanels.Add(w);

                    // クリックスルー?
                    if (Settings.Default.ClickThroughEnabled)
                    {
                        w.ToTransparentWindow();
                    }

                    /// このパネルに属するスペルを再描画させる
                    foreach (var spell in panel)
                    {
                        spell.UpdateDone = false;
                    }

                    w.Show();
                }

                w.SpellTimers = panel.ToArray();

                // ドラッグ中じゃない?
                if (!w.IsDragging)
                {
                    w.RefreshSpellTimer();
                }
            }
        }
        /// <summary>
        /// ACT標準のスペルタイマーの設定を追加・更新する
        /// </summary>
        /// <param name="spellTimer">元になるスペルタイマー</param>
        /// <param name="useRecastTime">リキャスト時間にRecastの値を使うか。falseの場合はCompleteScheduledTimeから計算される</param>
        public void updateNormalSpellTimer(SpellTimer spellTimer, bool useRecastTime)
        {
            if (!Settings.Default.EnabledNotifyNormalSpellTimer)
            {
                return;
            }

            var prefix = Settings.Default.NotifyNormalSpellTimerPrefix;
            var spellName = prefix + "spell_" + spellTimer.SpellTitle;
            var categoryName = prefix + spellTimer.Panel;
            var recastTime = useRecastTime ? spellTimer.RecastTime : (spellTimer.CompleteScheduledTime - DateTime.Now).TotalSeconds;

            var timerData = new TimerData(spellName, categoryName);
            timerData.TimerValue = (int)recastTime;
            timerData.RemoveValue = (int)-Settings.Default.TimeOfHideSpell;
            timerData.WarningValue = 0;
            timerData.OnlyMasterTicks = true;
            timerData.Tooltip = spellTimer.SpellTitleReplaced;

            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);
        }
        /// <summary>
        /// 不要なスペルタイマWindowを閉じる
        /// </summary>
        /// <param name="spells">Spell</param>
        private void GarbageSpellPanelWindows(
            SpellTimer[] spells)
        {
            if (this.SpellTimerPanels != null)
            {
                var removeList = new List<SpellTimerListWindow>();
                foreach (var panel in this.SpellTimerPanels)
                {
                    // パネルの位置を保存する
                    var setting = (
                        from x in PanelSettings.Default.SettingsTable
                        where
                        x.PanelName == panel.PanelName
                        select
                        x).FirstOrDefault();

                    if (setting == null)
                    {
                        setting = PanelSettings.Default.SettingsTable.NewPanelSettingsRow();
                        PanelSettings.Default.SettingsTable.AddPanelSettingsRow(setting);
                    }

                    setting.PanelName = panel.PanelName;
                    setting.Left = panel.Left;
                    setting.Top = panel.Top;

                    // 毎分0秒の時保存する
                    if (DateTime.Now.Second == 0)
                    {
                        PanelSettings.Default.Save();
                    }

                    // スペルリストに存在しないパネルを閉じる
                    if (!spells.Any(x => x.Panel == panel.PanelName))
                    {
                        ActInvoker.Invoke(() => panel.Close());
                        removeList.Add(panel);
                    }
                }

                foreach (var item in removeList)
                {
                    this.SpellTimerPanels.Remove(item);
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Spellをマッチングする
        /// </summary>
        /// <param name="spells">Spell</param>
        /// <param name="logLines">ログ</param>
        private void MatchSpells(
            SpellTimer[] spells,
            string[] logLines)
        {
            foreach (var logLine in logLines)
            {
                // マッチする?
                foreach (var spell in spells)
                {
                    var regex = spell.Regex;
                    var notifyNeeded = false;

                    if (!spell.IsInstance)
                    {
                        // 開始条件を確認する
                        if (ConditionUtility.CheckConditionsForSpell(spell))
                        {
                            // 正規表現が無効?
                            if (!spell.RegexEnabled ||
                                regex == null)
                            {
                                var keyword = spell.KeywordReplaced;
                                if (string.IsNullOrWhiteSpace(keyword))
                                {
                                    continue;
                                }

                                // キーワードが含まれるか?
                                if (logLine.ToUpper().Contains(
                                    keyword.ToUpper()))
                                {
                                    var targetSpell = spell;

                                    // ヒットしたログを格納する
                                    targetSpell.MatchedLog = logLine;

                                    // スペル名(表示テキスト)を置換する
                                    var replacedTitle = ConditionUtility.GetReplacedTitle(targetSpell);

                                    targetSpell.SpellTitleReplaced = replacedTitle;
                                    targetSpell.MatchDateTime = DateTime.Now;
                                    targetSpell.UpdateDone = false;
                                    targetSpell.OverDone = false;
                                    targetSpell.BeforeDone = false;
                                    targetSpell.TimeupDone = false;
                                    targetSpell.CompleteScheduledTime = targetSpell.MatchDateTime.AddSeconds(targetSpell.RecastTime);

                                    // マッチ時点のサウンドを再生する
                                    this.Play(targetSpell.MatchSound);
                                    this.Play(targetSpell.MatchTextToSpeak);

                                    notifyNeeded = true;
                                }
                            }
                            else
                            {
                                // 正規表現でマッチングする
                                var match = regex.Match(logLine);
                                if (match.Success)
                                {
                                    var targetSpell = spell;

                                    // ヒットしたログを格納する
                                    targetSpell.MatchedLog = logLine;

                                    // スペル名(表示テキスト)を置換する
                                    var replacedTitle = match.Result(ConditionUtility.GetReplacedTitle(targetSpell));

                                    // インスタンス化する?
                                    if (spell.ToInstance)
                                    {
                                        // 同じタイトルのインスタンススペルを探す
                                        // 存在すればそれを使用して、なければ新しいインスタンスを生成する
                                        targetSpell = SpellTimerTable.EnabledTable.FirstOrDefault(x =>
                                            x.IsInstance &&
                                            x.SpellTitleReplaced == replacedTitle) ??
                                            SpellTimerTable.CreateInstanceByElement(spell);
                                    }

                                    targetSpell.SpellTitleReplaced = replacedTitle;
                                    targetSpell.MatchDateTime = DateTime.Now;
                                    targetSpell.UpdateDone = false;
                                    targetSpell.OverDone = false;
                                    targetSpell.BeforeDone = false;
                                    targetSpell.TimeupDone = false;

                                    // 効果時間を決定する
                                    // グループ "duration" をキャプチャーしていた場合は効果時間を置換する
                                    var durationAsText = match.Groups["duration"].Value;
                                    long duration;
                                    if (!long.TryParse(durationAsText, out duration))
                                    {
                                        duration = targetSpell.RecastTime;
                                    }

                                    targetSpell.CompleteScheduledTime = targetSpell.MatchDateTime.AddSeconds(duration);

                                    // マッチ時点のサウンドを再生する
                                    this.Play(targetSpell.MatchSound);

                                    if (!string.IsNullOrWhiteSpace(targetSpell.MatchTextToSpeak))
                                    {
                                        var tts = match.Result(targetSpell.MatchTextToSpeak);
                                        this.Play(tts);
                                    }

                                    notifyNeeded = true;
                                }
                            }
                        }
                    }

                    // 延長をマッチングする
                    if (spell.MatchDateTime > DateTime.MinValue)
                    {
                        var keywords = new string[] { spell.KeywordForExtendReplaced1, spell.KeywordForExtendReplaced2 };
                        var regexes = new Regex[] { spell.RegexForExtend1, spell.RegexForExtend2 };
                        var timeToExtends = new long[] { spell.RecastTimeExtending1, spell.RecastTimeExtending2 };

                        for (int i = 0; i < 2; i++)
                        {
                            var keywordToExtend = keywords[i];
                            var regexToExtend = regexes[i];
                            var timeToExtend = timeToExtends[i];

                            // マッチングする
                            var match = false;

                            if (!spell.RegexEnabled ||
                                regexToExtend == null)
                            {
                                if (!string.IsNullOrWhiteSpace(keywordToExtend))
                                {
                                    match = logLine.ToUpper().Contains(keywordToExtend.ToUpper());
                                }
                            }
                            else
                            {
                                match = regexToExtend.Match(logLine).Success;
                            }

                            if (!match)
                            {
                                continue;
                            }

                            var now = DateTime.Now;

                            // リキャストタイムを延長する
                            var newSchedule = spell.CompleteScheduledTime.AddSeconds(timeToExtend);
                            spell.BeforeDone = false;
                            spell.UpdateDone = false;

                            if (spell.ExtendBeyondOriginalRecastTime)
                            {
                                if (spell.UpperLimitOfExtension > 0)
                                {
                                    var newDuration = (newSchedule - now).TotalSeconds;
                                    if (newDuration > (double)spell.UpperLimitOfExtension)
                                    {
                                        newSchedule = newSchedule.AddSeconds(
                                            (newDuration - (double)spell.UpperLimitOfExtension) * -1);
                                    }
                                }
                            }
                            else
                            {
                                var newDuration = (newSchedule - now).TotalSeconds;
                                if (newDuration > (double)spell.RecastTime)
                                {
                                    newSchedule = newSchedule.AddSeconds(
                                        (newDuration - (double)spell.RecastTime) * -1);
                                }
                            }

                            spell.MatchDateTime = now;
                            spell.CompleteScheduledTime = newSchedule;

                            notifyNeeded = true;
                        }
                    }
                    // end if 延長マッチング

                    // ACT標準のSpellTimerに変更を通知する
                    if (notifyNeeded)
                    {
                        this.updateNormalSpellTimer(spell, false);
                        this.notifyNormalSpellTimer(spell);
                    }
                }
                // end loop spells
            }

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

                // Repeat対象のSpellを更新する
                if (spell.RepeatEnabled &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (DateTime.Now >= spell.MatchDateTime.AddSeconds(spell.RecastTime))
                    {
                        spell.MatchDateTime = DateTime.Now;
                        spell.UpdateDone = false;
                        spell.OverDone = false;
                        spell.TimeupDone = false;
                    }
                }

                // n秒後のSoundを再生する
                if (spell.OverTime > 0 &&
                    !spell.OverDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    var over = spell.MatchDateTime.AddSeconds(spell.OverTime);

                    if (DateTime.Now >= over)
                    {
                        this.Play(spell.OverSound);
                        if (!string.IsNullOrWhiteSpace(spell.OverTextToSpeak))
                        {
                            var tts = spell.RegexEnabled && regex != null ?
                                regex.Replace(spell.MatchedLog, spell.OverTextToSpeak) :
                                spell.OverTextToSpeak;
                            this.Play(tts);
                        }

                        spell.OverDone = true;
                    }
                }

                // リキャストn秒前のSoundを再生する
                if (spell.BeforeTime > 0 &&
                    !spell.BeforeDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (spell.CompleteScheduledTime > DateTime.MinValue)
                    {
                        var before = spell.CompleteScheduledTime.AddSeconds(spell.BeforeTime * -1);

                        if (DateTime.Now >= before)
                        {
                            this.Play(spell.BeforeSound);
                            if (!string.IsNullOrWhiteSpace(spell.BeforeTextToSpeak))
                            {
                                var tts = spell.RegexEnabled && regex != null ?
                                    regex.Replace(spell.MatchedLog, spell.BeforeTextToSpeak) :
                                    spell.BeforeTextToSpeak;
                                this.Play(tts);
                            }

                            spell.BeforeDone = true;
                        }
                    }
                }

                // リキャスト完了のSoundを再生する
                if (spell.RecastTime > 0 &&
                    !spell.TimeupDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (spell.CompleteScheduledTime > DateTime.MinValue &&
                        DateTime.Now >= spell.CompleteScheduledTime)
                    {
                        this.Play(spell.TimeupSound);
                        if (!string.IsNullOrWhiteSpace(spell.TimeupTextToSpeak))
                        {
                            var tts = spell.RegexEnabled && regex != null ?
                                regex.Replace(spell.MatchedLog, spell.TimeupTextToSpeak) :
                                spell.TimeupTextToSpeak;
                            this.Play(tts);
                        }

                        spell.TimeupDone = true;
                    }
                }

                // インスタンス化したスペルを削除する
                if (spell.IsInstance)
                {
                    var ttl = Settings.Default.TimeOfHideSpell;
                    if (ttl < 1)
                    {
                        ttl = 60.0d;
                    }

                    if ((DateTime.Now - spell.CompleteScheduledTime).TotalSeconds >= (ttl + 0.05d))
                    {
                        SpellTimerTable.RemoveSpell(spell);
                    }
                }
            }

#if false
            Parallel.ForEach(spells, (spell) =>
            {
            }); // end loop spells
#endif
        }
 /// <summary>
 /// 指定したスペルをコレクションから除去する
 /// </summary>
 /// <param name="spell">除去するスペル</param>
 public static void RemoveSpell(
     SpellTimer spell)
 {
     lock (lockObject)
     {
         table.Remove(spell);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource">データソース</param>
        private void ShowDetail(
            SpellTimer dataSource)
        {
            var src = dataSource;

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

            this.DetailGroupBox.Visible = true;

            this.PanelNameTextBox.Text           = src.Panel;
            this.SpellTitleTextBox.Text          = src.SpellTitle;
            this.DisplayNoNumericUpDown.Value    = src.DisplayNo;
            this.KeywordTextBox.Text             = src.Keyword;
            this.RegexEnabledCheckBox.Checked    = src.RegexEnabled;
            this.RecastTimeNumericUpDown.Value   = src.RecastTime;
            this.RepeatCheckBox.Checked          = src.RepeatEnabled;
            this.ShowProgressBarCheckBox.Checked = src.ProgressBarVisible;

            this.MatchSoundComboBox.SelectedValue = src.MatchSound;
            this.MatchTextToSpeakTextBox.Text     = src.MatchTextToSpeak;

            this.OverSoundComboBox.SelectedValue = src.OverSound;
            this.OverTextToSpeakTextBox.Text     = src.OverTextToSpeak;
            this.OverTimeNumericUpDown.Value     = src.OverTime;

            this.TimeupSoundComboBox.SelectedValue = src.TimeupSound;
            this.TimeupTextToSpeakTextBox.Text     = src.TimeupTextToSpeak;

            this.IsReverseCheckBox.Checked = src.IsReverse;
            this.DontHideCheckBox.Checked  = src.DontHide;

            this.SpellVisualSetting.TextFont = new Font(
                src.FontFamily,
                src.FontSize,
                (FontStyle)src.FontStyle);
            this.SpellVisualSetting.BarColor = string.IsNullOrWhiteSpace(src.BarColor) ?
                                               Settings.Default.ProgressBarColor :
                                               src.BarColor.FromHTML();
            this.SpellVisualSetting.BarOutlineColor = string.IsNullOrWhiteSpace(src.BarOutlineColor) ?
                                                      Settings.Default.ProgressBarOutlineColor :
                                                      src.BarOutlineColor.FromHTML();
            this.SpellVisualSetting.FontColor = string.IsNullOrWhiteSpace(src.FontColor) ?
                                                Settings.Default.FontColor :
                                                src.FontColor.FromHTML();
            this.SpellVisualSetting.FontOutlineColor = string.IsNullOrWhiteSpace(src.FontOutlineColor) ?
                                                       Settings.Default.FontOutlineColor :
                                                       src.FontOutlineColor.FromHTML();
            this.SpellVisualSetting.BarSize         = new Size(src.BarWidth, src.BarHeight);
            this.SpellVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                                                      Settings.Default.BackgroundColor :
                                                      Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.SpellVisualSetting.RefreshSampleImage();

            // データソースをタグに突っ込んでおく
            this.DetailGroupBox.Tag = src;
        }
        /// <summary>
        /// Spellをマッチングする
        /// </summary>
        /// <param name="spells">Spell</param>
        /// <param name="logLines">ログ</param>
        private void MatchSpells(
            SpellTimer[] spells,
            string[] logLines)
        {
            Parallel.ForEach(spells, (spell) =>
            {
                var regex = spell.Regex;

                // マッチする?
                foreach (var logLine in logLines)
                {
                    // 正規表現が無効?
                    if (!spell.RegexEnabled ||
                        regex == null)
                    {
                        var keyword = spell.KeywordReplaced;
                        if (string.IsNullOrWhiteSpace(keyword))
                        {
                            continue;
                        }

                        // キーワードが含まれるか?
                        if (logLine.ToUpper().Contains(
                            keyword.ToUpper()))
                        {
                            // ヒットしたログを格納する
                            spell.MatchedLog = logLine;

                            spell.SpellTitleReplaced = spell.SpellTitle;
                            spell.MatchDateTime = DateTime.Now;
                            spell.OverDone = false;
                            spell.BeforeDone = false;
                            spell.TimeupDone = false;
                            spell.CompleteScheduledTime = spell.MatchDateTime.AddSeconds(spell.RecastTime);

                            // マッチ時点のサウンドを再生する
                            this.Play(spell.MatchSound);
                            this.Play(spell.MatchTextToSpeak);
                        }
                    }
                    else
                    {
                        // 正規表現でマッチングする
                        var match = regex.Match(logLine);
                        if (match.Success)
                        {
                            // ヒットしたログを格納する
                            spell.MatchedLog = logLine;

                            // 置換したスペル名を格納する
                            spell.SpellTitleReplaced = match.Result(spell.SpellTitle);

                            spell.MatchDateTime = DateTime.Now;
                            spell.OverDone = false;
                            spell.BeforeDone = false;
                            spell.TimeupDone = false;
                            spell.CompleteScheduledTime = spell.MatchDateTime.AddSeconds(spell.RecastTime);

                            // マッチ時点のサウンドを再生する
                            this.Play(spell.MatchSound);

                            if (!string.IsNullOrWhiteSpace(spell.MatchTextToSpeak))
                            {
                                var tts = match.Result(spell.MatchTextToSpeak);
                                this.Play(tts);
                            }
                        }
                    }

                    // 延長をマッチングする
                    if (spell.MatchDateTime > DateTime.MinValue)
                    {
                        var keywords = new string[] { spell.KeywordForExtendReplaced1, spell.KeywordForExtendReplaced2 };
                        var regexes = new Regex[] { spell.RegexForExtend1, spell.RegexForExtend2 };
                        var timeToExtends = new long[] { spell.RecastTimeExtending1, spell.RecastTimeExtending2 };

                        for (int i = 0; i < 2; i++)
                        {
                            var keywordToExtend = keywords[i];
                            var regexToExtend = regexes[i];
                            var timeToExtend = timeToExtends[i];

                            // マッチングする
                            var match = false;

                            if (!spell.RegexEnabled ||
                                regexToExtend == null)
                            {
                                if (!string.IsNullOrWhiteSpace(keywordToExtend))
                                {
                                    match = logLine.ToUpper().Contains(keywordToExtend.ToUpper());
                                }
                            }
                            else
                            {
                                match = regexToExtend.Match(logLine).Success;
                            }

                            if (!match)
                            {
                                continue;
                            }

                            // リキャストタイムを延長する
                            var newSchedule = spell.CompleteScheduledTime.AddSeconds(timeToExtend);
                            spell.BeforeDone = false;

                            if (spell.ExtendBeyondOriginalRecastTime)
                            {
                                if (spell.UpperLimitOfExtension > 0)
                                {
                                    var newDuration = (newSchedule - DateTime.Now).TotalSeconds;
                                    if (newDuration > (double)spell.UpperLimitOfExtension)
                                    {
                                        newSchedule = newSchedule.AddSeconds(
                                            (newDuration - (double)spell.UpperLimitOfExtension) * -1);
                                    }
                                }
                            }
                            else
                            {
                                var newDuration = (newSchedule - DateTime.Now).TotalSeconds;
                                if (newDuration > (double)spell.RecastTime)
                                {
                                    newSchedule = newSchedule.AddSeconds(
                                        (newDuration - (double)spell.RecastTime) * -1);
                                }
                            }

                            spell.CompleteScheduledTime = newSchedule;
                        }
                    }
                    // end if 延長マッチング
                }
                // end foreach マッチング

                // Repeat対象のSpellを更新する
                if (spell.RepeatEnabled &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (DateTime.Now >= spell.MatchDateTime.AddSeconds(spell.RecastTime))
                    {
                        spell.MatchDateTime = DateTime.Now;
                        spell.OverDone = false;
                        spell.TimeupDone = false;
                    }
                }

                // n秒後のSoundを再生する
                if (spell.OverTime > 0 &&
                    !spell.OverDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    var over = spell.MatchDateTime.AddSeconds(spell.OverTime);

                    if (DateTime.Now >= over)
                    {
                        this.Play(spell.OverSound);
                        if (!string.IsNullOrWhiteSpace(spell.OverTextToSpeak))
                        {
                            var tts = spell.RegexEnabled && regex != null ?
                                regex.Replace(spell.MatchedLog, spell.OverTextToSpeak) :
                                spell.OverTextToSpeak;
                            this.Play(tts);
                        }

                        spell.OverDone = true;
                    }
                }

                // リキャストn秒前のSoundを再生する
                if (spell.BeforeTime > 0 &&
                    !spell.BeforeDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (spell.CompleteScheduledTime > DateTime.MinValue)
                    {
                        var before = spell.CompleteScheduledTime.AddSeconds(spell.BeforeTime * -1);

                        if (DateTime.Now >= before)
                        {
                            this.Play(spell.BeforeSound);
                            if (!string.IsNullOrWhiteSpace(spell.BeforeTextToSpeak))
                            {
                                var tts = spell.RegexEnabled && regex != null ?
                                    regex.Replace(spell.MatchedLog, spell.BeforeTextToSpeak) :
                                    spell.BeforeTextToSpeak;
                                this.Play(tts);
                            }

                            spell.BeforeDone = true;
                        }
                    }
                }

                // リキャスト完了のSoundを再生する
                if (spell.RecastTime > 0 &&
                    !spell.TimeupDone &&
                    spell.MatchDateTime > DateTime.MinValue)
                {
                    if (spell.CompleteScheduledTime > DateTime.MinValue &&
                        DateTime.Now >= spell.CompleteScheduledTime)
                    {
                        this.Play(spell.TimeupSound);
                        if (!string.IsNullOrWhiteSpace(spell.TimeupTextToSpeak))
                        {
                            var tts = spell.RegexEnabled && regex != null ?
                                regex.Replace(spell.MatchedLog, spell.TimeupTextToSpeak) :
                                spell.TimeupTextToSpeak;
                            this.Play(tts);
                        }

                        spell.TimeupDone = true;
                    }
                }
            }); // end loop spells
        }
Exemplo n.º 14
0
        /// <summary>
        /// 定義のインスタンス(表示用のコピー)を生成する
        /// </summary>
        /// <param name="element">インスタンス化する定義</param>
        /// <returns>生成されたインスタンス</returns>
        public static SpellTimer CreateInstanceByElement(
            SpellTimer element)
        {
            var instance = new SpellTimer();

            instance.ID                             = Table.Max(x => x.ID) + 1;
            instance.guid                           = Guid.NewGuid();
            instance.Panel                          = element.Panel;
            instance.SpellTitle                     = element.SpellTitle;
            instance.SpellIcon                      = element.SpellIcon;
            instance.SpellIconSize                  = element.SpellIconSize;
            instance.Keyword                        = element.Keyword;
            instance.KeywordForExtend1              = element.KeywordForExtend1;
            instance.KeywordForExtend2              = element.KeywordForExtend2;
            instance.RecastTime                     = element.RecastTime;
            instance.RecastTimeExtending1           = element.RecastTimeExtending1;
            instance.RecastTimeExtending2           = element.RecastTimeExtending2;
            instance.ExtendBeyondOriginalRecastTime = element.ExtendBeyondOriginalRecastTime;
            instance.UpperLimitOfExtension          = element.UpperLimitOfExtension;
            instance.RepeatEnabled                  = element.RepeatEnabled;
            instance.ProgressBarVisible             = element.ProgressBarVisible;
            instance.MatchSound                     = element.MatchSound;
            instance.MatchTextToSpeak               = element.MatchTextToSpeak;
            instance.OverSound                      = element.OverSound;
            instance.OverTextToSpeak                = element.OverTextToSpeak;
            instance.OverTime                       = element.OverTime;
            instance.BeforeSound                    = element.BeforeSound;
            instance.BeforeTextToSpeak              = element.BeforeTextToSpeak;
            instance.BeforeTime                     = element.BeforeTime;
            instance.TimeupSound                    = element.TimeupSound;
            instance.TimeupTextToSpeak              = element.TimeupTextToSpeak;
            instance.MatchDateTime                  = element.MatchDateTime;
            instance.TimeupHide                     = element.TimeupHide;
            instance.IsReverse                      = element.IsReverse;
            instance.Font                           = element.Font;
            instance.FontFamily                     = element.FontFamily;
            instance.FontSize                       = element.FontSize;
            instance.FontStyle                      = element.FontStyle;
            instance.FontColor                      = element.FontColor;
            instance.FontOutlineColor               = element.FontOutlineColor;
            instance.BarColor                       = element.BarColor;
            instance.BarOutlineColor                = element.BarOutlineColor;
            instance.BarWidth                       = element.BarWidth;
            instance.BarHeight                      = element.BarHeight;
            instance.BackgroundColor                = element.BackgroundColor;
            instance.BackgroundAlpha                = element.BackgroundAlpha;
            instance.DontHide                       = element.DontHide;
            instance.HideSpellName                  = element.HideSpellName;
            instance.OverlapRecastTime              = element.OverlapRecastTime;
            instance.ReduceIconBrightness           = element.ReduceIconBrightness;
            instance.RegexEnabled                   = element.RegexEnabled;
            instance.JobFilter                      = element.JobFilter;
            instance.ZoneFilter                     = element.ZoneFilter;
            instance.TimersMustRunningForStart      = element.TimersMustRunningForStart;
            instance.TimersMustStoppingForStart     = element.TimersMustStoppingForStart;
            instance.Enabled                        = element.Enabled;

            instance.MatchedLog                = element.MatchedLog;
            instance.Regex                     = element.Regex;
            instance.RegexPattern              = element.RegexPattern;
            instance.KeywordReplaced           = element.KeywordReplaced;
            instance.RegexForExtend1           = element.RegexForExtend1;
            instance.RegexForExtendPattern1    = element.RegexForExtendPattern1;
            instance.KeywordForExtendReplaced1 = element.KeywordForExtendReplaced1;
            instance.RegexForExtend2           = element.RegexForExtend2;
            instance.RegexForExtendPattern2    = element.RegexForExtendPattern2;
            instance.KeywordForExtendReplaced2 = element.KeywordForExtendReplaced2;

            instance.ToInstance = false;
            instance.IsInstance = true;

            lock (lockObject)
            {
                table.Add(instance);

                var array = new SpellTimer[enabledTable.Length + 1];
                Array.Copy(enabledTable, array, enabledTable.Length);
                array[enabledTable.Length] = instance;
                enabledTable = array;
            }

            return(instance);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 詳細を表示する
        /// </summary>
        /// <param name="dataSource">データソース</param>
        private void ShowDetail(
            SpellTimer dataSource)
        {
            var src = dataSource;
            if (src == null)
            {
                this.DetailGroupBox.Visible = false;
                return;
            }

            this.DetailGroupBox.Visible = true;

            this.PanelNameTextBox.Text = src.Panel;
            this.SpellTitleTextBox.Text = src.SpellTitle;
            this.SpellIconComboBox.SelectedValue = src.SpellIcon;
            this.SpellIconSizeUpDown.Value = src.SpellIconSize;
            this.DisplayNoNumericUpDown.Value = src.DisplayNo;
            this.KeywordTextBox.Text = src.Keyword;
            this.RegexEnabledCheckBox.Checked = src.RegexEnabled;
            this.RecastTimeNumericUpDown.Value = src.RecastTime;
            this.RepeatCheckBox.Checked = src.RepeatEnabled;
            this.ShowProgressBarCheckBox.Checked = src.ProgressBarVisible;

            this.KeywordToExpand1TextBox.Text = src.KeywordForExtend1;
            this.ExpandSecounds1NumericUpDown.Value = src.RecastTimeExtending1;
            this.KeywordToExpand2TextBox.Text = src.KeywordForExtend2;
            this.ExpandSecounds2NumericUpDown.Value = src.RecastTimeExtending2;
            this.ExtendBeyondOriginalRecastTimeCheckBox.Checked = src.ExtendBeyondOriginalRecastTime;
            this.UpperLimitOfExtensionNumericUpDown.Value = src.UpperLimitOfExtension;

            this.MatchSoundComboBox.SelectedValue = src.MatchSound;
            this.MatchTextToSpeakTextBox.Text = src.MatchTextToSpeak;

            this.OverSoundComboBox.SelectedValue = src.OverSound;
            this.OverTextToSpeakTextBox.Text = src.OverTextToSpeak;
            this.OverTimeNumericUpDown.Value = src.OverTime;

            this.BeforeSoundComboBox.SelectedValue = src.BeforeSound;
            this.BeforeTextToSpeakTextBox.Text = src.BeforeTextToSpeak;
            this.BeforeTimeNumericUpDown.Value = src.BeforeTime;

            this.TimeupSoundComboBox.SelectedValue = src.TimeupSound;
            this.TimeupTextToSpeakTextBox.Text = src.TimeupTextToSpeak;

            this.IsReverseCheckBox.Checked = src.IsReverse;
            this.DontHideCheckBox.Checked = src.DontHide;
            this.HideSpellNameCheckBox.Checked = src.HideSpellName;
            this.OverlapRecastTimeCheckBox.Checked = src.OverlapRecastTime;
            this.ReduceIconBrightnessCheckBox.Checked = src.ReduceIconBrightness;
            this.ToInstanceCheckBox.Checked = src.ToInstance;

            this.SpellVisualSetting.SetFontInfo(src.Font);
            this.SpellVisualSetting.BarColor = string.IsNullOrWhiteSpace(src.BarColor) ?
                Settings.Default.ProgressBarColor :
                src.BarColor.FromHTML();
            this.SpellVisualSetting.BarOutlineColor = string.IsNullOrWhiteSpace(src.BarOutlineColor) ?
                Settings.Default.ProgressBarOutlineColor :
                src.BarOutlineColor.FromHTML();
            this.SpellVisualSetting.FontColor = string.IsNullOrWhiteSpace(src.FontColor) ?
                Settings.Default.FontColor :
                src.FontColor.FromHTML();
            this.SpellVisualSetting.FontOutlineColor = string.IsNullOrWhiteSpace(src.FontOutlineColor) ?
                Settings.Default.FontOutlineColor :
                src.FontOutlineColor.FromHTML();
            this.SpellVisualSetting.BarSize = new Size(src.BarWidth, src.BarHeight);
            this.SpellVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                Settings.Default.BackgroundColor :
                Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.SpellVisualSetting.SpellIcon = src.SpellIcon;
            this.SpellVisualSetting.SpellIconSize = src.SpellIconSize;
            this.SpellVisualSetting.HideSpellName = src.HideSpellName;
            this.SpellVisualSetting.OverlapRecastTime = src.OverlapRecastTime;

            this.SpellVisualSetting.RefreshSampleImage();

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

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

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

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

                nr.ID = SpellTimerTable.Table.Any() ?
                    SpellTimerTable.Table.Max(x => x.ID) + 1 :
                    1;
                nr.guid = Guid.NewGuid();
                nr.Panel = "General";
                nr.SpellTitle = "New Spell";
                nr.SpellIcon = string.Empty;
                nr.SpellIconSize = 24;
                nr.ProgressBarVisible = true;
                nr.FontColor = Settings.Default.FontColor.ToHTML();
                nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
                nr.BarColor = Settings.Default.ProgressBarColor.ToHTML();
                nr.BarOutlineColor = Settings.Default.ProgressBarOutlineColor.ToHTML();
                nr.FontFamily = Settings.Default.Font.Name;
                nr.FontSize = Settings.Default.Font.Size;
                nr.FontStyle = (int)Settings.Default.Font.Style;
                nr.BarWidth = Settings.Default.ProgressBarSize.Width;
                nr.BarHeight = Settings.Default.ProgressBarSize.Height;
                nr.BackgroundColor = Settings.Default.BackgroundColor.ToHTML();
                nr.JobFilter = string.Empty;
                nr.ZoneFilter = string.Empty;
                nr.TimersMustRunningForStart = new Guid[0];
                nr.TimersMustStoppingForStart = new Guid[0];

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

                    if (baseRow != null)
                    {
                        nr.Panel = baseRow.Panel;
                        nr.SpellTitle = baseRow.SpellTitle + " New";
                        nr.SpellIcon = baseRow.SpellIcon;
                        nr.SpellIconSize = baseRow.SpellIconSize;
                        nr.Keyword = baseRow.Keyword;
                        nr.RegexEnabled = baseRow.RegexEnabled;
                        nr.RecastTime = baseRow.RecastTime;
                        nr.KeywordForExtend1 = baseRow.KeywordForExtend1;
                        nr.RecastTimeExtending1 = baseRow.RecastTimeExtending1;
                        nr.KeywordForExtend2 = baseRow.KeywordForExtend2;
                        nr.RecastTimeExtending2 = baseRow.RecastTimeExtending2;
                        nr.ExtendBeyondOriginalRecastTime = baseRow.ExtendBeyondOriginalRecastTime;
                        nr.UpperLimitOfExtension = baseRow.UpperLimitOfExtension;
                        nr.RepeatEnabled = baseRow.RepeatEnabled;
                        nr.ProgressBarVisible = baseRow.ProgressBarVisible;
                        nr.IsReverse = baseRow.IsReverse;
                        nr.FontColor = baseRow.FontColor;
                        nr.FontOutlineColor = baseRow.FontOutlineColor;
                        nr.BarColor = baseRow.BarColor;
                        nr.BarOutlineColor = baseRow.BarOutlineColor;
                        nr.DontHide = baseRow.DontHide;
                        nr.HideSpellName = baseRow.HideSpellName;
                        nr.OverlapRecastTime = baseRow.OverlapRecastTime;
                        nr.ReduceIconBrightness = baseRow.ReduceIconBrightness;
                        nr.FontFamily = baseRow.FontFamily;
                        nr.FontSize = baseRow.FontSize;
                        nr.FontStyle = baseRow.FontStyle;
                        nr.Font = baseRow.Font;
                        nr.BarWidth = baseRow.BarWidth;
                        nr.BarHeight = baseRow.BarHeight;
                        nr.BackgroundColor = baseRow.BackgroundColor;
                        nr.BackgroundAlpha = baseRow.BackgroundAlpha;
                        nr.JobFilter = baseRow.JobFilter;
                        nr.ZoneFilter = baseRow.ZoneFilter;
                        nr.TimersMustRunningForStart = baseRow.TimersMustRunningForStart;
                        nr.TimersMustStoppingForStart = baseRow.TimersMustStoppingForStart;
                        nr.ToInstance = baseRow.ToInstance;
                    }
                }

                nr.MatchDateTime = DateTime.MinValue;
                nr.UpdateDone = false;
                nr.Enabled = true;
                nr.DisplayNo = SpellTimerTable.Table.Any() ?
                    SpellTimerTable.Table.Max(x => x.DisplayNo) + 1 :
                    50;
                nr.Regex = null;
                nr.RegexPattern = string.Empty;
                SpellTimerTable.Table.Add(nr);

                SpellTimerTable.ClearReplacedKeywords();
                SpellTimerTable.RemoveAllInstanceSpells();
                SpellTimerTable.Save();

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

                // 親ノードがあれば追加する
                foreach (TreeNode item in this.SpellTimerTreeView.Nodes)
                {
                    if (item.Text == nr.Panel)
                    {
                        item.Nodes.Add(node);
                        this.SpellTimerTreeView.SelectedNode = node;
                        break;
                    }
                }

                // 親ノードがなかった
                if (this.SpellTimerTreeView.SelectedNode != node)
                {
                    var parentNode = new TreeNode(nr.Panel, new TreeNode[] { node })
                    {
                        Checked = true
                    };

                    this.SpellTimerTreeView.Nodes.Add(parentNode);
                    this.SpellTimerTreeView.SelectedNode = node;
                }

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

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

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

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

            this.DetailGroupBox.Visible = true;

            this.PanelNameTextBox.Text = src.Panel;
            this.SpellTitleTextBox.Text = src.SpellTitle;
            this.DisplayNoNumericUpDown.Value = src.DisplayNo;
            this.KeywordTextBox.Text = src.Keyword;
            this.RegexEnabledCheckBox.Checked = src.RegexEnabled;
            this.RecastTimeNumericUpDown.Value = src.RecastTime;
            this.RepeatCheckBox.Checked = src.RepeatEnabled;
            this.ShowProgressBarCheckBox.Checked = src.ProgressBarVisible;

            this.KeywordToExpand1TextBox.Text = src.KeywordForExtend1;
            this.ExpandSecounds1NumericUpDown.Value = src.RecastTimeExtending1;
            this.KeywordToExpand2TextBox.Text = src.KeywordForExtend2;
            this.ExpandSecounds2NumericUpDown.Value = src.RecastTimeExtending2;
            this.ExtendBeyondOriginalRecastTimeCheckBox.Checked = src.ExtendBeyondOriginalRecastTime;
            this.UpperLimitOfExtensionNumericUpDown.Value = src.UpperLimitOfExtension;

            this.MatchSoundComboBox.SelectedValue = src.MatchSound;
            this.MatchTextToSpeakTextBox.Text = src.MatchTextToSpeak;

            this.OverSoundComboBox.SelectedValue = src.OverSound;
            this.OverTextToSpeakTextBox.Text = src.OverTextToSpeak;
            this.OverTimeNumericUpDown.Value = src.OverTime;

            this.BeforeSoundComboBox.SelectedValue = src.BeforeSound;
            this.BeforeTextToSpeakTextBox.Text = src.BeforeTextToSpeak;
            this.BeforeTimeNumericUpDown.Value = src.BeforeTime;

            this.TimeupSoundComboBox.SelectedValue = src.TimeupSound;
            this.TimeupTextToSpeakTextBox.Text = src.TimeupTextToSpeak;

            this.IsReverseCheckBox.Checked = src.IsReverse;
            this.DontHideCheckBox.Checked = src.DontHide;

            this.SpellVisualSetting.SetFontInfo(src.Font);
            this.SpellVisualSetting.BarColor = string.IsNullOrWhiteSpace(src.BarColor) ?
                Settings.Default.ProgressBarColor :
                src.BarColor.FromHTML();
            this.SpellVisualSetting.BarOutlineColor = string.IsNullOrWhiteSpace(src.BarOutlineColor) ?
                Settings.Default.ProgressBarOutlineColor :
                src.BarOutlineColor.FromHTML();
            this.SpellVisualSetting.FontColor = string.IsNullOrWhiteSpace(src.FontColor) ?
                Settings.Default.FontColor :
                src.FontColor.FromHTML();
            this.SpellVisualSetting.FontOutlineColor = string.IsNullOrWhiteSpace(src.FontOutlineColor) ?
                Settings.Default.FontOutlineColor :
                src.FontOutlineColor.FromHTML();
            this.SpellVisualSetting.BarSize = new Size(src.BarWidth, src.BarHeight);
            this.SpellVisualSetting.BackgroundColor = string.IsNullOrWhiteSpace(src.BackgroundColor) ?
                Settings.Default.BackgroundColor :
                Color.FromArgb(src.BackgroundAlpha, src.BackgroundColor.FromHTML());

            this.SpellVisualSetting.RefreshSampleImage();

            // データソースをタグに突っ込んでおく
            this.DetailGroupBox.Tag = src;
        }
        /// <summary>
        /// 追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            lock (SpellTimerTable.Table)
            {
                var nr = new SpellTimer();

                nr.ID = SpellTimerTable.Table.Any() ?
                    SpellTimerTable.Table.Max(x => x.ID) + 1 :
                    1;
                nr.Panel = "General";
                nr.SpellTitle = "New Spell";
                nr.ProgressBarVisible = true;
                nr.FontColor = Settings.Default.FontColor.ToHTML();
                nr.FontOutlineColor = Settings.Default.FontOutlineColor.ToHTML();
                nr.BarColor = Settings.Default.ProgressBarColor.ToHTML();
                nr.BarOutlineColor = Settings.Default.ProgressBarOutlineColor.ToHTML();
                nr.FontFamily = Settings.Default.Font.Name;
                nr.FontSize = Settings.Default.Font.Size;
                nr.FontStyle = (int)Settings.Default.Font.Style;
                nr.BarWidth = Settings.Default.ProgressBarSize.Width;
                nr.BarHeight = Settings.Default.ProgressBarSize.Height;
                nr.BackgroundColor = Settings.Default.BackgroundColor.ToHTML();
                nr.JobFilter = string.Empty;
                nr.ZoneFilter = string.Empty;

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

                    if (baseRow != null)
                    {
                        nr.Panel = baseRow.Panel;
                        nr.SpellTitle = baseRow.SpellTitle + " New";
                        nr.Keyword = baseRow.Keyword;
                        nr.RegexEnabled = baseRow.RegexEnabled;
                        nr.RecastTime = baseRow.RecastTime;
                        nr.KeywordForExtend1 = baseRow.KeywordForExtend1;
                        nr.RecastTimeExtending1 = baseRow.RecastTimeExtending1;
                        nr.KeywordForExtend2 = baseRow.KeywordForExtend2;
                        nr.RecastTimeExtending2 = baseRow.RecastTimeExtending2;
                        nr.ExtendBeyondOriginalRecastTime = baseRow.ExtendBeyondOriginalRecastTime;
                        nr.UpperLimitOfExtension = baseRow.UpperLimitOfExtension;
                        nr.RepeatEnabled = baseRow.RepeatEnabled;
                        nr.ProgressBarVisible = baseRow.ProgressBarVisible;
                        nr.IsReverse = baseRow.IsReverse;
                        nr.FontColor = baseRow.FontColor;
                        nr.FontOutlineColor = baseRow.FontOutlineColor;
                        nr.BarColor = baseRow.BarColor;
                        nr.BarOutlineColor = baseRow.BarOutlineColor;
                        nr.DontHide = baseRow.DontHide;
                        nr.FontFamily = baseRow.FontFamily;
                        nr.FontSize = baseRow.FontSize;
                        nr.FontStyle = baseRow.FontStyle;
                        nr.Font = baseRow.Font;
                        nr.BarWidth = baseRow.BarWidth;
                        nr.BarHeight = baseRow.BarHeight;
                        nr.BackgroundColor = baseRow.BackgroundColor;
                        nr.BackgroundAlpha = baseRow.BackgroundAlpha;
                        nr.JobFilter = baseRow.JobFilter;
                        nr.ZoneFilter = baseRow.ZoneFilter;
                    }
                }

                nr.MatchDateTime = DateTime.MinValue;
                nr.Enabled = true;
                nr.DisplayNo = SpellTimerTable.Table.Any() ?
                    SpellTimerTable.Table.Max(x => x.DisplayNo) + 1 :
                    50;
                nr.Regex = null;
                nr.RegexPattern = string.Empty;
                SpellTimerTable.Table.Add(nr);

                SpellTimerTable.ClearReplacedKeywords();
                SpellTimerTable.Save();

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

                // 親ノードがあれば追加する
                foreach (TreeNode item in this.SpellTimerTreeView.Nodes)
                {
                    if (item.Text == nr.Panel)
                    {
                        item.Nodes.Add(node);
                        this.SpellTimerTreeView.SelectedNode = node;
                        break;
                    }
                }

                // 親ノードがなかった
                if (this.SpellTimerTreeView.SelectedNode != node)
                {
                    var parentNode = new TreeNode(nr.Panel, new TreeNode[] { node })
                    {
                        Checked = true
                    };

                    this.SpellTimerTreeView.Nodes.Add(parentNode);
                    this.SpellTimerTreeView.SelectedNode = node;
                }
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// ACT標準のスペルタイマーに通知する
        /// </summary>
        /// <param name="spellTimer">通知先に対応するスペルタイマー</param>
        public void notifyNormalSpellTimer(SpellTimer spellTimer)
        {
            if (!Settings.Default.EnabledNotifyNormalSpellTimer)
            {
                return;
            }

            var prefix = Settings.Default.NotifyNormalSpellTimerPrefix;
            var spellName = prefix + "spell_" + spellTimer.SpellTitle;
            ActGlobals.oFormSpellTimers.NotifySpell("attacker", spellName, false, "victim", false);
        }
        /// <summary>
        /// スペルパネルWindowを更新する
        /// </summary>
        /// <param name="spells">
        /// 対象のスペル</param>
        private void RefreshSpellPanelWindows(
            SpellTimer[] spells)
        {
            var panelNames = spells.Select(x => x.Panel.Trim()).Distinct();
            foreach (var name in panelNames)
            {
                var w = this.SpellTimerPanels.Where(x => x.PanelName == name).FirstOrDefault();
                if (w == null)
                {
                    w = new SpellTimerListWindow()
                    {
                        Title = "SpecialSpellTimer - " + name,
                        PanelName = name,
                    };

                    this.SpellTimerPanels.Add(w);

                    // クリックスルー?
                    if (Settings.Default.ClickThroughEnabled)
                    {
                        w.ToTransparentWindow();
                    }

                    w.Show();
                }

                w.SpellTimers = (
                    from x in spells
                    where
                    x.Panel.Trim() == name
                    select
                    x).ToArray();

                // ドラッグ中じゃない?
                if (!w.IsDragging)
                {
                    w.RefreshSpellTimer();
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 追加 Click
        /// </summary>
        /// <param name="sender">イベント発生元</param>
        /// <param name="e">イベント引数</param>
        private void AddButton_Click(object sender, EventArgs e)
        {
            lock (SpellTimerTable.Table)
            {
                var nr = new SpellTimer();

                nr.ID = SpellTimerTable.Table.Any() ?
                        SpellTimerTable.Table.Max(x => x.ID) + 1 :
                        1;
                nr.Panel              = "General";
                nr.SpellTitle         = "New Spell";
                nr.ProgressBarVisible = true;
                nr.FontColor          = Settings.Default.FontColor.ToHTML();
                nr.FontOutlineColor   = Settings.Default.FontOutlineColor.ToHTML();
                nr.BarColor           = Settings.Default.ProgressBarColor.ToHTML();
                nr.BarOutlineColor    = Settings.Default.ProgressBarOutlineColor.ToHTML();
                nr.FontFamily         = Settings.Default.Font.Name;
                nr.FontSize           = Settings.Default.Font.Size;
                nr.FontStyle          = (int)Settings.Default.Font.Style;
                nr.BarWidth           = Settings.Default.ProgressBarSize.Width;
                nr.BarHeight          = Settings.Default.ProgressBarSize.Height;
                nr.BackgroundColor    = Settings.Default.BackgroundColor.ToHTML();
                nr.JobFilter          = string.Empty;

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

                    if (baseRow != null)
                    {
                        nr.Panel              = baseRow.Panel;
                        nr.SpellTitle         = baseRow.SpellTitle + " New";
                        nr.Keyword            = baseRow.Keyword;
                        nr.RegexEnabled       = baseRow.RegexEnabled;
                        nr.RecastTime         = baseRow.RecastTime;
                        nr.RepeatEnabled      = baseRow.RepeatEnabled;
                        nr.ProgressBarVisible = baseRow.ProgressBarVisible;
                        nr.IsReverse          = baseRow.IsReverse;
                        nr.FontColor          = baseRow.FontColor;
                        nr.FontOutlineColor   = baseRow.FontOutlineColor;
                        nr.BarColor           = baseRow.BarColor;
                        nr.BarOutlineColor    = baseRow.BarOutlineColor;
                        nr.DontHide           = baseRow.DontHide;
                        nr.FontFamily         = baseRow.FontFamily;
                        nr.FontSize           = baseRow.FontSize;
                        nr.FontStyle          = baseRow.FontStyle;
                        nr.BarWidth           = baseRow.BarWidth;
                        nr.BarHeight          = baseRow.BarHeight;
                        nr.BackgroundColor    = baseRow.BackgroundColor;
                        nr.BackgroundAlpha    = baseRow.BackgroundAlpha;
                        nr.JobFilter          = baseRow.JobFilter;
                    }
                }

                nr.MatchDateTime = DateTime.MinValue;
                nr.Enabled       = true;
                nr.DisplayNo     = SpellTimerTable.Table.Any() ?
                                   SpellTimerTable.Table.Max(x => x.DisplayNo) + 1 :
                                   50;
                nr.Regex        = null;
                nr.RegexPattern = string.Empty;
                SpellTimerTable.Table.Add(nr);

                SpellTimerTable.Save();

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

                // 親ノードがあれば追加する
                foreach (TreeNode item in this.SpellTimerTreeView.Nodes)
                {
                    if (item.Text == nr.Panel)
                    {
                        item.Nodes.Add(node);
                        this.SpellTimerTreeView.SelectedNode = node;
                        break;
                    }
                }

                // 親ノードがなかった
                if (this.SpellTimerTreeView.SelectedNode != node)
                {
                    var parentNode = new TreeNode(nr.Panel, new TreeNode[] { node })
                    {
                        Checked = true
                    };

                    this.SpellTimerTreeView.Nodes.Add(parentNode);
                    this.SpellTimerTreeView.SelectedNode = node;
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 同じスペル表示名のインスタンスを取得するか新たに作成する
        /// </summary>
        /// <param name="spellTitle">スペル表示名</param>
        /// <param name="sourceSpell">インスタンスの元となるスペル</param>
        /// <returns>
        /// インスタンススペル</returns>
        public static SpellTimer GetOrAddInstance(
            string spellTitle,
            SpellTimer sourceSpell)
        {
            var instance = instanceSpells.GetOrAdd(
                spellTitle,
                (x) =>
            {
                var ns = new SpellTimer();

                ns.SpellTitleReplaced = x;

                ns.guid                           = Guid.NewGuid();
                ns.Panel                          = sourceSpell.Panel;
                ns.SpellTitle                     = sourceSpell.SpellTitle;
                ns.SpellIcon                      = sourceSpell.SpellIcon;
                ns.SpellIconSize                  = sourceSpell.SpellIconSize;
                ns.Keyword                        = sourceSpell.Keyword;
                ns.KeywordForExtend1              = sourceSpell.KeywordForExtend1;
                ns.KeywordForExtend2              = sourceSpell.KeywordForExtend2;
                ns.RecastTime                     = sourceSpell.RecastTime;
                ns.RecastTimeExtending1           = sourceSpell.RecastTimeExtending1;
                ns.RecastTimeExtending2           = sourceSpell.RecastTimeExtending2;
                ns.ExtendBeyondOriginalRecastTime = sourceSpell.ExtendBeyondOriginalRecastTime;
                ns.UpperLimitOfExtension          = sourceSpell.UpperLimitOfExtension;
                ns.RepeatEnabled                  = sourceSpell.RepeatEnabled;
                ns.ProgressBarVisible             = sourceSpell.ProgressBarVisible;
                ns.MatchSound                     = sourceSpell.MatchSound;
                ns.MatchTextToSpeak               = sourceSpell.MatchTextToSpeak;
                ns.OverSound                      = sourceSpell.OverSound;
                ns.OverTextToSpeak                = sourceSpell.OverTextToSpeak;
                ns.OverTime                       = sourceSpell.OverTime;
                ns.BeforeSound                    = sourceSpell.BeforeSound;
                ns.BeforeTextToSpeak              = sourceSpell.BeforeTextToSpeak;
                ns.BeforeTime                     = sourceSpell.BeforeTime;
                ns.TimeupSound                    = sourceSpell.TimeupSound;
                ns.TimeupTextToSpeak              = sourceSpell.TimeupTextToSpeak;
                ns.MatchDateTime                  = sourceSpell.MatchDateTime;
                ns.TimeupHide                     = sourceSpell.TimeupHide;
                ns.IsReverse                      = sourceSpell.IsReverse;
                ns.Font                           = sourceSpell.Font;
                ns.FontFamily                     = sourceSpell.FontFamily;
                ns.FontSize                       = sourceSpell.FontSize;
                ns.FontStyle                      = sourceSpell.FontStyle;
                ns.FontColor                      = sourceSpell.FontColor;
                ns.FontOutlineColor               = sourceSpell.FontOutlineColor;
                ns.BarColor                       = sourceSpell.BarColor;
                ns.BarOutlineColor                = sourceSpell.BarOutlineColor;
                ns.BarWidth                       = sourceSpell.BarWidth;
                ns.BarHeight                      = sourceSpell.BarHeight;
                ns.BackgroundColor                = sourceSpell.BackgroundColor;
                ns.BackgroundAlpha                = sourceSpell.BackgroundAlpha;
                ns.DontHide                       = sourceSpell.DontHide;
                ns.HideSpellName                  = sourceSpell.HideSpellName;
                ns.OverlapRecastTime              = sourceSpell.OverlapRecastTime;
                ns.ReduceIconBrightness           = sourceSpell.ReduceIconBrightness;
                ns.RegexEnabled                   = sourceSpell.RegexEnabled;
                ns.JobFilter                      = sourceSpell.JobFilter;
                ns.ZoneFilter                     = sourceSpell.ZoneFilter;
                ns.TimersMustRunningForStart      = sourceSpell.TimersMustRunningForStart;
                ns.TimersMustStoppingForStart     = sourceSpell.TimersMustStoppingForStart;
                ns.Enabled                        = sourceSpell.Enabled;

                ns.MatchedLog                = sourceSpell.MatchedLog;
                ns.Regex                     = sourceSpell.Regex;
                ns.RegexPattern              = sourceSpell.RegexPattern;
                ns.KeywordReplaced           = sourceSpell.KeywordReplaced;
                ns.RegexForExtend1           = sourceSpell.RegexForExtend1;
                ns.RegexForExtendPattern1    = sourceSpell.RegexForExtendPattern1;
                ns.KeywordForExtendReplaced1 = sourceSpell.KeywordForExtendReplaced1;
                ns.RegexForExtend2           = sourceSpell.RegexForExtend2;
                ns.RegexForExtendPattern2    = sourceSpell.RegexForExtendPattern2;
                ns.KeywordForExtendReplaced2 = sourceSpell.KeywordForExtendReplaced2;

                ns.ToInstance = false;
                ns.IsInstance = true;

                return(ns);
            });

            lock (instance)
            {
                instance.CompleteScheduledTime = DateTime.MinValue;

                instanceSpells.TryAdd(
                    instance.SpellTitleReplaced,
                    instance);

                // スペルテーブル本体に登録する
                lock (lockObject)
                {
                    instance.ID = Table.Max(y => y.ID) + 1;

                    table.Add(instance);

                    var array = new SpellTimer[enabledTable.Length + 1];
                    Array.Copy(enabledTable, array, enabledTable.Length);
                    array[enabledTable.Length] = instance;
                    enabledTable = array;
                }
            }

            return(instance);
        }
        /// <summary>
        /// 定義のインスタンス(表示用のコピー)を生成する
        /// </summary>
        /// <param name="element">インスタンス化する定義</param>
        /// <returns>生成されたインスタンス</returns>
        public static SpellTimer CreateInstanceByElement(
            SpellTimer element)
        {
            var instance = new SpellTimer();

            instance.ID = Table.Max(x => x.ID) + 1;
            instance.guid = Guid.NewGuid();
            instance.Panel = element.Panel;
            instance.SpellTitle = element.SpellTitle;
            instance.SpellIcon = element.SpellIcon;
            instance.SpellIconSize = element.SpellIconSize;
            instance.Keyword = element.Keyword;
            instance.KeywordForExtend1 = element.KeywordForExtend1;
            instance.KeywordForExtend2 = element.KeywordForExtend2;
            instance.RecastTime = element.RecastTime;
            instance.RecastTimeExtending1 = element.RecastTimeExtending1;
            instance.RecastTimeExtending2 = element.RecastTimeExtending2;
            instance.ExtendBeyondOriginalRecastTime = element.ExtendBeyondOriginalRecastTime;
            instance.UpperLimitOfExtension = element.UpperLimitOfExtension;
            instance.RepeatEnabled = element.RepeatEnabled;
            instance.ProgressBarVisible = element.ProgressBarVisible;
            instance.MatchSound = element.MatchSound;
            instance.MatchTextToSpeak = element.MatchTextToSpeak;
            instance.OverSound = element.OverSound;
            instance.OverTextToSpeak = element.OverTextToSpeak;
            instance.OverTime = element.OverTime;
            instance.BeforeSound = element.BeforeSound;
            instance.BeforeTextToSpeak = element.BeforeTextToSpeak;
            instance.BeforeTime = element.BeforeTime;
            instance.TimeupSound = element.TimeupSound;
            instance.TimeupTextToSpeak = element.TimeupTextToSpeak;
            instance.MatchDateTime = element.MatchDateTime;
            instance.TimeupHide = element.TimeupHide;
            instance.IsReverse = element.IsReverse;
            instance.Font = element.Font;
            instance.FontFamily = element.FontFamily;
            instance.FontSize = element.FontSize;
            instance.FontStyle = element.FontStyle;
            instance.FontColor = element.FontColor;
            instance.FontOutlineColor = element.FontOutlineColor;
            instance.BarColor = element.BarColor;
            instance.BarOutlineColor = element.BarOutlineColor;
            instance.BarWidth = element.BarWidth;
            instance.BarHeight = element.BarHeight;
            instance.BackgroundColor = element.BackgroundColor;
            instance.BackgroundAlpha = element.BackgroundAlpha;
            instance.DontHide = element.DontHide;
            instance.HideSpellName = element.HideSpellName;
            instance.OverlapRecastTime = element.OverlapRecastTime;
            instance.ReduceIconBrightness = element.ReduceIconBrightness;
            instance.RegexEnabled = element.RegexEnabled;
            instance.JobFilter = element.JobFilter;
            instance.ZoneFilter = element.ZoneFilter;
            instance.TimersMustRunningForStart = element.TimersMustRunningForStart;
            instance.TimersMustStoppingForStart = element.TimersMustStoppingForStart;
            instance.Enabled = element.Enabled;

            instance.MatchedLog = element.MatchedLog;
            instance.Regex = element.Regex;
            instance.RegexPattern = element.RegexPattern;
            instance.KeywordReplaced = element.KeywordReplaced;
            instance.RegexForExtend1 = element.RegexForExtend1;
            instance.RegexForExtendPattern1 = element.RegexForExtendPattern1;
            instance.KeywordForExtendReplaced1 = element.KeywordForExtendReplaced1;
            instance.RegexForExtend2 = element.RegexForExtend2;
            instance.RegexForExtendPattern2 = element.RegexForExtendPattern2;
            instance.KeywordForExtendReplaced2 = element.KeywordForExtendReplaced2;

            instance.ToInstance = false;
            instance.IsInstance = true;

            lock (lockObject)
            {
                table.Add(instance);

                var array = new SpellTimer[enabledTable.Length + 1];
                Array.Copy(enabledTable, array, enabledTable.Length);
                array[enabledTable.Length] = instance;
                enabledTable = array;
            }

            return instance;
        }