protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     var store = new TransientDataStorage();
     store.Backup(() => ViewModel, this.ViewModel);
     store.Backup(ScrollPos, uxScrollViewer.VerticalOffset);
     LogInstance.LogInfo("Backed up to transient storage: {0}", this.ViewModel);
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (DesignerProperties.IsInDesignTool) return;

            const string key = TwitterSearchViewModel.StateKey;
            var store = new TransientDataStorage();
            var items = store.Restore<ObservableCollection<TweetItemViewModel>>(key);

            if (null == items || !items.Any())
                throw new NullReferenceException("Failed to find tweet items in store with key " + key);

            var arg = this.NavigationContext.QueryString["TweetId"];
            var tweetId = Convert.ToInt64(arg);

            this.ViewModel = items.Where(i => i.TweetId == tweetId).FirstOrDefault();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (DesignerProperties.IsInDesignTool) return;

            var store = new TransientDataStorage();
            var vm =  store.Restore(()=> ViewModel);

            var sessionIdArg = this.NavigationContext.QueryString["SessionId"];
            this.SessionId = Convert.ToInt32(sessionIdArg);

            if (null != vm && vm.SessionId == this.SessionId)
            {
                this.ViewModel = vm;
                this.ScrollOffset = store.Restore<double>(ScrollPos);
                LogInstance.LogInfo("Restored from transient storage: {0}", vm);
                return;
            }

            LoadFromCoreData();
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (DesignerProperties.IsInDesignTool) return;

            var speakerIdArg = this.NavigationContext.QueryString["SpeakerId"];
            var speakerId = Convert.ToInt32(speakerIdArg);

            var store = new TransientDataStorage();
            var vm = store.Restore(() => ViewModel);

            if (null != vm && vm.SpeakerId == speakerId)
            {
                this.ViewModel = vm;
                this.ScrollOffset = store.Restore<double>(ScrollPos);
                LogInstance.LogInfo("Restored from transient storage: {0}", vm);
                return;
            }

            var coreData = IoC.Get<ICoreData>();
            var speakers = coreData.Speakers;
            this.ViewModel = speakers.Where(i => i.SpeakerId == speakerId).FirstOrDefault();
        }
Example #5
0
        // Code to execute when the application is deactivated (sent to background)
        // This code will not execute when the application is closing
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            var tombstore = new TransientDataStorage();

            tombstore.Backup("t_isLoginFlag", isLoginFlag);
            tombstore.Backup("t_username", username);
            tombstore.Backup("t_password", password);
            tombstore.Backup("t_gtoken", gtoken);
            tombstore.Backup("t_galbumlist", galbumlist);
            tombstore.Backup("t_selectedAlbumIndex", selectedAlbumIndex);
            tombstore.Backup("t_galbumImages", galbumImages);
            tombstore.Backup("t_selectedImageIndex", selectedImageIndex);
        }
Example #6
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved)
            {
                //do nothing, app is already activated
            }
            else
            {

                var tombstore = new TransientDataStorage();
                
                isLoginFlag = tombstore.Restore<int>("t_isLoginFlag");
                username = tombstore.Restore<string>("t_username");
                password = tombstore.Restore<string>("t_password");
                gtoken = tombstore.Restore<string>("t_gtoken");
                galbumlist = tombstore.Restore<AlbumsList>("t_galbumlist");
                selectedAlbumIndex = tombstore.Restore<int>("t_selectedAlbumIndex");
                selectedImageIndex = tombstore.Restore<int>("t_selectedImageIndex");
                galbumImages = tombstore.Restore<AlbumImages>("t_galbumImages");
            }
         }
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved)
            {
                //do nothing
            }
            else
            {

                var tombstore = new TransientDataStorage();

                wDB.strtempUnit = tombstore.Restore<string>("Unit");

                wDB.strtemp = tombstore.Restore<string>("tempt");
                wDB.strTitle = tombstore.Restore<string>("title");
                wDB.strctext = tombstore.Restore<string>("cText");
                wDB.strcwindspeed = tombstore.Restore<string>("cWindSpeed");
                wDB.strspeedUnit = tombstore.Restore<string>("cSpeedUnit");
                wDB.strchumid = tombstore.Restore<string>("cHumidity");
                wDB.strcatmpressure = tombstore.Restore<string>("cPressure");
                wDB.strpressureUnit = tombstore.Restore<string>("cPressureUnit");
                wDB.strsunsettime = tombstore.Restore<string>("cSunset");
                wDB.strsunrisetime = tombstore.Restore<string>("cSunrise");

                wDB.strfdate = tombstore.Restore<string>("fdate");
                wDB.strfday = tombstore.Restore<string>("fday");
                wDB.strftext = tombstore.Restore<string>("fText");
                wDB.strfhigh = tombstore.Restore<string>("fhigh");
                wDB.strflow = tombstore.Restore<string>("flow");

            }
        }
        // Code to execute when the application is deactivated (sent to background)
        // This code will not execute when the application is closing
        private void Application_Deactivated(object sender, DeactivatedEventArgs e)
        {
            var tombstore = new TransientDataStorage();

            tombstore.Backup("Unit", App.wDB.strtempUnit);

            tombstore.Backup("tempt", wDB.strtemp);
            tombstore.Backup("title", wDB.strTitle);
            tombstore.Backup("cText", wDB.strctext);

            tombstore.Backup("cWindSpeed", wDB.strcwindspeed);
            tombstore.Backup("cSpeedUnit", wDB.strspeedUnit);
            tombstore.Backup("cHumidity", wDB.strchumid);
            tombstore.Backup("cPressure", wDB.strcatmpressure);
            tombstore.Backup("cPressureUnit", wDB.strpressureUnit);
            tombstore.Backup("cSunset", wDB.strsunsettime);
            tombstore.Backup("cSunrise", wDB.strsunrisetime);

            tombstore.Backup("fdate", wDB.strfdate);
            tombstore.Backup("fday", wDB.strfday);
            tombstore.Backup("fText", wDB.strftext);
            tombstore.Backup("fhigh", wDB.strfhigh);
            tombstore.Backup("flow", wDB.strflow);
        }
