/** * HexChat 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 HTM : Form { public string hexchatdir; public string themedir; OpenFileDialog importDialog; public HTM () { InitializeComponent (); if (RunningOnWindows() && File.Exists("portable-mode")) { hexchatdir = ("config\\"); if (!Directory.Exists(hexchatdir)) { MessageBox.Show("HexChat installation not found!\nCheck your .\\config folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(1); } } else { /* Environment.SpecialFolder.ApplicationData * Windows: %APPDATA% * Unix: ~/.config * Windows is case-insensitive so 'hexchat' should be fine for both */ hexchatdir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "hexchat"); if (!Directory.Exists(hexchatdir)) { if (RunningOnWindows()) { MessageBox.Show("HexChat installation not found!\nCheck your %APPDATA%\\HexChat folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("HexChat installation not found!\nCheck your ~/.config/hexchat folder", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Environment.Exit(1); } } themedir = Path.Combine(hexchatdir, "themes"); ListThemes(); String[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 1) { FileInfo fi = new FileInfo(arguments[1]); attemptImport(fi); } } private bool RunningOnWindows() { if (Environment.OSVersion.ToString().ToLower().Contains("windows")) { return true; } else { return false; } } private void ListThemes() { themelist.Items.Clear(); if (Directory.Exists(themedir)) { foreach (string theme in Directory.GetDirectories(themedir)) { themelist.Items.Add(theme.Remove(0, themedir.Length + 1)); } } else { Directory.CreateDirectory(themedir); } if (themelist.Items.Count == 0) { applybutton.Enabled = false; deleteButton.Enabled = false; } else { themelist.SetSelected(0, true); } } private void ShowColors(List> themecolors) { List labels = this.Controls.OfType