示例#1
0
        public override void Selected(UIKit.UIPickerView pickerView, nint row, nint component)
        {
            base.Selected(pickerView, row, component);

            if (!InitialSelected)
            {
                return;
            }

            var selectedVal = base.SelectedItem;

            Config.RegionDef region = selectedVal.Equals("Ireland") ? Config.RegionDef.Ireland : Config.RegionDef.UK;

            if (region != Config.Region)
            {
                Config.Region = region;

                this.MainVC.RegionSelectionComplete(true);
                return;
            }

            this.MainVC.RegionSelectionComplete(false);
        }
        private static async Task EnsureAppActivated(IActivatedEventArgs args)
        {
            if (CurrentApp.LicenseInformation != null && CurrentApp.LicenseInformation.ProductLicenses != null && CurrentApp.LicenseInformation.ProductLicenses.ContainsKey(AdFreeIAP))
            {
                App.IsFree = !CurrentApp.LicenseInformation.ProductLicenses[AdFreeIAP].IsActive;
            }
            else
            {
                App.IsFree = true;
            }

            if (App.IsFree)
            {
                try
                {
                    App.ListingInfo = await CurrentApp.LoadListingInformationAsync();
                }
                catch { }
            }

            int iCin = int.MinValue;

            if (args is LaunchActivatedEventArgs)
            {
                LaunchActivatedEventArgs largs = args as LaunchActivatedEventArgs;
                if (!String.IsNullOrEmpty(largs.Arguments) && !String.IsNullOrEmpty(largs.TileId))
                {
                    iCin = int.Parse(largs.TileId);
                }

                if (!String.IsNullOrEmpty(largs.Arguments))
                {
                    Config.RegionDef r = (Config.RegionDef)Enum.Parse(typeof(Config.RegionDef), largs.Arguments);
                    if (Config.Region != r)
                    {
                        Config.Region = r;
                    }
                }
            }

            Frame rootFrame = null;

            // Do not repeat app initialization when already running, just ensure that
            // the window is active
            if (args.PreviousExecutionState == ApplicationExecutionState.Running)
            {
                if (iCin == int.MinValue)
                {
                    Window.Current.Activate();
                    return;
                }
                else
                {
                    rootFrame = (Frame)Window.Current.Content;
                }
            }
            else
            {
                // Create a Frame to act as the navigation context and associate it with
                // a SuspensionManager key
                rootFrame = new Frame();
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");
            }

            //if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            //{
            //    // Restore the saved session state only when appropriate
            //    await SuspensionManager.RestoreAsync();
            //}

            if (rootFrame.Content == null || iCin != int.MinValue)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter

                if (iCin != int.MinValue)
                {
                    Config.ShowRegion = false;
                    //CinemaDetails.CinemaID = iCin;
                    rootFrame.Navigate(typeof(CinemaDetails), iCin);
                }
                else
                {
                    Config.ShowRegion = true;

                    if (!rootFrame.Navigate(typeof(Landing)))
                    {
                        throw new Exception("Failed to create initial page");
                    }
                }
            }

            // Place the frame in the current Window and ensure that it is active
            Window.Current.Content = rootFrame;
            Window.Current.Activate();

            int started = 0;

            if (Windows.Storage.ApplicationData.Current.RoamingSettings.Values.ContainsKey("started"))
            {
                started = (int)Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"];
            }

            started++;

            Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"] = started;

            string familyName = Package.Current.Id.FamilyName;

            if ((started == 5 || started == 10) && !Windows.Storage.ApplicationData.Current.RoamingSettings.Values.ContainsKey("rated"))
            {
                var  md           = new Windows.UI.Popups.MessageDialog("We'd love you to rate our app 5 stars\nShowing us some love on the store helps us to continue to work on the app and make things even better!", "Enjoying Cineworld app?");
                bool?reviewresult = null;
                md.Commands.Add(new Windows.UI.Popups.UICommand("OK", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult     = true)));
                md.Commands.Add(new Windows.UI.Popups.UICommand("Cancel", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult = false)));
                await md.ShowAsync();

                if (reviewresult == true)
                {
                    Windows.Storage.ApplicationData.Current.RoamingSettings.Values["rated"] = true;

                    await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", familyName)));
                }
            }


            ////Only when the debugger is attached
            //if (System.Diagnostics.Debugger.IsAttached)
            //{
            //    //Display the metro grid helper
            //    MC.MetroGridHelper.MetroGridHelper.CreateGrid();
            //}
        }