static private void SecureToolStripDropDownItems(System.Windows.Forms.ToolStripMenuItem menuStrip, bool securityState) { foreach (ToolStripMenuItem item in menuStrip.DropDownItems) { if (item.HasDropDownItems) { SecureToolStripDropDownItems(item, securityState); } if (CWProductProtection.IsObjectControlled(item.Name)) { item.Enabled = securityState; } } }
/// <summary> /// Initilize the cwactivation object. This overload does no includes a list of object to control. /// </summary> /// <param name="privateFileName"></param> /// <param name="activationCount"></param> /// <param name="packageName"></param> /// <param name="trialBegin"></param> /// <param name="trialPeriod"></param> /// <param name="periodType"></param> /// <param name="objectsToSecure"></param> /// <returns></returns> static public void Initilize(String privateFileName, Int32 activationCount, String packageName, DateTime trialBegin, Int32 trialPeriod, PeriodType periodType) { m_FileName = privateFileName; if (!InitActivationObject()) { InitCommonDataMembers(activationCount, packageName, trialBegin, trialPeriod, periodType); CWProductProtection.Persist(); //Save it. } }
/// <summary> /// Secure all controlled controls. /// It is left up to the user to determine when /// to call this method. /// </summary> /// <param name="formToSecure"></param> static private void SecureControls(System.Windows.Forms.Form formToSecure, bool securityState) { foreach (Control control in formToSecure.Controls) { if (CWProductProtection.IsObjectControlled(control.Name)) { control.Enabled = securityState; } if (control.Enabled && control.GetType() == typeof(System.Windows.Forms.MenuStrip)) { foreach (ToolStripMenuItem menuItem in ((MenuStrip)control).Items) { SecureMenuStrip(menuItem, securityState); } } } }
/// <summary> /// Initilize the cwactivation object. This overload includes a list of object to control. /// </summary> /// <param name="privateFileName"></param> /// <param name="activationCount"></param> /// <param name="packageName"></param> /// <param name="trialBegin"></param> /// <param name="trialPeriod"></param> /// <param name="periodType"></param> /// <param name="objectsToSecure"></param> /// <returns>Does not return any value</returns> static public void Initilize(String privateFileName, Int32 activationCount, String packageName, DateTime trialBegin, Int32 trialPeriod, PeriodType periodType, List <String> objectsToSecure) { m_FileName = privateFileName; if (!InitActivationObject()) { InitCommonDataMembers(activationCount, packageName, trialBegin, trialPeriod, periodType); foreach (String obj in objectsToSecure) { CWProductProtection.cwActivation.AddControlledObject(obj); } CWProductProtection.Persist(); //Save it. } }