Skip to content

Commit df989f9

Browse files
committed
Export and import functionality
1 parent 264679a commit df989f9

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

FidgetSpinnerEditor/FormMain.Designer.cs

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FidgetSpinnerEditor/FormMain.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Drawing;
55
using System.Drawing.Drawing2D;
6+
using System.Drawing.Imaging;
67
using System.IO;
78
using System.Linq;
89
using System.Windows.Forms;
@@ -244,6 +245,31 @@ private void importToolStripMenuItem_Click(object sender, EventArgs e)
244245
pictureBoxEditor.Invalidate();
245246
}
246247

248+
private void exportToolStripMenuItem_Click(object sender, EventArgs e)
249+
{
250+
if (saveFileDialogExport.ShowDialog() == DialogResult.OK)
251+
{
252+
var b = new Bitmap(LedColumns, LedRows);
253+
254+
for (var x = 0; x < LedColumns; x++)
255+
for (var y = 0; y < LedRows; y++)
256+
{
257+
b.SetPixel(x, y, GetBit(x * LedRows + y)?Color.Black:Color.White);
258+
}
259+
260+
try
261+
{
262+
b.Save(saveFileDialogExport.FileName, ImageFormat.Bmp);
263+
MessageBox.Show("File exported to: " + saveFileDialogExport.FileName, "Success", MessageBoxButtons.OK,
264+
MessageBoxIcon.Information);
265+
}
266+
catch (Exception ex)
267+
{
268+
MessageBox.Show("Error while exporting: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
269+
}
270+
}
271+
}
272+
247273
private void clockwiseToolStripMenuItem_Click(object sender, EventArgs e)
248274
{
249275
_rotation += 5;

FidgetSpinnerEditor/FormMain.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@
138138
<metadata name="openFileDialogImport.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
139139
<value>882, 17</value>
140140
</metadata>
141+
<metadata name="saveFileDialogExport.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
142+
<value>17, 56</value>
143+
</metadata>
144+
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
145+
<value>163</value>
146+
</metadata>
141147
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
142148
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
143149
<value>

FidgetSpinnerEditor/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("0.2.0.0")]
36-
[assembly: AssemblyFileVersion("0.2.0.0")]
35+
[assembly: AssemblyVersion("0.3.0.0")]
36+
[assembly: AssemblyFileVersion("0.3.0.0")]

0 commit comments

Comments
 (0)