angefangen Adress QR COde zu machen

This commit is contained in:
2024-12-08 14:18:43 +01:00
parent d6a3ee4ff4
commit 03d9425755
2 changed files with 318 additions and 3 deletions
+276 -1
View File
@@ -55,6 +55,31 @@
panel_ColorDark = new Panel(); panel_ColorDark = new Panel();
button_ChangeColorLight = new Button(); button_ChangeColorLight = new Button();
button_ChangeColorDark = new Button(); button_ChangeColorDark = new Button();
textBox_firstname = new TextBox();
textBox_lastname = new TextBox();
textBox_nickname = new TextBox();
textBox_workPhone = new TextBox();
textBox_mobilePhone = new TextBox();
textBox_phone = new TextBox();
textBox_zipCode = new TextBox();
textBox_city = new TextBox();
textBox_houseNumber = new TextBox();
textBox_street = new TextBox();
textBox_website = new TextBox();
textBox_email = new TextBox();
label4 = new Label();
label5 = new Label();
label6 = new Label();
label7 = new Label();
label8 = new Label();
label9 = new Label();
label10 = new Label();
label11 = new Label();
label12 = new Label();
label13 = new Label();
label14 = new Label();
label15 = new Label();
textBox_country = new TextBox();
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
tabPage1.SuspendLayout(); tabPage1.SuspendLayout();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
@@ -116,6 +141,31 @@
// //
// tabPage2 // tabPage2
// //
tabPage2.Controls.Add(textBox_country);
tabPage2.Controls.Add(label12);
tabPage2.Controls.Add(label13);
tabPage2.Controls.Add(label14);
tabPage2.Controls.Add(label15);
tabPage2.Controls.Add(label8);
tabPage2.Controls.Add(label9);
tabPage2.Controls.Add(label10);
tabPage2.Controls.Add(label11);
tabPage2.Controls.Add(label6);
tabPage2.Controls.Add(label7);
tabPage2.Controls.Add(label5);
tabPage2.Controls.Add(label4);
tabPage2.Controls.Add(textBox_zipCode);
tabPage2.Controls.Add(textBox_city);
tabPage2.Controls.Add(textBox_houseNumber);
tabPage2.Controls.Add(textBox_street);
tabPage2.Controls.Add(textBox_website);
tabPage2.Controls.Add(textBox_email);
tabPage2.Controls.Add(textBox_workPhone);
tabPage2.Controls.Add(textBox_mobilePhone);
tabPage2.Controls.Add(textBox_phone);
tabPage2.Controls.Add(textBox_nickname);
tabPage2.Controls.Add(textBox_lastname);
tabPage2.Controls.Add(textBox_firstname);
tabPage2.Controls.Add(bt_createQRAdress); tabPage2.Controls.Add(bt_createQRAdress);
tabPage2.Location = new Point(4, 24); tabPage2.Location = new Point(4, 24);
tabPage2.Name = "tabPage2"; tabPage2.Name = "tabPage2";
@@ -133,7 +183,7 @@
bt_createQRAdress.TabIndex = 0; bt_createQRAdress.TabIndex = 0;
bt_createQRAdress.Text = "generiere QR"; bt_createQRAdress.Text = "generiere QR";
bt_createQRAdress.UseVisualStyleBackColor = true; bt_createQRAdress.UseVisualStyleBackColor = true;
bt_createQRAdress.Click += bt_createQRAdress_Click;
// //
// tabPage3 // tabPage3
// //
@@ -321,6 +371,205 @@
button_ChangeColorDark.UseVisualStyleBackColor = true; button_ChangeColorDark.UseVisualStyleBackColor = true;
button_ChangeColorDark.Click += button_ChangeColorDark_Click; button_ChangeColorDark.Click += button_ChangeColorDark_Click;
// //
// textBox_firstname
//
textBox_firstname.Location = new Point(155, 44);
textBox_firstname.Name = "textBox_firstname";
textBox_firstname.Size = new Size(251, 23);
textBox_firstname.TabIndex = 1;
//
// textBox_lastname
//
textBox_lastname.Location = new Point(155, 73);
textBox_lastname.Name = "textBox_lastname";
textBox_lastname.Size = new Size(251, 23);
textBox_lastname.TabIndex = 2;
//
// textBox_nickname
//
textBox_nickname.Location = new Point(155, 102);
textBox_nickname.Name = "textBox_nickname";
textBox_nickname.Size = new Size(251, 23);
textBox_nickname.TabIndex = 3;
//
// textBox_workPhone
//
textBox_workPhone.Location = new Point(155, 189);
textBox_workPhone.Name = "textBox_workPhone";
textBox_workPhone.Size = new Size(251, 23);
textBox_workPhone.TabIndex = 6;
//
// textBox_mobilePhone
//
textBox_mobilePhone.Location = new Point(155, 160);
textBox_mobilePhone.Name = "textBox_mobilePhone";
textBox_mobilePhone.Size = new Size(251, 23);
textBox_mobilePhone.TabIndex = 5;
//
// textBox_phone
//
textBox_phone.Location = new Point(155, 131);
textBox_phone.Name = "textBox_phone";
textBox_phone.Size = new Size(251, 23);
textBox_phone.TabIndex = 4;
//
// textBox_zipCode
//
textBox_zipCode.Location = new Point(155, 337);
textBox_zipCode.Name = "textBox_zipCode";
textBox_zipCode.Size = new Size(251, 23);
textBox_zipCode.TabIndex = 12;
//
// textBox_city
//
textBox_city.Location = new Point(155, 308);
textBox_city.Name = "textBox_city";
textBox_city.Size = new Size(251, 23);
textBox_city.TabIndex = 11;
//
// textBox_houseNumber
//
textBox_houseNumber.Location = new Point(341, 279);
textBox_houseNumber.Name = "textBox_houseNumber";
textBox_houseNumber.Size = new Size(65, 23);
textBox_houseNumber.TabIndex = 10;
//
// textBox_street
//
textBox_street.Location = new Point(155, 279);
textBox_street.Name = "textBox_street";
textBox_street.Size = new Size(180, 23);
textBox_street.TabIndex = 9;
//
// textBox_website
//
textBox_website.Location = new Point(155, 247);
textBox_website.Name = "textBox_website";
textBox_website.Size = new Size(251, 23);
textBox_website.TabIndex = 8;
//
// textBox_email
//
textBox_email.Location = new Point(155, 218);
textBox_email.Name = "textBox_email";
textBox_email.Size = new Size(251, 23);
textBox_email.TabIndex = 7;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(6, 47);
label4.Name = "label4";
label4.Size = new Size(54, 15);
label4.TabIndex = 13;
label4.Text = "Vorname";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(6, 76);
label5.Name = "label5";
label5.Size = new Size(65, 15);
label5.TabIndex = 14;
label5.Text = "Nachname";
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(6, 134);
label6.Name = "label6";
label6.Size = new Size(38, 15);
label6.TabIndex = 16;
label6.Text = "label6";
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(6, 105);
label7.Name = "label7";
label7.Size = new Size(61, 15);
label7.TabIndex = 15;
label7.Text = "Nickname";
//
// label8
//
label8.AutoSize = true;
label8.Location = new Point(6, 250);
label8.Name = "label8";
label8.Size = new Size(38, 15);
label8.TabIndex = 20;
label8.Text = "label8";
//
// label9
//
label9.AutoSize = true;
label9.Location = new Point(6, 221);
label9.Name = "label9";
label9.Size = new Size(38, 15);
label9.TabIndex = 19;
label9.Text = "label9";
//
// label10
//
label10.AutoSize = true;
label10.Location = new Point(6, 192);
label10.Name = "label10";
label10.Size = new Size(44, 15);
label10.TabIndex = 18;
label10.Text = "label10";
//
// label11
//
label11.AutoSize = true;
label11.Location = new Point(6, 163);
label11.Name = "label11";
label11.Size = new Size(44, 15);
label11.TabIndex = 17;
label11.Text = "label11";
//
// label12
//
label12.AutoSize = true;
label12.Location = new Point(6, 366);
label12.Name = "label12";
label12.Size = new Size(44, 15);
label12.TabIndex = 24;
label12.Text = "label12";
//
// label13
//
label13.AutoSize = true;
label13.Location = new Point(6, 337);
label13.Name = "label13";
label13.Size = new Size(44, 15);
label13.TabIndex = 23;
label13.Text = "label13";
//
// label14
//
label14.AutoSize = true;
label14.Location = new Point(6, 308);
label14.Name = "label14";
label14.Size = new Size(44, 15);
label14.TabIndex = 22;
label14.Text = "label14";
//
// label15
//
label15.AutoSize = true;
label15.Location = new Point(6, 279);
label15.Name = "label15";
label15.Size = new Size(44, 15);
label15.TabIndex = 21;
label15.Text = "label15";
//
// textBox_country
//
textBox_country.Location = new Point(155, 366);
textBox_country.Name = "textBox_country";
textBox_country.Size = new Size(251, 23);
textBox_country.TabIndex = 25;
//
// Main // Main
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
@@ -344,6 +593,7 @@
tabPage1.ResumeLayout(false); tabPage1.ResumeLayout(false);
tabPage1.PerformLayout(); tabPage1.PerformLayout();
tabPage2.ResumeLayout(false); tabPage2.ResumeLayout(false);
tabPage2.PerformLayout();
tabPage3.ResumeLayout(false); tabPage3.ResumeLayout(false);
tabPage3.PerformLayout(); tabPage3.PerformLayout();
((System.ComponentModel.ISupportInitialize)pb_QRC).EndInit(); ((System.ComponentModel.ISupportInitialize)pb_QRC).EndInit();
@@ -380,5 +630,30 @@
private Panel panel_ColorDark; private Panel panel_ColorDark;
private Button button_ChangeColorLight; private Button button_ChangeColorLight;
private Button button_ChangeColorDark; private Button button_ChangeColorDark;
private Label label12;
private Label label13;
private Label label14;
private Label label15;
private Label label8;
private Label label9;
private Label label10;
private Label label11;
private Label label6;
private Label label7;
private Label label5;
private Label label4;
private TextBox textBox_zipCode;
private TextBox textBox_city;
private TextBox textBox_houseNumber;
private TextBox textBox_street;
private TextBox textBox_website;
private TextBox textBox_email;
private TextBox textBox_workPhone;
private TextBox textBox_mobilePhone;
private TextBox textBox_phone;
private TextBox textBox_nickname;
private TextBox textBox_lastname;
private TextBox textBox_firstname;
private TextBox textBox_country;
} }
} }
+42 -2
View File
@@ -2,6 +2,7 @@ using Newtonsoft.Json;
using QRCoder; using QRCoder;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using static QRCoder.PayloadGenerator;
namespace QR_Code_Generator namespace QR_Code_Generator
{ {
@@ -65,7 +66,11 @@ namespace QR_Code_Generator
private void bt_createQR_WIFI_Click(object sender, EventArgs e) private void bt_createQR_WIFI_Click(object sender, EventArgs e)
{ {
GenerateAndDisplayWiFiQRCode(); GenerateAndDisplayWIFIQRCode();
}
private void bt_createQRAdress_Click(object sender, EventArgs e)
{
GenerateAndDisplayAdressQRCode();
} }
private void button_Save_QRCode_Click(object sender, EventArgs e) private void button_Save_QRCode_Click(object sender, EventArgs e)
@@ -85,6 +90,39 @@ namespace QR_Code_Generator
#endregion #endregion
#region QR Code Generation #region QR Code Generation
private void GenerateAndDisplayAdressQRCode()
{
// Hilfsmethode, um null für leere Textboxen zurückzugeben
string? GetValueOrNull(TextBox textBox) => string.IsNullOrWhiteSpace(textBox.Text) ? null : textBox.Text;
// Erstellt den ContactData-Generator mit überprüften Werten
ContactData generator = new ContactData(
ContactData.ContactOutputType.VCard3,
textBox_firstname.Text,
textBox_lastname.Text,
GetValueOrNull(textBox_nickname),
GetValueOrNull(textBox_phone),
GetValueOrNull(textBox_mobilePhone),
GetValueOrNull(textBox_workPhone),
GetValueOrNull(textBox_email),
null,
GetValueOrNull(textBox_website),
GetValueOrNull(textBox_street),
GetValueOrNull(textBox_houseNumber),
GetValueOrNull(textBox_city),
GetValueOrNull(textBox_zipCode),
GetValueOrNull(textBox_country),
null,
null,
ContactData.AddressOrder.Default,
null,
null
);
// Erzeuge den QR-Code
string payload = generator.ToString();
pb_QRC.Image = GenerateQRCode(payload, darkColor, lightColor, eCCLevel);
}
private void GenerateAndDisplayQRCodeFromUrl() private void GenerateAndDisplayQRCodeFromUrl()
{ {
@@ -98,7 +136,7 @@ namespace QR_Code_Generator
pb_QRC.Image = GenerateQRCode(urlPayload, darkColor, lightColor, eCCLevel); pb_QRC.Image = GenerateQRCode(urlPayload, darkColor, lightColor, eCCLevel);
} }
private void GenerateAndDisplayWiFiQRCode() private void GenerateAndDisplayWIFIQRCode()
{ {
EncryptionType selectedType = radioButton_WPA.Checked ? EncryptionType.WPA : EncryptionType selectedType = radioButton_WPA.Checked ? EncryptionType.WPA :
radioButton_WEP.Checked ? EncryptionType.WEP : radioButton_WEP.Checked ? EncryptionType.WEP :
@@ -229,5 +267,7 @@ namespace QR_Code_Generator
} }
} }
#endregion #endregion
} }
} }