Esempio n. 1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            try
            {
                serviceDeferral        = taskInstance.GetDeferral();
                taskInstance.Canceled += OnTaskCanceled;

                ExecutingPlatform.Current = AppPlatform.UWP;
                var context = new EfCoreContext();
                var utData  = context.SetupSingleDtoAndEntities <AccountViewModel>();
                utData.AddSingleDto <CategoryViewModel>();
                utData.AddSingleDto <PaymentViewModel>();
                utData.AddSingleDto <RecurringPaymentViewModel>();

                var crudService = new CrudServicesAsync(context, utData.ConfigAndMapper);

                var liveTileManager = new LiveTileManager(crudService);
                await liveTileManager.UpdatePrimaryLiveTile();

                await liveTileManager.UpdateSecondaryLiveTiles();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Debug.WriteLine("LiveTile update failed.");
            }
            finally
            {
                serviceDeferral?.Complete();
            }
        }
Esempio n. 2
0
        private async void AddToStartMenu_ClickAsync(object sender, RoutedEventArgs e)
        {
            var element = (FrameworkElement)sender;

            if (!(element.DataContext is AccountViewModel account))
            {
                return;
            }
            if (!Mvx.IoCProvider.CanResolve <ICrudServicesAsync>())
            {
                return;
            }

            var liveTileManager = new LiveTileManager(Mvx.IoCProvider.Resolve <ICrudServicesAsync>());

            int  id       = account.Id;
            bool isPinned = SecondaryTile.Exists(id.ToString(CultureInfo.InvariantCulture));

            if (!isPinned)
            {
                SecondaryTile tile = new SecondaryTile(id.ToString(CultureInfo.InvariantCulture), "Money Fox", "a", new Uri("ms-appx:///Assets/SmallTile.scale-150.png"), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = false;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo   = false;
                tile.VisualElements.Square310x310Logo           = new Uri("ms-appx:///Assets/Square310x310Logo.scale-100.png");
                tile.VisualElements.Square150x150Logo           = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
                tile.VisualElements.Wide310x150Logo             = new Uri("ms-appx:///Assets/Wide310x150Logo.scale-100.png");
                tile.VisualElements.Square71x71Logo             = new Uri("ms-appx:///Assets/Square71x71Logo.scale-100.png");
                bool ispinned = await tile.RequestCreateAsync();

                if (ispinned)
                {
                    await liveTileManager.UpdateSecondaryLiveTiles().ConfigureAwait(true);
                }
            }
            else
            {
                await liveTileManager.UpdateSecondaryLiveTiles().ConfigureAwait(true);

                await liveTileManager.UpdatePrimaryLiveTile().ConfigureAwait(true);
            }
        }
Esempio n. 3
0
        private async void AddToStartMenu_ClickAsync(object sender, RoutedEventArgs e)
        {
            var element = (FrameworkElement)sender;

            if (!(element.DataContext is AccountViewModel account))
            {
                return;
            }

            var liveTileManager = new LiveTileManager(ServiceLocator.Current.GetInstance <ICrudServicesAsync>());

            int  id       = account.Id;
            bool isPinned = SecondaryTile.Exists(id.ToString(CultureInfo.InvariantCulture));

            if (!isPinned)
            {
                SecondaryTile tile = new SecondaryTile(id.ToString(CultureInfo.InvariantCulture), Strings.ApplicationTitle, "a", new Uri(SMALL_150_TILE_ICON), TileSize.Default);
                tile.VisualElements.ShowNameOnSquare150x150Logo = false;
                tile.VisualElements.ShowNameOnSquare310x310Logo = true;
                tile.VisualElements.ShowNameOnWide310x150Logo   = false;
                tile.VisualElements.Square310x310Logo           = new Uri(SQUARE_310_TILE_ICON);
                tile.VisualElements.Square150x150Logo           = new Uri(SQUARE_150_TILE_ICON);
                tile.VisualElements.Wide310x150Logo             = new Uri(WIDE_310_TILE_ICON);
                tile.VisualElements.Square71x71Logo             = new Uri(SQUARE_71_TILE_ICON);
                bool successfulPinned = await tile.RequestCreateAsync();

                if (successfulPinned)
                {
                    await liveTileManager.UpdateSecondaryLiveTiles();
                }
            }
            else
            {
                await liveTileManager.UpdateSecondaryLiveTiles();

                await liveTileManager.UpdatePrimaryLiveTile();
            }
        }