Skip to content

Commit 4eee6ef

Browse files
committed
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).
1 parent cce6259 commit 4eee6ef

4 files changed

Lines changed: 45 additions & 40 deletions

File tree

ASU/App.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<add key="ThirdPartyImageConverterCommandArgsExportFormat" value="-out {text} -overwrite -quiet -D {file_name}"/>
77
<add key="ThirdPartyImageConverterCommandArgsConvertImportToBitmap" value="-out bmp -overwrite -quiet -D {temp}"/>
88
<add key="SuppressThirdPartyImageConverterWarningMessage" value="false"/>
9-
<add key="PromptForDestinationFolder" value="true"/>
9+
<add key="PromptForDestinationFolder" value="false"/>
1010
<add key="AutoOpenDestinationFolder" value="true"/>
11+
<add key="PreservePallette" value="false"/>
1112
<add key="TileOutlineWidth" value="2"/>
1213
<add key="DistanceBetweenFrames" value="3"/>
1314
<add key="ExportedOptionsFileFormat" value="png"/>

ASU/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("16.0.0.0")]
36-
[assembly: AssemblyFileVersion("16.0.0.0")]
35+
[assembly: AssemblyVersion("17.0.0.0")]
36+
[assembly: AssemblyFileVersion("17.0.0.0")]

ASU/UI/MainForm.cs

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ private List<Rectangle> Boxes
5454
private static string ThirdPartyImageConverterPath;
5555
public static bool PromptForDestinationFolder = true;
5656
public static bool AutoOpenDestinationFolder = true;
57-
5857
public static bool MakeBackgroundTransparent = true;
58+
public static bool PreservePallette = false;
5959

6060
private System.Threading.Timer multipleUnpackerTimer;
6161
#endregion
@@ -66,6 +66,41 @@ public MainForm()
6666
this.InitializeComponent();
6767
}
6868

69+
private void MainForm_Load(object sender, System.EventArgs e)
70+
{
71+
try
72+
{
73+
this.SuppressThirdPartyWarningMessage = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["SuppressThirdPartyImageConverterWarningMessage"]);
74+
this.ExportLocationTextBox.Text = AppDomain.CurrentDomain.BaseDirectory;
75+
this.KeyPreview = true;
76+
ThirdPartyImageConverterPath = System.Configuration.ConfigurationManager.AppSettings["ThirdPartyImageConverter"];
77+
78+
if (ThirdPartyImageConverterPath.StartsWith("\\"))
79+
{
80+
ThirdPartyImageConverterPath = AppDomain.CurrentDomain.BaseDirectory + ThirdPartyImageConverterPath;
81+
}
82+
AutoOpenDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AutoOpenDestinationFolder"]);
83+
PromptForDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PromptForDestinationFolder"]);
84+
Outline.Width = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TileOutlineWidth"]);
85+
DistanceBetweenTiles = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DistanceBetweenFrames"]);
86+
MakeBackgroundTransparent = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsMakeBackgroundTransparent"]);
87+
PreservePallette = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PreservePallette"]);
88+
89+
Dictionary<string, System.Drawing.Imaging.ImageFormat> formats = new Dictionary<string, System.Drawing.Imaging.ImageFormat>();
90+
formats.Add("png", System.Drawing.Imaging.ImageFormat.Png);
91+
formats.Add("bmp", System.Drawing.Imaging.ImageFormat.Bmp);
92+
formats.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
93+
formats.Add("tiff", System.Drawing.Imaging.ImageFormat.Tiff);
94+
formats.Add("jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
95+
formats.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
96+
ExportFormat = formats[System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsFileFormat"].Replace(".", "").ToLower()];
97+
}
98+
catch (Exception ex)
99+
{
100+
ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "cat@forkandbeard.co.uk");
101+
}
102+
}
103+
69104
private List<BO.ImageUnpacker> unpackers = new List<BO.ImageUnpacker>();
70105
private void CreateUnpacker(Bitmap image, string fileName)
71106
{
@@ -83,7 +118,7 @@ private void CreateUnpacker(Bitmap image, string fileName)
83118

84119
this.ZoomPanel.Visible = false;
85120

86-
unpacker = new BO.ImageUnpacker(image, fileName, MakeBackgroundTransparent && !this.Options.PreservePalletteCheckBox.Checked);
121+
unpacker = new BO.ImageUnpacker(image, fileName, MakeBackgroundTransparent && !PreservePallette);
87122
this.unpackers.Add(unpacker);
88123
}
89124

