private void lsvMods_SelectedIndexChanged(object sender, EventArgs e)
{
deleteToolStripMenuItem.Enabled = forceInstallToolStripMenuItem.Enabled
= lsvMods.SelectedItems.Count > 0;
if (lsvMods.SelectedItems.Count > 0)
{
if (imagePreview.Image != null)
imagePreview.Image.Dispose();
imagePreview.Image = null;
imageLoop.Clear();
rtbDescription.Clear();
rtbDescription.AppendText("Loading...");
Mod item = lsvMods.SelectedItems[0].Tag as Mod;
string name = lsvMods.SelectedItems[0].Text;
if (!File.Exists(Paths.CACHE + "\\" + name + ".txt") ||
!GetFilesRegex(Paths.CACHE, Regex.Escape(name) + @"\d?\.jpg").Any())
_7z.Extract(item.Filename, name + "*.*", Paths.CACHE);
rtbDescription.Clear();
Font temp = rtbDescription.SelectionFont;
StringBuilder str = new StringBuilder();
StringBuilder ustr = new StringBuilder();
rtbDescription.SelectionFont = new Font(temp, FontStyle.Bold);
str.AppendLine(name);
foreach (KeyValuePair<string, object> kv in ((Mod)lsvMods.SelectedItems[0].Tag).Properties)
{
if (!kv.Key.StartsWith("."))
str.AppendLine(Thread.CurrentThread
.CurrentCulture.TextInfo.ToTitleCase(kv.Key.ToLower())
+ ": " + kv.Value);
}
rtbDescription.AppendText(str.ToString());
str.Clear();
rtbDescription.SelectionFont = temp;
if (File.Exists(Paths.CACHE + "\\" + name + ".txt"))
{
//Fix for font changing when foreign characters are read
string text = File.ReadAllText(Paths.CACHE + "\\" + name + ".txt");
foreach (char c in text)
{
if (c < 127)
{
str.Append(c);
rtbDescription.AppendText(ustr.ToString());
ustr.Clear();
continue;
}
else
{
ustr.Append(c);
rtbDescription.SelectionFont = temp;
rtbDescription.AppendText(str.ToString());
str.Clear();
}
}
rtbDescription.SelectionFont = temp;
rtbDescription.AppendText(str.ToString());
rtbDescription.AppendText(ustr.ToString());
}
else
{
rtbDescription.SelectionFont = new Font(temp, FontStyle.Italic);
rtbDescription.AppendText("[ No description found. ]");
rtbDescription.SelectionFont = temp;
}
string r = Regex.Escape(name) + @"\d?\.jpg";
imageLoop = GetFilesRegex(Paths.CACHE, Regex.Escape(name) + @"\d?\.jpg");
if (imageLoop.Count > 0)
{
using (Stream s = new FileStream(imageLoop[0], FileMode.Open))
imagePreview.Image = new Bitmap(s);
}
}
}
private void imageTimer_Tick(object sender, EventArgs e)