Erweitert
This commit is contained in:
Generated
+59
-9
@@ -32,7 +32,7 @@
|
|||||||
tabPage1 = new TabPage();
|
tabPage1 = new TabPage();
|
||||||
bt_gen_QR_URL = new Button();
|
bt_gen_QR_URL = new Button();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
tb_URL = new TextBox();
|
textBox_URL = new TextBox();
|
||||||
tabPage2 = new TabPage();
|
tabPage2 = new TabPage();
|
||||||
bt_createQRAdress = new Button();
|
bt_createQRAdress = new Button();
|
||||||
tabPage3 = new TabPage();
|
tabPage3 = new TabPage();
|
||||||
@@ -50,6 +50,11 @@
|
|||||||
pb_icon = new PictureBox();
|
pb_icon = new PictureBox();
|
||||||
bt_clear_Icon = new Button();
|
bt_clear_Icon = new Button();
|
||||||
button_Save_QRCode = new Button();
|
button_Save_QRCode = new Button();
|
||||||
|
colorDialog = new ColorDialog();
|
||||||
|
panel_ColorLight = new Panel();
|
||||||
|
panel_ColorDark = new Panel();
|
||||||
|
button_ChangeColorLight = new Button();
|
||||||
|
button_ChangeColorDark = new Button();
|
||||||
tabControl1.SuspendLayout();
|
tabControl1.SuspendLayout();
|
||||||
tabPage1.SuspendLayout();
|
tabPage1.SuspendLayout();
|
||||||
tabPage2.SuspendLayout();
|
tabPage2.SuspendLayout();
|
||||||
@@ -73,7 +78,7 @@
|
|||||||
//
|
//
|
||||||
tabPage1.Controls.Add(bt_gen_QR_URL);
|
tabPage1.Controls.Add(bt_gen_QR_URL);
|
||||||
tabPage1.Controls.Add(label1);
|
tabPage1.Controls.Add(label1);
|
||||||
tabPage1.Controls.Add(tb_URL);
|
tabPage1.Controls.Add(textBox_URL);
|
||||||
tabPage1.Location = new Point(4, 24);
|
tabPage1.Location = new Point(4, 24);
|
||||||
tabPage1.Name = "tabPage1";
|
tabPage1.Name = "tabPage1";
|
||||||
tabPage1.Padding = new Padding(3);
|
tabPage1.Padding = new Padding(3);
|
||||||
@@ -101,13 +106,13 @@
|
|||||||
label1.TabIndex = 1;
|
label1.TabIndex = 1;
|
||||||
label1.Text = "URL:";
|
label1.Text = "URL:";
|
||||||
//
|
//
|
||||||
// tb_URL
|
// textBox_URL
|
||||||
//
|
//
|
||||||
tb_URL.Location = new Point(6, 21);
|
textBox_URL.Location = new Point(6, 21);
|
||||||
tb_URL.Name = "tb_URL";
|
textBox_URL.Name = "textBox_URL";
|
||||||
tb_URL.Size = new Size(400, 23);
|
textBox_URL.Size = new Size(400, 23);
|
||||||
tb_URL.TabIndex = 0;
|
textBox_URL.TabIndex = 0;
|
||||||
tb_URL.Text = "https://www.youtube.com/watch?v=3XW7SxiJC-k";
|
textBox_URL.Text = "https://www.youtube.com/watch?v=3XW7SxiJC-k";
|
||||||
//
|
//
|
||||||
// tabPage2
|
// tabPage2
|
||||||
//
|
//
|
||||||
@@ -282,11 +287,49 @@
|
|||||||
button_Save_QRCode.UseVisualStyleBackColor = true;
|
button_Save_QRCode.UseVisualStyleBackColor = true;
|
||||||
button_Save_QRCode.Click += button_Save_QRCode_Click;
|
button_Save_QRCode.Click += button_Save_QRCode_Click;
|
||||||
//
|
//
|
||||||
|
// panel_ColorLight
|
||||||
|
//
|
||||||
|
panel_ColorLight.Location = new Point(480, 47);
|
||||||
|
panel_ColorLight.Name = "panel_ColorLight";
|
||||||
|
panel_ColorLight.Size = new Size(23, 23);
|
||||||
|
panel_ColorLight.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// panel_ColorDark
|
||||||
|
//
|
||||||
|
panel_ColorDark.Location = new Point(480, 73);
|
||||||
|
panel_ColorDark.Name = "panel_ColorDark";
|
||||||
|
panel_ColorDark.Size = new Size(23, 23);
|
||||||
|
panel_ColorDark.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// button_ChangeColorLight
|
||||||
|
//
|
||||||
|
button_ChangeColorLight.Location = new Point(509, 47);
|
||||||
|
button_ChangeColorLight.Name = "button_ChangeColorLight";
|
||||||
|
button_ChangeColorLight.Size = new Size(75, 23);
|
||||||
|
button_ChangeColorLight.TabIndex = 8;
|
||||||
|
button_ChangeColorLight.Text = "button2";
|
||||||
|
button_ChangeColorLight.UseVisualStyleBackColor = true;
|
||||||
|
button_ChangeColorLight.Click += button_ChangeColorLight_Click;
|
||||||
|
//
|
||||||
|
// button_ChangeColorDark
|
||||||
|
//
|
||||||
|
button_ChangeColorDark.Location = new Point(509, 73);
|
||||||
|
button_ChangeColorDark.Name = "button_ChangeColorDark";
|
||||||
|
button_ChangeColorDark.Size = new Size(75, 23);
|
||||||
|
button_ChangeColorDark.TabIndex = 9;
|
||||||
|
button_ChangeColorDark.Text = "button3";
|
||||||
|
button_ChangeColorDark.UseVisualStyleBackColor = true;
|
||||||
|
button_ChangeColorDark.Click += button_ChangeColorDark_Click;
|
||||||
|
//
|
||||||
// Main
|
// Main
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(929, 733);
|
ClientSize = new Size(929, 733);
|
||||||
|
Controls.Add(button_ChangeColorDark);
|
||||||
|
Controls.Add(button_ChangeColorLight);
|
||||||
|
Controls.Add(panel_ColorDark);
|
||||||
|
Controls.Add(panel_ColorLight);
|
||||||
Controls.Add(button_Save_QRCode);
|
Controls.Add(button_Save_QRCode);
|
||||||
Controls.Add(bt_clear_Icon);
|
Controls.Add(bt_clear_Icon);
|
||||||
Controls.Add(pb_icon);
|
Controls.Add(pb_icon);
|
||||||
@@ -295,6 +338,8 @@
|
|||||||
Controls.Add(tabControl1);
|
Controls.Add(tabControl1);
|
||||||
Name = "Main";
|
Name = "Main";
|
||||||
Text = "QR-Code Generator";
|
Text = "QR-Code Generator";
|
||||||
|
FormClosing += Main_FormClosing;
|
||||||
|
Load += Main_Load;
|
||||||
tabControl1.ResumeLayout(false);
|
tabControl1.ResumeLayout(false);
|
||||||
tabPage1.ResumeLayout(false);
|
tabPage1.ResumeLayout(false);
|
||||||
tabPage1.PerformLayout();
|
tabPage1.PerformLayout();
|
||||||
@@ -312,7 +357,7 @@
|
|||||||
private TabPage tabPage1;
|
private TabPage tabPage1;
|
||||||
private Button bt_gen_QR_URL;
|
private Button bt_gen_QR_URL;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private TextBox tb_URL;
|
private TextBox textBox_URL;
|
||||||
private TabPage tabPage2;
|
private TabPage tabPage2;
|
||||||
private PictureBox pb_QRC;
|
private PictureBox pb_QRC;
|
||||||
private Button button1;
|
private Button button1;
|
||||||
@@ -330,5 +375,10 @@
|
|||||||
private RadioButton radioButton_WEP;
|
private RadioButton radioButton_WEP;
|
||||||
private RadioButton radioButton_WPA;
|
private RadioButton radioButton_WPA;
|
||||||
private Button button_Save_QRCode;
|
private Button button_Save_QRCode;
|
||||||
|
private ColorDialog colorDialog;
|
||||||
|
private Panel panel_ColorLight;
|
||||||
|
private Panel panel_ColorDark;
|
||||||
|
private Button button_ChangeColorLight;
|
||||||
|
private Button button_ChangeColorDark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+114
-22
@@ -1,12 +1,19 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
using QRCoder;
|
using QRCoder;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using static QRCoder.PayloadGenerator;
|
using static QRCoder.PayloadGenerator;
|
||||||
|
using static QRCoder.QRCodeGenerator;
|
||||||
|
|
||||||
namespace QR_Code_Generator
|
namespace QR_Code_Generator
|
||||||
{
|
{
|
||||||
public partial class Main : Form
|
public partial class Main : Form
|
||||||
{
|
{
|
||||||
int pixlesPerModul = 20;
|
int pixlesPerModul = 20;
|
||||||
|
Color darkColor = Color.Black;
|
||||||
|
Color lightColor = Color.White;
|
||||||
|
bool drawQuietZones = true;
|
||||||
|
QRCodeGenerator.ECCLevel eCCLevel = ECCLevel.Q;
|
||||||
|
string colorConfigFile = "colors.json";
|
||||||
public enum EncryptionType
|
public enum EncryptionType
|
||||||
{
|
{
|
||||||
WPA,
|
WPA,
|
||||||
@@ -16,32 +23,28 @@ namespace QR_Code_Generator
|
|||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
panel_ColorDark.BackColor = darkColor;
|
||||||
|
panel_ColorLight.BackColor = lightColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bt_gen_QR_URL_Click(object sender, EventArgs e)
|
private void bt_gen_QR_URL_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Url generator = new Url(tb_URL.Text);
|
// Überprüfe, ob ein Link eingegeben wurde
|
||||||
string payload = generator.ToString();
|
if (string.IsNullOrWhiteSpace(textBox_URL.Text))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QRCodeGenerator qrg = new QRCodeGenerator();
|
|
||||||
QRCodeData qrCodeData = qrg.CreateQrCode(payload, QRCodeGenerator.ECCLevel.H);
|
|
||||||
generateQR(qrCodeData);
|
|
||||||
|
|
||||||
void generateQR(QRCodeData qrCodeData)
|
|
||||||
{
|
{
|
||||||
Bitmap? icon = null;
|
MessageBox.Show("Bitte geben Sie eine gültige URL ein.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
if (pb_icon.Image != null)
|
return;
|
||||||
{
|
|
||||||
icon = (Bitmap)pb_icon.Image;
|
|
||||||
}
|
|
||||||
using (QRCode qrCode = new QRCode(qrCodeData))
|
|
||||||
{
|
|
||||||
Bitmap qrCodeImage = qrCode.GetGraphic(pixlesPerModul, Color.Black, Color.White, icon, 25, 3);
|
|
||||||
pb_QRC.Image = qrCodeImage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Erstelle die URL-Payload
|
||||||
|
string url = textBox_URL.Text;
|
||||||
|
var urlPayload = new PayloadGenerator.Url(url).ToString();
|
||||||
|
|
||||||
|
// Generiere den QR-Code mit der URL-Payload
|
||||||
|
Bitmap qrCode = GenerateQRCode(urlPayload, darkColor, lightColor, eCCLevel);
|
||||||
|
|
||||||
|
// Setze den generierten QR-Code in die PictureBox
|
||||||
|
pb_QRC.Image = qrCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
@@ -107,13 +110,21 @@ namespace QR_Code_Generator
|
|||||||
string payload = wifiPayload.ToString();
|
string payload = wifiPayload.ToString();
|
||||||
|
|
||||||
// Generiere den QR-Code
|
// Generiere den QR-Code
|
||||||
using var qrGenerator = new QRCodeGenerator();
|
|
||||||
|
Bitmap qrCode = GenerateQRCode(payload, darkColor, lightColor, eCCLevel);
|
||||||
|
return qrCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bitmap GenerateQRCode(string payload, Color dark, Color light, ECCLevel eCC)
|
||||||
|
{
|
||||||
|
QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||||||
var qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
|
var qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
|
||||||
var qrCode = new QRCode(qrCodeData);
|
var qrCode = new QRCode(qrCodeData);
|
||||||
|
|
||||||
// Rückgabe als Bitmap
|
// Rückgabe als Bitmap
|
||||||
return qrCode.GetGraphic(20);
|
return qrCode.GetGraphic(20, dark, light, drawQuietZones);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveQRCodeFromPictureBox(PictureBox pictureBox)
|
public void SaveQRCodeFromPictureBox(PictureBox pictureBox)
|
||||||
{
|
{
|
||||||
// Überprüfen, ob ein Bild in der PictureBox vorhanden ist
|
// Überprüfen, ob ein Bild in der PictureBox vorhanden ist
|
||||||
@@ -150,5 +161,86 @@ namespace QR_Code_Generator
|
|||||||
{
|
{
|
||||||
SaveQRCodeFromPictureBox(pb_QRC);
|
SaveQRCodeFromPictureBox(pb_QRC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void button_ChangeColorLight_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (ColorDialog colorDialog = new ColorDialog())
|
||||||
|
{
|
||||||
|
// Optional: Standardfarbe festlegen
|
||||||
|
colorDialog.Color = lightColor;
|
||||||
|
|
||||||
|
// Dialog anzeigen
|
||||||
|
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// Ausgewählte Farbe anwenden
|
||||||
|
lightColor = colorDialog.Color;
|
||||||
|
panel_ColorLight.BackColor = lightColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button_ChangeColorDark_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (ColorDialog colorDialog = new ColorDialog())
|
||||||
|
{
|
||||||
|
// Optional: Standardfarbe festlegen
|
||||||
|
colorDialog.Color = darkColor;
|
||||||
|
|
||||||
|
// Dialog anzeigen
|
||||||
|
if (colorDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// Ausgewählte Farbe anwenden
|
||||||
|
darkColor = colorDialog.Color;
|
||||||
|
panel_ColorDark.BackColor = darkColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveColors(string filePath)
|
||||||
|
{
|
||||||
|
var colorConfig = new
|
||||||
|
{
|
||||||
|
DarkColor = darkColor.ToArgb(),
|
||||||
|
LightColor = lightColor.ToArgb()
|
||||||
|
};
|
||||||
|
|
||||||
|
File.WriteAllText(filePath, JsonConvert.SerializeObject(colorConfig));
|
||||||
|
// MessageBox.Show("Farben wurden erfolgreich gespeichert!", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
private void LoadColors(string filePath)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Die Konfigurationsdatei wurde nicht gefunden.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var colorConfig = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(filePath));
|
||||||
|
darkColor = Color.FromArgb((int)colorConfig.DarkColor);
|
||||||
|
lightColor = Color.FromArgb((int)colorConfig.LightColor);
|
||||||
|
|
||||||
|
// Aktualisiere die UI, z. B. Farbpanels
|
||||||
|
panel_ColorDark.BackColor = darkColor;
|
||||||
|
panel_ColorLight.BackColor = lightColor;
|
||||||
|
|
||||||
|
// MessageBox.Show("Farben wurden erfolgreich geladen!", "Erfolg", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"Fehler beim Laden der Farben: {ex.Message}", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
SaveColors(colorConfigFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Main_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadColors(colorConfigFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="colorDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user