public bool Display(Utils.LogType logType) { bool append = false; switch (logType) { case Utils.LogType.CoinLogging: append = this.coinLoggingToolStripMenuItem.Checked; break; case Utils.LogType.Connection: append = this.iPAddressesToolStripMenuItem.Checked; break; case Utils.LogType.DeleteAccount: append = this.accountDeleteToolStripMenuItem.Checked; break; case Utils.LogType.DeathCreature: append = this.deathCreatureToolStripMenuItem.Checked; break; case Utils.LogType.DeathLair: append = deathLairToolStripMenuItem.Checked; break; case Utils.LogType.DeathPlayer: append = this.deathPlayersToolStripMenuItem.Checked; break; case Utils.LogType.Disconnect: append = this.disconnectToolStripMenuItem.Checked; break; case Utils.LogType.ExceptionDetail: append = false; // all exceptions are logged to a separate log break; case Utils.LogType.ExperienceLevelGain: append = this.levelGainToolStripMenuItem.Checked; break; case Utils.LogType.ExperienceMeleeKill: append = this.meleeKillToolStripMenuItem.Checked; break; case Utils.LogType.ExperienceSpellAEKill: append = this.spellAEKillToolStripMenuItem.Checked; break; case Utils.LogType.ExperienceSpellCasting: append = this.spellcastingToolStripMenuItem.Checked; break; case Utils.LogType.ExperienceSpellKill: append = this.spellKillToolStripMenuItem.Checked; break; case Utils.LogType.ExperienceTraining: append = this.trainingToolStripMenuItem.Checked; break; case Utils.LogType.CombatDamageToCreature: append = this.combatDamageToCreatureToolStripMenuItem.Checked; break; case Utils.LogType.CombatDamageToPlayer: append = this.combatDamageToPlayerToolStripMenuItem.Checked; break; case Utils.LogType.CommandAllPlayer: append = this.allPlayerCommandsToolStripMenuItem.Checked; break; case Utils.LogType.CommandFailure: append = this.commandFailureToolStripMenuItem.Checked; break; case Utils.LogType.CommandImmortal: append = this.immortalToolStripMenuItem.Checked; break; case Utils.LogType.CriticalCombatDamageToCreature: append = this.criticalCombatDamageToCreatureToolStripMenuItem.Checked; break; case Utils.LogType.CriticalCombatDamageToPlayer: append = this.criticalCombatDamageToPlayerToolStripMenuItem.Checked; break; case Utils.LogType.DeletePlayer: append = this.playerDeleteToolStripMenuItem.Checked; break; case Utils.LogType.DisplayCreature: append = this.creatureDisplayMessagesToolStripMenuItem.Checked; break; case Utils.LogType.DisplayPlayer: append = this.playerDisplayMessagesToolStripMenuItem.Checked; break; case Utils.LogType.ItemAttuned: append = this.attunedToolStripMenuItem.Checked; break; case Utils.LogType.ItemFigurineUse: append = this.figurinesToolStripMenuItem.Checked; break; case Utils.LogType.Karma: append = true; // always logged break; case Utils.LogType.Login: append = this.loginToolStripMenuItem.Checked; break; case Utils.LogType.Logout: append = this.logoutToolStripMenuItem.Checked; break; case Utils.LogType.LootAlways: append = this.alwaysItemsToolStripMenuItem.Checked; break; case Utils.LogType.LootBelt: append = this.beltItemsToolStripMenuItem.Checked; break; case Utils.LogType.LootRare: append = this.rareToolStripMenuItem.Checked; break; case Utils.LogType.LootVeryRare: append = this.veryRareToolStripMenuItem.Checked; break; case Utils.LogType.Mark: append = true; // always logged break; case Utils.LogType.MerchantBuy: append = this.buyToolStripMenuItem.Checked; break; case Utils.LogType.MerchantSell: append = this.sellToolStripMenuItem.Checked; break; case Utils.LogType.MerchantTanning: append = this.tanningToolStripMenuItem.Checked; break; case Utils.LogType.QuestCompletion: append = this.questCompletionToolStripMenuItem.Checked; break; case Utils.LogType.SkillGainCombat: append = this.gainFromcombatToolStripMenuItem.Checked; break; case Utils.LogType.SkillGainNonCombat: append = this.gainFromnonCombatToolStripMenuItem.Checked; break; case Utils.LogType.SkillGainRisk: append = this.skillriskToolStripMenuItem.Checked; break; case Utils.LogType.SkillTraining: append = this.trainingToolStripMenuItem.Checked; break; case Utils.LogType.SpellBeneficialFromCreature: append = this.castingBeneficialFromCreatureToolStripMenuItem.Checked; break; case Utils.LogType.SpellBeneficialFromPlayer: append = this.castingBeneficialFromPlayerToolStripMenuItem.Checked; break; case Utils.LogType.SpellDamageFromMapEffect: append = this.spellDamageFromMapEffectToolStripMenuItem.Checked; break; case Utils.LogType.SpellDamageToCreature: append = this.spellDamageToCreatureToolStripMenuItem.Checked; break; case Utils.LogType.SpellDamageToPlayer: append = this.spellDamageToPlayerToolStripMenuItem.Checked; break; case Utils.LogType.SpellHarmfulFromCreature: append = this.castingHarmfulFromCreatureToolStripMenuItem.Checked; break; case Utils.LogType.SpellHarmfulFromPlayer: append = this.castingHarmfulFromPlayerToolStripMenuItem.Checked; break; case Utils.LogType.SpellWarmingFromCreature: append = this.warmingFromCreatureToolStripMenuItem.Checked; break; case Utils.LogType.SpellWarmingFromPlayer: append = this.warmingFromPlayerToolStripMenuItem.Checked; break; case Utils.LogType.SystemFailure: append = true; break; case Utils.LogType.SystemFatalError: append = true; break; case Utils.LogType.SystemGo: append = this.systemGoToolStripMenuItem.Checked; break; case Utils.LogType.SystemWarning: append = this.systemWarningToolStripMenuItem.Checked; break; case Utils.LogType.Timeout: append = this.timeoutToolStripMenuItem.Checked; break; case Utils.LogType.Unknown: append = true; break; } return(append); }
public void DisplayLogMessage(string message, Utils.LogType logType, RichTextBox richTextBox) { bool append = false; bool colorLog = false; if (System.Configuration.ConfigurationManager.AppSettings["ColorLog"].ToLower() == "true") { colorLog = true; } if (richTextBox == null) { richTextBox = this.rtbxLog; } richTextBox.SelectionBackColor = richTextBox.BackColor; richTextBox.SelectionColor = richTextBox.ForeColor; if (richTextBox == this.rtbxLog) { switch (logType) { case Utils.LogType.ExceptionDetail: if (colorLog) { richTextBox.SelectionBackColor = Color.Red; richTextBox.SelectionColor = Color.White; } richTextBox.AppendText(message); return; case Utils.LogType.SystemFailure: richTextBox.SelectionColor = Color.Red; this.rtbxLog.AppendText(message); return; case Utils.LogType.SystemFatalError: richTextBox.SelectionBackColor = Color.Red; richTextBox.SelectionColor = Color.White; this.rtbxLog.AppendText(message); return; case Utils.LogType.SystemWarning: richTextBox.SelectionColor = Color.Yellow; this.rtbxLog.AppendText(message); return; case Utils.LogType.Unknown: richTextBox.SelectionColor = Color.LightSalmon; richTextBox.AppendText(message); return; default: append = this.Display(logType); break; } } else { append = true; } if (append) { string time = message.Substring(0, message.IndexOf("M: {") + 3); message = message.Replace(time, ""); string logMessage = message.Substring(0, message.IndexOf("} ") + 1); message = message.Replace(logMessage, ""); message = message.Substring(1); if (colorLog) { richTextBox.SelectionColor = Color.DarkCyan; } richTextBox.AppendText(time); if (colorLog) { richTextBox.SelectionColor = Color.Cyan; } richTextBox.AppendText(logMessage); richTextBox.AppendText(" "); switch (logType) // choose a color for the logType { case Utils.LogType.DisplayCreature: richTextBox.SelectionBackColor = Color.DarkGreen; richTextBox.SelectionColor = Color.White; break; case Utils.LogType.DisplayPlayer: richTextBox.SelectionBackColor = Color.Blue; richTextBox.SelectionColor = Color.White; break; default: richTextBox.SelectionBackColor = richTextBox.BackColor; richTextBox.SelectionColor = richTextBox.ForeColor; break; } richTextBox.AppendText(message); } }