Example #1
0
        // Do not add any additional code to this method
        private void InitializePhoneApplication()
        {
            if (phoneApplicationInitialized)
            {
                return;
            }

            WP_to_WP.Shared.Services.UiSettings Settings = new WP_to_WP.Shared.Services.UiSettings();
            Settings.SetDefaultLanguage();


            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame = new RadPhoneApplicationFrame
            {
                Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri("Assets/SplashScreenImage-WVGA.png", UriKind.RelativeOrAbsolute)),
                    Opacity     = 1,
                    Stretch     = Stretch.UniformToFill
                }
                ,
                Height = 800
            };
            RootFrame.Navigated += CompleteInitializePhoneApplication;

            // Handle navigation failures
            RootFrame.NavigationFailed += RootFrame_NavigationFailed;

            // Ensure we don't initialize again

            SetTile();

            phoneApplicationInitialized = true;
        }
        public void Start()
        {
            PeriodicTask periodicTask = new PeriodicTask(Constants.SETTINGS.LIVE_TILE_AGENT);

            WP_to_WP.Shared.Services.UiSettings Settings = new WP_to_WP.Shared.Services.UiSettings();

            periodicTask.Description = Settings.AppName() + " Task";
            periodicTask.ExpirationTime = System.DateTime.Now.AddDays(10);

            if (Exists())
            {
                ScheduledActionService.Remove(Constants.SETTINGS.LIVE_TILE_AGENT);
            }

            try
            {
                ScheduledActionService.Add(periodicTask);

            #if DEBUG
                ScheduledActionService.LaunchForTest(Constants.SETTINGS.LIVE_TILE_AGENT, TimeSpan.FromMinutes(20));
            #endif

            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message.Contains("BNS Error: The action is disabled"))
                {
                    // MessageBox.Show("Background agents for this application have been disabled by the user.");
                }

            }
        }
        public void Start()
        {
            PeriodicTask periodicTask = new PeriodicTask(Constants.SETTINGS.LIVE_TILE_AGENT);

            WP_to_WP.Shared.Services.UiSettings Settings = new WP_to_WP.Shared.Services.UiSettings();

            periodicTask.Description    = Settings.AppName() + " Task";
            periodicTask.ExpirationTime = System.DateTime.Now.AddDays(10);

            if (Exists())
            {
                ScheduledActionService.Remove(Constants.SETTINGS.LIVE_TILE_AGENT);
            }

            try
            {
                ScheduledActionService.Add(periodicTask);

#if DEBUG
                ScheduledActionService.LaunchForTest(Constants.SETTINGS.LIVE_TILE_AGENT, TimeSpan.FromMinutes(20));
#endif
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Message.Contains("BNS Error: The action is disabled"))
                {
                    // MessageBox.Show("Background agents for this application have been disabled by the user.");
                }
            }
        }
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            Settings = new WP_to_WP.Shared.Services.UiSettings();

            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
            LocalizationManager.GlobalResourceManager = WP_to_WP.International.Translations.ResourceManager;
            //InputLocalizationManager.Instance.ResourceManager = WP_to_WP.International.Translations.ResourceManager;
            //Creates an instance of the Diagnostics component.
            diagnostics = new RadDiagnostics();

            //Defines the default email where the diagnostics info will be send.
            diagnostics.EmailTo = Settings.SupportEmail();

            //Initializes this instance.
            diagnostics.Init();

            //Creates a new instance of the RadRateApplicationReminder component.
            rateReminder = new RadRateApplicationReminder();

            //Sets how often the rate reminder is displayed.
            rateReminder.RecurrencePerUsageCount = 1;
            ThemeManager.ToDarkTheme();
        }
