Initial code, everything seems to be working
This commit is contained in:
1 parent
67e3873714
commit
78c897f542
15 files changed
+8513
No files matched your search
+175
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FrappeMocha
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
protected Keygen frappeKeygen;
|
||||
private object[] windowsLicenseTypeItems = new object[2];
|
||||
private object[] macLicenseTypeItems = new object[2];
|
||||
private object[] javaLicenseTypeItems = new object[5];
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
TypeDropDown.SelectedIndex = 0;
|
||||
productSelect.SelectedIndex = 0;
|
||||
frappeKeygen = new Keygen();
|
||||
this.initDropDownMenuItems();
|
||||
}
|
||||
|
||||
private void initDropDownMenuItems()
|
||||
{
|
||||
TypeDropDown.Items.CopyTo(windowsLicenseTypeItems, 0);
|
||||
|
||||
initJavaLicenseTypeItems();
|
||||
initMacLicenseTypeItems();
|
||||
|
||||
TypeDropDown.Items.Clear();
|
||||
TypeDropDown.Items.AddRange(this.windowsLicenseTypeItems);
|
||||
TypeDropDown.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void initJavaLicenseTypeItems()
|
||||
{
|
||||
TypeDropDown.Items.Clear();
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
TypeDropDown.Items.Add((char) ('A' + i));
|
||||
}
|
||||
TypeDropDown.Items.CopyTo(this.javaLicenseTypeItems, 0);
|
||||
}
|
||||
|
||||
private void initMacLicenseTypeItems()
|
||||
{
|
||||
TypeDropDown.Items.Clear();
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
TypeDropDown.Items.Add((char)('a' + i));
|
||||
}
|
||||
TypeDropDown.Items.CopyTo(this.macLicenseTypeItems, 0);
|
||||
}
|
||||
|
||||
private void submit_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (productSelect.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
this.keygen(Keygen.LicenseTypes.License3270);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
this.keygen(Keygen.LicenseTypes.License5250);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
this.keygen(Keygen.LicenseTypes.License3812);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseTelnet);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseJava3270);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseJava5250);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseJavaTelnet);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseMac3270);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
this.keygen(Keygen.LicenseTypes.LicenseMac5250);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void TypeDropDown_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (TypeDropDown.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
companyusernamelabel.Text = "Company Name";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
companyusernamelabel.Text = "User Name";
|
||||
break;
|
||||
}
|
||||
|
||||
if (TypeDropDown.Items.Count > 2)
|
||||
{
|
||||
companyusernamelabel.Text = "Name";
|
||||
}
|
||||
}
|
||||
|
||||
private void keygen(Keygen.LicenseTypes license)
|
||||
{
|
||||
if (companytext.Text.Length <= 1)
|
||||
{
|
||||
MessageBox.Show(
|
||||
(TypeDropDown.SelectedIndex == 0
|
||||
? "Company Name"
|
||||
: "User Name") + " must be longer than one character", "Error",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string genlicense = frappeKeygen.GenLicense(TypeDropDown.SelectedIndex, companytext.Text, license);
|
||||
if (!frappeKeygen.CheckLicense(genlicense, companytext.Text, license))
|
||||
{
|
||||
MessageBox.Show("Generated license did not pass self check, please try again", "Warning",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
licensebox.Text = genlicense;
|
||||
}
|
||||
|
||||
private void productSelect_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (productSelect.SelectedIndex)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
if (this.windowsLicenseTypeItems[0] != null)
|
||||
{
|
||||
TypeDropDown.Items.Clear();
|
||||
TypeDropDown.Items.AddRange(this.windowsLicenseTypeItems);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
TypeDropDown.Items.Clear();
|
||||
TypeDropDown.Items.AddRange(this.javaLicenseTypeItems);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 8:
|
||||
TypeDropDown.Items.Clear();
|
||||
TypeDropDown.Items.AddRange(this.macLicenseTypeItems);
|
||||
break;
|
||||
}
|
||||
TypeDropDown.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user