public FormColors(IceChatMessageFormat MessageFormat, IceChatColors IceChatColors) { InitializeComponent(); this.Load += new EventHandler(FormColors_Load); //add the events for the Tab Bar Color Picker this.pictureTabCurrent.Click += new EventHandler(OnColor_Click); this.pictureTabMessage.Click += new EventHandler(OnColor_Click); this.pictureTabAction.Click += new EventHandler(OnColor_Click); this.pictureTabJoin.Click += new EventHandler(OnColor_Click); this.pictureTabPart.Click += new EventHandler(OnColor_Click); this.pictureTabQuit.Click += new EventHandler(OnColor_Click); this.pictureTabServer.Click += new EventHandler(OnColor_Click); this.pictureTabServerNotice.Click += new EventHandler(OnColor_Click); this.pictureTabBuddyNotice.Click += new EventHandler(OnColor_Click); this.pictureTabOther.Click += new EventHandler(OnColor_Click); this.pictureTabDefault.Click += new EventHandler(OnColor_Click); //add the events for the Nick Color Picker this.pictureAdmin.Click += new EventHandler(OnColor_Click); this.pictureOwner.Click += new EventHandler(OnColor_Click); this.pictureOperator.Click += new EventHandler(OnColor_Click); this.pictureHalfOperator.Click += new EventHandler(OnColor_Click); this.pictureVoice.Click += new EventHandler(OnColor_Click); this.pictureDefault.Click += new EventHandler(OnColor_Click); this.pictureConsole.Click += new EventHandler(OnColor_Click); this.pictureChannel.Click += new EventHandler(OnColor_Click); this.pictureQuery.Click += new EventHandler(OnColor_Click); this.pictureNickList.Click += new EventHandler(OnColor_Click); this.pictureServerList.Click += new EventHandler(OnColor_Click); this.pictureTabBarCurrent1.Click += new EventHandler(OnColor_Click); this.pictureTabBarCurrent2.Click += new EventHandler(OnColor_Click); this.pictureTabBarOther1.Click += new EventHandler(OnColor_Click); this.pictureTabBarOther2.Click += new EventHandler(OnColor_Click); this.pictureTabBackground.Click += new EventHandler(OnColor_Click); this.pictureTabBarHover1.Click += new EventHandler(OnColor_Click); this.pictureTabBarHover2.Click += new EventHandler(OnColor_Click); this.picturePanelHeaderBG1.Click += new EventHandler(OnColor_Click); this.picturePanelHeaderBG2.Click += new EventHandler(OnColor_Click); this.picturePanelHeaderForeColor.Click += new EventHandler(OnColor_Click); this.pictureUnreadTextMarkerColor.Click += new EventHandler(OnColor_Click); this.pictureToolBar.Click += new EventHandler(OnColor_Click); this.pictureMenuBar.Click += new EventHandler(OnColor_Click); this.pictureInputBox.Click += new EventHandler(OnColor_Click); this.pictureInputBoxFore.Click += new EventHandler(OnColor_Click); this.pictureChannelList.Click += new EventHandler(OnColor_Click); this.pictureChannelListFore.Click += new EventHandler(OnColor_Click); this.pictureStatusBar.Click += new EventHandler(OnColor_Click); this.pictureStatusFore.Click += new EventHandler(OnColor_Click); this.pictureHyperlink.Click += new EventHandler(OnColor_Click); this.iceChatColors = IceChatColors; UpdateColorSettings(); messageIdentifiers = new Hashtable(); AddMessageIdentifiers(); colorPicker = new ColorButtonArray(panelColorPicker); colorPicker.OnClick += new ColorButtonArray.ColorSelected(colorPicker_OnClick); treeMessages.AfterSelect += new TreeViewEventHandler(treeMessages_AfterSelect); textRawMessage.TextChanged+=new EventHandler(textRawMessage_TextChanged); textRawMessage.KeyDown += new KeyEventHandler(textRawMessage_KeyDown); listIdentifiers.DoubleClick += new EventHandler(listIdentifiers_DoubleClick); treeBasicMessages.AfterSelect += new TreeViewEventHandler(treeBasicMessages_AfterSelect); tabMessages.SelectedTab = tabBasic; iceChatMessages = MessageFormat; textFormattedText.SingleLine = true; textFormattedText.NoEmoticons = true; textFormattedBasic.SingleLine = true; textFormattedBasic.NoEmoticons = true; //populate Message Settings UpdateMessageSettings(); //load any plugin addons foreach (Plugin p in FormMain.Instance.LoadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (ipc.plugin.Enabled == true) ipc.plugin.LoadColorsForm(this.tabControlColors); } } ApplyLanguage(); if (FormMain.Instance.IceChatOptions.Theme != null) { foreach (ThemeItem theme in FormMain.Instance.IceChatOptions.Theme) { ComboItem item = new ComboItem(); item.ThemeName = theme.ThemeName; item.ThemeType = theme.ThemeType; comboTheme.Items.Add(item); } } if (FormMain.Instance.IceChatPluginThemes != null) { foreach (IThemeIceChat theme in FormMain.Instance.IceChatPluginThemes) { ComboItem item = new ComboItem(); item.ThemeName = theme.Name; item.ThemeType = "Plugin"; item.FileName = theme.FileName; comboTheme.Items.Add(item); } } comboTheme.Text = FormMain.Instance.IceChatOptions.CurrentTheme; this.comboTheme.SelectedIndexChanged += new System.EventHandler(this.comboTheme_SelectedIndexChanged); }
private void comboTheme_SelectedIndexChanged(object sender, EventArgs e) { //change the current theme //ComboItem item = (ComboItem)comboTheme.SelectedItem; ComboItem item = (ComboItem)comboTheme.Items[comboTheme.SelectedIndex]; System.Diagnostics.Debug.WriteLine("Change theme to " + item.ThemeName); string themeColorsFile = ""; string themeMessagesFile = ""; if (item.ThemeName == "Default" && item.ThemeType == "XML") { themeColorsFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatColors.xml"; themeMessagesFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatMessages.xml"; } else if (item.ThemeType == "XML") { themeColorsFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + item.ThemeName + ".xml"; themeMessagesFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + item.ThemeName + ".xml"; } else if (item.ThemeType == "Plugin") { //update the stuff accordingly foreach (IThemeIceChat theme in FormMain.Instance.IceChatPluginThemes) { if (theme.FileName == item.FileName) { //update, this is the match iceChatColors.ChannelAdminColor = theme.ChannelAdminColor; iceChatColors.ChannelBackColor = theme.ChannelBackColor; iceChatColors.ChannelHalfOpColor = theme.ChannelHalfOpColor; iceChatColors.ChannelJoinColorChange = theme.ChannelJoinColorChange; iceChatColors.ChannelListBackColor = theme.ChannelListBackColor; iceChatColors.ChannelListForeColor = theme.ChannelListForeColor; iceChatColors.ChannelOpColor = theme.ChannelOpColor; iceChatColors.ChannelOwnerColor = theme.ChannelOwnerColor; iceChatColors.ChannelPartColorChange = theme.ChannelPartColorChange; iceChatColors.ChannelRegularColor = theme.ChannelRegularColor; iceChatColors.ChannelVoiceColor = theme.ChannelVoiceColor; iceChatColors.ConsoleBackColor = theme.ConsoleBackColor; iceChatColors.InputboxBackColor = theme.InputboxBackColor; iceChatColors.InputboxForeColor = theme.InputboxForeColor; iceChatColors.MenubarBackColor = theme.MenubarBackColor; iceChatColors.NewMessageColorChange = theme.NewMessageColorChange; iceChatColors.NickListBackColor = theme.NickListBackColor; iceChatColors.OtherMessageColorChange = theme.OtherMessageColorChange; iceChatColors.PanelHeaderBG1 = theme.PanelHeaderBG1; iceChatColors.PanelHeaderBG2 = theme.PanelHeaderBG2; iceChatColors.PanelHeaderForeColor = theme.PanelHeaderForeColor; iceChatColors.QueryBackColor = theme.QueryBackColor; iceChatColors.RandomizeNickColors = theme.RandomizeNickColors; iceChatColors.ServerListBackColor = theme.ServerListBackColor; iceChatColors.ServerMessageColorChange = theme.ServerMessageColorChange; iceChatColors.ServerQuitColorChange = theme.ServerQuitColorChange; iceChatColors.StatusbarBackColor = theme.StatusbarBackColor; iceChatColors.StatusbarForeColor = theme.StatusbarForeColor; iceChatColors.TabBarChannelJoin = theme.TabBarChannelJoin; iceChatColors.TabBarChannelPart = theme.TabBarChannelPart; iceChatColors.TabBarCurrent = theme.TabBarCurrent; iceChatColors.TabBarDefault = theme.TabBarDefault; iceChatColors.TabBarNewMessage = theme.TabBarNewMessage; iceChatColors.TabBarOtherMessage = theme.TabBarOtherMessage; iceChatColors.TabBarServerMessage = theme.TabBarServerMessage; iceChatColors.TabBarServerQuit = theme.TabBarServerQuit; iceChatColors.TabBarNewAction = theme.TabBarNewAction; iceChatColors.TabBarServerNotice = theme.TabBarServerNotice; iceChatColors.TabBarBuddyNotice = theme.TabBarBuddyNotice; iceChatColors.ToolbarBackColor = theme.ToolbarBackColor; iceChatColors.UnreadTextMarkerColor = theme.UnreadTextMarkerColor; } } } if (themeColorsFile.Length > 0 && File.Exists(themeColorsFile) && item.ThemeType == "XML") { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatColors)); TextReader textReader = new StreamReader(themeColorsFile); this.iceChatColors = (IceChatColors)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); FormMain.Instance.IceChatOptions.CurrentTheme = item.ThemeName; FormMain.Instance.ColorsFile = themeColorsFile; UpdateColorSettings(); } if (themeMessagesFile.Length > 0 && File.Exists(themeMessagesFile) && item.ThemeType == "XML") { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatMessageFormat)); TextReader textReader = new StreamReader(themeMessagesFile); this.iceChatMessages = (IceChatMessageFormat)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); FormMain.Instance.MessagesFile = themeMessagesFile; UpdateMessageSettings(); } }
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); } } } } }
private void themeChoice_Click(object sender, EventArgs e) { string theme = ((ToolStripMenuItem)sender).Text; if (File.Exists(CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + theme + ".xml")) { try { colorsFile = CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + theme + ".xml"; messagesFile = CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + theme + ".xml"; XmlSerializer deserializer = new XmlSerializer(typeof(IceChatMessageFormat)); TextReader textReader = new StreamReader(messagesFile); iceChatMessages = (IceChatMessageFormat)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); XmlSerializer deserializerC = new XmlSerializer(typeof(IceChatColors)); TextReader textReaderC = new StreamReader(colorsFile); iceChatColors = (IceChatColors)deserializerC.Deserialize(textReaderC); textReaderC.Close(); textReaderC.Dispose(); //save the current theme iceChatOptions.CurrentTheme = theme; SaveOptions(); //update the colors fc_SaveColors(iceChatColors, iceChatMessages); //uncheck all other themes, check this one foreach (ToolStripMenuItem t in themesToolStripMenuItem.DropDownItems) { if (t.Text == theme) t.Checked = true; else t.Checked = false; } } catch (Exception) { WindowMessage(inputPanel.CurrentConnection, "Console", "\x00034Error: Theme Files error for " + theme, "", true); } } else { WindowMessage(inputPanel.CurrentConnection, "Console", "\x00034Error: Theme Files not found for " + theme, "", true); } }
private void fc_SaveColors(IceChatColors colors, IceChatMessageFormat messages) { this.iceChatColors = colors; SaveColors(); this.iceChatMessages = messages; SaveMessageFormat(); toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; serverListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; serverListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; nickListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; nickListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; channelListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; channelListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; buddyListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; buddyListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); serverTree.SetListColors(); nickList.SetListColors(); nickList.Invalidate(); mainChannelBar.Invalidate(); serverTree.Invalidate(); buddyList.Invalidate(); channelList.Invalidate(); panelDockLeft.TabControl.Invalidate(); panelDockRight.TabControl.Invalidate(); //rebuild the themes menu foreach (ToolStripMenuItem t in themesToolStripMenuItem.DropDownItems) t.Click -= themeChoice_Click; themesToolStripMenuItem.DropDownItems.Clear(); this.themesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.defaultToolStripMenuItem}); defaultToolStripMenuItem.Click +=new EventHandler(defaultToolStripMenuItem_Click); foreach (ThemeItem theme in IceChatOptions.Theme) { if (!theme.ThemeName.Equals("Default")) { ToolStripMenuItem t = new ToolStripMenuItem(theme.ThemeName); if (iceChatOptions.CurrentTheme == theme.ThemeName) t.Checked = true; t.Click += new EventHandler(themeChoice_Click); themesToolStripMenuItem.DropDownItems.Add(t); } } //save options (for theme values) SaveOptions(); //update all the console windows foreach (ConsoleTab c in mainChannelBar.GetTabPage("Console").ConsoleTab.TabPages) { ((TextWindow)c.Controls[0]).IRCBackColor = iceChatColors.ConsoleBackColor; } //update all the Channel and Query Tabs Windows foreach (IceTabPage t in mainChannelBar.TabPages) { if (t.WindowStyle == IceTabPage.WindowType.Channel) { t.TopicWindow.IRCBackColor = iceChatColors.ChannelBackColor; t.TextWindow.IRCBackColor = iceChatColors.ChannelBackColor; } if (t.WindowStyle == IceTabPage.WindowType.Query) t.TextWindow.IRCBackColor = iceChatColors.QueryBackColor; if (t.WindowStyle == IceTabPage.WindowType.DCCChat) t.TextWindow.IRCBackColor = iceChatColors.QueryBackColor; } }
public FormMain(string[] args, Form splash) { FormMain.Instance = this; System.Diagnostics.FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); BuildNumber = fv.FileVersion; if (StaticMethods.IsRunningOnMono()) player = new System.Media.SoundPlayer(); else mp3Player = new MP3Player(); bool forceCurrentFolder = false; errorMessages = new List<string>(); _variables = new Variables(); _globalTimers = new List<IrcTimer>(); if (args.Length > 0) { string prevArg = ""; foreach (string arg in args) { if (prevArg.Length == 0) { prevArg = arg; if (arg.ToLower().StartsWith("irc://")) { //parse out the server name and channel name string server = arg.Substring(6).TrimEnd(); if (server.IndexOf("/") != -1) { string host = server.Split('/')[0]; string channel = server.Split('/')[1]; if (channel.StartsWith("#")) autoStartCommand = "/joinserv " + host + " " + channel; else autoStartCommand = "/joinserv " + host + " #" + channel; } else autoStartCommand = "/server " + arg.Substring(6).TrimEnd(); } if (arg.ToLower() == "-disableauto") { disableAutoStart = true; } } else { switch (prevArg.ToLower()) { case "-profile": currentFolder = arg; //check if the folder exists, ir not, create it if (!Directory.Exists(currentFolder)) Directory.CreateDirectory(currentFolder); forceCurrentFolder = true; break; case "-disableauto": disableAutoStart = true; break; } prevArg = ""; } } } //mutex = new System.Threading.Mutex(true, "IceChatMutex"); #region Settings Files //check if the xml settings files exist in current folder if (currentFolder == null) currentFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //check for IceChatPackage.xml in Assembly Folder if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPackage.xml")) { //read the package file //create the IceChatServer.xml file from the package, if it doesnt exist serversFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml"; optionsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatOptions.xml"; if (!File.Exists(serversFile)) { if (!Directory.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings")) Directory.CreateDirectory(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings"); //ask for a Default Nickname InputBoxDialog i = new InputBoxDialog(); i.FormCaption = "Enter Default Nickname"; i.FormPrompt = "Please enter your Nick name"; i.ShowDialog(); if (i.InputResponse.Length > 0) { //changedData[count] = i.InputResponse; System.Diagnostics.Debug.WriteLine("Package Exists - Create Defaults"); XmlSerializer deserializer = new XmlSerializer(typeof(IceChatPackage)); TextReader textReader = new StreamReader(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPackage.xml"); IceChatPackage package = (IceChatPackage)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); IceChatServers servers = new IceChatServers(); foreach (ServerSetting s in package.Servers) { s.NickName = i.InputResponse; s.AltNickName = s.NickName + "_"; s.AwayNickName = s.NickName + "[A]"; servers.AddServer(s); } //save the server(s) to IceChatServer.xml XmlSerializer serializer = new XmlSerializer(typeof(IceChatServers)); TextWriter textWriter = new StreamWriter(serversFile); serializer.Serialize(textWriter, servers); textWriter.Close(); textWriter.Dispose(); servers.listServers.Clear(); serializer = null; textWriter = null; //load the options and save IceChatOptions options = package.Options; serializer = new XmlSerializer(typeof(IceChatOptions)); textWriter = new StreamWriter(optionsFile); serializer.Serialize(textWriter, options); textWriter.Close(); textWriter.Dispose(); currentFolder += System.IO.Path.DirectorySeparatorChar + "Settings"; } i.Dispose(); //change the currentFolder } } //check for Settings/IceChatServer.xml if (File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Settings" + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml")) { currentFolder += System.IO.Path.DirectorySeparatorChar + "Settings"; } else if (!File.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml") && !forceCurrentFolder) { if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody")) Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody"); currentFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody Networks" + Path.DirectorySeparatorChar + "Monody"; } //load all files from the Local AppData folder, unless it exist in the current folder serversFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml"; optionsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatOptions.xml"; messagesFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatMessages.xml"; fontsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatFonts.xml"; colorsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatColors.xml"; soundsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatSounds.xml"; favoriteChannelsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatChannels.xml"; aliasesFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatAliases.xml"; popupsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPopups.xml"; pluginsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPlugins.xml"; emoticonsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Emoticons" + System.IO.Path.DirectorySeparatorChar + "IceChatEmoticons.xml"; channelSettingsFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "ChannelSetting.xml"; colorPaletteFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "ColorPalette.xml"; //set a new logs folder logsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Logs"; scriptsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Scripts"; soundsFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Sounds"; picturesFolder = currentFolder + System.IO.Path.DirectorySeparatorChar + "Pictures"; pluginsFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + System.IO.Path.DirectorySeparatorChar + "Plugins"; if (!Directory.Exists(pluginsFolder)) Directory.CreateDirectory(pluginsFolder); if (!Directory.Exists(scriptsFolder)) Directory.CreateDirectory(scriptsFolder); if (!Directory.Exists(soundsFolder)) Directory.CreateDirectory(soundsFolder); if (!Directory.Exists(picturesFolder)) Directory.CreateDirectory(picturesFolder); if (!Directory.Exists(currentFolder + Path.DirectorySeparatorChar + "Update")) Directory.CreateDirectory(currentFolder + Path.DirectorySeparatorChar + "Update"); #endregion languageFiles = new List<LanguageItem>(); DirectoryInfo languageDirectory = null; languageDirectory = new DirectoryInfo(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages"); if (!Directory.Exists(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages")) Directory.CreateDirectory(currentFolder + System.IO.Path.DirectorySeparatorChar + "Languages"); if (languageDirectory != null) { // scan the language directory for xml files and make LanguageItems for each file FileInfo[] langFiles = languageDirectory.GetFiles("*.xml"); foreach (FileInfo fi in langFiles) { string langFile = languageDirectory.FullName + System.IO.Path.DirectorySeparatorChar + fi.Name; LanguageItem languageItem = LoadLanguageItem(langFile); if (languageItem != null) languageFiles.Add(languageItem); } if (languageFiles.Count == 0) { currentLanguageFile = new LanguageItem(); languageFiles.Add(currentLanguageFile); // default language English } } //load the color palette LoadColorPalette(); LoadOptions(); LoadColors(); LoadSounds(); // use the language saved in options if available, // if not (e.g. user deleted xml file) default is used foreach (LanguageItem li in languageFiles) { if (li.LanguageName == iceChatOptions.Language) { currentLanguageFile = li; break; } } LoadLanguage(); // The language class MUST be loaded before any GUI component is created //set the new log folder if (iceChatOptions.LogFolder.Length > 0) { logsFolder = iceChatOptions.LogFolder; } else { iceChatOptions.LogFolder = logsFolder; } //check if we have any servers/settings saved, if not, load firstrun if (!File.Exists(serversFile)) { FormFirstRun firstRun = new FormFirstRun(currentFolder); firstRun.SaveOptions += new FormFirstRun.SaveOptionsDelegate(FirstRunSaveOptions); firstRun.ShowDialog(this); } InitializeComponent(); //load icons from Embedded Resources or Pictures Image this.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); if (iceChatOptions.SystemTrayIcon == null || iceChatOptions.SystemTrayIcon.Trim().Length == 0) { this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); } else { //make sure the image exists and is an ICO file if (File.Exists(iceChatOptions.SystemTrayIcon)) this.notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(iceChatOptions.SystemTrayIcon); else this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); } //this.notifyIcon.Icon = System.Drawing.Icon.FromHandle(StaticMethods.LoadResourceImage("new-tray-icon.ico").GetHicon()); this.notifyIcon.Visible = iceChatOptions.ShowSytemTrayIcon; //disable this by default this.toolStripUpdate.Visible = false; this.updateAvailableToolStripMenuItem1.Visible = false; serverListToolStripMenuItem.Checked = iceChatOptions.ShowServerTree; panelDockLeft.Visible = serverListToolStripMenuItem.Checked; splitterLeft.Visible = serverListToolStripMenuItem.Checked; nickListToolStripMenuItem.Checked = iceChatOptions.ShowNickList; panelDockRight.Visible = nickListToolStripMenuItem.Checked; panelDockRight.TabControl.Alignment = TabAlignment.Right; splitterRight.Visible = nickListToolStripMenuItem.Checked; statusBarToolStripMenuItem.Checked = iceChatOptions.ShowStatusBar; statusStripMain.Visible = statusBarToolStripMenuItem.Checked; toolBarToolStripMenuItem.Checked = iceChatOptions.ShowToolBar; toolStripMain.Visible = toolBarToolStripMenuItem.Checked; viewChannelBarToolStripMenuItem.Checked = iceChatOptions.ShowTabBar; mainChannelBar.Visible = iceChatOptions.ShowTabBar; mainChannelBar.SingleRow = iceChatOptions.SingleRowTabBar; this.Text = ProgramID + " " + VersionID; //this can be customized if (iceChatOptions.SystemTrayText == null || iceChatOptions.SystemTrayText.Trim().Length == 0) this.notifyIcon.Text = ProgramID + " " + VersionID; else this.notifyIcon.Text = iceChatOptions.SystemTrayText; if (!Directory.Exists(logsFolder)) Directory.CreateDirectory(logsFolder); try { errorFile = new StreamWriter(logsFolder + System.IO.Path.DirectorySeparatorChar + "errors.log", true); } catch (IOException io) { System.Diagnostics.Debug.WriteLine("Can not create errors.log:" + io.Message); } catch (Exception eo) { System.Diagnostics.Debug.WriteLine("Can not create errors.log:" + eo.Message); } if (iceChatOptions.WindowSize != null) { if (iceChatOptions.WindowSize.Width > 100 && iceChatOptions.WindowSize.Height > 100) { this.Size = iceChatOptions.WindowSize; this.WindowState = iceChatOptions.WindowState; } else { this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; } } else { this.Width = Screen.PrimaryScreen.WorkingArea.Width; this.Height = Screen.PrimaryScreen.WorkingArea.Height; } if (iceChatOptions.WindowLocation != null) { //check if the location is valid, could try and place it on a 2nd screen that no longer exists if (Screen.AllScreens.Length == 1) { if (Screen.PrimaryScreen.Bounds.Contains(iceChatOptions.WindowLocation)) this.Location = iceChatOptions.WindowLocation; } else { //check if we are in the bounds of the screen location foreach (Screen screen in Screen.AllScreens) if (screen.Bounds.Contains(iceChatOptions.WindowLocation)) this.Location = iceChatOptions.WindowLocation; } } statusStripMain.Visible = iceChatOptions.ShowStatusBar; LoadAliases(); LoadPopups(); LoadEmoticons(); LoadMessageFormat(); LoadFonts(); bool fileThemeFound = true; if (iceChatOptions.CurrentTheme == null) { iceChatOptions.CurrentTheme = "Default"; defaultToolStripMenuItem.Checked = true; //reload all the theme files } else { //load in the new color theme, if it not Default if (iceChatOptions.CurrentTheme != "Default") { string themeFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + iceChatOptions.CurrentTheme + ".xml"; if (File.Exists(themeFile)) { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatColors)); TextReader textReader = new StreamReader(themeFile); iceChatColors = (IceChatColors)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); colorsFile = themeFile; } else { System.Diagnostics.Debug.WriteLine("Color Theme File not found:" + themeFile); fileThemeFound = false; } themeFile = currentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + iceChatOptions.CurrentTheme + ".xml"; if (File.Exists(themeFile)) { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatMessageFormat)); TextReader textReader = new StreamReader(themeFile); iceChatMessages = (IceChatMessageFormat)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); messagesFile = themeFile; } else { System.Diagnostics.Debug.WriteLine("Messages Theme File not found:" + themeFile); fileThemeFound = false; } } else defaultToolStripMenuItem.Checked = true; } if (iceChatOptions.Theme == null) { defaultToolStripMenuItem.Checked = true; iceChatOptions.CurrentTheme = "Default"; DirectoryInfo _currentFolder = new DirectoryInfo(currentFolder); FileInfo[] xmlFiles = _currentFolder.GetFiles("*.xml"); int totalThemes = 1; foreach (FileInfo fi in xmlFiles) { if (fi.Name.StartsWith("Colors-")) { totalThemes++; } } iceChatOptions.Theme = new ThemeItem[totalThemes]; iceChatOptions.Theme[0] = new ThemeItem(); iceChatOptions.Theme[0].ThemeName = "Default"; iceChatOptions.Theme[0].ThemeType = "XML"; int t = 1; foreach (FileInfo fi in xmlFiles) { if (fi.Name.StartsWith("Colors-")) { string themeName = fi.Name.Replace("Colors-", "").Replace(".xml", ""); ; iceChatOptions.Theme[t] = new ThemeItem(); iceChatOptions.Theme[t].ThemeName = themeName; iceChatOptions.Theme[t].ThemeType = "XML"; t++; } } } channelList = new ChannelList(this); channelList.Dock = DockStyle.Fill; buddyList = new BuddyList(this); buddyList.Dock = DockStyle.Fill; toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); serverTree.SetListColors(); nickList.SetListColors(); this.nickList.Header = iceChatLanguage.consoleTabTitle; nickListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; nickListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; serverListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; serverListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; channelListTab = new TabPage("Favorite Channels"); Panel channelPanel = new Panel(); channelPanel.Dock = DockStyle.Fill; channelPanel.Controls.Add(channelList); channelListTab.Controls.Add(channelPanel); channelListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; channelListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; buddyListTab = new TabPage("Buddy List"); Panel buddyPanel = new Panel(); buddyPanel.Dock = DockStyle.Fill; buddyPanel.Controls.Add(buddyList); buddyListTab.Controls.Add(buddyPanel); buddyListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; buddyListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; panelDockLeft.Width = iceChatOptions.LeftPanelWidth; panelDockRight.Width = iceChatOptions.RightPanelWidth; //Load the panel items in order if (iceChatOptions.LeftPanels != null) { foreach (string arrayitem in iceChatOptions.LeftPanels) { if (arrayitem == serverListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(serverListTab); else if (arrayitem == channelListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(channelListTab); else if (arrayitem == nickListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(nickListTab); else if (arrayitem == buddyListTab.Text) this.panelDockLeft.TabControl.TabPages.Add(buddyListTab); } } if (iceChatOptions.RightPanels != null) { foreach (string arrayitem in iceChatOptions.RightPanels) { if (arrayitem == serverListTab.Text) this.panelDockRight.TabControl.TabPages.Add(serverListTab); else if (arrayitem == nickListTab.Text) this.panelDockRight.TabControl.TabPages.Add(nickListTab); else if (arrayitem == channelListTab.Text) this.panelDockRight.TabControl.TabPages.Add(channelListTab); else if (arrayitem == buddyListTab.Text) this.panelDockRight.TabControl.TabPages.Add(buddyListTab); } } //If any panels are missing if (!panelDockLeft.TabControl.TabPages.Contains(serverListTab) && !panelDockRight.TabControl.TabPages.Contains(serverListTab)) this.panelDockLeft.TabControl.TabPages.Add(serverListTab); if (!panelDockLeft.TabControl.TabPages.Contains(nickListTab) && !panelDockRight.TabControl.TabPages.Contains(nickListTab)) this.panelDockRight.TabControl.TabPages.Add(nickListTab); if (!panelDockLeft.TabControl.TabPages.Contains(channelListTab) && !panelDockRight.TabControl.TabPages.Contains(channelListTab)) this.panelDockRight.TabControl.TabPages.Add(channelListTab); if (!panelDockLeft.TabControl.TabPages.Contains(buddyListTab) && !panelDockRight.TabControl.TabPages.Contains(buddyListTab)) this.panelDockRight.TabControl.TabPages.Add(buddyListTab); this.MinimumSize = new Size(panelDockLeft.Width + panelDockRight.Width + 300, 300); //hide the left or right panel if it is empty if (panelDockLeft.TabControl.TabPages.Count == 0) { this.splitterLeft.Visible = false; panelDockLeft.Visible = false; this.MinimumSize = new Size(panelDockRight.Width + 300, 300); } if (panelDockRight.TabControl.TabPages.Count == 0) { this.splitterRight.Visible = false; panelDockRight.Visible = false; if (panelDockLeft.Visible) this.MinimumSize = new Size(panelDockLeft.Width + 300, 300); else this.MinimumSize = new Size(300, 300); } if (iceChatOptions.LockWindowSize) { fixWindowSizeToolStripMenuItem.Checked = true; this.FormBorderStyle = FormBorderStyle.FixedSingle; } nickList.Font = new Font(iceChatFonts.FontSettings[3].FontName, iceChatFonts.FontSettings[3].FontSize); serverTree.Font = new Font(iceChatFonts.FontSettings[4].FontName, iceChatFonts.FontSettings[4].FontSize); mainChannelBar.TabFont = new Font(iceChatFonts.FontSettings[8].FontName, iceChatFonts.FontSettings[8].FontSize); menuMainStrip.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize); toolStripMain.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize); inputPanel.OnCommand +=new InputPanel.OnCommandDelegate(inputPanel_OnCommand); inputPanel.InputBoxFont = new Font(iceChatFonts.FontSettings[5].FontName, iceChatFonts.FontSettings[5].FontSize); inputPanel.ShowColorPicker = iceChatOptions.ShowColorPicker; inputPanel.ShowEmoticonPicker = iceChatOptions.ShowEmoticonPicker; inputPanel.ShowBasicCommands = iceChatOptions.ShowBasicCommands; inputPanel.ShowSendButton = iceChatOptions.ShowSendButton; inputPanel.ShowWideTextPanel = iceChatOptions.ShowMultilineEditbox; if (iceChatOptions.ShowEmoticons == false) inputPanel.ShowEmoticonPicker = false; mainChannelBar.OnTabClosed += new ChannelBar.TabClosedDelegate(OnTabClosed); mainChannelBar.SelectedIndexChanged += new ChannelBar.TabEventHandler(OnTabSelectedIndexChanged); panelDockLeft.Initialize(); panelDockRight.Initialize(); if (iceChatOptions.DockLeftPanel == true) panelDockLeft.DockControl(); if (iceChatOptions.DockRightPanel == true) panelDockRight.DockControl(); LoadChannelSettings(); CreateDefaultConsoleWindow(); //**** WindowMessage(null, "Console", "\x000304Data Folder: " + currentFolder, "", true); WindowMessage(null, "Console", "\x000304Plugins Folder: " + pluginsFolder, "", true); WindowMessage(null, "Console", "\x000304Logs Folder: " + logsFolder, "", true); serverTree.NewServerConnection += new NewServerConnectionDelegate(NewServerConnection); serverTree.SaveDefault += new ServerTree.SaveDefaultDelegate(OnDefaultServerSettings); loadedPluginThemes = new List<IThemeIceChat>(); loadedPlugins = new List<Plugin>(); //load the plugin settings file LoadPluginFiles(); //load any plugin addons LoadPlugins(); //**** WindowMessage(null, "Console", "\x00034Using Theme - " + iceChatOptions.CurrentTheme, "", true); //set any plugins as disabled //add any items to the pluginsFile if they do not exist, or remove any that do not foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { bool found = false; for (int i = 0; i < iceChatPlugins.listPlugins.Count; i++) { if (iceChatPlugins.listPlugins[i].PluginFile.Equals(ipc.plugin.FileName)) { found = true; if (iceChatPlugins.listPlugins[i].Enabled == false) { WindowMessage(null, "Console", "\x000304Disabled Plugin - " + ipc.plugin.Name + " v" + ipc.plugin.Version, "", true); foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems) if (t.ToolTipText.ToLower() == ipc.plugin.FileName.ToLower()) t.Image = StaticMethods.LoadResourceImage("CloseButton.png"); ipc.plugin.Enabled = false; } } } if (found == false) { //plugin file not found in plugin Items file, add it PluginItem item = new PluginItem(); item.Enabled = true; item.PluginFile = ipc.plugin.FileName; iceChatPlugins.AddPlugin(item); SavePluginFiles(); } } } if (iceChatPlugins.listPlugins.Count != loadedPlugins.Count) { //find the file that is missing List<int> removeItems = new List<int>(); for (int i = 0; i < iceChatPlugins.listPlugins.Count; i++) { bool found = false; foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (iceChatPlugins.listPlugins[i].PluginFile.Equals(ipc.plugin.FileName)) found = true; } } if (found == false) removeItems.Add(i); } if (removeItems.Count > 0) { try { foreach (int i in removeItems) iceChatPlugins.listPlugins.Remove(iceChatPlugins.listPlugins[i]); } catch { } SavePluginFiles(); } } //initialize each of the plugins on its own thread foreach (Plugin p in loadedPlugins) { IceChatPlugin ipc = p as IceChatPlugin; if (ipc != null) { if (ipc.plugin.Enabled == true) { System.Threading.Thread initPlugin = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(InitializePlugin)); initPlugin.Start(ipc.plugin); } } } foreach (string s in errorMessages) { WindowMessage(null, "Console", "\x000304Error: " + s,"", true); } errorMessages.Clear(); pluginsToolStripMenuItem.DropDownOpening += new EventHandler(pluginsToolStripMenuItem_DropDownOpening); if (fileThemeFound == false) { //check for the Plugin File theme foreach (IThemeIceChat theme in IceChatPluginThemes) { if (theme.Name == iceChatOptions.CurrentTheme) { //update, this is the match iceChatColors.ChannelAdminColor = theme.ChannelAdminColor; iceChatColors.ChannelBackColor = theme.ChannelBackColor; iceChatColors.ChannelHalfOpColor = theme.ChannelHalfOpColor; iceChatColors.ChannelJoinColorChange = theme.ChannelJoinColorChange; iceChatColors.ChannelListBackColor = theme.ChannelListBackColor; iceChatColors.ChannelListForeColor = theme.ChannelListForeColor; iceChatColors.ChannelOpColor = theme.ChannelOpColor; iceChatColors.ChannelOwnerColor = theme.ChannelOwnerColor; iceChatColors.ChannelPartColorChange = theme.ChannelPartColorChange; iceChatColors.ChannelRegularColor = theme.ChannelRegularColor; iceChatColors.ChannelVoiceColor = theme.ChannelVoiceColor; iceChatColors.ConsoleBackColor = theme.ConsoleBackColor; iceChatColors.InputboxBackColor = theme.InputboxBackColor; iceChatColors.InputboxForeColor = theme.InputboxForeColor; iceChatColors.MenubarBackColor = theme.MenubarBackColor; iceChatColors.NewMessageColorChange = theme.NewMessageColorChange; iceChatColors.NickListBackColor = theme.NickListBackColor; iceChatColors.OtherMessageColorChange = theme.OtherMessageColorChange; iceChatColors.PanelHeaderBG1 = theme.PanelHeaderBG1; iceChatColors.PanelHeaderBG2 = theme.PanelHeaderBG2; iceChatColors.PanelHeaderForeColor = theme.PanelHeaderForeColor; iceChatColors.QueryBackColor = theme.QueryBackColor; iceChatColors.RandomizeNickColors = theme.RandomizeNickColors; iceChatColors.ServerListBackColor = theme.ServerListBackColor; iceChatColors.ServerMessageColorChange = theme.ServerMessageColorChange; iceChatColors.ServerQuitColorChange = theme.ServerQuitColorChange; iceChatColors.StatusbarBackColor = theme.StatusbarBackColor; iceChatColors.StatusbarForeColor = theme.StatusbarForeColor; iceChatColors.TabBarChannelJoin = theme.TabBarChannelJoin; iceChatColors.TabBarChannelPart = theme.TabBarChannelPart; iceChatColors.TabBarCurrent = theme.TabBarCurrent; iceChatColors.TabBarDefault = theme.TabBarDefault; iceChatColors.TabBarNewMessage = theme.TabBarNewMessage; iceChatColors.TabBarOtherMessage = theme.TabBarOtherMessage; iceChatColors.TabBarServerMessage = theme.TabBarServerMessage; iceChatColors.TabBarServerQuit = theme.TabBarServerQuit; iceChatColors.ToolbarBackColor = theme.ToolbarBackColor; iceChatColors.UnreadTextMarkerColor = theme.UnreadTextMarkerColor; inputPanel.SetInputBoxColors(); toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor]; menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor]; statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor]; toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor]; serverListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; serverListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; nickListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; nickListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; channelListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; channelListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; buddyListTab.BackColor = IrcColor.colors[iceChatColors.PanelHeaderBG1]; buddyListTab.ForeColor = IrcColor.colors[iceChatColors.PanelHeaderForeColor]; inputPanel.SetInputBoxColors(); channelList.SetListColors(); buddyList.SetListColors(); nickList.SetListColors(); serverTree.SetListColors(); nickList.Invalidate(); mainChannelBar.Invalidate(); serverTree.Invalidate(); } } } //add the themes to the view menu if (iceChatOptions.Theme != null) { foreach (ThemeItem theme in iceChatOptions.Theme) { if (!theme.ThemeName.Equals("Default")) { ToolStripMenuItem t = new ToolStripMenuItem(theme.ThemeName); if (iceChatOptions.CurrentTheme == theme.ThemeName) t.Checked = true; t.Click += new EventHandler(themeChoice_Click); themesToolStripMenuItem.DropDownItems.Add(t); } } } this.FormClosing += new FormClosingEventHandler(FormMainClosing); this.Resize += new EventHandler(FormMainResize); if (iceChatOptions.IdentServer && !System.Diagnostics.Debugger.IsAttached) identServer = new IdentServer(); if (iceChatLanguage.LanguageName != "English") ApplyLanguage(); // ApplyLanguage can first be called after all child controls are created //get a new router ip if (!System.Diagnostics.Debugger.IsAttached) { if (iceChatOptions.DCCAutogetRouterIP == true) { System.Threading.Thread dccThread = new System.Threading.Thread(getLocalIPAddress); dccThread.Name = "DCCIPAutoUpdate"; dccThread.Start(); } } splash.Close(); splash.Dispose(); this.Activated += new EventHandler(FormMainActivated); nickList.ShowNickButtons = iceChatOptions.ShowNickButtons; serverTree.ShowServerButtons = iceChatOptions.ShowServerButtons; showButtonsNickListToolStripMenuItem.Checked = iceChatOptions.ShowNickButtons; showButtonsServerTreeToolStripMenuItem1.Checked = iceChatOptions.ShowServerButtons; // check for background images for nicklist and server tree if (iceChatOptions.NickListImage != null && iceChatOptions.NickListImage.Length > 0) { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.NickListImage)) this.nickList.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.NickListImage; else if (File.Exists(iceChatOptions.NickListImage)) this.nickList.BackGroundImage = iceChatOptions.NickListImage; } if (iceChatOptions.ServerTreeImage != null && iceChatOptions.ServerTreeImage.Length > 0) { if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.ServerTreeImage)) this.serverTree.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + iceChatOptions.ServerTreeImage; else if (File.Exists(iceChatOptions.NickListImage)) this.serverTree.BackGroundImage = iceChatOptions.ServerTreeImage; } this.flashTrayIconTimer = new System.Timers.Timer(2000); this.flashTrayIconTimer.Enabled = false; this.flashTrayIconTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTrayIconTimer_Elapsed); this.notifyIcon.Tag = "off"; this.flashTrayCount = 0; this.flashTaskBarIconTimer = new System.Timers.Timer(2000); this.flashTaskBarIconTimer.Enabled = false; this.flashTaskBarIconTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTaskBarIconTimer_Elapsed); this.Tag = "off"; this.flashTrayCount = 0; //new toolstrip renderer for the main menu strip menuMainStrip.RenderMode = ToolStripRenderMode.System; toolStripMain.RenderMode = ToolStripRenderMode.System; //setup windowed mode if saved if (iceChatOptions.WindowedMode) { resizeWindowToolStripMenuItem.PerformClick(); } if (!System.Diagnostics.Debugger.IsAttached) { //check for an update and setup DDE, if NOT in debugger System.Threading.Thread checkThread = new System.Threading.Thread(checkForUpdate); checkThread.Start(); } System.Diagnostics.Debug.WriteLine(mainChannelBar.Height + ":" + mainChannelBar.Location.Y + ":" + mainChannelBar.Visible + ":" + mainChannelBar.Parent.Name); foreach (string s in args) { if (s.IndexOf(' ') > -1) _args += " \"" + s + "\""; else _args += " " + s; } }
private void LoadColors() { if (File.Exists(colorsFile)) { XmlTextReader textReader = null; try { XmlSerializer deserializer = new XmlSerializer(typeof(IceChatColors)); textReader = new XmlTextReader(colorsFile); iceChatColors = (IceChatColors)deserializer.Deserialize(textReader); textReader.Close(); } catch (Exception) { textReader.Close(); errorMessages.Add("There was a problem loading IceChatColors.xml. Default colors loaded"); iceChatColors = new IceChatColors(); } } else iceChatColors = new IceChatColors(); }