using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using System.Text; namespace GroundZero.KeyCodes { /// /// Summary description for Form1. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Panel panel1; private System.Windows.Forms.TextBox edOut; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox edRegTo; private System.Windows.Forms.CheckBox ckWebInterface; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox edSchedUsers; private System.Windows.Forms.CheckBox ckQuickBooksInterface; private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem mnGenerateKey; private System.Windows.Forms.MenuItem mnuReadKey; private System.Windows.Forms.Label label4; private System.Windows.Forms.Button btn31Days; private Infragistics.Win.UltraWinEditors.UltraDateTimeEditor dtExpires; private Infragistics.Win.UltraWinEditors.UltraOptionSet setType; /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (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() { Infragistics.Win.Appearance appearance1 = new Infragistics.Win.Appearance(); Infragistics.Win.ValueListItem valueListItem1 = new Infragistics.Win.ValueListItem(); Infragistics.Win.ValueListItem valueListItem2 = new Infragistics.Win.ValueListItem(); Infragistics.Win.ValueListItem valueListItem3 = new Infragistics.Win.ValueListItem(); this.panel1 = new System.Windows.Forms.Panel(); this.setType = new Infragistics.Win.UltraWinEditors.UltraOptionSet(); this.btn31Days = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.dtExpires = new Infragistics.Win.UltraWinEditors.UltraDateTimeEditor(); this.ckQuickBooksInterface = new System.Windows.Forms.CheckBox(); this.edSchedUsers = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.ckWebInterface = new System.Windows.Forms.CheckBox(); this.edRegTo = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.edOut = new System.Windows.Forms.TextBox(); this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.mnGenerateKey = new System.Windows.Forms.MenuItem(); this.mnuReadKey = new System.Windows.Forms.MenuItem(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.setType)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dtExpires)).BeginInit(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.setType); this.panel1.Controls.Add(this.btn31Days); this.panel1.Controls.Add(this.label4); this.panel1.Controls.Add(this.dtExpires); this.panel1.Controls.Add(this.ckQuickBooksInterface); this.panel1.Controls.Add(this.edSchedUsers); this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.label2); this.panel1.Controls.Add(this.ckWebInterface); this.panel1.Controls.Add(this.edRegTo); this.panel1.Controls.Add(this.label1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(704, 232); this.panel1.TabIndex = 0; // // setType // this.setType.CheckedIndex = 0; this.setType.FlatMode = true; this.setType.ItemAppearance = appearance1; valueListItem1.DataValue = "NEW"; valueListItem1.DisplayText = "New license"; valueListItem2.DataValue = "ADD"; valueListItem2.DisplayText = "Add on"; valueListItem3.DataValue = "LICENSETRIAL"; valueListItem3.DisplayText = "Licensed trial"; this.setType.Items.Add(valueListItem1); this.setType.Items.Add(valueListItem2); this.setType.Items.Add(valueListItem3); this.setType.ItemSpacingVertical = 5; this.setType.Location = new System.Drawing.Point(8, 16); this.setType.Name = "setType"; this.setType.Size = new System.Drawing.Size(272, 56); this.setType.TabIndex = 11; this.setType.Text = "New license"; // // btn31Days // this.btn31Days.Location = new System.Drawing.Point(176, 200); this.btn31Days.Name = "btn31Days"; this.btn31Days.TabIndex = 10; this.btn31Days.Text = "31 days"; this.btn31Days.Click += new System.EventHandler(this.btn31Days_Click); // // label4 // this.label4.Location = new System.Drawing.Point(8, 184); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(312, 16); this.label4.TabIndex = 9; this.label4.Text = "Expires: (leave blank for no expiry)"; // // dtExpires // this.dtExpires.Location = new System.Drawing.Point(8, 200); this.dtExpires.Name = "dtExpires"; this.dtExpires.TabIndex = 8; this.dtExpires.Value = null; // // ckQuickBooksInterface // this.ckQuickBooksInterface.Location = new System.Drawing.Point(456, 40); this.ckQuickBooksInterface.Name = "ckQuickBooksInterface"; this.ckQuickBooksInterface.Size = new System.Drawing.Size(184, 24); this.ckQuickBooksInterface.TabIndex = 6; this.ckQuickBooksInterface.Text = "QuickBooks interface"; // // edSchedUsers // this.edSchedUsers.Location = new System.Drawing.Point(8, 144); this.edSchedUsers.Name = "edSchedUsers"; this.edSchedUsers.TabIndex = 5; this.edSchedUsers.Text = "5"; // // label3 // this.label3.Location = new System.Drawing.Point(8, 128); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(312, 16); this.label3.TabIndex = 4; this.label3.Text = "Scheduleable users:"; // // label2 // this.label2.Location = new System.Drawing.Point(456, 0); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(100, 16); this.label2.TabIndex = 3; this.label2.Text = "Options:"; // // ckWebInterface // this.ckWebInterface.Location = new System.Drawing.Point(456, 16); this.ckWebInterface.Name = "ckWebInterface"; this.ckWebInterface.Size = new System.Drawing.Size(184, 24); this.ckWebInterface.TabIndex = 2; this.ckWebInterface.Text = "Web interface"; // // edRegTo // this.edRegTo.Location = new System.Drawing.Point(8, 96); this.edRegTo.Name = "edRegTo"; this.edRegTo.Size = new System.Drawing.Size(360, 20); this.edRegTo.TabIndex = 1; this.edRegTo.Text = "Unregistered trial"; // // label1 // this.label1.Location = new System.Drawing.Point(8, 80); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(100, 16); this.label1.TabIndex = 0; this.label1.Text = "Registered to:"; // // edOut // this.edOut.Dock = System.Windows.Forms.DockStyle.Fill; this.edOut.Location = new System.Drawing.Point(0, 232); this.edOut.Multiline = true; this.edOut.Name = "edOut"; this.edOut.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.edOut.Size = new System.Drawing.Size(704, 321); this.edOut.TabIndex = 1; this.edOut.Text = ""; // // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.mnGenerateKey, this.mnuReadKey}); // // mnGenerateKey // this.mnGenerateKey.Index = 0; this.mnGenerateKey.Text = "Generate key to clipboard"; this.mnGenerateKey.Click += new System.EventHandler(this.mnGenerateKey_Click); // // mnuReadKey // this.mnuReadKey.Index = 1; this.mnuReadKey.Text = "Validate key"; this.mnuReadKey.Click += new System.EventHandler(this.mnuReadKey_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(704, 553); this.Controls.Add(this.edOut); this.Controls.Add(this.panel1); this.Menu = this.mainMenu1; this.Name = "Form1"; this.Text = "Keymaster (25-April-2006)"; this.Load += new System.EventHandler(this.Form1_Load); this.panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.setType)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dtExpires)).EndInit(); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } private void mnGenerateKey_Click(object sender, System.EventArgs e) { if(setType.CheckedItem==null) { MessageBox.Show("Select a license type to proceed"); return; } string SelectedLicenseType=setType.CheckedItem.DataValue.ToString(); KeyGen kg=new KeyGen(); kg.FeatureQuickBooksInterface=this.ckQuickBooksInterface.Checked; kg.FeatureWebInterface=this.ckWebInterface.Checked; kg.RegisteredTo=this.edRegTo.Text; kg.ScheduleableUsers=System.Convert.ToInt32(this.edSchedUsers.Text); bool bWillExpire=false; if(dtExpires.Value!=null && dtExpires.Value!=DBNull.Value) { kg.Expires=dtExpires.DateTime; bWillExpire=true; } else kg.Expires=DateTime.Today; string strKey=""; #region format message if(SelectedLicenseType=="NEW") { #region New strKey="Thank you for your purchase and welcome to the \r\n" + "world-wide community of AyaNova users! \r\n" + " \r\n" + "Below is your activation key with instructions for entry into the \r\n" + "trial of AyaNova v3 that you previously downloaded from our website, \r\n" + "installed and tested for suitability. \r\n" + " \r\n" + "Reminder: no physical product will be shipped to you, this license key \r\n" + "fulfills your order in full. \r\n" + " \r\n" + " \r\n" + "HELP AND SUPPORT RESOURCES: \r\n" + "AyaNova web site: \r\n" + "http://www.ayanova.com \r\n" + "Users manual: \r\n" + "http://www.ayanova.com/download.htm \r\n" + "Answers to frequently asked questions: \r\n" + "http://www.ayanova.com/faqAnswers.htm \r\n" + "Technical support forum: \r\n" + "http://forum.ayanova.com \r\n" + "Latest AyaNova version update information: \r\n" + "http://forum.ayanova.com \r\n" + " \r\n" + " \r\n" + LicenseInfo(kg,setType.Value.ToString())+ "HOW TO ENTER YOUR ACTIVATION KEY \r\n" + " \r\n" + "1. Copy only all the text from between the -=-=-=-=-=- below to the Windows clip board \r\n" + "(highlight the text, right-click, select Copy) \r\n" + " \r\n" + "Do not edit any of the key text, AyaNova will not accept an altered key. \r\n" + " \r\n" + "2. Ensure no other users are accessing AyaNova v3 \r\n" + " \r\n" + "3. Log into the trial AyaNova v3 as the AyaNova Administrator \r\n" + "(default is manager with password letmein ) \r\n" + "(no quotation marks and in lowercase) \r\n" + " \r\n" + "4. Select Help->License from the main menu to bring up the keycode window. \r\n" + " \r\n" + "5. Select the menu option Paste license key \r\n" + " \r\n" + "6. Close AyaNova \r\n" + " \r\n" + "7. Log back into AyaNova v3 as manager with password letmein \r\n" + "(no quotation marks and in lowercase) \r\n" + " \r\n" + "8. As the trial AyaNova v3 has 5 sample scheduleable users, if the number of licenses \r\n" + "purchased are less than 5, you will receive a message that 5 are set to Active, and \r\n" + "the number of licenses do not match the number set Active. \r\n" + "If you receive this message and are not going to erase the trial data, you will need \r\n" + "to manually delete or close all workorders where sample scheduleable users are \r\n" + "selected. Then open the Administration pane, open the Users grid, \r\n" + "and set the sample scheduleable users to In-active. \r\n" + " \r\n" + "9. To erase all trial entered data and users, select Help->License from the main menu \r\n" + "to bring up the keycode window. Select the menu option to erase sample data. \r\n" + " \r\n" + "10. Refer to the AyaNova v3 Manual for details on all features, tutorials, tips on use, \r\n" + "and for installing and configuring for a network environment \r\n" + " \r\n" + " =-=-=-=-=-=-< LICENSE KEYCODE >-=-=-=-=-=-=- \r\n" + kg.Generate() + " \r\n" + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= \r\n" + " \r\n" ; #endregion new } else if(SelectedLicenseType=="ADD") //Add on { #region Add on strKey="Thank you for your additional license purchase! \r\n" + "\r\n" + "Below is your replacement activation key with \r\n" + "instructions for entering it. \r\n" + "\r\n" + "Your previous key is no longer licensed and is no \r\n" + "longer required as this key supersedes all \r\n" + "previous keys purchased. \r\n" + "\r\n" + "Reminder: no physical product will be shipped to you, this license key \r\n" + "fulfills your order in full. \r\n" + "\r\n" + "\r\n" + "HELP AND SUPPORT RESOURCES: \r\n" + "AyaNova web site: \r\n" + "http://www.ayanova.com \r\n" + "Users manual: \r\n" + "http://www.ayanova.com/download.htm \r\n" + "Answers to frequently asked questions: \r\n" + "http://www.ayanova.com/faqAnswers.htm \r\n" + "Technical support forum: \r\n" + "http://forum.ayanova.com \r\n" + "\r\n" + "\r\n " + LicenseInfo(kg,setType.Value.ToString())+ "PURCHASING ADDITIONAL LICENSES \r\n" + "If you wish to purchase additional licenses in future you must use the \r\n" + "same registration name and registered email address used when you purchased this key. \r\n" + " \r\n" + " \r\n" + "HOW TO ENTER YOUR ACTIVATION KEY \r\n" + " \r\n" + "1. Copy only all the text from between the -=-=-=-=-=- below to the Windows clip board \r\n" + "(highlight the text, right-click, select Copy) \r\n" + " \r\n" + "Do not edit any of the key text, AyaNova will not accept an altered key. \r\n" + " \r\n" + "2. Ensure no other users are accessing AyaNova v3 \r\n" + " \r\n" + "3. Log into AyaNova v3 as the AyaNova Administrator \r\n" + "(default is manager with password letmein ) \r\n" + "(no quotation marks and in lowercase) \r\n" + " \r\n" + "4. Select Help->License from the main menu to bring up the keycode window. \r\n" + " \r\n" + "5. Select the menu option Paste license key \r\n" + " \r\n" + "6. Close AyaNova \r\n" + " \r\n" + " \r\n" + " =-=-=-=-=-=-< LICENSE KEYCODE >-=-=-=-=-=-=- \r\n" + kg.Generate() + " \r\n" + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= \r\n" + " \r\n" ; #endregion add on } else//Licensed trial { if(!bWillExpire) MessageBox.Show("WARNING: A licensed trial should have an expiry date"); #region Licensed trial strKey="Thank you for evaluating AyaNova \r\n" + " \r\n" + "Below is your temporary activation key with instructions for entry into the \r\n" + "trial of AyaNova v3 that you previously downloaded from our website. \r\n" + " \r\n" + " \r\n" + "HELP AND SUPPORT RESOURCES: \r\n" + "AyaNova web site: \r\n" + "http://www.ayanova.com \r\n" + "Users manual: \r\n" + "http://www.ayanova.com/download.htm \r\n" + "Answers to frequently asked questions: \r\n" + "http://www.ayanova.com/faqAnswers.htm \r\n" + "Technical support forum: \r\n" + "http://forum.ayanova.com \r\n" + "Latest AyaNova version update information: \r\n" + "http://forum.ayanova.com \r\n" + " \r\n" + " \r\n" + LicenseInfo(kg,setType.Value.ToString())+ "HOW TO ENTER YOUR ACTIVATION KEY \r\n" + " \r\n" + "1. Copy only all the text from between the -=-=-=-=-=- below to the Windows clip board \r\n" + "(highlight the text, right-click, select Copy) \r\n" + " \r\n" + "Do not edit any of the key text, AyaNova will not accept an altered key. \r\n" + " \r\n" + "2. Ensure no other users are accessing AyaNova v3 \r\n" + " \r\n" + "3. Log into the trial AyaNova v3 as the AyaNova Administrator \r\n" + "(default is manager with password letmein ) \r\n" + "(no quotation marks and in lowercase) \r\n" + " \r\n" + "4. Select Help->License from the main menu to bring up the keycode window. \r\n" + " \r\n" + "5. Select the menu option Paste license key \r\n" + " \r\n" + "6. Close AyaNova \r\n" + " \r\n" + "7. Log back into AyaNova v3 as manager with password letmein \r\n" + "(no quotation marks and in lowercase) \r\n" + " \r\n" + "8. As the trial AyaNova v3 has 5 sample scheduleable users, if the number of licenses \r\n" + "purchased are less than 5, you will receive a message that 5 are set to Active, and \r\n" + "the number of licenses do not match the number set Active. \r\n" + "If you receive this message and are not going to erase the trial data, you will need \r\n" + "to manually delete or close all workorders where sample scheduleable users are \r\n" + "selected. Then open the Administration pane, open the Users grid, \r\n" + "and set the sample scheduleable users to In-active. \r\n" + " \r\n" + "9. To erase all trial entered data and users, select Help->License from the main menu \r\n" + "to bring up the keycode window. Select the menu option to erase sample data. \r\n" + " \r\n" + "10. Refer to the AyaNova v3 Manual for details on all features, tutorials, tips on use, \r\n" + "importing AyaNova CE 1.9.4.4 data, and for installing and configuring \r\n" + "for a network environment \r\n" + " \r\n"+ " =-=-=-=-=-=-< LICENSE KEYCODE >-=-=-=-=-=-=- \r\n" + kg.Generate() + " \r\n" + "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= \r\n" + " \r\n" ; // // strKey="Thank you for evaluating AyaNova \r\n" + // " \r\n" + // "Below is your temporary activation key with instructions for entry into the\r\n" + // "trial of AyaNova that you previously downloaded from our website. \r\n" + // " \r\n" + // " \r\n" + // "HELP AND SUPPORT RESOURCES: \r\n" + // "AyaNova web site: \r\n" + // "http://www.ayanova.com \r\n" + // "Users manual: \r\n" + // "http://www.ayanova.com/download.htm \r\n" + // "Answers to frequently asked questions: \r\n" + // "http://www.ayanova.com/faqAnswers.htm \r\n" + // "Technical support forum: \r\n" + // "http://forum.ayanova.com \r\n" + // " \r\n" + // " \r\n" + // LicenseInfo(kg,setType.Value.ToString())+ // "HOW TO ENTER YOUR ACTIVATION KEY \r\n" + // " \r\n" + // "1. Copy only all the text from between the -=-=-=-=-=- below to the Windows clip board \r\n" + // "(highlight the text, right-click, select Copy) \r\n" + // "\r\n" + // "Do not edit any of the key text, AyaNova will not accept an altered key. " + // " \r\n" + // "2. Ensure no other users are accessing AyaNova v3 \r\n" + // " \r\n" + // "3. Log into the trial AyaNova v3 as \"manager\" with password \"letmein\" \r\n" + // "(no quotation marks and in lowercase) \r\n" + // " \r\n" + // "4. Select Help->License from the main menu to bring up the keycode window. \r\n" + // " \r\n" + // "5. Select the menu option Paste license key \r\n" + // " \r\n" + // "6. Close AyaNova \r\n" + // " \r\n" + // "7. Log back into AyaNova v3 as \"manager\" with password \"letmein\" \r\n" + // "(no quotation marks and in lowercase) \r\n" + // " \r\n" + // "8. As the trial AyaNova v3 has 5 sample scheduleable users, if the number of licenses provided are less than 5, \r\n" + // "you will receive a message that 5 are set to Active, and the number of licenses do not match the number set Active. \r\n" + // "If you receive this message and are not going to erase the trial data, open the Administration pane, open the Users \r\n" + // "grid, and set the sample scheduleable users to In-active . \r\n" + // " \r\n" + // "9. Refer to the AyaNova v3 Manual Technical section for installing and configuring for a network environment, \r\n" + // " importing your AyaNova CE 1.9.4.4 data and for erasing the trial sample data and users. \r\n" + // " \r\n" + // " \r\n" + // // " =-=-=-=-=-=-< LICENSE KEYCODE >-=-=-=-=-=-=- \r\n" + // kg.Generate() + " \r\n" + // "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= \r\n" + // " \r\n" ; #endregion licensed trial } #endregion edOut.Text=strKey; edOut.SelectAll(); edOut.Copy(); } /// /// Extra info to display about key at top of key message /// /// /// private string LicenseInfo(KeyGen kg, string stype) { StringBuilder sb = new StringBuilder(); sb.Append("LICENSE DETAILS\r\n"); sb.Append("This key must be installed by: "); sb.Append(System.DateTime.Today.AddDays(3).ToString()); sb.Append("\r\n"); if(!System.DateTime.Today.Date.Equals(kg.Expires.Date)) { if(stype=="LICENSEDTRIAL") { sb.Append("*** This has been provided for temporary evaluation purposes only *** \r\n"); sb.Append("This key will stop working after: " + kg.Expires.ToString() + "\r\n"); } else { sb.Append("This license key is provided for temporary use pending payment.\r\n"); sb.Append("The key will stop working after: " + kg.Expires.ToString() + "\r\n"); sb.Append("\r\n"); sb.Append("A permanent license key will be sent to you when payment \r\n" + "has been received and processed. There will be no extensions or \r\n" + "exceptions. Please send in payment early enough to allow for \r\n" + "mail and processing time to ensure uninterrupted use of AyaNova. \r\n"); } sb.Append("\r\n"); } sb.Append("Registered to: "); sb.Append(kg.RegisteredTo); sb.Append("\r\n"); sb.Append("Schedulable users: "); sb.Append(kg.ScheduleableUsers); sb.Append("\r\n"); sb.Append("QuickBooks interface optional add on: "); sb.Append(kg.FeatureQuickBooksInterface?"YES":" Not purchased"); sb.Append("\r\n"); sb.Append("Web interface optional add on: "); sb.Append(kg.FeatureWebInterface?"YES":" Not purchased"); sb.Append("\r\n\r\n"); return sb.ToString(); } private void mnuReadKey_Click(object sender, System.EventArgs e) { KeyReader kr=new KeyReader(edOut.Text); if(!kr.IsValid) MessageBox.Show(kr.Status); else { string strExpiry="Expires: n/a"; if(kr.Expires!=null) strExpiry="Expires: " + ((DateTime)kr.Expires).ToString(); MessageBox.Show( "Key is OK:\r\n" + strExpiry + "\r\n" + kr.RegisteredTo+"\r\n"+ kr.ScheduleableUsers.ToString() + "\r\n" + kr.Generated.ToString()+ "\r\nInstallable: " + kr.Installable.ToString()); } } private void btn31Days_Click(object sender, System.EventArgs e) { dtExpires.Value=System.DateTime.Now.AddDays(31); } private void Form1_Load(object sender, System.EventArgs e) { dtExpires.Value=DBNull.Value; } } }