Ejemplo n.º 1
0
        /// <summary>
        /// Sets up a periodic tile update that shows 5 recently played and popular game images from the Steamflix API.
        /// </summary>
        private void SetupPeriodicTileUpdate()
        {
            try
            {
                TileUpdater tileUpdateManager = null;

                // IoT Core doesn't support tile updates
                tileUpdateManager = TileUpdateManager.CreateTileUpdaterForApplication();

                var steamId = GetSteamId();
                var uris    = new List <Uri>
                {
                    new Uri($"{_steamflixTileApiUrl}/0/{steamId}"),
                    new Uri($"{_steamflixTileApiUrl}/1/{steamId}"),
                    new Uri($"{_steamflixTileApiUrl}/2/{steamId}"),
                    new Uri($"{_steamflixTileApiUrl}/3/{steamId}"),
                    new Uri($"{_steamflixTileApiUrl}/4/{steamId}")
                };

                tileUpdateManager.EnableNotificationQueue(true);
                tileUpdateManager.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.TwelveHours);
            }
            catch
            {
                return;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Método que configura a URL das live tiles do aplicativo.
        /// </summary>
        public static void CreateTile()
        {
            var uris = new List <Uri>();

            for (int i = 0; i < 5; i++)
            {
                uris.Add(new Uri("http://" + backendUrl + "notifications/tiles/tile.php" + finalUrl + "&tile=" + i));
            }

            TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            LiveTileUpdater.Clear();
            LiveTileUpdater.EnableNotificationQueue(true);
            LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.Daily);

            BadgeUpdater BadgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            BadgeUpdater.Clear();
            BadgeUpdater.StartPeriodicUpdate(new Uri("http://" + backendUrl + "notifications/tiles/badge.php" + finalUrl), PeriodicUpdateRecurrence.Daily);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                kraigb.Common.SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                //TODO: replace the URI here with the actual address of the periodic update service
                List <Uri> urisToPoll = new List <Uri>(5);
                for (int i = 1; i <= 5; i++)
                {
                    //TODO: replace the URIs after uploading the files on the server
                    urisToPoll.Add(new Uri("http://www.juliandev.ro/kraigb/tile_" + i + ".php"));
                }
                TileUpdater updater = Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication();
                updater.EnableNotificationQueue(true);
                updater.StartPeriodicUpdateBatch(urisToPoll, PeriodicUpdateRecurrence.Hour);


                var connectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
                if (connectionProfile != null)
                {
                    /*FeedDataSource feedDataSource = (FeedDataSource)App.Current.Resources["feedDataSource"];
                     * if (feedDataSource != null)
                     * {
                     *  if (feedDataSource.Feeds.Count == 0)
                     *  {
                     *      await feedDataSource.GetFeedsAsync();
                     *  }
                     * }*/
                }
                else
                {
                    //TODO: check for cached data and load that, then only warn that you won't get new stuff--best to just say "offline" somewhere in the UI.
                    var messageDialog = new Windows.UI.Popups.MessageDialog("An internet connection is needed to download feeds. Please check your connection and restart the app.");
                    var result        = messageDialog.ShowAsync();
                }

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Load state from previously suspended and terminated app
                    await kraigb.Common.SuspensionManager.RestoreAsync();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // 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 (!rootFrame.Navigate(typeof(SplitPage), args.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                Xamarin.Forms.Forms.Init(e);
                Xamarin.Forms.DependencyService.Register <Dependencies_UWP>();

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                var uris = new List <Uri>();

                for (int i = 0; i < 5; i++)
                {
                    uris.Add(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/tile.php" + Other.Other.GetFinalUrl() + "&tile=" + i));
                }

                TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                LiveTileUpdater.Clear();
                LiveTileUpdater.EnableNotificationQueue(true);
                LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.Daily);

                BadgeUpdater BadgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
                BadgeUpdater.Clear();
                BadgeUpdater.StartPeriodicUpdate(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/badge.php" + Other.Other.GetFinalUrl()), PeriodicUpdateRecurrence.Daily);

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                Xamarin.Forms.Forms.Init(e);
                Xamarin.Forms.DependencyService.Register <Dependencies_WinPhone>();

                ImageCircleRenderer.Init();
                WindowsRuntimeResourceManager.PatchResourceManagersInAssembly(typeof(Resx.AppResources));

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                var uris = new List <Uri>();

                for (int i = 0; i < 5; i++)
                {
                    uris.Add(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/tile.php" + Other.Other.GetFinalUrl() + "&tile=" + i));
                }

                TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
                LiveTileUpdater.Clear();
                LiveTileUpdater.EnableNotificationQueue(true);
                LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.Daily);

                BadgeUpdater BadgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
                BadgeUpdater.Clear();
                BadgeUpdater.StartPeriodicUpdate(new Uri("http://" + Other.Other.GetBackendUrl() + "notifications/tiles/badge.php" + Other.Other.GetFinalUrl()), PeriodicUpdateRecurrence.Daily);

                string colorPrimary = Other.Other.GetColorPrimary();

                byte a = byte.Parse(colorPrimary.Substring(1, 2), NumberStyles.HexNumber);
                byte r = byte.Parse(colorPrimary.Substring(3, 2), NumberStyles.HexNumber);
                byte g = byte.Parse(colorPrimary.Substring(5, 2), NumberStyles.HexNumber);
                byte b = byte.Parse(colorPrimary.Substring(7, 2), NumberStyles.HexNumber);

                StatusBar.GetForCurrentView().ForegroundColor   = Colors.White;
                StatusBar.GetForCurrentView().BackgroundColor   = Color.FromArgb(a, r, g, b);
                StatusBar.GetForCurrentView().BackgroundOpacity = 1;

                OneSignal.Init(Other.Other.GetOneSignalAppId(), e, (message, additionalData, isActivity) => {
                    if (additionalData.ContainsKey("eventid"))
                    {
                        GDG_SP.MainPage.openEvent = int.Parse(additionalData["eventid"]);
                    }
                });

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;

                // 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 (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }