private void ButtonGeneruj_Click(object sender, EventArgs e) { MyLicense licencja = new MyLicense { LicenseOwner = textBoxOwner.Text, CreateDateTime = DateTime.Now, LicenseNumber = textBoxLicenseNumber.Text, LicenseEnd = new DateTime(dateTimePickerKoniec.Value.Year, dateTimePickerKoniec.Value.Month, dateTimePickerKoniec.Value.Day, 23, 59, 59), Atr1 = textBoxAtr1.Text }; using (MemoryStream ms = new MemoryStream()) using (Bitmap bitmap = new Bitmap(pictureBoxLogo.Image)) { bitmap.Save(ms, ImageFormat.Png); licencja.LogoOwner = Convert.ToBase64String(ms.GetBuffer()); } if (radioButtonSingle.Checked) { if (LicenseHandler.ValidateUidFormat(textBoxUid.Text.Trim())) { licencja.Type = LicenseTypes.Single; licencja.Uid = textBoxUid.Text.Trim(); } else { MessageBox.Show(@"Błędny lub pusty identyfikator licencji", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else if (radioButtonVolume.Checked) { licencja.Type = LicenseTypes.Volume; licencja.Uid = string.Empty; } byte[] certPrivateKeyData; Assembly assembly = Assembly.GetExecutingAssembly(); using (MemoryStream memoryStream = new MemoryStream()) { assembly.GetManifestResourceStream("LicenseGenerator.LicenseSign.pfx")?.CopyTo(memoryStream); certPrivateKeyData = memoryStream.ToArray(); } textBoxLicencja.Text = LicenseHandler.GenerateLicense(licencja, certPrivateKeyData, _certPwd); }
private void ButtonGeneruj_Click(object sender, EventArgs e) { MyLicense licencja = new MyLicense { LicenseOwner = textBoxOwner.Text, CreateDateTime = DateTime.Now, LicenseNumber = textBoxLicenseNumber.Text, LicenseEnd = new DateTime(dateTimePickerKoniec.Value.Year, dateTimePickerKoniec.Value.Month, dateTimePickerKoniec.Value.Day, 23, 59, 59) }; using (MemoryStream ms = new MemoryStream()) using (Bitmap bitmap = new Bitmap(_logoPath)) { bitmap.Save(ms, ImageFormat.Png); licencja.LogoOwner = Convert.ToBase64String(ms.GetBuffer()); } if (radioButtonSingle.Checked) { if (LicenseHandler.ValidateUidFormat(textBoxUid.Text.Trim())) { licencja.Type = LicenseTypes.Single; licencja.Uid = textBoxUid.Text.Trim(); } else { MessageBox.Show(@"Błędny lub pusty identyfikator licencji", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else if (radioButtonVolume.Checked) { licencja.Type = LicenseTypes.Volume; licencja.Uid = string.Empty; } textBoxLicencja.Text = LicenseHandler.GenerateLicense(licencja, _certPrivateKeyData, _certPwd); }