Skip to content

Commit 1474eea

Browse files
committed
Some refactoring
1 parent 5e50660 commit 1474eea

File tree

7 files changed

+503
-30
lines changed

7 files changed

+503
-30
lines changed

Diff for: ImageFormats/FormMain.Designer.cs

+11-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ImageFormats/FormMain.cs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System;
1+
using ImageFormats.Properties;
2+
using System;
23
using System.Diagnostics;
34
using System.Drawing;
4-
using System.IO;
55
using System.Windows.Forms;
66

77
/*
@@ -28,13 +28,13 @@ public FormMain()
2828
this.Text = Application.ProductName;
2929
}
3030

31-
private void Form1_DragEnter(object sender, DragEventArgs e)
31+
private void FormMain_DragEnter(object sender, DragEventArgs e)
3232
{
3333
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
3434
e.Effect = DragDropEffects.All;
3535
}
3636

37-
private void Form1_DragDrop(object sender, DragEventArgs e)
37+
private void FormMain_DragDrop(object sender, DragEventArgs e)
3838
{
3939
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
4040
if (files.Length == 0) return;
@@ -46,20 +46,18 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
4646
var openDlg = new OpenFileDialog();
4747
openDlg.DefaultExt = ".*";
4848
openDlg.CheckFileExists = true;
49-
openDlg.Title = "Open file...";
49+
openDlg.Title = Resources.openDlgTitle;
5050
openDlg.Filter = "All Files (*.*)|*.*";
5151
openDlg.FilterIndex = 1;
5252
if (openDlg.ShowDialog() == DialogResult.Cancel) return;
5353
OpenFile(openDlg.FileName);
5454
}
5555

56-
5756
private void OpenFile(string fileName)
5857
{
5958
try
6059
{
6160
Bitmap bmp = null;
62-
6361
bmp = MechanikaDesign.ImageFormats.Picture.Load(fileName);
6462

6563
if (bmp == null)
@@ -70,7 +68,7 @@ private void OpenFile(string fileName)
7068
}
7169

7270
if (bmp == null)
73-
throw new ApplicationException("Could not load the specified file.");
71+
throw new ApplicationException(Resources.errorLoadFailed);
7472

7573
pictureBox1.Image = bmp;
7674
pictureBox1.Size = bmp.Size;

Diff for: ImageFormats/FormMain.resx

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<root>
3+
<!--
4+
Microsoft ResX Schema
5+
6+
Version 2.0
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
11+
associated with the data types.
12+
13+
Example:
14+
15+
... ado.net/XML headers & schema ...
16+
<resheader name="resmimetype">text/microsoft-resx</resheader>
17+
<resheader name="version">2.0</resheader>
18+
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19+
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20+
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21+
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22+
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23+
<value>[base64 mime encoded serialized .NET Framework object]</value>
24+
</data>
25+
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26+
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27+
<comment>This is a comment</comment>
28+
</data>
29+
30+
There are any number of "resheader" rows that contain simple
31+
name/value pairs.
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
37+
mimetype set.
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
41+
extensible. For a given mimetype the value must be set accordingly:
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
45+
read any of the formats listed below.
46+
47+
mimetype: application/x-microsoft.net.object.binary.base64
48+
value : The object must be serialized with
49+
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50+
: and then encoded with base64 encoding.
51+
52+
mimetype: application/x-microsoft.net.object.soap.base64
53+
value : The object must be serialized with
54+
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55+
: and then encoded with base64 encoding.
56+
mimetype: application/x-microsoft.net.object.bytearray.base64
57+
value : The object must be serialized into a byte array
58+
: using a System.ComponentModel.TypeConverter
59+
: and then encoded with base64 encoding.
60+
-->
61+
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
62+
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
63+
<xsd:element name="root" msdata:IsDataSet="true">
64+
<xsd:complexType>
65+
<xsd:choice maxOccurs="unbounded">
66+
<xsd:element name="metadata">
67+
<xsd:complexType>
68+
<xsd:sequence>
69+
<xsd:element name="value" type="xsd:string" minOccurs="0" />
70+
</xsd:sequence>
71+
<xsd:attribute name="name" use="required" type="xsd:string" />
72+
<xsd:attribute name="type" type="xsd:string" />
73+
<xsd:attribute name="mimetype" type="xsd:string" />
74+
<xsd:attribute ref="xml:space" />
75+
</xsd:complexType>
76+
</xsd:element>
77+
<xsd:element name="assembly">
78+
<xsd:complexType>
79+
<xsd:attribute name="alias" type="xsd:string" />
80+
<xsd:attribute name="name" type="xsd:string" />
81+
</xsd:complexType>
82+
</xsd:element>
83+
<xsd:element name="data">
84+
<xsd:complexType>
85+
<xsd:sequence>
86+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
87+
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
88+
</xsd:sequence>
89+
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
90+
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
91+
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
92+
<xsd:attribute ref="xml:space" />
93+
</xsd:complexType>
94+
</xsd:element>
95+
<xsd:element name="resheader">
96+
<xsd:complexType>
97+
<xsd:sequence>
98+
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
99+
</xsd:sequence>
100+
<xsd:attribute name="name" type="xsd:string" use="required" />
101+
</xsd:complexType>
102+
</xsd:element>
103+
</xsd:choice>
104+
</xsd:complexType>
105+
</xsd:element>
106+
</xsd:schema>
107+
<resheader name="resmimetype">
108+
<value>text/microsoft-resx</value>
109+
</resheader>
110+
<resheader name="version">
111+
<value>2.0</value>
112+
</resheader>
113+
<resheader name="reader">
114+
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115+
</resheader>
116+
<resheader name="writer">
117+
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118+
</resheader>
119+
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
120+
<value>17, 17</value>
121+
</metadata>
122+
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
123+
<data name="openToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
124+
<value>112, 22</value>
125+
</data>
126+
<data name="openToolStripMenuItem.Text" xml:space="preserve">
127+
<value>Open...</value>
128+
</data>
129+
<data name="fileToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
130+
<value>37, 20</value>
131+
</data>
132+
<data name="fileToolStripMenuItem.Text" xml:space="preserve">
133+
<value>File</value>
134+
</data>
135+
<data name="menuStrip1.Location" type="System.Drawing.Point, System.Drawing">
136+
<value>0, 0</value>
137+
</data>
138+
<data name="menuStrip1.Size" type="System.Drawing.Size, System.Drawing">
139+
<value>427, 24</value>
140+
</data>
141+
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
142+
<data name="menuStrip1.TabIndex" type="System.Int32, mscorlib">
143+
<value>1</value>
144+
</data>
145+
<data name="menuStrip1.Text" xml:space="preserve">
146+
<value>menuStrip1</value>
147+
</data>
148+
<data name="&gt;&gt;menuStrip1.Name" xml:space="preserve">
149+
<value>menuStrip1</value>
150+
</data>
151+
<data name="&gt;&gt;menuStrip1.Type" xml:space="preserve">
152+
<value>System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
153+
</data>
154+
<data name="&gt;&gt;menuStrip1.Parent" xml:space="preserve">
155+
<value>$this</value>
156+
</data>
157+
<data name="&gt;&gt;menuStrip1.ZOrder" xml:space="preserve">
158+
<value>1</value>
159+
</data>
160+
<data name="panel1.AutoScroll" type="System.Boolean, mscorlib">
161+
<value>True</value>
162+
</data>
163+
<data name="pictureBox1.Location" type="System.Drawing.Point, System.Drawing">
164+
<value>0, 0</value>
165+
</data>
166+
<data name="pictureBox1.Size" type="System.Drawing.Size, System.Drawing">
167+
<value>94, 83</value>
168+
</data>
169+
<data name="pictureBox1.TabIndex" type="System.Int32, mscorlib">
170+
<value>0</value>
171+
</data>
172+
<data name="&gt;&gt;pictureBox1.Name" xml:space="preserve">
173+
<value>pictureBox1</value>
174+
</data>
175+
<data name="&gt;&gt;pictureBox1.Type" xml:space="preserve">
176+
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
177+
</data>
178+
<data name="&gt;&gt;pictureBox1.Parent" xml:space="preserve">
179+
<value>panel1</value>
180+
</data>
181+
<data name="&gt;&gt;pictureBox1.ZOrder" xml:space="preserve">
182+
<value>0</value>
183+
</data>
184+
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
185+
<data name="panel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
186+
<value>Fill</value>
187+
</data>
188+
<data name="panel1.Location" type="System.Drawing.Point, System.Drawing">
189+
<value>0, 24</value>
190+
</data>
191+
<data name="panel1.Size" type="System.Drawing.Size, System.Drawing">
192+
<value>427, 255</value>
193+
</data>
194+
<data name="panel1.TabIndex" type="System.Int32, mscorlib">
195+
<value>2</value>
196+
</data>
197+
<data name="&gt;&gt;panel1.Name" xml:space="preserve">
198+
<value>panel1</value>
199+
</data>
200+
<data name="&gt;&gt;panel1.Type" xml:space="preserve">
201+
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
202+
</data>
203+
<data name="&gt;&gt;panel1.Parent" xml:space="preserve">
204+
<value>$this</value>
205+
</data>
206+
<data name="&gt;&gt;panel1.ZOrder" xml:space="preserve">
207+
<value>0</value>
208+
</data>
209+
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
210+
<value>True</value>
211+
</metadata>
212+
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
213+
<value>6, 13</value>
214+
</data>
215+
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
216+
<value>427, 279</value>
217+
</data>
218+
<data name="&gt;&gt;fileToolStripMenuItem.Name" xml:space="preserve">
219+
<value>fileToolStripMenuItem</value>
220+
</data>
221+
<data name="&gt;&gt;fileToolStripMenuItem.Type" xml:space="preserve">
222+
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
223+
</data>
224+
<data name="&gt;&gt;openToolStripMenuItem.Name" xml:space="preserve">
225+
<value>openToolStripMenuItem</value>
226+
</data>
227+
<data name="&gt;&gt;openToolStripMenuItem.Type" xml:space="preserve">
228+
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
229+
</data>
230+
<data name="&gt;&gt;$this.Name" xml:space="preserve">
231+
<value>Form1</value>
232+
</data>
233+
<data name="&gt;&gt;$this.Type" xml:space="preserve">
234+
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
235+
</data>
236+
</root>

Diff for: ImageFormats/ImageFormats.csproj

+18
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,27 @@
5959
<Compile Include="PnmReader.cs" />
6060
<Compile Include="Program.cs" />
6161
<Compile Include="Properties\AssemblyInfo.cs" />
62+
<Compile Include="Properties\Resources.Designer.cs">
63+
<AutoGen>True</AutoGen>
64+
<DesignTime>True</DesignTime>
65+
<DependentUpon>Resources.resx</DependentUpon>
66+
</Compile>
6267
<Compile Include="RasReader.cs" />
6368
<Compile Include="SgiReader.cs" />
6469
<Compile Include="TgaReader.cs" />
6570
</ItemGroup>
71+
<ItemGroup>
72+
<EmbeddedResource Include="FormMain.resx">
73+
<DependentUpon>FormMain.cs</DependentUpon>
74+
<Generator>ResXFileCodeGenerator</Generator>
75+
<LastGenOutput>FormMain1.Designer.cs</LastGenOutput>
76+
<SubType>Designer</SubType>
77+
</EmbeddedResource>
78+
<EmbeddedResource Include="Properties\Resources.resx">
79+
<Generator>ResXFileCodeGenerator</Generator>
80+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
81+
<SubType>Designer</SubType>
82+
</EmbeddedResource>
83+
</ItemGroup>
6684
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6785
</Project>

0 commit comments

Comments
 (0)