Skip to content

Commit 8ba7099

Browse files
authored
Merge pull request #252 from iamartyom/feature/add-controls-to-select-colors-in-demo-project
Add logic to select primary and background colors in demo windows forms app
2 parents e5ef4ce + bbfea15 commit 8ba7099

File tree

3 files changed

+98
-11
lines changed

3 files changed

+98
-11
lines changed

QRCoderDemo/Form1.Designer.cs

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

QRCoderDemo/Form1.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ private void RenderQrCode()
4040
{
4141
using (QRCode qrCode = new QRCode(qrCodeData))
4242
{
43-
44-
pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, Color.Black, Color.White,
43+
pictureBoxQRCode.BackgroundImage = qrCode.GetGraphic(20, GetPrimaryColor(), GetBackgroundColor(),
4544
GetIconBitmap(), (int) iconSize.Value);
4645

4746
this.pictureBoxQRCode.Size = new System.Drawing.Size(pictureBoxQRCode.Width, pictureBoxQRCode.Height);
@@ -154,5 +153,33 @@ private void comboBoxECC_SelectedIndexChanged(object sender, EventArgs e)
154153
{
155154
RenderQrCode();
156155
}
156+
157+
private void panelPreviewPrimaryColor_Click(object sender, EventArgs e)
158+
{
159+
if (colorDialogPrimaryColor.ShowDialog() == DialogResult.OK)
160+
{
161+
panelPreviewPrimaryColor.BackColor = colorDialogPrimaryColor.Color;
162+
RenderQrCode();
163+
}
164+
}
165+
166+
private void panelPreviewBackgroundColor_Click(object sender, EventArgs e)
167+
{
168+
if (colorDialogBackgroundColor.ShowDialog() == DialogResult.OK)
169+
{
170+
panelPreviewBackgroundColor.BackColor = colorDialogBackgroundColor.Color;
171+
RenderQrCode();
172+
}
173+
}
174+
175+
private Color GetPrimaryColor()
176+
{
177+
return panelPreviewPrimaryColor.BackColor;
178+
}
179+
180+
private Color GetBackgroundColor()
181+
{
182+
return panelPreviewBackgroundColor.BackColor;
183+
}
157184
}
158185
}

QRCoderDemo/Form1.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<metadata name="colorDialogPrimaryColor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121+
<value>17, 17</value>
122+
</metadata>
123+
<metadata name="colorDialogBackgroundColor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<value>202, 17</value>
125+
</metadata>
120126
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
121127
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
122128
<value>

0 commit comments

Comments
 (0)