using DatenDB; using Microsoft.VisualBasic; using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Deckungsbeitrag.UserControls { public partial class UCFeedback : UserControl { private string eingabe; private Benutzer user; private string bildDateiname; private bool bildDone = false; //private string vaultPath = Program.vaultPath; public UCFeedback(Benutzer benutzer) { InitializeComponent(); this.user = benutzer; } private void buttonFeedback_Click(object sender, EventArgs e) { DialogResult result = DialogResult.Cancel; string timestamp = string.Empty; string bildDateiname = string.Empty; Image clone = null; // Fragen ob Bild erstellt werden soll. Inkl. Anleitung wie Screenshot funktioniert. // Wenn bildDone ist true wird die Frage nichtmehr gestellt. if (!bildDone) result = MessageBox.Show("Benötigst du für das Feedback einen Screenshot?\n\nDann bestätige mit [JA] und erstelle einen Screenshot mit den Tasten [Win]+[Shift]+[S].\n\nDanach click nochmals auf den Button [Feedback].", "Screenshot", MessageBoxButtons.YesNo); // Wenn Bild benötigt, wird bildDone auf true gesetzt. if (result == DialogResult.Yes) { bildDone = true; return; } // Wenn kein Bild benötigt oder bildDone true ist wird Feedback abgefragt. if (result == DialogResult.No || bildDone) { eingabe = Interaction.InputBox("Welches Feedback möchtest du senden?\n\nFeedback:", "Feedback erstellen", ""); timestamp = DateTime.Now.ToString("dd.MM.yyyy-HH-mm"); // Wenn bildDone wird Bild erstellt und gespeichert. if (bildDone) { if (Clipboard.ContainsImage()) { using (Image img = Clipboard.GetImage()) { clone = new Bitmap(img); bildDateiname = $"feedback-{timestamp}.png"; string bildPath = Path.Combine("N:\\TECHNIK\\Software\\Wirl-Verwaltung\\Feedback", bildDateiname); //TODO: Warum der falsche Path? Immer mit \\ string tempPath = Path.Combine(Path.GetTempPath(), Path.GetFileName(bildPath)); try { clone.Save(tempPath, System.Drawing.Imaging.ImageFormat.Png); clone.Dispose(); File.Copy(tempPath, bildPath, true); File.Delete(tempPath); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } else throw new InvalidOperationException("Zwischenablage enthält kein Bild."); } } // Rückgabe an Program. Program.AddFeedback(user, eingabe, bildDateiname, timestamp); } } }