Skip to content

Commit

Permalink
added open file button
Browse files Browse the repository at this point in the history
  • Loading branch information
foobit committed Sep 3, 2015
1 parent b272976 commit d98342f
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 235 deletions.
438 changes: 225 additions & 213 deletions Source/MainForm.Designer.cs

Large diffs are not rendered by default.

40 changes: 26 additions & 14 deletions Source/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,26 @@ partial class MainForm : Form

private string p8file;
private string imgFile;
private string lastOpenFile;

private SaveFileDialog saveDialog;
private OpenFileDialog openDialog;

public MainForm()
{
InitializeComponent();
picViewer.CurrentScaleChanged += PicViewer_CurrentScaleChanged;
colorOptions.SelectedIndex = 0;

saveDialog = new SaveFileDialog();
}
saveDialog.Filter = "PNG Files|*.png|All Files|*.*";
saveDialog.DefaultExt = ".png";
saveDialog.Title = "Save PNG";

openDialog = new OpenFileDialog();
openDialog.Filter = "Open Files|*.png;*.p8|PNG Files|*.png|Cart Files|*.p8|All Files|*.*";
openDialog.Title = "Open Image or Cart";
}

private string P8File
{
Expand Down Expand Up @@ -256,16 +266,7 @@ private void ExtractP8(string file)

// replace with PICO-8 palette
applyPicoPalette(img);
/*
var pal = img.Palette;
for (int i = 0; i < 256; i++)
{
pal.Entries[i] = i < 16 ? picoPalette[i] : Color.Black;
}
img.Palette = pal;
*/


// copy bits
var ary = pixels.ToArray();
var bmp = img.LockBits(new Rectangle(0, 0, img.Width, img.Height), ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
Expand Down Expand Up @@ -421,9 +422,6 @@ private void btnExtract_Click(object sender, EventArgs e)
{
if (picViewer.Image != null)
{
saveDialog.Filter = "PNG Files|*.png|All Files|*.*";
saveDialog.DefaultExt = ".png";
saveDialog.Title = "Save PNG";
saveDialog.InitialDirectory = String.IsNullOrWhiteSpace(imgFile) ? "" : Path.GetDirectoryName(imgFile);
saveDialog.FileName = Path.GetFileName(imgFile);

Expand Down Expand Up @@ -495,5 +493,19 @@ private void btnAbout_Click(object sender, EventArgs e)
{
MessageBox.Show(this, "PICO8Tool v" + Application.ProductVersion + "\nby Scott Ramsay\nhttps://github.com/foobit/PICO8Tool", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void btnOpen_Click(object sender, EventArgs e)
{
openDialog.InitialDirectory = String.IsNullOrWhiteSpace(lastOpenFile) ? "" : Path.GetDirectoryName(lastOpenFile);
openDialog.FileName = Path.GetFileName(lastOpenFile);

if (openDialog.ShowDialog(this) == DialogResult.Cancel)
{
return;
}

lastOpenFile = openDialog.FileName;
LoadFile(lastOpenFile);
}
}
}
1 change: 1 addition & 0 deletions Source/PICO8Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="PICO8Tool.ico" />
<None Include="Resources\OpenFolder.bmp" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
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("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyVersion("0.2.0.0")]
[assembly: AssemblyFileVersion("0.2.0.0")]
10 changes: 10 additions & 0 deletions Source/Properties/Resources.Designer.cs

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

15 changes: 9 additions & 6 deletions Source/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@
<data name="checker1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\checker1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Control_PictureBox" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Control_PictureBox.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="NewDocument" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NewDocument.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="checker0" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\checker0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Resize" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Resize.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand All @@ -136,10 +139,10 @@
<data name="Information" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Information.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="checker0" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\checker0.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="Control_PictureBox" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Control_PictureBox.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NewDocument" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\NewDocument.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="OpenFolder" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\OpenFolder.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added Source/Resources/OpenFolder.bmp
Binary file not shown.

0 comments on commit d98342f

Please sign in to comment.