private IceChatServers LoadServers() { IceChatServers servers; XmlSerializer deserializer = new XmlSerializer(typeof(IceChatServers)); if (File.Exists(FormMain.Instance.ServersFile)) { TextReader textReader = new StreamReader(FormMain.Instance.ServersFile); servers = (IceChatServers)deserializer.Deserialize(textReader); textReader.Close(); textReader.Dispose(); } else { //create default server settings servers = new IceChatServers(); SaveServers(servers); } return servers; }
internal void SaveServers(IceChatServers servers) { XmlSerializer serializer = new XmlSerializer(typeof(IceChatServers)); TextWriter textWriter = new StreamWriter(FormMain.Instance.ServersFile); serializer.Serialize(textWriter, servers); textWriter.Close(); textWriter.Dispose(); }
public ServerTree() { InitializeComponent(); headerCaption = "Favorite Servers"; this.MouseUp += new MouseEventHandler(OnMouseUp); this.MouseDown += new MouseEventHandler(OnMouseDown); this.MouseMove += new MouseEventHandler(OnMouseMove); this.MouseWheel += new MouseEventHandler(OnMouseWheel); this.DoubleClick += new EventHandler(OnDoubleClick); this.Paint += new PaintEventHandler(OnPaint); this.FontChanged += new EventHandler(OnFontChanged); this.Resize += new EventHandler(OnResize); this.KeyDown += new KeyEventHandler(OnKeyDown); this.panelButtons.Resize += new EventHandler(panelButtons_Resize); this.panelButtons.VisibleChanged += new EventHandler(panelButtons_VisibleChanged); this.vScrollBar.Scroll += new ScrollEventHandler(OnScroll); this.DoubleBuffered = true; SetStyle(ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); serverConnections = new SortedList(); serverNodes = new List<KeyValuePair<string,object>>(); serversCollection = LoadServers(); //renumber the server ID's if needed int serverID = 1; foreach (ServerSetting s in serversCollection.listServers) { if (s.AltNickName == null) s.AltNickName = s.NickName + "_"; s.IAL = new Hashtable(); s.ID = serverID; serverID++; } flashTabTimer = new System.Timers.Timer(); flashTabTimer.Interval = 1000; flashTabTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnFlashTabTimerElapsed); toolTip = new ToolTip(); toolTip.AutoPopDelay = 3000; Invalidate(); }
private void MakeDefaultFiles() { //make the server file string serversFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml"; IceChatServers servers = new IceChatServers(); int ID = 1; _nickName = _nickName.Replace(" ", ""); _nickName = _nickName.Replace("#", ""); _nickName = _nickName.Replace(",", ""); _nickName = _nickName.Replace("`", ""); FormMain.Instance.IceChatOptions.DefaultNick = _nickName; if (comboData.Text.Length > 0) { ServerSetting s = new ServerSetting(); s.ID = ID; s.ServerName = comboData.Text; s.NickName = _nickName; s.AltNickName = _nickName + "_"; s.ServerPort = "6667"; s.FullName = FormMain.Instance.IceChatOptions.DefaultFullName; s.IdentName = FormMain.Instance.IceChatOptions.DefaultIdent; s.QuitMessage = FormMain.Instance.IceChatOptions.DefaultQuitMessage; s.SetModeI = true; if (comboData.Text.ToLower() == "irc.quakenet.org") { s.AutoJoinChannels = new string[] { "#icechat" }; s.AutoJoinEnable = true; } ID++; servers.AddServer(s); } foreach (string server in comboData.Items) { if (server != comboData.Text && server.Length > 0) { ServerSetting ss = new ServerSetting(); ss.ID = ID; ss.ServerName = server; ss.NickName = _nickName; ss.AltNickName = _nickName + "_"; ss.ServerPort = "6667"; ss.SetModeI = true; ss.FullName = FormMain.Instance.IceChatOptions.DefaultFullName; ss.IdentName = FormMain.Instance.IceChatOptions.DefaultIdent; ss.QuitMessage = FormMain.Instance.IceChatOptions.DefaultQuitMessage; if (server.ToLower() == "irc.quakenet.org") { ss.AutoJoinChannels = new string[] { "#icechat" }; ss.AutoJoinEnable = true; } ID++; servers.AddServer(ss); } } XmlSerializer serializer = new XmlSerializer(typeof(IceChatServers)); TextWriter textWriter = new StreamWriter(FormMain.Instance.ServersFile); serializer.Serialize(textWriter, servers); textWriter.Close(); textWriter.Dispose(); //make the default aliases file string aliasesFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatAliases.xml"; IceChatAliases aliasList = new IceChatAliases(); foreach (string alias in Default_Aliases) { AliasItem a = new AliasItem(); string name = alias.Substring(0,alias.IndexOf(" ")).Trim(); string command = alias.Substring(alias.IndexOf(" ") + 1); a.AliasName = name; a.Command = new String[] { command }; aliasList.AddAlias(a); } XmlSerializer serializerA = new XmlSerializer(typeof(IceChatAliases)); TextWriter textWriterA = new StreamWriter(aliasesFile); serializerA.Serialize(textWriterA, aliasList); textWriterA.Close(); textWriterA.Dispose(); //make the default popups file string popupsFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPopups.xml"; IceChatPopupMenus popupList = new IceChatPopupMenus(); popupList.AddPopup(newPopupMenu("NickList", Nicklist_Popup)); popupList.AddPopup(newPopupMenu("Console", Console_Popup)); popupList.AddPopup(newPopupMenu("Channel", Channel_Popup)); popupList.AddPopup(newPopupMenu("Query", Query_Popup)); XmlSerializer serializerP = new XmlSerializer(typeof(IceChatPopupMenus)); TextWriter textWriterP = new StreamWriter(popupsFile); serializerP.Serialize(textWriterP, popupList); textWriterP.Close(); textWriterP.Dispose(); }