Example #5
0
        /// <summary>
        /// Constructor for the Application object.
        /// </summary>
        public App()
        {
            Settings = new WP_to_WP.Shared.Services.UiSettings();

            // Global handler for uncaught exceptions.
            UnhandledException += Application_UnhandledException;

            // Standard Silverlight initialization
            InitializeComponent();

            // Phone-specific initialization
            InitializePhoneApplication();

            // Show graphics profiling information while debugging.
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Display the current frame rate counters.
                Application.Current.Host.Settings.EnableFrameRateCounter = true;

                // Show the areas of the app that are being redrawn in each frame.
                //Application.Current.Host.Settings.EnableRedrawRegions = true;

                // Enable non-production analysis visualization mode,
                // which shows areas of a page that are being GPU accelerated with a colored overlay.
                //Application.Current.Host.Settings.EnableCacheVisualization = true;

                // Disable the application idle detection by setting the UserIdleDetectionMode property of the
                // application's PhoneApplicationService object to Disabled.
                // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
                // and consume battery power when the user is not using the phone.
                PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
            }
            LocalizationManager.GlobalResourceManager = WP_to_WP.International.Translations.ResourceManager;
            //InputLocalizationManager.Instance.ResourceManager = WP_to_WP.International.Translations.ResourceManager;
            //Creates an instance of the Diagnostics component.
            diagnostics = new RadDiagnostics();

            //Defines the default email where the diagnostics info will be send.
            diagnostics.EmailTo = Settings.SupportEmail();

            //Initializes this instance.
            diagnostics.Init();

            //Creates a new instance of the RadRateApplicationReminder component.
            rateReminder = new RadRateApplicationReminder();

            //Sets how often the rate reminder is displayed.
            rateReminder.RecurrencePerUsageCount = 1;
            ThemeManager.ToDarkTheme();
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            WP_to_WP.Shared.Services.UiSettings settings = new WP_to_WP.Shared.Services.UiSettings();

            WP_to_WP.Shared.Services.UiStorage storage = new WP_to_WP.Shared.Services.UiStorage();

            Domain.Services.AgentService service = new Domain.Services.AgentService(storage, settings);

            var result = await service.GetUpdates("112", storage);


            if (result.Count > 0)
            {

                string toastMessage = string.Format(International.Translations.NewPosts, result.Count);

                ShellToast toast = new ShellToast();
                toast.Title = settings.AppName();
                toast.Content = toastMessage;
                toast.Show();

                if (ShellTile.ActiveTiles.Any())
                {
                    var tile = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri == new Uri("/Home.xaml", UriKind.RelativeOrAbsolute));
                    var flipTileData = new RadFlipTileData
                    {
                        Count = result.Count,
                        Title = Domain.AppBase.Current.Config.AppName,
                        IsTransparencySupported = true,
                        //Title = International.Translations.AppName,
                        BackTitle = result[0].Title,
                        BackgroundImage = new Uri("/Assets/FlipCycleTileSmall_159_159.png", UriKind.RelativeOrAbsolute),
                        WideBackgroundImage = new Uri("/Assets/FlipCycleTitleLarge_691_336.png", UriKind.RelativeOrAbsolute),

                     
                        WideBackBackgroundImage = new Uri(result[0].Url, UriKind.RelativeOrAbsolute),
                        BackBackgroundImage = new Uri(result[0].Url, UriKind.RelativeOrAbsolute)

                    };


                    //List<Uri> images = new List<Uri>();
                    //RadCycleTileData RadTile = new RadCycleTileData();

                    //int start = 0;
                    //int max = 10;


                    //for (int i = 0; i < 9; i++)
                    //{
                    //    images.Add(null);

                    //}

                    //foreach (var item in result)
                    //{
                    //    images[start] = new Uri(item.Url, UriKind.Absolute);
                    //    start++;
                    //    if (start >= max)
                    //        break;

                    //}



                    //IEnumerable<Uri> CycleImages = images;

                    //RadTile.CycleImages = CycleImages;

                    LiveTileHelper.UpdateTile(tile, flipTileData);


                }
            }



            NotifyComplete();
        }
        // Do not add any additional code to this method
        private void InitializePhoneApplication()
        {
            if (phoneApplicationInitialized)
                return;

            WP_to_WP.Shared.Services.UiSettings Settings = new WP_to_WP.Shared.Services.UiSettings();
            Settings.SetDefaultLanguage();

            // Create the frame but don't set it as RootVisual yet; this allows the splash
            // screen to remain active until the application is ready to render.
            RootFrame = new RadPhoneApplicationFrame
            {
                Background = new ImageBrush
                {
                    ImageSource = new BitmapImage(new Uri("Assets/SplashScreenImage-WVGA.png", UriKind.RelativeOrAbsolute)),
                    Opacity = 1,
                    Stretch = Stretch.UniformToFill
                }
                ,
                Height = 800
            };
            RootFrame.Navigated += CompleteInitializePhoneApplication;

            // Handle navigation failures
            RootFrame.NavigationFailed += RootFrame_NavigationFailed;

            // Ensure we don't initialize again

            SetTile();

            phoneApplicationInitialized = true;
        }
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            WP_to_WP.Shared.Services.UiSettings settings = new WP_to_WP.Shared.Services.UiSettings();

            WP_to_WP.Shared.Services.UiStorage storage = new WP_to_WP.Shared.Services.UiStorage();

            Domain.Services.AgentService service = new Domain.Services.AgentService(storage, settings);

            var result = await service.GetUpdates("112", storage);


            if (result.Count > 0)
            {
                string toastMessage = string.Format(International.Translations.NewPosts, result.Count);

                ShellToast toast = new ShellToast();
                toast.Title   = settings.AppName();
                toast.Content = toastMessage;
                toast.Show();

                if (ShellTile.ActiveTiles.Any())
                {
                    var tile         = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri == new Uri("/Home.xaml", UriKind.RelativeOrAbsolute));
                    var flipTileData = new RadFlipTileData
                    {
                        Count = result.Count,
                        Title = Domain.AppBase.Current.Config.AppName,
                        IsTransparencySupported = true,
                        //Title = International.Translations.AppName,
                        BackTitle           = result[0].Title,
                        BackgroundImage     = new Uri("/Assets/FlipCycleTileSmall_159_159.png", UriKind.RelativeOrAbsolute),
                        WideBackgroundImage = new Uri("/Assets/FlipCycleTitleLarge_691_336.png", UriKind.RelativeOrAbsolute),


                        WideBackBackgroundImage = new Uri(result[0].Url, UriKind.RelativeOrAbsolute),
                        BackBackgroundImage     = new Uri(result[0].Url, UriKind.RelativeOrAbsolute)
                    };


                    //List<Uri> images = new List<Uri>();
                    //RadCycleTileData RadTile = new RadCycleTileData();

                    //int start = 0;
                    //int max = 10;


                    //for (int i = 0; i < 9; i++)
                    //{
                    //    images.Add(null);

                    //}

                    //foreach (var item in result)
                    //{
                    //    images[start] = new Uri(item.Url, UriKind.Absolute);
                    //    start++;
                    //    if (start >= max)
                    //        break;

                    //}



                    //IEnumerable<Uri> CycleImages = images;

                    //RadTile.CycleImages = CycleImages;

                    LiveTileHelper.UpdateTile(tile, flipTileData);
                }
            }



            NotifyComplete();
        }