Skip to content

Commit

Permalink
Fixed #162: Wrong Filename Requested Against Case-Sensitive UNC/Mappe…
Browse files Browse the repository at this point in the history
…d Network Share

- Clean up code
  • Loading branch information
d2phap committed Mar 18, 2017
1 parent bb0928b commit 41f990f
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 155 deletions.
34 changes: 21 additions & 13 deletions Source/Components/ImageGlass.Core/Interpreter.cs
Expand Up @@ -17,25 +17,33 @@ public class Interpreter
/// <returns></returns>
public static Bitmap Load(string path, int @width = 0, int @height = 0)
{
path = path.ToLower();
var ext = Path.GetExtension(path).ToLower();

Bitmap bmp = null;

if (path.EndsWith(".gif"))
{
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
bmp = new Bitmap(path, true);
}
}
else if (path.EndsWith(".ico"))
switch (ext)
{
bmp = ReadIconFile(path);
case ".gif":
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
{
bmp = new Bitmap(path, true);
}
break;

case ".ico":
bmp = ReadIconFile(path);
break;

default:
GetBitmapFromFile();
break;
}
else

void GetBitmapFromFile()
{
var settings = new MagickReadSettings();

if (path.EndsWith(".svg"))
if (ext.CompareTo(".svg") == 0)
{
settings.BackgroundColor = MagickColors.Transparent;
}
Expand Down Expand Up @@ -76,7 +84,7 @@ public static Bitmap Load(string path, int @width = 0, int @height = 0)
bmp = magicImg.ToBitmap();
}
}

return bmp;
}

Expand Down
Expand Up @@ -234,13 +234,13 @@ internal static Image GetThumbnailBmp(string filename, Size size, UseEmbeddedThu

Image source = null;
Image thumb = null;
filename = filename.ToLower();
var ext = Path.GetExtension(filename).ToLower();

try
{
var settings = new MagickReadSettings();

if (filename.EndsWith(".svg"))
if (ext.CompareTo(".svg") == 0)
{
settings.BackgroundColor = MagickColors.Transparent;
}
Expand Down
Expand Up @@ -142,6 +142,7 @@ public static class GlobalSetting
private static Library.Language _langPack = new Library.Language();
private static bool _isPortableMode = false;
private static bool _isStartUpDirWritable = true;
private static bool _isTempMemoryData = false;
private static ConfigurationFile _configFile = new ConfigurationFile();
private static string _builtInImageFormats = "*.jpg;*.jpe;*.jfif;*.jpeg;*.png;*.gif;*.ico;*.bmp;*.dib;*.tif;*.tiff;*.exif;*.wmf;*.emf;*.svg;*.webp;*.tga;|*.hdr;*.exr;*.tga;*.psd;";

Expand Down Expand Up @@ -171,7 +172,6 @@ public static class GlobalSetting

private static bool _isAllowMultiInstances = true;
private static bool _isShowCheckedBackground = false;
private static bool _isTempMemoryData = false;
private static bool _isMouseNavigation = false;

private static bool _isWindowAlwaysOnTop = false;
Expand Down Expand Up @@ -505,7 +505,7 @@ public static bool IsTempMemoryData
}

/// <summary>
/// Gets temporary directory of ImageGlass, e.g. C:\Users\xxx\AppData\Roaming\ImageGlass\
/// Gets temporary directory of ImageGlass, e.g. C:\Users\xxx\AppData\Roaming\ImageGlass\Temp\
/// </summary>
public static string TempDir
{
Expand Down Expand Up @@ -657,42 +657,15 @@ public static void LoadImageOrderConfig()

if (int.TryParse(s, out int i))
{
if (-1 < i && i < 7) //<=== Number of items in array
if (-1 < i && i < Enum.GetNames(typeof(ImageOrderBy)).Length) //<=== Number of items in enum
{ }
else
{
i = 0;
}
}
if (i == 1)
{
ImageOrderBy = ImageOrderBy.Length;
}
else if (i == 2)
{
ImageOrderBy = ImageOrderBy.CreationTime;
}
else if (i == 3)
{
ImageOrderBy = ImageOrderBy.LastAccessTime;
}
else if (i == 4)
{
ImageOrderBy = ImageOrderBy.LastWriteTime;
}
else if (i == 5)
{
ImageOrderBy = ImageOrderBy.Extension;
}
else if (i == 6)
{
ImageOrderBy = ImageOrderBy.Random;
}
else
{
ImageOrderBy = ImageOrderBy.Name;
}


ImageOrderBy = (ImageOrderBy)i;
}

/// <summary>
Expand Down
34 changes: 27 additions & 7 deletions Source/Components/ImageGlass.Theme/frmDialogBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Source/Components/ImageGlass.Theme/frmDialogBox.resx
Expand Up @@ -117,4 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="panel1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAgAAAB4CAYAAADPLbNKAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAADhJREFUWEftyjERADAMA7HwJxkKZuAOvwdA7wdtmt3tZZL0YoABBhhggAEGGGCA
AQYYYIABP4T0AXQ0R3sUNnksAAAAAElFTkSuQmCC
</value>
</data>
</root>
2 changes: 1 addition & 1 deletion Source/ImageGlass/ImageGlass.csproj.user
Expand Up @@ -11,7 +11,7 @@
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>C:\Users\d2pha\Desktop\phap.png</StartArguments>
<StartArguments>D:\DEV\ImageGlass\Samples\GIF\cards.gif</StartArguments>
<RemoteDebugEnabled>false</RemoteDebugEnabled>
<StartWorkingDirectory>
</StartWorkingDirectory>
Expand Down
4 changes: 2 additions & 2 deletions Source/ImageGlass/Properties/AssemblyInfo.cs
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.5.9.19")]
[assembly: AssemblyFileVersion("3.5.9.19")]
[assembly: AssemblyVersion("3.5.9.20")]
[assembly: AssemblyFileVersion("3.5.9.20")]

1 comment on commit 41f990f

@d2phap
Copy link
Owner Author

@d2phap d2phap commented on 41f990f Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit for issue #165

Please sign in to comment.