PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/Forms/FormColors.cs

https://github.com/SkyFire/icechat
C# | 1527 lines | 1184 code | 283 blank | 60 comment | 205 complexity | b9514805bd99fc33519af913ef254099 MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /******************************************************************************\
  2. * IceChat 9 Internet Relay Chat Client
  3. *
  4. * Copyright (C) 2011 Paul Vanderzee <snerf@icechat.net>
  5. * <www.icechat.net>
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. *
  20. * Please consult the LICENSE.txt file included with this project for
  21. * more details
  22. *
  23. \******************************************************************************/
  24. using System;
  25. using System.Collections.Generic;
  26. using System.Collections;
  27. using System.ComponentModel;
  28. using System.Data;
  29. using System.Drawing;
  30. using System.Text;
  31. using System.Text.RegularExpressions;
  32. using System.Windows.Forms;
  33. using System.Xml.Serialization;
  34. using System.IO;
  35. using IceChatPlugin;
  36. namespace IceChat
  37. {
  38. public partial class FormColors : Form
  39. {
  40. public delegate void SaveColorsDelegate(IceChatColors colors, IceChatMessageFormat messages);
  41. public event SaveColorsDelegate SaveColors;
  42. private ColorButtonArray colorPicker;
  43. private Hashtable messageIdentifiers;
  44. private IceChatMessageFormat iceChatMessages;
  45. private IceChatColors iceChatColors;
  46. private object currentColorPick;
  47. private const char newColorChar = '\xFF03';
  48. public FormColors(IceChatMessageFormat MessageFormat, IceChatColors IceChatColors)
  49. {
  50. InitializeComponent();
  51. //add the events for the Tab Bar Color Picker
  52. this.pictureTabCurrent.Click += new EventHandler(OnColor_Click);
  53. this.pictureTabMessage.Click += new EventHandler(OnColor_Click);
  54. this.pictureTabJoin.Click += new EventHandler(OnColor_Click);
  55. this.pictureTabPart.Click += new EventHandler(OnColor_Click);
  56. this.pictureTabQuit.Click += new EventHandler(OnColor_Click);
  57. this.pictureTabServer.Click += new EventHandler(OnColor_Click);
  58. this.pictureTabOther.Click += new EventHandler(OnColor_Click);
  59. this.pictureTabDefault.Click += new EventHandler(OnColor_Click);
  60. //add the events for the Nick Color Picker
  61. this.pictureAdmin.Click += new EventHandler(OnColor_Click);
  62. this.pictureOwner.Click += new EventHandler(OnColor_Click);
  63. this.pictureOperator.Click += new EventHandler(OnColor_Click);
  64. this.pictureHalfOperator.Click += new EventHandler(OnColor_Click);
  65. this.pictureVoice.Click += new EventHandler(OnColor_Click);
  66. this.pictureDefault.Click += new EventHandler(OnColor_Click);
  67. this.pictureConsole.Click += new EventHandler(OnColor_Click);
  68. this.pictureChannel.Click += new EventHandler(OnColor_Click);
  69. this.pictureQuery.Click += new EventHandler(OnColor_Click);
  70. this.pictureNickList.Click += new EventHandler(OnColor_Click);
  71. this.pictureServerList.Click += new EventHandler(OnColor_Click);
  72. this.pictureTabBarCurrent1.Click += new EventHandler(OnColor_Click);
  73. this.pictureTabBarCurrent2.Click += new EventHandler(OnColor_Click);
  74. this.pictureTabBarOther1.Click += new EventHandler(OnColor_Click);
  75. this.pictureTabBarOther2.Click += new EventHandler(OnColor_Click);
  76. this.pictureTabBackground.Click += new EventHandler(OnColor_Click);
  77. this.pictureTabBarHover1.Click += new EventHandler(OnColor_Click);
  78. this.pictureTabBarHover2.Click += new EventHandler(OnColor_Click);
  79. this.picturePanelHeaderBG1.Click += new EventHandler(OnColor_Click);
  80. this.picturePanelHeaderBG2.Click += new EventHandler(OnColor_Click);
  81. this.picturePanelHeaderForeColor.Click += new EventHandler(OnColor_Click);
  82. this.pictureUnreadTextMarkerColor.Click += new EventHandler(OnColor_Click);
  83. this.pictureToolBar.Click += new EventHandler(OnColor_Click);
  84. this.pictureMenuBar.Click += new EventHandler(OnColor_Click);
  85. this.pictureInputBox.Click += new EventHandler(OnColor_Click);
  86. this.pictureInputBoxFore.Click += new EventHandler(OnColor_Click);
  87. this.pictureChannelList.Click += new EventHandler(OnColor_Click);
  88. this.pictureChannelListFore.Click += new EventHandler(OnColor_Click);
  89. this.pictureStatusBar.Click += new EventHandler(OnColor_Click);
  90. this.pictureStatusFore.Click += new EventHandler(OnColor_Click);
  91. this.iceChatColors = IceChatColors;
  92. UpdateColorSettings();
  93. messageIdentifiers = new Hashtable();
  94. AddMessageIdentifiers();
  95. colorPicker = new ColorButtonArray(panelColorPicker);
  96. colorPicker.OnClick += new ColorButtonArray.ColorSelected(colorPicker_OnClick);
  97. treeMessages.AfterSelect += new TreeViewEventHandler(treeMessages_AfterSelect);
  98. textRawMessage.TextChanged+=new EventHandler(textRawMessage_TextChanged);
  99. textRawMessage.KeyDown += new KeyEventHandler(textRawMessage_KeyDown);
  100. listIdentifiers.DoubleClick += new EventHandler(listIdentifiers_DoubleClick);
  101. treeBasicMessages.AfterSelect += new TreeViewEventHandler(treeBasicMessages_AfterSelect);
  102. tabMessages.SelectedTab = tabBasic;
  103. iceChatMessages = MessageFormat;
  104. textFormattedText.SingleLine = true;
  105. textFormattedText.NoEmoticons = true;
  106. textFormattedBasic.SingleLine = true;
  107. textFormattedBasic.NoEmoticons = true;
  108. //populate Message Settings
  109. UpdateMessageSettings();
  110. //load any plugin addons
  111. foreach (IPluginIceChat ipc in FormMain.Instance.IceChatPlugins)
  112. {
  113. if (ipc.Enabled == true)
  114. ipc.LoadColorsForm(this.tabControlColors);
  115. }
  116. ApplyLanguage();
  117. if (FormMain.Instance.IceChatOptions.Themes != null)
  118. {
  119. foreach (string theme in FormMain.Instance.IceChatOptions.Themes)
  120. comboTheme.Items.Add(theme);
  121. }
  122. comboTheme.Text = FormMain.Instance.IceChatOptions.CurrentTheme;
  123. }
  124. private void ApplyLanguage()
  125. {
  126. }
  127. private void OnColor_Click(object sender, EventArgs e)
  128. {
  129. currentColorPick = sender;
  130. colorPicker.SelectedColor = (int)((PictureBox)sender).Tag;
  131. labelCurrent.Text = "Current Selected:" + Environment.NewLine + GetLabelText((PictureBox)sender);
  132. }
  133. private string GetLabelText(PictureBox sender)
  134. {
  135. try
  136. {
  137. Label l = this.GetType().GetField("label" + sender.Name.Substring(7).ToString(), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this) as Label;
  138. return l.Text;
  139. }
  140. catch (NullReferenceException)
  141. {
  142. return "";
  143. }
  144. }
  145. private void textRawMessage_KeyDown(object sender, KeyEventArgs e)
  146. {
  147. if (e.Modifiers == Keys.Control)
  148. {
  149. if (e.KeyCode == Keys.K)
  150. {
  151. textRawMessage.SelectedText = ((char)3).ToString();
  152. e.Handled = true;
  153. }
  154. if (e.KeyCode == Keys.B)
  155. {
  156. textRawMessage.SelectedText = ((char)2).ToString();
  157. e.Handled = true;
  158. }
  159. if (e.KeyCode == Keys.U)
  160. {
  161. textRawMessage.SelectedText = ((char)31).ToString();
  162. e.Handled = true;
  163. }
  164. }
  165. }
  166. private void listIdentifiers_DoubleClick(object sender, EventArgs e)
  167. {
  168. int s = listIdentifiers.SelectedIndex;
  169. if (s == -1) return;
  170. string t = listIdentifiers.Items[s].ToString();
  171. t = t.Substring(0,t.IndexOf(" "));
  172. textRawMessage.SelectedText = t;
  173. }
  174. #region AddMessageIdentifiers
  175. private void AddMsgIdent(string MessageName, string Identifier)
  176. {
  177. if (messageIdentifiers.Contains(MessageName))
  178. {
  179. ArrayList idents = (ArrayList)messageIdentifiers[MessageName];
  180. bool Found = false;
  181. int i = 0;
  182. IEnumerator myEnum = idents.GetEnumerator();
  183. while (myEnum.MoveNext())
  184. {
  185. if (myEnum.Current.ToString().IndexOf(Identifier.Substring(0, Identifier.IndexOf(' '))) > -1)
  186. {
  187. Found = true;
  188. break;
  189. }
  190. i++;
  191. }
  192. if (!Found)
  193. idents.Add(Identifier);
  194. else
  195. idents[i] = Identifier;
  196. messageIdentifiers[MessageName] = idents;
  197. }
  198. else
  199. {
  200. ArrayList a = new ArrayList();
  201. a.Add(Identifier);
  202. messageIdentifiers.Add(MessageName, a);
  203. }
  204. }
  205. private void AddMessageIdentifiers()
  206. {
  207. AddMsgIdent("Server Connect", "$server - actual server name");
  208. AddMsgIdent("Server Connect", "$serverip - server IP Address");
  209. AddMsgIdent("Server Connect", "$port - server port");
  210. AddMsgIdent("Server Disconnect", "$server - server name");
  211. AddMsgIdent("Server Disconnect", "$serverip - server IP Address");
  212. AddMsgIdent("Server Disconnect", "$port - server port");
  213. AddMsgIdent("Server Reconnect", "$server - server name");
  214. AddMsgIdent("Server Reconnect", "$serverip - server IP Address");
  215. AddMsgIdent("Server Reconnect", "$port - server port");
  216. AddMsgIdent("Channel Invite", "$nick - nickname who invited you");
  217. AddMsgIdent("Channel Invite", "$host - hostname of nick");
  218. AddMsgIdent("Channel Invite", "$channel - channel you were invited to");
  219. AddMsgIdent("Channel Message", "$nick - nickname who messaged");
  220. AddMsgIdent("Channel Message", "$host - hostname of nick");
  221. AddMsgIdent("Channel Message", "$status - op/voice status of nick");
  222. AddMsgIdent("Channel Message", "$channel - channel name");
  223. AddMsgIdent("Channel Message", "$message - channel message");
  224. AddMsgIdent("Channel Message", "$color - nickname nicklist color");
  225. AddMsgIdent("Channel Action", "$nick - nickname who performed action");
  226. AddMsgIdent("Channel Action", "$host - hostname of nick");
  227. AddMsgIdent("Channel Action", "$status - op/voice status of nick");
  228. AddMsgIdent("Channel Action", "$channel - channel name");
  229. AddMsgIdent("Channel Action", "$message - channel action");
  230. AddMsgIdent("Channel Join", "$nick - nickname who joined");
  231. AddMsgIdent("Channel Join", "$host - hostname of nick");
  232. //AddMsgIdent("Channel Join", "$status - op/voice status of nick");
  233. AddMsgIdent("Channel Join", "$channel - channel name");
  234. AddMsgIdent("Channel Part", "$nick - nickname who parted");
  235. AddMsgIdent("Channel Part", "$host - hostname of nick");
  236. AddMsgIdent("Channel Part", "$status - op/voice status of nick");
  237. AddMsgIdent("Channel Part", "$channel - channel name");
  238. AddMsgIdent("Channel Part", "$reason - part reason");
  239. AddMsgIdent("Channel Kick", "$nick - nickname who performed kick");
  240. AddMsgIdent("Channel Kick", "$host - hostname of nick who performed");
  241. //AddMsgIdent("Channel Kick", "$status - op/voice status of nick");
  242. AddMsgIdent("Channel Kick", "$channel - channel name");
  243. AddMsgIdent("Channel Kick", "$kickee - the nick who was kicked");
  244. AddMsgIdent("Channel Kick", "$reason - kick reason");
  245. AddMsgIdent("Channel Mode", "$nick - who performed the mode change");
  246. AddMsgIdent("Channel Mode", "$host - host of who performed the mode change");
  247. AddMsgIdent("Channel Mode", "$channel - what channel had the mode change");
  248. AddMsgIdent("Channel Mode", "$mode - the channel mode that changed");
  249. AddMsgIdent("Channel Mode", "$modeparam - the parameters for the mode");
  250. AddMsgIdent("Channel Notice", "$nick - nickname who noticed");
  251. AddMsgIdent("Channel Notice", "$host - host of nick");
  252. AddMsgIdent("Channel Notice", "$status - the status level in the channel the notice was sent to");
  253. AddMsgIdent("Channel Notice", "$channel - the channel the notice was sent to");
  254. AddMsgIdent("Channel Notice", "$message - the notice message sent");
  255. AddMsgIdent("Channel Other", "$message - the message");
  256. AddMsgIdent("Channel Nick Change", "$nick - the old nick name");
  257. AddMsgIdent("Channel Nick Change", "$host - hostname");
  258. AddMsgIdent("Channel Nick Change", "$newnick - the new nick name");
  259. AddMsgIdent("Self Channel Join", "$nick - yourself");
  260. AddMsgIdent("Self Channel Join", "$host - your hostname");
  261. AddMsgIdent("Self Channel Join", "$channel - channel name");
  262. AddMsgIdent("Self Channel Part", "$nick - yourself");
  263. AddMsgIdent("Self Channel Part", "$host - your hostname");
  264. AddMsgIdent("Self Channel Part", "$status - your op/voice status");
  265. AddMsgIdent("Self Channel Part", "$channel - channel name");
  266. AddMsgIdent("Self Channel Part", "$reason - part reason");
  267. AddMsgIdent("Self Channel Kick", "$nick - yourself");
  268. //AddMsgIdent("Self Channel Kick", "$status - your op/voice status");
  269. AddMsgIdent("Self Channel Kick", "$channel - channel name");
  270. AddMsgIdent("Self Channel Kick", "$kicker - the nick who performed the kick");
  271. AddMsgIdent("Self Channel Kick", "$host - the host of who performed the kick");
  272. AddMsgIdent("Self Channel Kick", "$reason - kick reason");
  273. AddMsgIdent("Self Channel Message", "$nick - yourself");
  274. //AddMsgIdent("Self Channel Message", "$host - your hostname ");
  275. AddMsgIdent("Self Channel Message", "$status - your op/voice status");
  276. AddMsgIdent("Self Channel Message", "$channel - channel name");
  277. AddMsgIdent("Self Channel Message", "$message - channel message");
  278. AddMsgIdent("Self Channel Message", "$color - nickname nicklist color");
  279. AddMsgIdent("Self Channel Action", "$nick - yourself");
  280. //AddMsgIdent("Self Channel Action", "$host - your hostname");
  281. //AddMsgIdent("Self Channel Action", "$status - your op/voice status");
  282. AddMsgIdent("Self Channel Action", "$channel - channel name");
  283. AddMsgIdent("Self Channel Action", "$message - channel action");
  284. AddMsgIdent("Self Nick Change", "$nick - your old nick name");
  285. AddMsgIdent("Self Nick Change", "$host - your hostname");
  286. AddMsgIdent("Self Nick Change", "$newnick - your new nick name");
  287. AddMsgIdent("Self Notice", "$nick - who you are sending notice to");
  288. AddMsgIdent("Self Notice", "$message - the notice message");
  289. AddMsgIdent("Private Message", "$nick - nickname who messaged");
  290. AddMsgIdent("Private Message", "$host - hostname of nick");
  291. AddMsgIdent("Private Message", "$message - channel message");
  292. AddMsgIdent("Self Private Message", "$nick - yourself");
  293. AddMsgIdent("Self Private Message", "$host - your hostname");
  294. AddMsgIdent("Self Private Message", "$message - private message");
  295. AddMsgIdent("Private Action", "$nick - nickname who performed action");
  296. AddMsgIdent("Private Action", "$host - hostname of nick");
  297. AddMsgIdent("Private Action", "$message - private action");
  298. AddMsgIdent("Self Private Action", "$nick - yourself");
  299. AddMsgIdent("Self Private Action", "$host - your hostname");
  300. AddMsgIdent("Self Private Action", "$message - private action");
  301. AddMsgIdent("Server Mode", "$mode - the mode the server changed for you");
  302. AddMsgIdent("Server Mode", "$nick - your nickname");
  303. AddMsgIdent("Server Mode", "$server - the server name");
  304. AddMsgIdent("User Notice", "$nick - who sent the notice");
  305. AddMsgIdent("User Notice", "$message - the notice");
  306. AddMsgIdent("User Echo", "$message - the message to echo");
  307. AddMsgIdent("User Whois", "$nick - the nick for the whois");
  308. AddMsgIdent("User Whois", "$data - the whois information");
  309. AddMsgIdent("User Error", "$message - the error message");
  310. AddMsgIdent("Server Notice", "$server - the server name");
  311. AddMsgIdent("Server Notice", "$message - the notice");
  312. AddMsgIdent("Server Notice", "$nick - your nickname");
  313. AddMsgIdent("Server MOTD", "$message - the MOTD message");
  314. AddMsgIdent("Server Quit", "$nick - nickname who quit");
  315. AddMsgIdent("Server Quit", "$host - hostname of nick");
  316. AddMsgIdent("Server Quit", "$reason - quit reason");
  317. AddMsgIdent("Server Message", "$server - the server name");
  318. AddMsgIdent("Server Message", "$message - the message");
  319. AddMsgIdent("Server Error", "$server - the server name");
  320. AddMsgIdent("Server Error", "$message - the error message");
  321. AddMsgIdent("CTCP Request", "$nick - the nick the Ctcp request is for");
  322. AddMsgIdent("CTCP Request", "$ctcp - the Ctcp you wish to request for");
  323. AddMsgIdent("CTCP Reply", "$nick - who you send the Ctcp Request to");
  324. AddMsgIdent("CTCP Reply", "$host - the host of the nick");
  325. AddMsgIdent("CTCP Reply", "$ctcp - which Ctcp was requested");
  326. AddMsgIdent("CTCP Reply", "$reply - the Ctcp was reply");
  327. AddMsgIdent("CTCP Send", "$nick - the nick you want to send a Ctcp Request to");
  328. AddMsgIdent("CTCP Send", "$ctcp - the Ctcp you wish to request");
  329. AddMsgIdent("Channel Topic Change", "$topic - channel topic");
  330. AddMsgIdent("Channel Topic Change", "$channel - channel name");
  331. AddMsgIdent("Channel Topic Change", "$nick - who changed topic");
  332. AddMsgIdent("Channel Topic Change", "$host - who changed topic host");
  333. AddMsgIdent("Channel Topic Text", "$channel - channel name");
  334. AddMsgIdent("Channel Topic Text", "$topic - channel topic");
  335. AddMsgIdent("DCC Chat Request", "$nick - nickname of person who requests chat");
  336. AddMsgIdent("DCC Chat Request", "$host - host of nickname");
  337. AddMsgIdent("DCC File Send", "$nick - nickname of person who is sending file");
  338. AddMsgIdent("DCC File Send", "$host - host of nickname");
  339. AddMsgIdent("DCC File Send", "$file - name of the file trying to be sent");
  340. AddMsgIdent("DCC File Send", "$filesize - the size in bytes of file");
  341. AddMsgIdent("DCC Chat Message", "$nick - nickname who messaged");
  342. AddMsgIdent("DCC Chat Message", "$message - chat message");
  343. AddMsgIdent("Self DCC Chat Message", "$nick - yourself");
  344. AddMsgIdent("Self DCC Chat Message", "$host - your hostname");
  345. AddMsgIdent("Self DCC Chat Message", "$message - chat message");
  346. AddMsgIdent("DCC Chat Action", "$nick - nickname who performed action");
  347. AddMsgIdent("DCC Chat Action", "$message - the action performed");
  348. AddMsgIdent("Self DCC Chat Action", "$nick - yourself");
  349. AddMsgIdent("Self DCC Chat Action", "$host - your hostname");
  350. AddMsgIdent("Self DCC Chat Action", "$message - the action performed");
  351. AddMsgIdent("DCC Chat Request", "$nick - nickname who performed request");
  352. AddMsgIdent("DCC Chat Request", "$host- nickname host");
  353. AddMsgIdent("DCC Chat Outgoing", "$nick - who you want to chat with");
  354. AddMsgIdent("DCC Chat Connect", "$nick - who you are chatting with");
  355. AddMsgIdent("DCC Chat Disconnect", "$nick - who you are chatting with");
  356. AddMsgIdent("DCC Chat Timeout", "$nick - who you want to chat with");
  357. }
  358. #endregion
  359. private void colorPicker_OnClick(int colorSelected)
  360. {
  361. if (tabControlColors.SelectedTab.Text == "Messages")
  362. {
  363. //check if we are in basic or advanced
  364. if (tabMessages.SelectedTab.Text == "Advanced")
  365. {
  366. if (treeMessages.SelectedNode == null)
  367. return;
  368. //add in the color code in the current place in the textbox
  369. if (this.checkBGColor.Checked == true)
  370. {
  371. textFormattedText.IRCBackColor = colorSelected;
  372. }
  373. else
  374. {
  375. if (textRawMessage.Text.StartsWith(""))
  376. {
  377. if (textRawMessage.SelectionStart == 0)
  378. {
  379. int result;
  380. if (int.TryParse(textRawMessage.Text.Substring(1, 2), out result))
  381. textRawMessage.Text = "" + colorSelected.ToString("00") + textRawMessage.Text.Substring(3);
  382. else
  383. textRawMessage.Text = "" + colorSelected.ToString("00") + textRawMessage.Text.Substring(2);
  384. }
  385. else
  386. this.textRawMessage.SelectedText = "" + colorSelected.ToString("00");
  387. }
  388. else
  389. this.textRawMessage.Text = "" + colorSelected.ToString("00") + textRawMessage.Text;
  390. }
  391. }
  392. else
  393. {
  394. //basic settings
  395. if (treeBasicMessages.SelectedNode == null)
  396. return;
  397. if (this.checkChangeBGBasic.Checked == true)
  398. {
  399. textFormattedBasic.IRCBackColor = colorSelected;
  400. }
  401. else
  402. {
  403. string message = treeBasicMessages.SelectedNode.Tag.ToString();
  404. message = message.Replace("&#x3;", ((char)3).ToString());
  405. message = RemoveColorCodes(message);
  406. message = "" + colorSelected.ToString("00") + message;
  407. message = message.Replace(((char)3).ToString(),"&#x3;");
  408. treeBasicMessages.SelectedNode.Tag = message;
  409. UpdateBasicText();
  410. }
  411. }
  412. }
  413. if (tabControlColors.SelectedTab.Text == "Nick List")
  414. {
  415. if (currentColorPick != null)
  416. {
  417. ((PictureBox)currentColorPick).BackColor = IrcColor.colors[colorSelected];
  418. ((PictureBox)currentColorPick).Tag = colorSelected;
  419. }
  420. }
  421. if (tabControlColors.SelectedTab.Text == "Tab Bar")
  422. {
  423. if (currentColorPick != null)
  424. {
  425. ((PictureBox)currentColorPick).BackColor = IrcColor.colors[colorSelected];
  426. ((PictureBox)currentColorPick).Tag = colorSelected;
  427. }
  428. }
  429. if (tabControlColors.SelectedTab.Text == "Other")
  430. {
  431. if (currentColorPick != null)
  432. {
  433. ((PictureBox)currentColorPick).BackColor = IrcColor.colors[colorSelected];
  434. ((PictureBox)currentColorPick).Tag = colorSelected;
  435. }
  436. }
  437. }
  438. private void treeBasicMessages_AfterSelect(object sender, TreeViewEventArgs e)
  439. {
  440. if (e.Node.Parent == null)
  441. {
  442. textFormattedBasic.ClearTextWindow();
  443. return;
  444. }
  445. if (treeBasicMessages.SelectedNode == null)
  446. return;
  447. if (treeBasicMessages.SelectedNode.Parent == null)
  448. return;
  449. string type = e.Node.Text.Split(' ').GetValue(0).ToString();
  450. if (type == "Server")
  451. textFormattedBasic.IRCBackColor = iceChatColors.ConsoleBackColor;
  452. else if (type == "User")
  453. textFormattedBasic.IRCBackColor = iceChatColors.ConsoleBackColor;
  454. else if (type == "Channel")
  455. textFormattedBasic.IRCBackColor = iceChatColors.ChannelBackColor;
  456. else if (type == "Private")
  457. textFormattedBasic.IRCBackColor = iceChatColors.QueryBackColor;
  458. else if (type == "DCC")
  459. textFormattedBasic.IRCBackColor = iceChatColors.QueryBackColor;
  460. else if (type == "Self")
  461. {
  462. type = e.Node.Text.Split(' ').GetValue(1).ToString();
  463. if (type == "Server")
  464. textFormattedBasic.IRCBackColor = iceChatColors.ConsoleBackColor;
  465. else if (type == "Channel")
  466. textFormattedBasic.IRCBackColor = iceChatColors.ChannelBackColor;
  467. else if (type == "Nick")
  468. textFormattedBasic.IRCBackColor = iceChatColors.ChannelBackColor;
  469. else if (type == "Private")
  470. textFormattedBasic.IRCBackColor = iceChatColors.QueryBackColor;
  471. else
  472. textFormattedBasic.IRCBackColor = 0;
  473. }
  474. else
  475. textFormattedBasic.IRCBackColor = 0;
  476. this.listIdentifiers.Items.Clear();
  477. IDictionaryEnumerator msgIdent = messageIdentifiers.GetEnumerator();
  478. while (msgIdent.MoveNext())
  479. {
  480. if (msgIdent.Key.ToString().ToLower() == e.Node.Text.ToLower())
  481. {
  482. ArrayList idents = (ArrayList)msgIdent.Value;
  483. foreach (object ident in idents)
  484. this.listIdentifiers.Items.Add(ident);
  485. }
  486. }
  487. UpdateBasicText();
  488. }
  489. private void treeMessages_AfterSelect(object sender, TreeViewEventArgs e)
  490. {
  491. if (e.Node.Parent == null)
  492. {
  493. textRawMessage.Text = null;
  494. textFormattedText.ClearTextWindow();
  495. return;
  496. }
  497. //get the window type and set the background color
  498. string type = e.Node.Text.Split(' ').GetValue(0).ToString();
  499. if (type == "Server")
  500. textFormattedText.IRCBackColor = iceChatColors.ConsoleBackColor;
  501. else if (type == "User")
  502. textFormattedText.IRCBackColor = iceChatColors.ConsoleBackColor;
  503. else if (type == "Channel")
  504. textFormattedText.IRCBackColor = iceChatColors.ChannelBackColor;
  505. else if (type == "Private")
  506. textFormattedText.IRCBackColor = iceChatColors.QueryBackColor;
  507. else if (type == "DCC")
  508. textFormattedText.IRCBackColor = iceChatColors.QueryBackColor;
  509. else if (type == "Self")
  510. {
  511. type = e.Node.Text.Split(' ').GetValue(1).ToString();
  512. if (type == "Server")
  513. textFormattedText.IRCBackColor = iceChatColors.ConsoleBackColor;
  514. else if (type == "Channel")
  515. textFormattedText.IRCBackColor = iceChatColors.ChannelBackColor;
  516. else if (type == "Nick")
  517. textFormattedText.IRCBackColor = iceChatColors.ChannelBackColor;
  518. else if (type == "Private")
  519. textFormattedText.IRCBackColor = iceChatColors.QueryBackColor;
  520. else
  521. textFormattedText.IRCBackColor = 0;
  522. }
  523. else
  524. textFormattedText.IRCBackColor = 0;
  525. textRawMessage.Text = e.Node.Tag.ToString();
  526. //replace the color code
  527. textRawMessage.Text = textRawMessage.Text.Replace("&#x3;", ((char)3).ToString());
  528. //replace the bold code
  529. textRawMessage.Text = textRawMessage.Text.Replace("&#x2;", ((char)2).ToString());
  530. this.listIdentifiers.Items.Clear();
  531. IDictionaryEnumerator msgIdent = messageIdentifiers.GetEnumerator();
  532. while (msgIdent.MoveNext())
  533. {
  534. if (msgIdent.Key.ToString().ToLower() == e.Node.Text.ToLower())
  535. {
  536. ArrayList idents = (ArrayList)msgIdent.Value;
  537. foreach (object ident in idents)
  538. this.listIdentifiers.Items.Add(ident);
  539. }
  540. }
  541. UpdateFormattedText();
  542. }
  543. private void UpdateBasicText()
  544. {
  545. this.textFormattedBasic.ClearTextWindow();
  546. string message = treeBasicMessages.SelectedNode.Tag.ToString();
  547. SetMessageFormat(treeBasicMessages.SelectedNode.Text, message);
  548. //replace some of the basic identifiers to make it look right
  549. if (CheckIdentifier("$status"))
  550. message = message.Replace("$status", "@");
  551. if (CheckIdentifier("$nick"))
  552. message = message.Replace("$nick", "Nick");
  553. if (CheckIdentifier("$newnick"))
  554. message = message.Replace("$newnick", "NewNick");
  555. if (CheckIdentifier("$kickee"))
  556. message = message.Replace("$kickee", "ThisNick");
  557. if (CheckIdentifier("$kicker"))
  558. message = message.Replace("$kicker", "WhoKicked");
  559. if (CheckIdentifier("$channel"))
  560. message = message.Replace("$channel", "#channel");
  561. if (CheckIdentifier("$host"))
  562. message = message.Replace("$host", "ident@host.com");
  563. if (CheckIdentifier("$reason"))
  564. message = message.Replace("$reason", "Reason");
  565. if (CheckIdentifier("$message"))
  566. message = message.Replace("$message", "message");
  567. if (CheckIdentifier("$modeparam"))
  568. message = message.Replace("$modeparam", "nick!ident@host");
  569. if (CheckIdentifier("$mode"))
  570. message = message.Replace("$mode", "+o");
  571. if (CheckIdentifier("$ctcp"))
  572. message = message.Replace("$ctcp", "VERSION");
  573. if (CheckIdentifier("$reply"))
  574. message = message.Replace("$reply", "CTCP Reply");
  575. if (CheckIdentifier("$serverip"))
  576. message = message.Replace("$serverip", "192.168.1.101");
  577. if (CheckIdentifier("$server"))
  578. message = message.Replace("$server", "irc.server.com");
  579. if (CheckIdentifier("$port"))
  580. message = message.Replace("$port", "6667");
  581. if (CheckIdentifier("$topic"))
  582. message = message.Replace("$topic", "The Channel Topic");
  583. if (CheckIdentifier("$filesize"))
  584. message = message.Replace("$filesize", "512");
  585. if (CheckIdentifier("$file"))
  586. message = message.Replace("$file", "file.ext");
  587. message = message.Replace("$color", ((char)3).ToString() + "12");
  588. this.textFormattedBasic.AppendText(message, 1);
  589. }
  590. private void UpdateFormattedText()
  591. {
  592. if (treeMessages.SelectedNode == null)
  593. return;
  594. if (treeMessages.SelectedNode.Parent == null)
  595. return;
  596. this.textFormattedText.ClearTextWindow();
  597. string message = this.textRawMessage.Text;
  598. treeMessages.SelectedNode.Tag = message;
  599. SetMessageFormat(treeMessages.SelectedNode.Text, message);
  600. //replace some of the basic identifiers to make it look right
  601. if (CheckIdentifier("$status"))
  602. message = message.Replace("$status", "@");
  603. if (CheckIdentifier("$nick"))
  604. message = message.Replace("$nick", "Nick");
  605. if (CheckIdentifier("$newnick"))
  606. message = message.Replace("$newnick", "NewNick");
  607. if (CheckIdentifier("$kickee"))
  608. message = message.Replace("$kickee", "ThisNick");
  609. if (CheckIdentifier("$kicker"))
  610. message = message.Replace("$kicker", "WhoKicked");
  611. if (CheckIdentifier("$channel"))
  612. message = message.Replace("$channel", "#channel");
  613. if (CheckIdentifier("$host"))
  614. message = message.Replace("$host", "ident@host.com");
  615. if (CheckIdentifier("$reason"))
  616. message = message.Replace("$reason", "Reason");
  617. if (CheckIdentifier("$message"))
  618. message = message.Replace("$message", "message");
  619. if (CheckIdentifier("$modeparam"))
  620. message = message.Replace("$modeparam", "nick!ident@host");
  621. if (CheckIdentifier("$mode"))
  622. message = message.Replace("$mode", "+o");
  623. if (CheckIdentifier("$ctcp"))
  624. message = message.Replace("$ctcp", "VERSION");
  625. if (CheckIdentifier("$reply"))
  626. message = message.Replace("$reply", "CTCP Reply");
  627. if (CheckIdentifier("$serverip"))
  628. message = message.Replace("$serverip", "192.168.1.101");
  629. if (CheckIdentifier("$server"))
  630. message = message.Replace("$server", "irc.server.com");
  631. if (CheckIdentifier("$port"))
  632. message = message.Replace("$port", "6667");
  633. if (CheckIdentifier("$topic"))
  634. message = message.Replace("$topic", "The Channel Topic");
  635. if (CheckIdentifier("$filesize"))
  636. message = message.Replace("$filesize", "512");
  637. if (CheckIdentifier("$file"))
  638. message = message.Replace("$file", "file.ext");
  639. message = message.Replace("$color", ((char)3).ToString() + "12");
  640. this.textFormattedText.AppendText(message, 1);
  641. }
  642. private bool CheckIdentifier(string identifier)
  643. {
  644. foreach (string m in listIdentifiers.Items)
  645. {
  646. if (m.StartsWith(identifier))
  647. return true;
  648. }
  649. return false;
  650. }
  651. private void SetMessageFormat(string MessageName, string MessageFormat)
  652. {
  653. foreach (ServerMessageFormatItem msg in iceChatMessages.MessageSettings)
  654. {
  655. if (msg.MessageName.ToLower() == MessageName.ToLower())
  656. {
  657. msg.FormattedMessage = MessageFormat.Replace(((char)3).ToString(), "&#x3;").Replace(((char)2).ToString(), "&#x2;");
  658. return;
  659. }
  660. }
  661. }
  662. private void textRawMessage_TextChanged(object sender, EventArgs e)
  663. {
  664. UpdateFormattedText();
  665. }
  666. private void UpdateMessageSettings()
  667. {
  668. treeMessages.Nodes.Clear();
  669. treeBasicMessages.Nodes.Clear();
  670. System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Channel Messages");
  671. System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Server Messages");
  672. System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Private Messages");
  673. System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Self Messages");
  674. System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Ctcp");
  675. System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("DCC");
  676. System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("Other");
  677. System.Windows.Forms.TreeNode treeNode8 = new System.Windows.Forms.TreeNode("Channel Messages");
  678. System.Windows.Forms.TreeNode treeNode9 = new System.Windows.Forms.TreeNode("Server Messages");
  679. System.Windows.Forms.TreeNode treeNode10 = new System.Windows.Forms.TreeNode("Private Messages");
  680. System.Windows.Forms.TreeNode treeNode11 = new System.Windows.Forms.TreeNode("Self Messages");
  681. System.Windows.Forms.TreeNode treeNode12 = new System.Windows.Forms.TreeNode("Ctcp");
  682. System.Windows.Forms.TreeNode treeNode13 = new System.Windows.Forms.TreeNode("DCC");
  683. System.Windows.Forms.TreeNode treeNode14 = new System.Windows.Forms.TreeNode("Other");
  684. this.treeBasicMessages.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
  685. treeNode1,
  686. treeNode2,
  687. treeNode3,
  688. treeNode4,
  689. treeNode5,
  690. treeNode6,
  691. treeNode7});
  692. this.treeMessages.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
  693. treeNode8,
  694. treeNode9,
  695. treeNode10,
  696. treeNode11,
  697. treeNode12,
  698. treeNode13,
  699. treeNode14});
  700. if (iceChatMessages.MessageSettings != null)
  701. {
  702. foreach (ServerMessageFormatItem msg in iceChatMessages.MessageSettings)
  703. {
  704. if (msg.MessageName.StartsWith("Channel"))
  705. {
  706. TreeNode t = new TreeNode(msg.MessageName);
  707. t.Tag = msg.FormattedMessage;
  708. treeMessages.Nodes[0].Nodes.Add(t);
  709. TreeNode t2 = new TreeNode(msg.MessageName);
  710. t2.Tag = msg.FormattedMessage;
  711. treeBasicMessages.Nodes[0].Nodes.Add(t2);
  712. }
  713. else if (msg.MessageName.StartsWith("Server"))
  714. {
  715. TreeNode t = new TreeNode(msg.MessageName);
  716. t.Tag = msg.FormattedMessage;
  717. treeMessages.Nodes[1].Nodes.Add(t);
  718. TreeNode t2 = new TreeNode(msg.MessageName);
  719. t2.Tag = msg.FormattedMessage;
  720. treeBasicMessages.Nodes[1].Nodes.Add(t2);
  721. }
  722. else if (msg.MessageName.StartsWith("Private"))
  723. {
  724. TreeNode t = new TreeNode(msg.MessageName);
  725. t.Tag = msg.FormattedMessage;
  726. treeMessages.Nodes[2].Nodes.Add(t);
  727. TreeNode t2 = new TreeNode(msg.MessageName);
  728. t2.Tag = msg.FormattedMessage;
  729. treeBasicMessages.Nodes[2].Nodes.Add(t2);
  730. }
  731. else if (msg.MessageName.StartsWith("Self"))
  732. {
  733. TreeNode t = new TreeNode(msg.MessageName);
  734. t.Tag = msg.FormattedMessage;
  735. treeMessages.Nodes[3].Nodes.Add(t);
  736. TreeNode t2 = new TreeNode(msg.MessageName);
  737. t2.Tag = msg.FormattedMessage;
  738. treeBasicMessages.Nodes[3].Nodes.Add(t2);
  739. }
  740. else if (msg.MessageName.StartsWith("Ctcp"))
  741. {
  742. TreeNode t = new TreeNode(msg.MessageName);
  743. t.Tag = msg.FormattedMessage;
  744. treeMessages.Nodes[4].Nodes.Add(t);
  745. TreeNode t2 = new TreeNode(msg.MessageName);
  746. t2.Tag = msg.FormattedMessage;
  747. treeBasicMessages.Nodes[4].Nodes.Add(t2);
  748. }
  749. else if (msg.MessageName.StartsWith("DCC"))
  750. {
  751. TreeNode t = new TreeNode(msg.MessageName);
  752. t.Tag = msg.FormattedMessage;
  753. treeMessages.Nodes[5].Nodes.Add(t);
  754. TreeNode t2 = new TreeNode(msg.MessageName);
  755. t2.Tag = msg.FormattedMessage;
  756. treeBasicMessages.Nodes[5].Nodes.Add(t2);
  757. }
  758. else
  759. {
  760. TreeNode t = new TreeNode(msg.MessageName);
  761. t.Tag = msg.FormattedMessage;
  762. treeMessages.Nodes[6].Nodes.Add(t);
  763. TreeNode t2 = new TreeNode(msg.MessageName);
  764. t2.Tag = msg.FormattedMessage;
  765. treeBasicMessages.Nodes[6].Nodes.Add(t2);
  766. }
  767. }
  768. }
  769. treeMessages.ExpandAll();
  770. treeBasicMessages.ExpandAll();
  771. }
  772. private void UpdateColorSettings()
  773. {
  774. this.pictureOwner.BackColor = IrcColor.colors[iceChatColors.ChannelOwnerColor];
  775. this.pictureOwner.Tag = iceChatColors.ChannelOwnerColor;
  776. this.pictureAdmin.BackColor = IrcColor.colors[iceChatColors.ChannelAdminColor];
  777. this.pictureAdmin.Tag = iceChatColors.ChannelAdminColor;
  778. this.pictureOperator.BackColor = IrcColor.colors[iceChatColors.ChannelOpColor];
  779. this.pictureOperator.Tag = iceChatColors.ChannelOpColor;
  780. this.pictureHalfOperator.BackColor = IrcColor.colors[iceChatColors.ChannelHalfOpColor];
  781. this.pictureHalfOperator.Tag = iceChatColors.ChannelHalfOpColor;
  782. this.pictureVoice.BackColor = IrcColor.colors[iceChatColors.ChannelVoiceColor];
  783. this.pictureVoice.Tag = iceChatColors.ChannelVoiceColor;
  784. this.pictureDefault.BackColor = IrcColor.colors[iceChatColors.ChannelRegularColor];
  785. this.pictureDefault.Tag = iceChatColors.ChannelRegularColor;
  786. this.pictureTabCurrent.BackColor = IrcColor.colors[iceChatColors.TabBarCurrent];
  787. this.pictureTabCurrent.Tag = iceChatColors.TabBarCurrent;
  788. this.pictureTabMessage.BackColor = IrcColor.colors[iceChatColors.TabBarNewMessage];
  789. this.pictureTabMessage.Tag = iceChatColors.TabBarNewMessage;
  790. this.pictureTabJoin.BackColor = IrcColor.colors[iceChatColors.TabBarChannelJoin];
  791. this.pictureTabJoin.Tag = iceChatColors.TabBarChannelJoin;
  792. this.pictureTabPart.BackColor = IrcColor.colors[iceChatColors.TabBarChannelPart];
  793. this.pictureTabPart.Tag = iceChatColors.TabBarChannelPart;
  794. this.pictureTabQuit.BackColor = IrcColor.colors[iceChatColors.TabBarServerQuit];
  795. this.pictureTabQuit.Tag = iceChatColors.TabBarServerQuit;
  796. this.pictureTabServer.BackColor = IrcColor.colors[iceChatColors.TabBarServerMessage];
  797. this.pictureTabServer.Tag = iceChatColors.TabBarServerMessage;
  798. this.pictureTabOther.BackColor = IrcColor.colors[iceChatColors.TabBarOtherMessage];
  799. this.pictureTabOther.Tag = iceChatColors.TabBarOtherMessage;
  800. this.pictureTabDefault.BackColor = IrcColor.colors[iceChatColors.TabBarDefault];
  801. this.pictureTabDefault.Tag = iceChatColors.TabBarDefault;
  802. this.pictureTabBarCurrent1.BackColor = IrcColor.colors[iceChatColors.TabBarCurrentBG1];
  803. this.pictureTabBarCurrent1.Tag = iceChatColors.TabBarCurrentBG1;
  804. this.pictureTabBarCurrent2.BackColor = IrcColor.colors[iceChatColors.TabBarCurrentBG2];
  805. this.pictureTabBarCurrent2.Tag = iceChatColors.TabBarCurrentBG2;
  806. this.pictureTabBarOther1.BackColor = IrcColor.colors[iceChatColors.TabBarOtherBG1];
  807. this.pictureTabBarOther1.Tag = iceChatColors.TabBarOtherBG1;
  808. this.pictureTabBarOther2.BackColor = IrcColor.colors[iceChatColors.TabBarOtherBG2];
  809. this.pictureTabBarOther2.Tag = iceChatColors.TabBarOtherBG2;
  810. this.pictureTabBarHover1.BackColor = IrcColor.colors[iceChatColors.TabBarHoverBG1];
  811. this.pictureTabBarHover1.Tag = iceChatColors.TabBarHoverBG1;
  812. this.pictureTabBarHover2.BackColor = IrcColor.colors[iceChatColors.TabBarHoverBG2];
  813. this.pictureTabBarHover2.Tag = iceChatColors.TabBarHoverBG2;
  814. this.pictureTabBackground.BackColor = IrcColor.colors[iceChatColors.TabbarBackColor];
  815. this.pictureTabBackground.Tag = iceChatColors.TabbarBackColor;
  816. this.picturePanelHeaderBG1.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1];
  817. this.picturePanelHeaderBG1.Tag = iceChatColors.PanelHeaderBG1;
  818. this.picturePanelHeaderBG2.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG2];
  819. this.picturePanelHeaderBG2.Tag = iceChatColors.PanelHeaderBG2;
  820. this.picturePanelHeaderForeColor.BackColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor];
  821. this.picturePanelHeaderForeColor.Tag = iceChatColors.PanelHeaderForeColor;
  822. this.pictureUnreadTextMarkerColor.BackColor = IrcColor.colors[iceChatColors.UnreadTextMarkerColor];
  823. this.pictureUnreadTextMarkerColor.Tag = iceChatColors.UnreadTextMarkerColor;
  824. this.pictureMenuBar.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor];
  825. this.pictureMenuBar.Tag = iceChatColors.MenubarBackColor;
  826. this.pictureToolBar.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor];
  827. this.pictureToolBar.Tag = iceChatColors.ToolbarBackColor;
  828. this.pictureConsole.BackColor = IrcColor.colors[iceChatColors.ConsoleBackColor];
  829. this.pictureConsole.Tag = iceChatColors.ConsoleBackColor;
  830. this.pictureChannel.BackColor = IrcColor.colors[iceChatColors.ChannelBackColor];
  831. this.pictureChannel.Tag = iceChatColors.ChannelBackColor;
  832. this.pictureQuery.BackColor = IrcColor.colors[iceChatColors.QueryBackColor];
  833. this.pictureQuery.Tag = iceChatColors.QueryBackColor;
  834. this.pictureNickList.BackColor = IrcColor.colors[iceChatColors.NickListBackColor];
  835. this.pictureNickList.Tag = iceChatColors.NickListBackColor;
  836. this.pictureServerList.BackColor = IrcColor.colors[iceChatColors.ServerListBackColor];
  837. this.pictureServerList.Tag = iceChatColors.ServerListBackColor;
  838. this.pictureChannelList.BackColor = IrcColor.colors[iceChatColors.ChannelListBackColor];
  839. this.pictureChannelList.Tag = iceChatColors.ChannelListBackColor;
  840. this.pictureInputBox.BackColor = IrcColor.colors[iceChatColors.InputboxBackColor];
  841. this.pictureInputBox.Tag = iceChatColors.InputboxBackColor;
  842. this.pictureInputBoxFore.BackColor = IrcColor.colors[iceChatColors.InputboxForeColor];
  843. this.pictureInputBoxFore.Tag = iceChatColors.InputboxForeColor;
  844. this.pictureChannelListFore.BackColor = IrcColor.colors[iceChatColors.ChannelListForeColor];
  845. this.pictureChannelListFore.Tag = iceChatColors.ChannelListForeColor;
  846. this.pictureStatusBar.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor];
  847. this.pictureStatusBar.Tag = iceChatColors.StatusbarBackColor;
  848. thi

Large files files are truncated, but you can click here to view the full file