{"category":{"version":"591f17ae21d2ff0f00cf5a3f","project":"547cd7662eaee50800ed1089","_id":"591f17af21d2ff0f00cf5a41","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-21T09:47:49.247Z","from_sync":false,"order":1,"slug":"getting-started-windows-framework","title":"Get Started: Windows Apps"},"parentDoc":null,"project":"547cd7662eaee50800ed1089","user":"547cd6ac78fd57080023ca99","version":{"__v":1,"_id":"591f17ae21d2ff0f00cf5a3f","project":"547cd7662eaee50800ed1089","createdAt":"2017-05-19T16:05:02.775Z","releaseDate":"2017-05-19T16:05:02.775Z","categories":["591f17af21d2ff0f00cf5a40","591f17af21d2ff0f00cf5a41","591f17af21d2ff0f00cf5a42","591f17af21d2ff0f00cf5a43","591f17af21d2ff0f00cf5a44","591f17af21d2ff0f00cf5a45","591f17af21d2ff0f00cf5a46","591f17af21d2ff0f00cf5a47","591f17af21d2ff0f00cf5a48"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.1","version":"1.0.1"},"_id":"591f17b021d2ff0f00cf5a4c","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-21T13:52:18.102Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":16,"body":"1. Take the steps described in [Integrate DevMateKit](doc:integrate-devmatekit) if you haven't done it yet.\n2. Add the following properties to `DMFrameworkSettings`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DMFrameworkSettings.PublickRSAKey = :::at:::\\\"-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzRWGeVD5D1FDuRhpSKzU P19hTLUNE0AHZHjdU05AZOUa8gxlCfMSHjsuM95dtk2Z+Pgd9Vq1OTGrYhav9jZP xUMdtHcinyAnXjAz2hgSSb3/1qrXPxaSoG05x8LPTEN5RYxal6PorRDGOAvG8sgN /nHIBmylZMpQOegWo8JppIpKHEfii23JcGuXkoo/oen33TQq5y/HhWWRKfxVbnGx RnD25WAOcWpvg+H2gWVrfLwRAu9GK0yGBhOhbgKsfO056NAwfM02HhRAtwfC7Xhc ID6kPWp/qThVLSfGhwXkUNwAxfCHh/5dH2rF/xfCAhvfBhxLYx7Njg3Ana/Ybo1L 5wIDAQAB -----END PUBLIC KEY-----\\\";\\n//!!! \\nDMFrameworkSettings.IsFirstRun = false;\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"NOTE\",\n  \"body\": \"On first clean run of the application, the `IsFirstRun` property must be set to “true”.\\nAlso note that you must specify `PublickRSAKey` to enable the Activation functionality. A unique key is provided by DevMate's Add Application wizard on the Configure Activation step.\"\n}\n[/block]\n3. You can specify additional `DMFrameworkSettings` properties if needed. DevMate Activation provides the following configuration options:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Property\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`IsFirstRun`\",\n    \"0-1\": \"bool\",\n    \"0-2\": \"Property (bool) must be set to “true” on first clean run of the application. In this case, DevMate will receive a report from the application that contains data on the first actual launch of the app.\",\n    \"1-0\": \"`IsBeta`\",\n    \"1-1\": \"bool\",\n    \"1-2\": \"Specifies whether a current version of the application is Beta.\",\n    \"2-0\": \"`URLActivationSchema`\",\n    \"2-1\": \"string\",\n    \"2-2\": \"Used for running the application by the URL Scheme. For more details, read [Configure Activation via URL Scheme](https://docs.devmate.com/v1.0/docs/add-activation#section-configuring-activation-via-url-scheme-optional-).\",\n    \"3-0\": \"`StoreAdditionalParameters`\",\n    \"3-1\": \"Dictionary<string,string>\",\n    \"3-2\": \"Configures additional GET parameters for your Store Link.\",\n    \"4-0\": \"`ApplicationIcon`\",\n    \"4-1\": \"string\",\n    \"4-2\": \"Sets a “TitleBar” icon for DevMate Framework windows. Must contain at least one 16x16pt icon. Example: *pack://application:,,,/TestApp;component/icon.ico*.\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\n3. Configure a trial mode of an application.\nUse the following code snippet to disable the trial mode in the Activation window:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DMActivationWindow window = new DMActivationWindow(); \\nwindow.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png\\\")); \\nwindow.ShowDialog();\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n   Use the following code snippet to enable the trial mode in the Activation window (make sure you've specified `DMFrameworkSettings.TrialType` before:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DMActivationWindow window = new DMActivationWindow(true); window.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png\\\")); \\nwindow.ShowDialog();\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nNote that you must use 128x128pt icon for the `BigIconSource` property. \nIf you want to open “DMActivationWindow” on the Enter Activation Key screen, set the following property to “true” before calling `ShowDialog()`:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"window.ShowEnterActivationNumberScreenAtStart = true\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n#Configuring Activation via URL Scheme (optional)\n1. Register the URL scheme on the client PC by creating the following registry keys and values:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"HKEY_CLASSES_ROOT\\\\[URL_Schema_Name]:\\n\\tSet the default value to “URL [Application_Name] Activation Protocol”.\\n\\tCreate an empty string value in HKEY_CLASSES_ROOT\\\\[URL_Schema_Name] with the \\tname \\\"URL Protocol”.\\nHKEY_CLASSES_ROOT\\\\[URL_Schema_Name]\\\\shell\\nHKEY_CLASSES_ROOT\\\\[URL_Schema_Name]\\\\shell\\\\open\\nHKEY_CLASSES_ROOT\\\\[URL_Schema_Name]\\\\shell\\\\open\\\\command:\\n\\tSet the default value to \\\"[PATH_TO_MAIN_APPLICATION_EXE]\\\" “%1”\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"NOTE\",\n  \"body\": \"You need the administrator’s permissions to complete this action. You can get these permissions during installation process.\"\n}\n[/block]\n2. Add the following code snippet to your application (it processes command line arguments):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DMFrameworkSettings.URLActivationSchema = [URL_Schema_Name];\\nbool fromURL = ActivationFramework.Current.IsRunUsingURLSchema();\\nif (fromURL)\\n{\\n    DMActivationWindow window = new DMActivationWindow( ActivationFramework.Current.GetKeyFromURLSchema());\\n    window.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png”));\\n    window.ShowDialog();  \\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"NOTE\",\n  \"body\": \"Read <a href=\\\"https://msdn.microsoft.com/library/aa767914(v=vs.85).aspx\\\">Registering an Application to a URI Scheme (MSDN)</a> to find out more.\"\n}\n[/block]\n#Configuring Activation API\nActivation API contains the following properties that must be obtained through `FindDelegate` method:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public class DelegateType\\n{\\n    public const int IsActivated;\\n    public const int LicenseInformation;\\n    public const int Activate;\\n    public const int StartTrial;\\n    public const int GetTrial;\\n    public const int GetRawTrialValue;\\n    public const int GetStoreLink;\\n }\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n###IsActivated\nIf you use the `IsActivated` property, the method verifies whether the application is activated.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.IsActivated) as Func<int>;\\nint isActivated = func.Invoke();\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nPossible results are the following:\n* 0 - not activated\n* 1 - activated\n* 2 - expired\n\n###LicenseInformation\nIf you use the `LicenseInformation` property, the method verifies the license information by comparing it to the user information from DevMate.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.LicenseInformation) as Func<int, object>;\\nstring ActivationIdKey = func.Invoke(LicenseInformationKeys.ActivationIdKey).ToString();\\nstring UserName = func.Invoke(LicenseInformationKeys.UserNameKey).ToString();\\nstring UserEmail = func.Invoke(LicenseInformationKeys.UserEmailKey).ToString();\\nlong ActivationDate = Convert.ToInt64(func.Invoke(LicenseInformationKeys.ActivationDateKey));\\nlong ExpirationDate = Convert.ToInt64(func.Invoke(LicenseInformationKeys.ExpirationDateKey));\\nstring ExpirationVersion = func.Invoke(LicenseInformationKeys.ExpirationVersionKey).ToString();\\nstring ActivationTag = func.Invoke(LicenseInformationKeys.ActivationTagKey).ToString();\\nbool IsBetaOnly = Convert.ToBoolean(func.Invoke(LicenseInformationKeys.BetaOnlyKey));\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n`UserName` and `UserEmail` values are not null/empty only if a user specified them during license activation. It becomes possible when an activation number has the pattern id<numbers>u<any two letters>.  Entering this kind of an activation number opens an extended activation dialog with mandatory user name and email fields.\n`ExpirationVersion` value specifies the ultimate application version covered by the current license. An owner of this license is not eligible for upgrade to versions higher than the specified one.  \n\n###Activate\nIf you use the `Activate` property, the method sends user data to DevMate to register (activate) a license.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.Activate) as Func<string, string, string, bool?, long>; Task.Factory.StartNew(() => \\n{\\t\\t\\t\\n      return func.Invoke(ActivationCode, UserName, UserEmail, KeepUpToDate);  }).ContinueWith((result) => \\n{\\n      var activationResult = (ActivationResult)Marshal.PtrToStructure(new IntPtr(result.Result), typeof(ActivationResult));\\n      if (activationResult.Success)\\n      {         //Show Success Screen\\n      }\\n      else\\n      {\\n          ErrorText = activationResult.Error;\\n      }\\n});\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n###StartTrial\nIf you use the `StartTrial` property, the method sends a report about the beginning of a trial period when a user clicks the Start Trial button.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.StartTrial) as Func<long, bool>;\\nTrialType trialType = new TrialType() { DMTrialWeek = true };   \\n\\nIntPtr trialIntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(trialType));\\nMarshal.StructureToPtr(trialType, trialIntPtr, true);\\nlong timeTrialRef = (long)trialIntPtr;   \\n\\nbool res = func.Invoke(timeTrialRef);\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n`TrialType` class includes the following properties:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"public bool DMTrialDay { get; set; }\\npublic bool DMTrialWeek { get; set; }\\npublic bool DMTrialTwoWeeks { get; set; }\\npublic bool DMTrialMonth { get; set; }\\npublic bool DMTrialYear { get; set; }\\n\\npublic bool DMCustom { get; set; }\\npublic long DMTrialPeriond { get; set; }\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nPlease note that only one of the “TrialType” properties can be set to “true” at a time. If more than one property is set to “true”, DevMate will use only the last one applied.\nIf `DMCustom` is set to “true\", `DMTrialPeriond` is used. If `DMCustom` is set to “true” and `DMTrialPeriond` is not set, the default value is used  (86400 seconds).\n\n###GetTrial\nIf you use the `GetTrial` property, the method returns total duration of a trial period (in hours) and the number of hours that is already spent in the trial mode.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetTrial) as Func<Tuple<int,int>>;\\nvar trialInfo = func.Invoke();\\n\\nif (trialInfo.Item1 == -1 || trialInfo.Item2 == -1) \\n{\\n  //Trial not started \\n} \\nelse \\n{  \\nTrialPeriod = trialInfo.Item2; //In hours  \\nPassedTrial = trialInfo.Item1; //In hours \\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n###GetRawTrialValue\nIf you use the `GetRawTrialValue` property, the method returns total duration of a trial period (in seconds) and its expiration date (UNIX timestamp).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetRawTrialValue) as Func<Tuple<long,long>>;\\nvar trialInfo = func.Invoke();\\n\\nif (trialInfo.Item1 == -1 || trialInfo.Item2 == -1) \\n{\\n  //Trial not started \\n} \\nelse\\n{\\n  TrialPeriod = trialInfo.Item2; //In seconds\\n  TrialExpireDate = trialInfo.Item1; //In UNIX timestamp \\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n###GetTrialTimeRemained\nIf you use the `GetTrialTimeRemained` property, the method returns a total number of seconds left till the end of a trial period.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetTrialTimeRemained) as Func<long>;\\nvar trialInfo = func.Invoke();\\n \\nif (trialInfo==-1)\\n{\\n //Trial not started\\n}\\nelse\\n{\\n TrialPeriodRemained = trialInfo ; //In seconds\\n}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\n###GetStoreLink\nIf you use the `GetStoreLink` property, the method returns a link to the store where a user can buy a license.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetStoreLink) as Func<string>; \\nstring storeLink = func.Invoke(); \\nProcess.Start(storeLink); //Open link in default browser\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nNote that you can add GET parameters to the link by using this method:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"DMFrameworkSettings.StoreAdditionalParameters.Add(\\\"key\\\", “value\\\");\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"add-activation","type":"basic","title":"Configure Activation"}

Configure Activation


1. Take the steps described in [Integrate DevMateKit](doc:integrate-devmatekit) if you haven't done it yet. 2. Add the following properties to `DMFrameworkSettings`: [block:code] { "codes": [ { "code": "DMFrameworkSettings.PublickRSAKey = @\"-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzRWGeVD5D1FDuRhpSKzU P19hTLUNE0AHZHjdU05AZOUa8gxlCfMSHjsuM95dtk2Z+Pgd9Vq1OTGrYhav9jZP xUMdtHcinyAnXjAz2hgSSb3/1qrXPxaSoG05x8LPTEN5RYxal6PorRDGOAvG8sgN /nHIBmylZMpQOegWo8JppIpKHEfii23JcGuXkoo/oen33TQq5y/HhWWRKfxVbnGx RnD25WAOcWpvg+H2gWVrfLwRAu9GK0yGBhOhbgKsfO056NAwfM02HhRAtwfC7Xhc ID6kPWp/qThVLSfGhwXkUNwAxfCHh/5dH2rF/xfCAhvfBhxLYx7Njg3Ana/Ybo1L 5wIDAQAB -----END PUBLIC KEY-----\";\n//!!! \nDMFrameworkSettings.IsFirstRun = false;", "language": "csharp" } ] } [/block] [block:callout] { "type": "info", "title": "NOTE", "body": "On first clean run of the application, the `IsFirstRun` property must be set to “true”.\nAlso note that you must specify `PublickRSAKey` to enable the Activation functionality. A unique key is provided by DevMate's Add Application wizard on the Configure Activation step." } [/block] 3. You can specify additional `DMFrameworkSettings` properties if needed. DevMate Activation provides the following configuration options: [block:parameters] { "data": { "h-0": "Property", "h-1": "Type", "h-2": "Description", "0-0": "`IsFirstRun`", "0-1": "bool", "0-2": "Property (bool) must be set to “true” on first clean run of the application. In this case, DevMate will receive a report from the application that contains data on the first actual launch of the app.", "1-0": "`IsBeta`", "1-1": "bool", "1-2": "Specifies whether a current version of the application is Beta.", "2-0": "`URLActivationSchema`", "2-1": "string", "2-2": "Used for running the application by the URL Scheme. For more details, read [Configure Activation via URL Scheme](https://docs.devmate.com/v1.0/docs/add-activation#section-configuring-activation-via-url-scheme-optional-).", "3-0": "`StoreAdditionalParameters`", "3-1": "Dictionary<string,string>", "3-2": "Configures additional GET parameters for your Store Link.", "4-0": "`ApplicationIcon`", "4-1": "string", "4-2": "Sets a “TitleBar” icon for DevMate Framework windows. Must contain at least one 16x16pt icon. Example: *pack://application:,,,/TestApp;component/icon.ico*." }, "cols": 3, "rows": 5 } [/block] 3. Configure a trial mode of an application. Use the following code snippet to disable the trial mode in the Activation window: [block:code] { "codes": [ { "code": "DMActivationWindow window = new DMActivationWindow(); \nwindow.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png\")); \nwindow.ShowDialog();", "language": "csharp" } ] } [/block] Use the following code snippet to enable the trial mode in the Activation window (make sure you've specified `DMFrameworkSettings.TrialType` before: [block:code] { "codes": [ { "code": "DMActivationWindow window = new DMActivationWindow(true); window.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png\")); \nwindow.ShowDialog();", "language": "csharp" } ] } [/block] Note that you must use 128x128pt icon for the `BigIconSource` property. If you want to open “DMActivationWindow” on the Enter Activation Key screen, set the following property to “true” before calling `ShowDialog()`: [block:code] { "codes": [ { "code": "window.ShowEnterActivationNumberScreenAtStart = true", "language": "csharp" } ] } [/block] #Configuring Activation via URL Scheme (optional) 1. Register the URL scheme on the client PC by creating the following registry keys and values: [block:code] { "codes": [ { "code": "HKEY_CLASSES_ROOT\\[URL_Schema_Name]:\n\tSet the default value to “URL [Application_Name] Activation Protocol”.\n\tCreate an empty string value in HKEY_CLASSES_ROOT\\[URL_Schema_Name] with the \tname \"URL Protocol”.\nHKEY_CLASSES_ROOT\\[URL_Schema_Name]\\shell\nHKEY_CLASSES_ROOT\\[URL_Schema_Name]\\shell\\open\nHKEY_CLASSES_ROOT\\[URL_Schema_Name]\\shell\\open\\command:\n\tSet the default value to \"[PATH_TO_MAIN_APPLICATION_EXE]\" “%1”", "language": "text" } ] } [/block] [block:callout] { "type": "info", "title": "NOTE", "body": "You need the administrator’s permissions to complete this action. You can get these permissions during installation process." } [/block] 2. Add the following code snippet to your application (it processes command line arguments): [block:code] { "codes": [ { "code": "DMFrameworkSettings.URLActivationSchema = [URL_Schema_Name];\nbool fromURL = ActivationFramework.Current.IsRunUsingURLSchema();\nif (fromURL)\n{\n DMActivationWindow window = new DMActivationWindow( ActivationFramework.Current.GetKeyFromURLSchema());\n window.BigIconSource = new BitmapImage(new Uri(“pack://application:,,,/Images/icon.png”));\n window.ShowDialog(); \n}", "language": "csharp" } ] } [/block] [block:callout] { "type": "info", "title": "NOTE", "body": "Read <a href=\"https://msdn.microsoft.com/library/aa767914(v=vs.85).aspx\">Registering an Application to a URI Scheme (MSDN)</a> to find out more." } [/block] #Configuring Activation API Activation API contains the following properties that must be obtained through `FindDelegate` method: [block:code] { "codes": [ { "code": "public class DelegateType\n{\n public const int IsActivated;\n public const int LicenseInformation;\n public const int Activate;\n public const int StartTrial;\n public const int GetTrial;\n public const int GetRawTrialValue;\n public const int GetStoreLink;\n }", "language": "csharp" } ] } [/block] ###IsActivated If you use the `IsActivated` property, the method verifies whether the application is activated. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.IsActivated) as Func<int>;\nint isActivated = func.Invoke();", "language": "csharp" } ] } [/block] Possible results are the following: * 0 - not activated * 1 - activated * 2 - expired ###LicenseInformation If you use the `LicenseInformation` property, the method verifies the license information by comparing it to the user information from DevMate. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.LicenseInformation) as Func<int, object>;\nstring ActivationIdKey = func.Invoke(LicenseInformationKeys.ActivationIdKey).ToString();\nstring UserName = func.Invoke(LicenseInformationKeys.UserNameKey).ToString();\nstring UserEmail = func.Invoke(LicenseInformationKeys.UserEmailKey).ToString();\nlong ActivationDate = Convert.ToInt64(func.Invoke(LicenseInformationKeys.ActivationDateKey));\nlong ExpirationDate = Convert.ToInt64(func.Invoke(LicenseInformationKeys.ExpirationDateKey));\nstring ExpirationVersion = func.Invoke(LicenseInformationKeys.ExpirationVersionKey).ToString();\nstring ActivationTag = func.Invoke(LicenseInformationKeys.ActivationTagKey).ToString();\nbool IsBetaOnly = Convert.ToBoolean(func.Invoke(LicenseInformationKeys.BetaOnlyKey));", "language": "csharp" } ] } [/block] `UserName` and `UserEmail` values are not null/empty only if a user specified them during license activation. It becomes possible when an activation number has the pattern id<numbers>u<any two letters>. Entering this kind of an activation number opens an extended activation dialog with mandatory user name and email fields. `ExpirationVersion` value specifies the ultimate application version covered by the current license. An owner of this license is not eligible for upgrade to versions higher than the specified one. ###Activate If you use the `Activate` property, the method sends user data to DevMate to register (activate) a license. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.Activate) as Func<string, string, string, bool?, long>; Task.Factory.StartNew(() => \n{\t\t\t\n return func.Invoke(ActivationCode, UserName, UserEmail, KeepUpToDate); }).ContinueWith((result) => \n{\n var activationResult = (ActivationResult)Marshal.PtrToStructure(new IntPtr(result.Result), typeof(ActivationResult));\n if (activationResult.Success)\n { //Show Success Screen\n }\n else\n {\n ErrorText = activationResult.Error;\n }\n});", "language": "csharp" } ] } [/block] ###StartTrial If you use the `StartTrial` property, the method sends a report about the beginning of a trial period when a user clicks the Start Trial button. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.StartTrial) as Func<long, bool>;\nTrialType trialType = new TrialType() { DMTrialWeek = true };   \n\nIntPtr trialIntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(trialType));\nMarshal.StructureToPtr(trialType, trialIntPtr, true);\nlong timeTrialRef = (long)trialIntPtr;   \n\nbool res = func.Invoke(timeTrialRef);", "language": "csharp" } ] } [/block] `TrialType` class includes the following properties: [block:code] { "codes": [ { "code": "public bool DMTrialDay { get; set; }\npublic bool DMTrialWeek { get; set; }\npublic bool DMTrialTwoWeeks { get; set; }\npublic bool DMTrialMonth { get; set; }\npublic bool DMTrialYear { get; set; }\n\npublic bool DMCustom { get; set; }\npublic long DMTrialPeriond { get; set; }", "language": "csharp" } ] } [/block] Please note that only one of the “TrialType” properties can be set to “true” at a time. If more than one property is set to “true”, DevMate will use only the last one applied. If `DMCustom` is set to “true", `DMTrialPeriond` is used. If `DMCustom` is set to “true” and `DMTrialPeriond` is not set, the default value is used (86400 seconds). ###GetTrial If you use the `GetTrial` property, the method returns total duration of a trial period (in hours) and the number of hours that is already spent in the trial mode. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetTrial) as Func<Tuple<int,int>>;\nvar trialInfo = func.Invoke();\n\nif (trialInfo.Item1 == -1 || trialInfo.Item2 == -1) \n{\n //Trial not started \n} \nelse \n{ \nTrialPeriod = trialInfo.Item2; //In hours \nPassedTrial = trialInfo.Item1; //In hours \n}", "language": "csharp" } ] } [/block] ###GetRawTrialValue If you use the `GetRawTrialValue` property, the method returns total duration of a trial period (in seconds) and its expiration date (UNIX timestamp). [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetRawTrialValue) as Func<Tuple<long,long>>;\nvar trialInfo = func.Invoke();\n\nif (trialInfo.Item1 == -1 || trialInfo.Item2 == -1) \n{\n //Trial not started \n} \nelse\n{\n TrialPeriod = trialInfo.Item2; //In seconds\n TrialExpireDate = trialInfo.Item1; //In UNIX timestamp \n}", "language": "csharp" } ] } [/block] ###GetTrialTimeRemained If you use the `GetTrialTimeRemained` property, the method returns a total number of seconds left till the end of a trial period. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetTrialTimeRemained) as Func<long>;\nvar trialInfo = func.Invoke();\n \nif (trialInfo==-1)\n{\n //Trial not started\n}\nelse\n{\n TrialPeriodRemained = trialInfo ; //In seconds\n}", "language": "csharp" } ] } [/block] ###GetStoreLink If you use the `GetStoreLink` property, the method returns a link to the store where a user can buy a license. [block:code] { "codes": [ { "code": "var func = ActivationFramework.Current.FindDelegate((int) DelegateType.GetStoreLink) as Func<string>; \nstring storeLink = func.Invoke(); \nProcess.Start(storeLink); //Open link in default browser", "language": "csharp" } ] } [/block] Note that you can add GET parameters to the link by using this method: [block:code] { "codes": [ { "code": "DMFrameworkSettings.StoreAdditionalParameters.Add(\"key\", “value\");", "language": "csharp" } ] } [/block]