From 6bca080d93e73132a7d41977687bffc476cff697 Mon Sep 17 00:00:00 2001 From: Patrick Griffs Date: Sun, 17 Jun 2012 05:45:08 +0200 Subject: Add XChat Theme Manager (TingPing) --- src/xtm/Main.cs | 269 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 src/xtm/Main.cs (limited to 'src/xtm/Main.cs') diff --git a/src/xtm/Main.cs b/src/xtm/Main.cs new file mode 100644 index 00000000..e740e994 --- /dev/null +++ b/src/xtm/Main.cs @@ -0,0 +1,269 @@ +/* XChat Theme Manager + * + * Copyright (C) 2012 Patrick Griffs + * Copyright (C) 2012 Berke Viktor + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +using System; +using System.Collections.Generic; +using System.Collections; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +/* using System.IO.Compression; */ +using System.IO.Packaging; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Net; + +namespace thememan +{ + public partial class XTM : Form + { + public string appdata = (Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\X-Chat 2\\"); + public string home = (Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/.xchat2/"); + + public string xchatdir; + public string themedir = "themes\\"; + + OpenFileDialog importDialog; + + public XTM () + { + InitializeComponent (); + + if (File.Exists ("portable-mode")) + xchatdir = ("config\\"); + else if (Directory.Exists (appdata)) + xchatdir = (appdata); + else if (Directory.Exists (home)) { + xchatdir = (home); themedir = "themes/"; + } else + Console.WriteLine("Install not found"); + + ListThemes(); + } + + private void ListThemes() + { + themelist.Items.Clear(); + + if (Directory.Exists(xchatdir + themedir)) + { + foreach (string theme in Directory.GetDirectories(xchatdir + themedir)) + { + themelist.Items.Add(theme.Remove(0, xchatdir.Length + themedir.Length)); + } + } + else + { + Directory.CreateDirectory(xchatdir + themedir); + } + + if (themelist.Items.Count == 0) + { + applybutton.Enabled = false; + } + else + { + themelist.SetSelected(0, true); + } + } + + private void ShowColors(List> themecolors) + { + List labels = this.Controls.OfType