using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using IntelOrca.Launchpad; using IntelOrca.LaunchpadTests; using Kidd_s_Passwort_Generator; namespace Kidd_s_Passwort_Generator { public partial class Form_MainMenue : Form { LaunchpadDevice device; PWGenerator Generator; Queue ImageList; public Form_MainMenue() { InitializeComponent(); try { // Assign the launchpad if one is plugged in device = new LaunchpadDevice(); device.DoubleBuffered = true; } catch { Console.WriteLine("No launchpad found"); Console.ReadLine(); return; } } private void button_startLaunchPad_Click(object sender, EventArgs e) { textBox_finalesPassword.Text = ""; PassWort_Anleitung.Controls.Clear(); bool userCancel; switch (comboBox_Device.Text) { case "Novation Launchpad": try { if (device == null) { device = new LaunchpadDevice(); device.DoubleBuffered = true; } //Try to initialize with custom parameters otherwise use the default ones Generator = new PWGenerator(device, Convert.ToInt32(textBox_Seed.Text), Convert.ToInt32(textBox_pKey.Text), comboBox_CharSet.Text, comboBox_CodePage.Text); } catch { if (device == null) { device = new LaunchpadDevice(); device.DoubleBuffered = true; } Generator = new PWGenerator(device); } userCancel = Generator.Run(); // after confirmation is pushed leave the routine and display the password textBox_finalesPassword.Text = Generator.GetFinalPassword(); if (!userCancel) { ImageList = new Queue(); ImageList = Generator.GetInstructionList(); generateInstruction(ImageList); } device.Reset(); Generator = null; break; case "8 x 8 Eingabefeld": default: Generator = new PWGenerator(device, Convert.ToInt32(textBox_Seed.Text), Convert.ToInt32(textBox_pKey.Text), comboBox_CharSet.Text, comboBox_CodePage.Text); _8x8EingabeFeld Feld = new _8x8EingabeFeld(Generator); Feld.Show(); //Problem: Nach show ausführung wird hier nichtmehr wiederholt!!! Andere Routine überlegen!!! // ToDo: // Eingabefeld von PWGenerator Logik entkoppeln!!! // D.h. Generator liefert daten wie bei device wird jedoch gefüttert mit input von eingabefeld // after confirmation is pushed leave the routine and display the password //textBox_finalesPassword.Text = Generator.GetFinalPassword(); /*if (!userCancel) { ImageList = new Queue(); ImageList = Generator.GetInstructionList(); generateInstruction(ImageList); }*/ //Feld = null; //Generator = null; break; } } private void generateInstruction(Queue Instructions) { Queue InstructionList = new Queue(); int XPos = 20; int YPos = 20; int stdWidth = 52; int stdHeight = 52; PassWort_Anleitung.Controls.Clear(); if (Instructions.Count() > 0) { while (Instructions.Count() > 0) { PictureBox Picture = new PictureBox(); Picture.SizeMode = PictureBoxSizeMode.Zoom; Picture.ImageLocation = Instructions.Dequeue(); Picture.Width = stdWidth * 2; Picture.Height = stdHeight * 2; Picture.Left = XPos; Picture.Top = YPos; Picture.Load(); PassWort_Anleitung.Controls.Add(Picture); XPos += stdWidth * 2; if (XPos > 8 * (stdWidth * 2)) { YPos += stdHeight * 2; XPos = 20; } } } } } }