diff --git a/QR-Code-Generator.sln b/QR-Code-Generator.sln new file mode 100644 index 0000000..70aeaba --- /dev/null +++ b/QR-Code-Generator.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35219.272 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QR-Code-Generator", "QR-Code-Generator\QR-Code-Generator.csproj", "{F2A91F64-A3F5-46C0-9E58-A3F8A8A67496}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F2A91F64-A3F5-46C0-9E58-A3F8A8A67496}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2A91F64-A3F5-46C0-9E58-A3F8A8A67496}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2A91F64-A3F5-46C0-9E58-A3F8A8A67496}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2A91F64-A3F5-46C0-9E58-A3F8A8A67496}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CED21D64-9D33-4424-BDA4-36DDE450548D} + EndGlobalSection +EndGlobal diff --git a/QR-Code-Generator/Main.Designer.cs b/QR-Code-Generator/Main.Designer.cs new file mode 100644 index 0000000..fce2c07 --- /dev/null +++ b/QR-Code-Generator/Main.Designer.cs @@ -0,0 +1,165 @@ +namespace QR_Code_Generator +{ + partial class Main + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + tabControl1 = new TabControl(); + tabPage1 = new TabPage(); + bt_gen_QR_URL = new Button(); + label1 = new Label(); + tb_URL = new TextBox(); + tabPage2 = new TabPage(); + pb_QRC = new PictureBox(); + button1 = new Button(); + pb_icon = new PictureBox(); + tabControl1.SuspendLayout(); + tabPage1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pb_QRC).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pb_icon).BeginInit(); + SuspendLayout(); + // + // tabControl1 + // + tabControl1.Controls.Add(tabPage1); + tabControl1.Controls.Add(tabPage2); + tabControl1.Location = new Point(12, 12); + tabControl1.Name = "tabControl1"; + tabControl1.SelectedIndex = 0; + tabControl1.Size = new Size(420, 200); + tabControl1.TabIndex = 0; + // + // tabPage1 + // + tabPage1.Controls.Add(bt_gen_QR_URL); + tabPage1.Controls.Add(label1); + tabPage1.Controls.Add(tb_URL); + tabPage1.Location = new Point(4, 24); + tabPage1.Name = "tabPage1"; + tabPage1.Padding = new Padding(3); + tabPage1.Size = new Size(412, 172); + tabPage1.TabIndex = 0; + tabPage1.Text = "tabPage1"; + tabPage1.UseVisualStyleBackColor = true; + // + // bt_gen_QR_URL + // + bt_gen_QR_URL.Location = new Point(71, 91); + bt_gen_QR_URL.Name = "bt_gen_QR_URL"; + bt_gen_QR_URL.Size = new Size(254, 23); + bt_gen_QR_URL.TabIndex = 2; + bt_gen_QR_URL.Text = "generiere QR"; + bt_gen_QR_URL.UseVisualStyleBackColor = true; + bt_gen_QR_URL.Click += bt_gen_QR_URL_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(34, 70); + label1.Name = "label1"; + label1.Size = new Size(31, 15); + label1.TabIndex = 1; + label1.Text = "URL:"; + // + // tb_URL + // + tb_URL.Location = new Point(71, 62); + tb_URL.Name = "tb_URL"; + tb_URL.Size = new Size(254, 23); + tb_URL.TabIndex = 0; + tb_URL.Text = "https://www.youtube.com/watch?v=3XW7SxiJC-k"; + // + // tabPage2 + // + tabPage2.Location = new Point(4, 24); + tabPage2.Name = "tabPage2"; + tabPage2.Padding = new Padding(3); + tabPage2.Size = new Size(412, 294); + tabPage2.TabIndex = 1; + tabPage2.Text = "tabPage2"; + tabPage2.UseVisualStyleBackColor = true; + // + // pb_QRC + // + pb_QRC.Location = new Point(16, 218); + pb_QRC.Name = "pb_QRC"; + pb_QRC.Size = new Size(300, 300); + pb_QRC.SizeMode = PictureBoxSizeMode.Zoom; + pb_QRC.TabIndex = 1; + pb_QRC.TabStop = false; + // + // button1 + // + button1.Location = new Point(434, 36); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 2; + button1.Text = "Icon?"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // pb_icon + // + pb_icon.Location = new Point(625, 40); + pb_icon.Name = "pb_icon"; + pb_icon.Size = new Size(184, 168); + pb_icon.SizeMode = PictureBoxSizeMode.Zoom; + pb_icon.TabIndex = 3; + pb_icon.TabStop = false; + // + // Main + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(929, 633); + Controls.Add(pb_icon); + Controls.Add(button1); + Controls.Add(pb_QRC); + Controls.Add(tabControl1); + Name = "Main"; + Text = "QR-Code Generator"; + tabControl1.ResumeLayout(false); + tabPage1.ResumeLayout(false); + tabPage1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pb_QRC).EndInit(); + ((System.ComponentModel.ISupportInitialize)pb_icon).EndInit(); + ResumeLayout(false); + } + + #endregion + + private TabControl tabControl1; + private TabPage tabPage1; + private Button bt_gen_QR_URL; + private Label label1; + private TextBox tb_URL; + private TabPage tabPage2; + private PictureBox pb_QRC; + private Button button1; + private PictureBox pb_icon; + } +} diff --git a/QR-Code-Generator/Main.cs b/QR-Code-Generator/Main.cs new file mode 100644 index 0000000..49c6772 --- /dev/null +++ b/QR-Code-Generator/Main.cs @@ -0,0 +1,66 @@ +using QRCoder; +using System.Reflection.Emit; +using static QRCoder.PayloadGenerator; + +namespace QR_Code_Generator +{ + public partial class Main : Form + { + public Main() + { + InitializeComponent(); + } + + private void bt_gen_QR_URL_Click(object sender, EventArgs e) + { + Url generator = new Url(tb_URL.Text); + string payload = generator.ToString(); + + + + QRCodeGenerator qrg = new QRCodeGenerator(); + QRCodeData qrCodeData = qrg.CreateQrCode(payload, QRCodeGenerator.ECCLevel.H); + generateQR(qrCodeData); + + void generateQR(QRCodeData qrCodeData) + { + Bitmap icon = null; + if (pb_icon.Image != null) + { + icon = (Bitmap)pb_icon.Image; + } + using (QRCode qrCode = new QRCode(qrCodeData)) + { + Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, icon, 25, 3); + pb_QRC.Image = qrCodeImage; + } + } + } + + private void button1_Click(object sender, EventArgs e) + { + pb_icon.Image = SelectImage(); + } + private Image SelectImage() + { + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + // Filter für Bilddateien festlegen + openFileDialog.Filter = "Bilddateien (*.jpg;*.jpeg;*.png;*.bmp;*.gif)|*.jpg;*.jpeg;*.png;*.bmp;*.gif"; + openFileDialog.Title = "Bild auswählen"; + + // Wenn der Benutzer eine Datei auswählt und auf OK klickt + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + // Bild aus dem ausgewählten Pfad laden und zurückgeben + return Image.FromFile(openFileDialog.FileName); + } + else + { + // Gibt null zurück, wenn keine Datei ausgewählt wurde + return null; + } + } + } + } +} diff --git a/QR-Code-Generator/Main.resx b/QR-Code-Generator/Main.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/QR-Code-Generator/Main.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/QR-Code-Generator/Program.cs b/QR-Code-Generator/Program.cs new file mode 100644 index 0000000..53b71a9 --- /dev/null +++ b/QR-Code-Generator/Program.cs @@ -0,0 +1,17 @@ +namespace QR_Code_Generator +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new Main()); + } + } +} \ No newline at end of file diff --git a/QR-Code-Generator/QR-Code-Generator.csproj b/QR-Code-Generator/QR-Code-Generator.csproj new file mode 100644 index 0000000..f20e77e --- /dev/null +++ b/QR-Code-Generator/QR-Code-Generator.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + QR_Code_Generator + enable + true + enable + + + + + + + \ No newline at end of file