-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to drag drop exception when Options not opened
Some poor logic uses the OptionsForm controls for settings which doesn't work when the form hasn't been opened previously. Made a change (fixes #7). Also changed the default app.config settings (fixes #6).
- Loading branch information
1 parent
cce6259
commit 4eee6ef
Showing
4 changed files
with
45 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,8 @@ private List<Rectangle> Boxes | |
private static string ThirdPartyImageConverterPath; | ||
public static bool PromptForDestinationFolder = true; | ||
public static bool AutoOpenDestinationFolder = true; | ||
|
||
public static bool MakeBackgroundTransparent = true; | ||
public static bool PreservePallette = false; | ||
|
||
private System.Threading.Timer multipleUnpackerTimer; | ||
#endregion | ||
|
@@ -66,6 +66,41 @@ public MainForm() | |
this.InitializeComponent(); | ||
} | ||
|
||
private void MainForm_Load(object sender, System.EventArgs e) | ||
{ | ||
try | ||
{ | ||
this.SuppressThirdPartyWarningMessage = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["SuppressThirdPartyImageConverterWarningMessage"]); | ||
this.ExportLocationTextBox.Text = AppDomain.CurrentDomain.BaseDirectory; | ||
this.KeyPreview = true; | ||
ThirdPartyImageConverterPath = System.Configuration.ConfigurationManager.AppSettings["ThirdPartyImageConverter"]; | ||
|
||
if (ThirdPartyImageConverterPath.StartsWith("\\")) | ||
{ | ||
ThirdPartyImageConverterPath = AppDomain.CurrentDomain.BaseDirectory + ThirdPartyImageConverterPath; | ||
} | ||
AutoOpenDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AutoOpenDestinationFolder"]); | ||
PromptForDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PromptForDestinationFolder"]); | ||
Outline.Width = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TileOutlineWidth"]); | ||
DistanceBetweenTiles = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DistanceBetweenFrames"]); | ||
MakeBackgroundTransparent = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsMakeBackgroundTransparent"]); | ||
PreservePallette = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PreservePallette"]); | ||
|
||
Dictionary<string, System.Drawing.Imaging.ImageFormat> formats = new Dictionary<string, System.Drawing.Imaging.ImageFormat>(); | ||
formats.Add("png", System.Drawing.Imaging.ImageFormat.Png); | ||
formats.Add("bmp", System.Drawing.Imaging.ImageFormat.Bmp); | ||
formats.Add("gif", System.Drawing.Imaging.ImageFormat.Gif); | ||
formats.Add("tiff", System.Drawing.Imaging.ImageFormat.Tiff); | ||
formats.Add("jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
formats.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
ExportFormat = formats[System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsFileFormat"].Replace(".", "").ToLower()]; | ||
} | ||
catch (Exception ex) | ||
{ | ||
ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "[email protected]"); | ||
} | ||
} | ||
|
||
private List<BO.ImageUnpacker> unpackers = new List<BO.ImageUnpacker>(); | ||
private void CreateUnpacker(Bitmap image, string fileName) | ||
{ | ||
|
@@ -83,7 +118,7 @@ private void CreateUnpacker(Bitmap image, string fileName) | |
|
||
this.ZoomPanel.Visible = false; | ||
|
||
unpacker = new BO.ImageUnpacker(image, fileName, MakeBackgroundTransparent && !this.Options.PreservePalletteCheckBox.Checked); | ||
unpacker = new BO.ImageUnpacker(image, fileName, MakeBackgroundTransparent && !PreservePallette); | ||
this.unpackers.Add(unpacker); | ||
} | ||
|
||
|
@@ -386,40 +421,6 @@ private void frmMain_FormClosing(object sender, System.Windows.Forms.FormClosing | |
} | ||
} | ||
|
||
private void MainForm_Load(object sender, System.EventArgs e) | ||
{ | ||
try | ||
{ | ||
this.SuppressThirdPartyWarningMessage = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["SuppressThirdPartyImageConverterWarningMessage"]); | ||
this.ExportLocationTextBox.Text = AppDomain.CurrentDomain.BaseDirectory; | ||
this.KeyPreview = true; | ||
ThirdPartyImageConverterPath = System.Configuration.ConfigurationManager.AppSettings["ThirdPartyImageConverter"]; | ||
|
||
if (ThirdPartyImageConverterPath.StartsWith("\\")) | ||
{ | ||
ThirdPartyImageConverterPath = AppDomain.CurrentDomain.BaseDirectory + ThirdPartyImageConverterPath; | ||
} | ||
AutoOpenDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AutoOpenDestinationFolder"]); | ||
PromptForDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PromptForDestinationFolder"]); | ||
Outline.Width = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TileOutlineWidth"]); | ||
DistanceBetweenTiles = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DistanceBetweenFrames"]); | ||
MakeBackgroundTransparent = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsMakeBackgroundTransparent"]); | ||
|
||
Dictionary<string, System.Drawing.Imaging.ImageFormat> formats = new Dictionary<string, System.Drawing.Imaging.ImageFormat>(); | ||
formats.Add("png", System.Drawing.Imaging.ImageFormat.Png); | ||
formats.Add("bmp", System.Drawing.Imaging.ImageFormat.Bmp); | ||
formats.Add("gif", System.Drawing.Imaging.ImageFormat.Gif); | ||
formats.Add("tiff", System.Drawing.Imaging.ImageFormat.Tiff); | ||
formats.Add("jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
formats.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg); | ||
ExportFormat = formats[System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsFileFormat"].Replace(".", "").ToLower()]; | ||
} | ||
catch (Exception ex) | ||
{ | ||
ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "[email protected]"); | ||
} | ||
} | ||
|
||
private void MainPanel_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) | ||
{ | ||
object dropped = null; | ||
|
@@ -1026,7 +1027,7 @@ private void ExportUnpackers(List<BO.ImageUnpacker> unpackers) | |
objGraphics.Dispose(); | ||
} | ||
|
||
if (this.Options != null && this.Options.PreservePalletteCheckBox.Checked) | ||
if (PreservePallette) | ||
{ | ||
if (unpacker.GetPallette() != null) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters