diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-07 15:44:53 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-02-07 15:44:53 +0300 |
commit | 9af7f42494c371f3a79d90a4c2948592ab970b86 (patch) | |
tree | a10a7357a88b888681f37a36a827a836acaa7827 | |
parent | 6acdf173afa655042b4dba4bbb840cb422cad69e (diff) |
Fixes by HaTaX
-rw-r--r-- | ImageGooglerForm.cs | 7 | ||||
-rw-r--r-- | MainForm.cs | 18 | ||||
-rw-r--r-- | NesGame.cs | 18 | ||||
-rw-r--r-- | TreeContructorForm.cs | 2 | ||||
-rw-r--r-- | WorkerForm.cs | 1 |
5 files changed, 24 insertions, 22 deletions
diff --git a/ImageGooglerForm.cs b/ImageGooglerForm.cs index a8818a4b..77f0dc48 100644 --- a/ImageGooglerForm.cs +++ b/ImageGooglerForm.cs @@ -55,14 +55,17 @@ namespace com.clusterrr.hakchi_gui MatchCollection matches = Regex.Matches(responseFromServer, search);
foreach (Match match in matches)
{
- urls.Add(match.Groups[1].Value);
+ urls.Add(HttpUtility.UrlDecode(match.Groups[1].Value.Replace("\\u00", "%")));
}
+ // For some reason Google returns different data for dirrefent users (IPs?)
+ // There is alternative method
search = @"imgurl=(.*?)&";
matches = Regex.Matches(responseFromServer, search);
foreach (Match match in matches)
{
- urls.Add(match.Groups[1].Value);
+ // Not sure about it.
+ urls.Add(HttpUtility.UrlDecode(match.Groups[1].Value.Replace("\\u00", "%")));
}
return urls.ToArray();
diff --git a/MainForm.cs b/MainForm.cs index e8c5ad77..3e95b06a 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -227,7 +227,7 @@ namespace com.clusterrr.hakchi_gui textBoxPublisher.Text = game.Publisher;
textBoxArguments.Text = game.Args;
if (File.Exists(game.IconPath))
- pictureBoxArt.Image = LoadBitmap(game.IconPath);
+ pictureBoxArt.Image = NesGame.LoadBitmap(game.IconPath);
else
pictureBoxArt.Image = null;
textBoxGameGenie.Enabled = game.Type == NesGame.GameType.Cartridge;
@@ -313,7 +313,7 @@ namespace com.clusterrr.hakchi_gui var selected = checkedListBoxGames.SelectedItem;
if (selected == null || !(selected is NesGame)) return;
var game = (selected as NesGame);
- game.SetImage(Image.FromFile(openFileDialogImage.FileName), ConfigIni.EightBitPngCompression);
+ game.SetImage(NesGame.LoadBitmap(openFileDialogImage.FileName), ConfigIni.EightBitPngCompression);
ShowSelected();
}
}
@@ -331,20 +331,6 @@ namespace com.clusterrr.hakchi_gui }
}
- public static Bitmap LoadBitmap(string path)
- {
- //Open file in read only mode
- using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
- //Get a binary reader for the file stream
- using (BinaryReader reader = new BinaryReader(stream))
- {
- //copy the content of the file into a memory stream
- var memoryStream = new MemoryStream(reader.ReadBytes((int)stream.Length));
- //make a new Bitmap object the owner of the MemoryStream
- return new Bitmap(memoryStream);
- }
- }
-
private void textBoxName_TextChanged(object sender, EventArgs e)
{
var selected = checkedListBoxGames.SelectedItem;
@@ -307,10 +307,10 @@ namespace com.clusterrr.hakchi_gui {
var imagePath = Path.Combine(Path.GetDirectoryName(nesFileName), Path.GetFileNameWithoutExtension(nesFileName) + ".png");
if (File.Exists(imagePath))
- cover = Image.FromFile(imagePath);
+ cover = LoadBitmap(imagePath);
imagePath = Path.Combine(Path.GetDirectoryName(nesFileName), Path.GetFileNameWithoutExtension(nesFileName) + ".jpg");
if (File.Exists(imagePath))
- cover = Image.FromFile(imagePath);
+ cover = LoadBitmap(imagePath);
}
if (cover != null)
SetImage(cover, ConfigIni.EightBitPngCompression);
@@ -541,6 +541,20 @@ namespace com.clusterrr.hakchi_gui Debug.WriteLine(ex.Message + ex.StackTrace);
}
}
+
+ public static Bitmap LoadBitmap(string path)
+ {
+ //Open file in read only mode
+ using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
+ //Get a binary reader for the file stream
+ using (BinaryReader reader = new BinaryReader(stream))
+ {
+ //copy the content of the file into a memory stream
+ var memoryStream = new MemoryStream(reader.ReadBytes((int)stream.Length));
+ //make a new Bitmap object the owner of the MemoryStream
+ return new Bitmap(memoryStream);
+ }
+ }
}
}
diff --git a/TreeContructorForm.cs b/TreeContructorForm.cs index e4a4fb0b..9e931754 100644 --- a/TreeContructorForm.cs +++ b/TreeContructorForm.cs @@ -133,7 +133,7 @@ namespace com.clusterrr.hakchi_gui if (node != null && node.Tag is NesGame)
{
var game = node.Tag as NesGame;
- pictureBoxArt.Image = MainForm.LoadBitmap(game.IconPath);
+ pictureBoxArt.Image = NesGame.LoadBitmap(game.IconPath);
pictureBoxArt.Enabled = true;
listViewContent.Enabled = false;
}
diff --git a/WorkerForm.cs b/WorkerForm.cs index 015aea30..7e127649 100644 --- a/WorkerForm.cs +++ b/WorkerForm.cs @@ -919,7 +919,6 @@ namespace com.clusterrr.hakchi_gui lGameGenieDataBase.ImportCodes(lGameGeniePath, true);
lGameGenieDataBase.Save();
}
-
}
catch (Exception ex)
{
|