private void buttonImportTheme_Click(object sender, EventArgs e) { //this will load an icechat 7 theme //do it the same way as icechat 7 did, from the clipboard OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ".ini"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.AddExtension = true; ofd.AutoUpgradeEnabled = true; ofd.Filter = "Monody INI Setting (*.ini)|*.ini"; ofd.Title = "Locate the Monody.ini settings file?"; string directory = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody"; //check if the folder exists if (File.Exists(directory + Path.DirectorySeparatorChar + "icechat.ini")) ofd.InitialDirectory = directory; else ofd.InitialDirectory = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData); if (ofd.ShowDialog() == DialogResult.OK) { //make sure it is icechat.ini System.Diagnostics.Debug.WriteLine(ofd.FileName); if (Path.GetFileName(ofd.FileName).ToLower().Equals("icechat.ini")) { IniParser parser = new IniParser(ofd.FileName); string[] themes = parser.EnumSectionTheme("Color Themes"); foreach (string theme in themes) { string name = theme.Substring(0, theme.IndexOf((char)255)); string value = theme.Substring(theme.IndexOf((char)255) + 1); string[] colors = value.Split(','); if (name == "Default") name = "DefaultIce7"; IceChatColors ic = new IceChatColors(); ic.ChannelAdminColor = Convert.ToInt32(colors[38]); ic.ChannelBackColor = Convert.ToInt32(colors[43]); ic.ChannelListBackColor = Convert.ToInt32(colors[63]); ic.ChannelListForeColor = Convert.ToInt32(colors[86]); ic.ChannelOwnerColor = Convert.ToInt32(colors[39]); ic.ChannelRegularColor = Convert.ToInt32(colors[34]); ic.ChannelVoiceColor = Convert.ToInt32(colors[35]); ic.ChannelHalfOpColor = Convert.ToInt32(colors[36]); ic.ChannelOpColor = Convert.ToInt32(colors[37]); ic.ConsoleBackColor = Convert.ToInt32(colors[42]); ic.InputboxBackColor = Convert.ToInt32(colors[52]); ic.InputboxForeColor = Convert.ToInt32(colors[25]); ic.NickListBackColor = Convert.ToInt32(colors[53]); ic.PanelHeaderBG1 = Convert.ToInt32(colors[70]); ic.PanelHeaderBG2 = Convert.ToInt32(colors[71]); ic.PanelHeaderForeColor = Convert.ToInt32(colors[88]); ic.QueryBackColor = Convert.ToInt32(colors[44]); ic.RandomizeNickColors = false; ic.ServerListBackColor = Convert.ToInt32(colors[54]); ic.StatusbarBackColor = Convert.ToInt32(colors[90]); ic.StatusbarForeColor = Convert.ToInt32(colors[89]); ic.TabBarChannelJoin = Convert.ToInt32(colors[30]); ic.TabBarChannelPart = Convert.ToInt32(colors[31]); ic.TabBarCurrent = Convert.ToInt32(colors[28]); ic.TabBarDefault = Convert.ToInt32(colors[28]); ic.TabBarNewMessage = Convert.ToInt32(colors[29]); ic.TabBarOtherMessage = Convert.ToInt32(colors[32]); ic.TabBarServerMessage = Convert.ToInt32(colors[32]); ic.TabBarServerQuit = Convert.ToInt32(colors[32]); ic.TabBarNewAction = Convert.ToInt32(colors[29]); ic.TabBarServerNotice = Convert.ToInt32(colors[32]); ic.TabBarBuddyNotice = Convert.ToInt32(colors[32]); ic.ToolbarBackColor = Convert.ToInt32(colors[68]); ic.UnreadTextMarkerColor = Convert.ToInt32(colors[67]); XmlSerializer serializerC = new XmlSerializer(typeof(IceChatColors)); string themeFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + name + ".xml"; TextWriter textWriterC = new StreamWriter(themeFile); serializerC.Serialize(textWriterC, ic); textWriterC.Close(); textWriterC.Dispose(); IceChatMessageFormat im = new IceChatMessageFormat(); im.MessageSettings = new ServerMessageFormatItem[49]; im.MessageSettings[0] = NewMessageFormat("Server Connect", "" + colors[18] + "*** Attempting to connect to $server ($serverip) on port $port"); im.MessageSettings[1] = NewMessageFormat("Server Disconnect", "" + colors[19] + "*** Server disconnected on $server"); im.MessageSettings[2] = NewMessageFormat("Server Reconnect", "" + colors[11] + "*** Attempting to re-connect to $server"); im.MessageSettings[3] = NewMessageFormat("Channel Invite", "" + colors[22] + "* $nick invites you to $channel"); im.MessageSettings[4] = NewMessageFormat("Ctcp Reply", "" + colors[27] + "[$nick $ctcp Reply] : $reply"); im.MessageSettings[5] = NewMessageFormat("Ctcp Send", "" + colors[26] + "--> [$nick] $ctcp"); im.MessageSettings[6] = NewMessageFormat("Ctcp Request", "" + colors[11] + "[$nick] $ctcp"); im.MessageSettings[7] = NewMessageFormat("Channel Mode", "" + colors[7] + "* $nick sets mode $mode $modeparam for $channel"); im.MessageSettings[8] = NewMessageFormat("Server Mode", "" + colors[16] + "* Your mode is now $mode"); im.MessageSettings[9] = NewMessageFormat("Server Notice", "" + colors[24] + "*** $server $message"); im.MessageSettings[10] = NewMessageFormat("Server Message", "" + colors[11] + "-$server- $message"); im.MessageSettings[11] = NewMessageFormat("User Notice", "" + colors[3] + "--$nick-- $message"); im.MessageSettings[12] = NewMessageFormat("Channel Message", "" + colors[0] + "<$color$status$nick> $message"); im.MessageSettings[13] = NewMessageFormat("Self Channel Message", "" + colors[2] + "<$nick> $message"); im.MessageSettings[14] = NewMessageFormat("Channel Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[15] = NewMessageFormat("Self Channel Action", "" + colors[2] + "* $nick $message"); im.MessageSettings[16] = NewMessageFormat("Channel Join", "" + colors[5] + "* $nick ($host)$account has joined channel $channel"); im.MessageSettings[17] = NewMessageFormat("Self Channel Join", "" + colors[5] + "* You have joined $channel"); im.MessageSettings[18] = NewMessageFormat("Channel Part", "" + colors[4] + "* $nick ($host) has left $channel $reason"); im.MessageSettings[19] = NewMessageFormat("Self Channel Part", "" + colors[4] + "* You have left $channel - You will be missed 10 $reason"); im.MessageSettings[20] = NewMessageFormat("Server Quit", "" + colors[21] + "* $nick ($host) Quit ($reason)"); im.MessageSettings[21] = NewMessageFormat("Channel Nick Change", "" + colors[20] + "* $nick is now known as $newnick"); im.MessageSettings[22] = NewMessageFormat("Self Nick Change", "" + colors[20] + "* You are now known as $newnick"); im.MessageSettings[23] = NewMessageFormat("Channel Kick", "" + colors[6] + "* $kickee was kicked by $nick($host) 3 - Reason ($reason)"); im.MessageSettings[24] = NewMessageFormat("Self Channel Kick", "" + colors[6] + "* You were kicked from $channel by $kicker (3$reason)"); im.MessageSettings[25] = NewMessageFormat("Private Message", "" + colors[0] + "<$nick> $message"); im.MessageSettings[26] = NewMessageFormat("Self Private Message", "" + colors[2] + "<$nick>1 $message"); im.MessageSettings[27] = NewMessageFormat("Private Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[28] = NewMessageFormat("Self Private Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[29] = NewMessageFormat("DCC Chat Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[30] = NewMessageFormat("Self DCC Chat Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[31] = NewMessageFormat("DCC Chat Message", "" + colors[0] + "<$nick> $message"); im.MessageSettings[32] = NewMessageFormat("Self DCC Chat Message", "" + colors[2] + "<$nick> $message"); im.MessageSettings[33] = NewMessageFormat("DCC Chat Request", "" + colors[11] + "* $nick ($host) is requesting a DCC Chat"); im.MessageSettings[34] = NewMessageFormat("DCC File Send", "" + colors[11] + "* $nick ($host) is trying to send you a file ($file) [$filesize bytes]"); im.MessageSettings[35] = NewMessageFormat("Channel Topic Change", "" + colors[8] + "* $nick changes topic to: $topic"); im.MessageSettings[36] = NewMessageFormat("Channel Topic Text", "" + colors[8] + " Topic: $topic"); im.MessageSettings[37] = NewMessageFormat("Server MOTD", "" + colors[10] + "$message"); im.MessageSettings[38] = NewMessageFormat("Channel Notice", "" + colors[3] + "-$nick:$status$channel- $message"); im.MessageSettings[39] = NewMessageFormat("Channel Other", "" + colors[9] + "$message"); im.MessageSettings[40] = NewMessageFormat("User Echo", "" + colors[15] + "$message"); im.MessageSettings[41] = NewMessageFormat("Server Error", "" + colors[17] + "ERROR: $message"); im.MessageSettings[42] = NewMessageFormat("User Whois", "" + colors[14] + "->> $nick $data"); im.MessageSettings[43] = NewMessageFormat("User Error", "" + colors[12] + "ERROR: $message"); im.MessageSettings[44] = NewMessageFormat("DCC Chat Connect", "" + colors[18] + "* DCC Chat Connection Established with $nick"); im.MessageSettings[45] = NewMessageFormat("DCC Chat Disconnect", "" + colors[19] + "* DCC Chat Disconnected from $nick"); im.MessageSettings[46] = NewMessageFormat("DCC Chat Outgoing", "" + colors[11] + "* DCC Chat Requested with $nick"); im.MessageSettings[47] = NewMessageFormat("DCC Chat Timeout", "" + colors[11] + "* DCC Chat with $nick timed out"); im.MessageSettings[48] = NewMessageFormat("Self Notice", "" + colors[24] + "--> $nick - $message"); //check if we have this theme already... bool themeFound = false; foreach (ComboItem checkTheme in comboTheme.Items) { if (checkTheme.ThemeName.ToLower().Equals(name.ToLower())) themeFound = true; } if (themeFound == false) { XmlSerializer serializerIM = new XmlSerializer(typeof(IceChatMessageFormat)); string messFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + name + ".xml"; TextWriter textWriterIM = new StreamWriter(messFile); serializerIM.Serialize(textWriterIM, im); textWriterIM.Close(); textWriterIM.Dispose(); ComboItem item = new ComboItem(); item.ThemeName = name; item.ThemeType = "XML"; comboTheme.Items.Add(item); } } } } }