@@ -386,40 +421,6 @@ private void frmMain_FormClosing(object sender, System.Windows.Forms.FormClosing
386421
}
387422
}
388423

389-
private void MainForm_Load(object sender, System.EventArgs e)
390-
{
391-
try
392-
{
393-
this.SuppressThirdPartyWarningMessage = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["SuppressThirdPartyImageConverterWarningMessage"]);
394-
this.ExportLocationTextBox.Text = AppDomain.CurrentDomain.BaseDirectory;
395-
this.KeyPreview = true;
396-
ThirdPartyImageConverterPath = System.Configuration.ConfigurationManager.AppSettings["ThirdPartyImageConverter"];
397-
398-
if (ThirdPartyImageConverterPath.StartsWith("\\"))
399-
{
400-
ThirdPartyImageConverterPath = AppDomain.CurrentDomain.BaseDirectory + ThirdPartyImageConverterPath;
401-
}
402-
AutoOpenDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["AutoOpenDestinationFolder"]);
403-
PromptForDestinationFolder = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["PromptForDestinationFolder"]);
404-
Outline.Width = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["TileOutlineWidth"]);
405-
DistanceBetweenTiles = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["DistanceBetweenFrames"]);
406-
MakeBackgroundTransparent = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsMakeBackgroundTransparent"]);
407-
408-
Dictionary<string, System.Drawing.Imaging.ImageFormat> formats = new Dictionary<string, System.Drawing.Imaging.ImageFormat>();
409-
formats.Add("png", System.Drawing.Imaging.ImageFormat.Png);
410-
formats.Add("bmp", System.Drawing.Imaging.ImageFormat.Bmp);
411-
formats.Add("gif", System.Drawing.Imaging.ImageFormat.Gif);
412-
formats.Add("tiff", System.Drawing.Imaging.ImageFormat.Tiff);
413-
formats.Add("jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
414-
formats.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
415-
ExportFormat = formats[System.Configuration.ConfigurationManager.AppSettings["ExportedOptionsFileFormat"].Replace(".", "").ToLower()];
416-
}
417-
catch (Exception ex)
418-
{
419-
ForkandBeard.Logic.ExceptionHandler.HandleException(ex, "cat@forkandbeard.co.uk");
420-
}
421-
}
422-
423424
private void MainPanel_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
424425
{
425426
object dropped = null;
@@ -1026,7 +1027,7 @@ private void ExportUnpackers(List<BO.ImageUnpacker> unpackers)
10261027
objGraphics.Dispose();
10271028
}
10281029

1029-
if (this.Options != null && this.Options.PreservePalletteCheckBox.Checked)
1030+
if (PreservePallette)
10301031
{
10311032
if (unpacker.GetPallette() != null)
10321033
{

ASU/UI/OptionsForm.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ private void OptionsForm_Load(object sender, System.EventArgs e)
4444
this.HoverColourPanel.BackColor = MainForm.HoverFill.Color;
4545
this.DistanceBetweenTilesUpDown.Value = MainForm.DistanceBetweenTiles;
4646
this.OutlineWidthUpDown.Value = Convert.ToDecimal(MainForm.Outline.Width);
47+
this.PreservePalletteCheckBox.Checked = MainForm.PreservePallette;
48+
4749
if (MainForm.ExportFormat != null)
4850
{
4951
this.ExportFormatComboBox.SelectedItem = MainForm.ExportFormat;
@@ -96,6 +98,7 @@ private void CloseButton_Click(System.Object sender, System.EventArgs e)
9698
MainForm.PromptForDestinationFolder = this.PromptDestinationFolderCheckBox.Checked;
9799
MainForm.AutoOpenDestinationFolder = this.OpenExportedDestinationCheckBox.Checked;
98100
MainForm.MakeBackgroundTransparent = this.ExportBGTransparentCheckBox.Checked;
101+
MainForm.PreservePallette = this.PreservePalletteCheckBox.Checked;
99102

100103
if (this.ExportFormatComboBox.Text != STR_ADVANCED_EXPORT_FILE_FORMAT)
101104
{

0 commit comments

Comments
 (0)