Part 31: Detecting Trial Versions

Sign in to queue

Description

In this final Hands On Lab, we use the CurrentAppSimulator class to simulate interaction with the Windows Store API.  Here we simply use the configuration file to declaratively modify the user interface.  This simulates the data retrieved from the Windows Store.
 

Embed

Download

Download this episode

The Discussion

  • User profile image
    salem

    thank you rly it interested

  • User profile image
    JohnrL

    Hello,

    Great videos!!

    John

  • User profile image
    JohnMarsing

    Hey Bob, Did you forget to add the code from Task 2 step 4? ("an override for OnWindowCreated in your App class, so we can catch the window's dispatcher")

    You paste in step 3 at 10:36 in the video, but then proceed to step 5.

  • User profile image
    JohnMarsing

    Also when I have <IsTrial>true</IsTrial> in the license.xml file and I run my app, I don't see the price on the about page unless I drag my mouse over the field (i.e. select it).

  • User profile image
    JohnMarsing

    It looks like you caught your mistake in the next video (part 32).

  • User profile image
    BobTabor

    @JohnMarsing: Yes, nice catch ... sorry for the confusion.  I did in fact miss a step, then fixed it in the next lesson.

  • User profile image
    Anderson

    In Video It seems to Examples in this link http://code.msdn.microsoft.com/windowsapps/Licensing-API-Sample-19712f1a

    If I tried to include this in my project It doesn't works
    Here is my code:

    private async Task LoadTrialModeProxyFileAsync()
    {
    licenseChangeHandler = new LicenseChangedEventHandler(ReloadLicense);

    StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); //REMOVE FOR RELEASE
    StorageFile proxyFile = await proxyDataFolder.GetFileAsync("trial-mode.xml"); //REMOVE FOR RELEASE
    CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler; //REMOVE FOR RELEASE
    await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile); //REMOVE FOR RELEASE
    }

    private void ReloadLicense()
    {
    if (CurrentAppSimulator.LicenseInformation.IsActive)
    {
    if (CurrentAppSimulator.LicenseInformation.IsTrial)
    {
    // Show the features that are available during trial only.
    CONTROLLER.Time = 3;
    }
    else
    {
    // Show the features that are available only with a full license.
    }
    }
    else
    {
    // A license is inactive only when there's an error.
    }
    }

    On the above code Normal mode it will give 5 min. But for trail mode it should complete in 3 min. But, after compiling in debug mode it opening project will goes in 5 min only.
    How could i solve this?

  • User profile image
    BobTabor

    @Anderson: Well, from what I can decipher about your code, it looks like this part isn't your problem.  I don't know what the CONTROLLER is, and I don't see where it is observed ... but if you set a break point on that line and run the app in the debugger, I don't doubt that value is being set.  So, I guess, the question is ... is there somewhere else it is being overridden?  Or is it being ignored when you actually use that .Time property elsewhere in your app?  Carefully debug and I'm betting you'll find that something else is at play here.  I would need to see more before I could comment further.  Good luck!

  • User profile image
    VanceLee​Meurer

    Did you notice JohnMarsing's comment about the <IsTrial> issue.  In our screens only the ABOUT has a darker background.  The wording for "Contso Cookbook" and "Trial Version" are black text on white background.  The button is not shown but if I click where the button is, the button text turns black while I depress the button and disappears again when I release.  I reviewed the video several times and never did see where you code was different than mine that would cause this, but this will not stop me from moving forward.  Maybe you also address this in later.  Thanks

  • User profile image
    BobTabor

    @VanceLeeMeurer: Yes, actually I do talk about this because it caused quite a bit of confusion for me (and for the creators of the hands on labs) as I was researching all this.  It has to do with the DEFAULT background color of the flyout page.

    https://github.com/timheuer/callisto/issues/100

    The change is subtle ... perhaps I didn't call out enough attention to it and where it diverges from the textual instructions of the HOL ... I believe I solved it using a different property to set the color for the background of the flyout.  Unfortunately, it's been about 6+ months since I had to figure it out and I can't remember the exact solution.  Hopefully that will point you in the right direction.  Sorry for the confusion!

  • User profile image
    Ben

    Hi Bob.

    Great series. Thanks!
    In response to the background color issue (which I experienced as well), the solution for me was to make the same background color change to app.xaml for the About command that you made in an earlier lab for the Preferences command. So the About command code in OnCommandsRequested becomes:

    // Add an About command
    var about = new SettingsCommand("about", "About", (handler) =>
    {
    var settings = new SettingsFlyout();
    settings.Content = new AboutUserControl();
    settings.HeaderBrush = new SolidColorBrush(_background);
    //settings.Background = new SolidColorBrush(_background);
    settings.ContentBackgroundBrush = new SolidColorBrush(_background);
    settings.HeaderText = "About";
    settings.IsOpen = true;
    });

    Ben

  • User profile image
    BobTabor

    @Ben: Thanks Ben, good solution!  Thanks for writing - bt

  • User profile image
    Najeeb Anwer

    Hi Bob,
    Actually, the easiest solution to the problem of the background color in the flyouts being the same as the text is to change the default theme. In App.xaml, just add RequestedTheme="Light" after the xmlns declarations at the top of the page. This changes the theme from the default of "Dark" to "Light" - the pages in the cookbook will have a white background, but at least everything else will work as it should.

    Thanks for the great training.

    Najeeb

  • User profile image
    BobTabor

    @Najeeb Anwer: Thank you for posting this solution.

  • User profile image
    BobTabor

    Opening comments

Add Your 2 Cents