Example #9
0
        private void RestoreFromTransientStorage()
        {
            LogInstance.LogInfo("Restoring from transient storage");
            var storage = new TransientDataStorage();
            this.Sessions = storage.Restore<List<SessionItemViewModel>>("CoreData.Sessions");
            this.Speakers = storage.Restore<List<SpeakerItemViewModel>>("CoreData.Speakers");

            LogInstance.LogInfo((null == this.Sessions) ? "Sessions not found in storage" : "Restored sessions from storage");
            LogInstance.LogInfo((null == this.Speakers) ? "Speakers not found in storage" : "Restored speakers from storage");

            if (null == this.Sessions)
                this.Sessions = new List<SessionItemViewModel>();

            if (null == this.Speakers)
                this.Speakers = new List<SpeakerItemViewModel>();

            this.IsLoaded = (this.Sessions.Any() && this.Speakers.Any());

            LogInstance.LogInfo("Restore complete. Data found? : {0}", this.IsLoaded);
        }
Example #10
0
 private void BackupToTransientStorage()
 {
     LogInstance.LogInfo("Backing up core data to transient storage");
     var storage = new TransientDataStorage();
     storage.Backup("CoreData.Sessions", this.Sessions);
     storage.Backup("CoreData.Speakers", this.Speakers);
     LogInstance.LogInfo("Core data backup complete");
 }
Example #11
0
 // Code to execute when the application is deactivated (sent to background)
 // This code will not execute when the application is closing
 private void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     //Backup Transient data
     var store = new TransientDataStorage();
     store.Backup(IsolatedStorageKeys.MAIN_VIEW_MODEL, App.MainVM);
     store.Backup(IsolatedStorageKeys.SEARCH_VIEW_MODEL, App.SearchVM);
     store.Backup(IsolatedStorageKeys.JOB_VIEW_MODEL, App.JobVM);
 }
Example #12
0
 // Code to execute when the application is activated (brought to foreground)
 // This code will not execute when the application is first launched
 private void Application_Activated(object sender, ActivatedEventArgs e)
 {
     //CheckLicense();
     //Restore Transient data
     var store = new TransientDataStorage();
     App.MainVM = store.Restore<MainViewModel>(IsolatedStorageKeys.MAIN_VIEW_MODEL);
     App.SearchVM = store.Restore<SearchViewModel>(IsolatedStorageKeys.SEARCH_VIEW_MODEL);
     App.JobVM = store.Restore<JobViewModel>(IsolatedStorageKeys.JOB_VIEW_MODEL);
 }
Example #13
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved)
            {
                //do nothing
            }
            else
            {

                var store = new TransientDataStorage();
                username = store.Restore<string>("username");
                password = store.Restore<string>("password");
                auth = store.Restore<string>("auth");
                albums = store.Restore<MyAlbumCollection>("albums");
                albumImages = store.Restore<MyAllalbumimages>("albumImages");
                selectedImageIndex =  store.Restore<int>("selectedImageIndex");
                selectedAlbumIndex = store.Restore<int>("selectedAlbumIndex");
                
            }
        }
Example #14
0
 // Code to execute when the application is deactivated (sent to background)
 // This code will not execute when the application is closing
 private void Application_Deactivated(object sender, DeactivatedEventArgs e)
 {
     var store = new TransientDataStorage();
     store.Backup("username", username);
     store.Backup("password", password);
     store.Backup("auth", auth);
     store.Backup("albums", albums);
     store.Backup("albumImages",albumImages);
     store.Backup("selectedImageIndex", selectedImageIndex);
     store.Backup("selectedAlbumIndex",selectedAlbumIndex);
 }