public SettingsPage() { this.InitializeComponent(); DataContext = this; var localHelper = new LocalObjectStorageHelper(); if (localHelper.KeyExists("BalanceThreshold")) { BalanceSlider.Value = localHelper.Read("BalanceThreshold", 5); } else { BalanceSlider.Value = 5; } if (localHelper.KeyExists("IsLowBalanceAlertEnabled")) { LowBalanceAlertToggleSwitch.IsOn = localHelper.Read("IsLowBalanceAlertEnabled", true); } else { LowBalanceAlertToggleSwitch.IsOn = true; } var packageVersion = Package.Current.Id.Version; Version = String.Format("{0}.{1}.{2}.{3}", packageVersion.Major, packageVersion.Minor, packageVersion.Build, packageVersion.Revision); }
public WatchItLater( IScheduler scheduler, SubscriptionManager subscriptionManager, Models.Provider.LoginUserHistoryProvider loginUserDataProvider, UseCase.Playlist.PlaylistAggregateGetter playlistAggregate ) { Scheduler = scheduler; SubscriptionManager = subscriptionManager; LoginUserDataProvider = loginUserDataProvider; _playlistAggregate = playlistAggregate; Refresh = new AsyncReactiveCommand(); Refresh.Subscribe(async() => await Update()) .AddTo(_disposables); { var localObjectStorageHelper = new LocalObjectStorageHelper(); IsAutoUpdateEnabled = localObjectStorageHelper.Read(nameof(IsAutoUpdateEnabled), true); AutoUpdateInterval = localObjectStorageHelper.Read(nameof(AutoUpdateInterval), DefaultAutoUpdateInterval); } this.ObserveProperty(x => x.IsAutoUpdateEnabled) .Subscribe(x => { var localObjectStorageHelper = new LocalObjectStorageHelper(); localObjectStorageHelper.Save(nameof(IsAutoUpdateEnabled), IsAutoUpdateEnabled); }) .AddTo(_disposables); this.ObserveProperty(x => x.AutoUpdateInterval) .Subscribe(x => { var localObjectStorageHelper = new LocalObjectStorageHelper(); localObjectStorageHelper.Save(nameof(AutoUpdateInterval), AutoUpdateInterval); }) .AddTo(_disposables); Observable.Merge(new[] { this.ObserveProperty(x => x.IsAutoUpdateEnabled).ToUnit(), this.ObserveProperty(x => x.AutoUpdateInterval).ToUnit() }) .Subscribe(x => { if (IsAutoUpdateEnabled) { StartOrResetAutoUpdate(); } else { StopAutoUpdate(); } }) .AddTo(_disposables); App.Current.Suspending += Current_Suspending; App.Current.Resuming += Current_Resuming; }
private async void RootPage_Loaded(object sender, RoutedEventArgs e) { var localHelper = new LocalObjectStorageHelper(); string oldImgaeUri = null; if (localHelper.KeyExists("BackgroundImage")) { oldImgaeUri = localHelper.Read <string>("BackgroundImage"); } if (oldImgaeUri != null) { OldBackgroundImage.Source = await ImageCache.Instance.GetFromCacheAsync(new Uri(oldImgaeUri)); } var imageSource = await AssetsHelper.GetBingWallpaperAsync(); if (imageSource != null) { NewBackgroundImage.Source = new BitmapImage(imageSource); localHelper.Save("BackgroundImage", imageSource.OriginalString); } if (imageSource != null) { if (this.Resources["FadeIn_Image"] is Storyboard fadeIn) { fadeIn.Begin(); } } }
private async void Init() { LocalObjectStorageHelper LocalObjectStorageHelper = new LocalObjectStorageHelper(); if (!LocalObjectStorageHelper.KeyExists("rules")) { StorageFile JsonRules = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/rules.json")); string StringRules = await FileIO.ReadTextAsync(JsonRules); Rules = JsonConvert.DeserializeObject <Rules>(StringRules); LocalObjectStorageHelper.Save("rules", Rules); } else { Rules = LocalObjectStorageHelper.Read("rules", Rules); } CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; var TitleBar = ApplicationView.GetForCurrentView().TitleBar; TitleBar.BackgroundColor = Colors.Transparent; TitleBar.ButtonBackgroundColor = Colors.Transparent; TitleBar.ButtonInactiveForegroundColor = Colors.Transparent; TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; MainFrame.Navigate(typeof(ShellPage)); }
public MainPage() { InitializeComponent(); var items = MainNavView.MenuItems.ToList(); foreach (var item in items) { MainMenuItems.Add(item as NavigationViewItem); } // Bind and populate menu MainNavView.MenuItemsSource = MainMenuItems; MainNavView.SelectedItem = MainMenuItems[1]; MainMenuItems[1].IsSelected = true; ContentFrame.Navigate(typeof(Settings)); // Load user LoadUser(LocalStorage.Read <int>("currentUserId")); // Set window sizing options ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(600, 675)); ApplicationView.PreferredLaunchViewSize = new Size(1040, 700); ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; }
public static async Task <int> RestoreLegacyLocalMylistGroups(LocalMylistManager manager) { try { var localStorage = new LocalObjectStorageHelper(); var isMigrateLocalMylist = localStorage.Read("is_migrate_local_mylist_0_17_0", false); if (!isMigrateLocalMylist) { var items = await LoadLegacyLocalMylistGroups(); foreach (var regacyItem in items) { manager.Mylists.Add(new LocalMylistGroup(regacyItem.Id, regacyItem.Label, new ObservableCollection <string>(regacyItem.PlaylistItems.Select(x => x.ContentId)))); } localStorage.Save("is_migrate_local_mylist_0_17_0", true); return(items.Count); } else { return(0); } } catch { return(0); } }
public static async void EnsureCacheLatest() { var settingsStorage = new LocalObjectStorageHelper(); var onlineDocsSHA = await GetDocsSHA(); var cacheSHA = settingsStorage.Read <string>(_cacheSHAKey); bool outdatedCache = onlineDocsSHA != null && cacheSHA != null && onlineDocsSHA != cacheSHA; bool noCache = onlineDocsSHA != null && cacheSHA == null; if (outdatedCache || noCache) { // Delete everything in the Cache Folder. Could be Pre 3.0.0 Cache data. foreach (var item in await ApplicationData.Current.LocalCacheFolder.GetItemsAsync()) { try { await item.DeleteAsync(StorageDeleteOption.Default); } catch { } } // Update Cache Version info. settingsStorage.Save(_cacheSHAKey, onlineDocsSHA); } }
public async Task RunAsync(IBackgroundTaskInstance taskInstance) { // Create services var localObjectStorageHelper = new LocalObjectStorageHelper(); // Check if notifications are enabled var notificationsEnabled = localObjectStorageHelper.Read(LocalStorageConstants.EnableNewEpisodeNotificationsOption, true); if (!notificationsEnabled) { return; } // Retrieve token to access API string token = RetrieveToken(); // Create services (2) var tvshowtimeApiService = new TVShowTimeApiService(token); // Retrieve episodes from the agenda (episodes that will be aired soon) var agendaResponse = await tvshowtimeApiService.GetAgendaAsync(); if (agendaResponse.Result == "OK") { // Retrieve list of episodes already notified var newEpisodesIdsNotified = new List <long>(); if (await localObjectStorageHelper.FileExistsAsync(LocalStorageConstants.NewEpisodesIdsNotified)) { newEpisodesIdsNotified = await localObjectStorageHelper .ReadFileAsync(LocalStorageConstants.NewEpisodesIdsNotified, new List <long>()); } var episodesInAgenda = agendaResponse.Episodes; foreach (var episode in episodesInAgenda) { var timeSpanDiff = episode.AirDate.Value.Subtract(DateTime.Now.ToUniversalTime()); if (episode.AirTime.HasValue) { timeSpanDiff = timeSpanDiff .Add(TimeSpan.FromHours(episode.AirTime.Value.DateTime.Hour)); timeSpanDiff = timeSpanDiff .Add(TimeSpan.FromMinutes(episode.AirTime.Value.DateTime.Minute)); } if (newEpisodesIdsNotified.All(id => episode.Id != id) && timeSpanDiff.TotalDays <= 0) { // Create Toast notification when a new episode is out GenerateToastNotification(episode); newEpisodesIdsNotified.Add(episode.Id); } } // Save the updated list in local storage await localObjectStorageHelper.SaveFileAsync(LocalStorageConstants.NewEpisodesIdsNotified, newEpisodesIdsNotified); } }
private PocketClient LoadCacheClient() { string cacheKey = Cache.CacheKeys.Pocket; if (!CacheHandler.KeyExists(cacheKey)) { return(null); } return(new PocketClient(ApiKeys.Pocket, CacheHandler.Read(cacheKey, ""))); }
protected override void OnNavigatedTo(NavigationEventArgs e) { LocalObjectStorageHelper localObjectStorage = new LocalObjectStorageHelper(); if (localObjectStorage.KeyExists("passenger")) { Passenger = localObjectStorage.Read <Passenger>("passenger"); } ViewModel.Connect(Passenger.Email); }
private async Task LowBalanceAlert() { var localHelper = new LocalObjectStorageHelper(); var isLowBalanceAlertEnabled = true; if (localHelper.KeyExists("IsLowBalanceAlertEnabled")) { isLowBalanceAlertEnabled = localHelper.Read("IsLowBalanceAlertEnabled", true); } if (isLowBalanceAlertEnabled) { var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile(); if (profile != null) { var status = await NetHelper.GetStatusAsync(); if (status != null) { var balance = Convert.ToDouble(status["balance"]); var balanceDescription = Utility.GetBalanceDescription(balance); var threshold = 5; if (localHelper.KeyExists("BalanceThreshold")) { threshold = localHelper.Read("BalanceThreshold", 5); } if (balance < threshold) { var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse(); var toast = new NotificationToast(".Net Campus", String.Format(resourceLoader.GetString("LowBalanceAlertNotification"), balanceDescription)) { Tag = "65", Group = "Balance" }; toast.Show(); } } } } }
internal static async Task PreLaunchAsync(LaunchActivatedEventArgs e) { if (_licenseInformation.IsTrial) { // Trial: set HasShown to false to trigger detection. Reset(); _licenseInformation.LicenseChanged += LicenseInformation_LicenseChanged; } else { // Purchased: set HasShown to true to inhibit detecting, but only if we were not detecting already. var hasShown = _localSettings.Read(HasShown, true); if (hasShown) { Deactivate(); } } await Task.CompletedTask; }
public SetupDownloadDialog() { InitializeComponent(); var helper = new LocalObjectStorageHelper(); EnableBackgroundDownloading.IsOn = helper.Read(App.EnableDownload, false); Loaded += SetupDownloadDialog_Loaded; }
private async void passwordResetButton_Click(object sender, RoutedEventArgs e) { if(string.IsNullOrEmpty(passwordResetBox.Password)||string.IsNullOrWhiteSpace(passwordResetBox.Password)) { var messageDialog = new MessageDialog("Type password before you click on change"); await messageDialog.ShowAsync(); } else { try { passwordResetButton.IsEnabled = false; ProgressRingPasswordReset.IsActive = true; ProgressRingPasswordReset.Visibility = Visibility.Visible; string empId = ""; string newPassword = ""; var localObjectStorageHelper = new LocalObjectStorageHelper(); // Read and Save with simple objects string keySimpleObject = "47"; if (localObjectStorageHelper.KeyExists(keySimpleObject)) { empId = localObjectStorageHelper.Read<string>(keySimpleObject); } newPassword = passwordResetBox.Password; await EmployeeSync.GetAllEmployeesAsnc(EmployeeCharacters, empId); string condition = EmployeeCharacters[0]._id.Oid.ToString(); string setValue = String.Format("{{\"$set\":{{\"Password\":\"{0}\"}}}}", newPassword); await EmployeeSync.EmpPasswordPutAsync(condition, setValue); var messageDialog = new MessageDialog("Password changed"); await messageDialog.ShowAsync(); passwordResetButton.IsEnabled = true; ProgressRingPasswordReset.Visibility = Visibility.Collapsed; ProgressRingPasswordReset.IsActive = false; passwordResetBox.Password = ""; } catch { var messageDialog = new MessageDialog("Password not changed !Error "); await messageDialog.ShowAsync(); ProgressRingPasswordReset.Visibility = Visibility.Collapsed; ProgressRingPasswordReset.IsActive = false; passwordResetButton.IsEnabled = true; } } }
private void GetRecentConnections() { if (storageHelper.KeyExists(connectionStore)) { recentConnectionStrings = storageHelper.Read <ObservableCollection <ConnectionString> >(connectionStore); } else { recentConnectionStrings = new ObservableCollection <ConnectionString>(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { Contact = e.Parameter as Passenger; LocalObjectStorageHelper localObjectStorage = new LocalObjectStorageHelper(); if (localObjectStorage.KeyExists("passenger")) { Passenger = localObjectStorage.Read <Passenger>("passenger"); } ViewModel.Connect(Passenger.Email, Contact.Email); ViewModel.SetMessages(Contact.Email); }
public MainPage() { this.InitializeComponent(); _stravaService = new StravaService(); _loginService = new LoginService(_stravaService); DataContext = new MainViewModel(_stravaService); var storageHelper = new LocalObjectStorageHelper(); if (storageHelper.KeyExists(StorageKeys.ACCESSTOKEN)) { _stravaService.AccessToken = storageHelper.Read <string>(StorageKeys.ACCESSTOKEN); } }
public async Task InitializeAsync() { if (_storageHelper.KeyExists(current_api_key)) { var config = _storageHelper.Read <ApiConfig>(current_api_key); CurrentApiMode = ApiModes.FirstOrDefault(i => i.ApiConfig == config); } if (CurrentApiMode == null) { CurrentApiMode = ApiModes.First(); _storageHelper.Save(current_api_key, CurrentApiMode.ApiConfig); } await rebuildForumListAsync(CurrentApiMode.ApiConfig); }
internal static async Task ShowIfAppropriateAsync(LaunchActivatedEventArgs e) { bool hasShownFirstRun = _localSettings.Read(HasShown, false); if (!hasShownFirstRun) { var dialog = new FirstUseDialog(); var response = await dialog.ShowAsync(); if (response == ContentDialogResult.Secondary) { Deactivate(); } } }
protected async override void OnNavigatedTo(NavigationEventArgs e) { string LeaveType = (string)e.Parameter; string empId = ""; var localObjectStorageHelper = new LocalObjectStorageHelper(); // Read and Save with simple objects string keySimpleObject = "47"; if (localObjectStorageHelper.KeyExists(keySimpleObject)) { empId = localObjectStorageHelper.Read <string>(keySimpleObject); } await LeaveTransactionGetPostPut.GetLeaveTransactionAsnc(LeaveTransactions, empId, LeaveType); }
public static void MigrateFeedGroupToSubscriptionManager(SubscriptionManager instance) { var localObjectStorageHelper = new LocalObjectStorageHelper(); if (!localObjectStorageHelper.Read(nameof(MigrateFeedGroupToSubscriptionManager), false)) { Debug.WriteLine("フィードを購読に移行:開始"); var feedGroups = Database.FeedDb.GetAll(); var subsc = SubscriptionManager.CreateNewSubscription("旧 新着"); subsc.Destinations.Add(new SubscriptionDestination( "@view".ToCulturelizeString(), SubscriptionDestinationTarget.LocalPlaylist, HohoemaPlaylist.WatchAfterPlaylistId) ); foreach (var feedSource in feedGroups.SelectMany(x => x.Sources)) { SubscriptionSourceType?sourceType = null; switch (feedSource.BookmarkType) { case Database.BookmarkType.User: sourceType = SubscriptionSourceType.User; break; case Database.BookmarkType.Mylist: sourceType = SubscriptionSourceType.Mylist; break; case Database.BookmarkType.SearchWithTag: sourceType = SubscriptionSourceType.TagSearch; break; case Database.BookmarkType.SearchWithKeyword: sourceType = SubscriptionSourceType.KeywordSearch; break; } if (sourceType.HasValue) { subsc.Sources.Add(new SubscriptionSource(feedSource.Label, sourceType.Value, feedSource.Content)); } } if (subsc.Sources.Any()) { instance.Subscriptions.Add(subsc); localObjectStorageHelper.Save(nameof(MigrateFeedGroupToSubscriptionManager), true); } Debug.WriteLine("フィードを購読に移行:完了!"); } }
private MarkdownSetting LoadTheme() { var wCache = new LocalObjectStorageHelper(); try { var json = wCache.Read(CacheKeys.ReadmeTheme, ""); return(Newtonsoft.Json.JsonConvert.DeserializeObject <MarkdownSetting>(json)); } catch { return(new MarkdownSetting { BgColor = "#ffffff", Theme = ElementTheme.Light }); } }
//默认视频为《创造101》 public VideoPlayer() { this.InitializeComponent(); Rules = LocalObjectStorageHelper.Read <Rules>("rules"); if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { Blur.Background = new AcrylicBrush { BackgroundSource = AcrylicBackgroundSource.Backdrop, TintColor = Colors.Transparent, TintOpacity = 0.5 }; } SystemNavigationManager SystemNavigationManager = SystemNavigationManager.GetForCurrentView(); SystemNavigationManager.BackRequested += BackRequested; SystemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; }
public Search() { this.InitializeComponent(); if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) { Blur.Background = new AcrylicBrush { BackgroundSource = AcrylicBackgroundSource.Backdrop, TintColor = Colors.Transparent, TintOpacity = 0.1 }; } Rules = LocalObjectStorageHelper.Read <Rules>("rules"); Loading.IsActive = true; Blur.Visibility = Visibility.Visible; SearchWebView.Navigate(UriSearch); SystemNavigationManager.BackRequested += BackRequested; SystemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; }
public static User LoginFromCache() { var wCache = new LocalObjectStorageHelper(); var key = CacheKeys.UserKey; if (wCache.KeyExists(key)) { var json = wCache.Read(key, ""); if (json.Length < 4) { return(null); } return(JsonConvert.DeserializeObject <User>(json)); } else { return(null); } }
private async void InitRules() { LocalObjectStorageHelper LocalObjectStorageHelper = new LocalObjectStorageHelper(); if (!await LocalObjectStorageHelper.FileExistsAsync("rules_origin")) { var Folder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); var FileRules = await Folder.GetFileAsync("rules.json"); string StringRules = await FileIO.ReadTextAsync(FileRules); var TempRules = JsonConvert.DeserializeObject <Rules>(StringRules); await LocalObjectStorageHelper.SaveFileAsync("rules_origin", TempRules); } if (!await LocalObjectStorageHelper.FileExistsAsync("rules")) { var Folder = await Package.Current.InstalledLocation.GetFolderAsync("Data"); var FileRules = await Folder.GetFileAsync("rules.json"); string StringRules = await FileIO.ReadTextAsync(FileRules); Rules = JsonConvert.DeserializeObject <Rules>(StringRules); await LocalObjectStorageHelper.SaveFileAsync("rules", Rules); } else { Rules = await LocalObjectStorageHelper.ReadFileAsync <Rules>("rules"); } if (!LocalObjectStorageHelper.KeyExists("settings")) { LocalObjectStorageHelper.Save("settings", Rules.GetSettings()); } else { var settings = LocalObjectStorageHelper.Read <Dictionary <string, bool> >("settings"); Rules.SetSettings(settings); } }
public void Test_StorageHelper_LegacyIntTest() { string key = "LifeUniverseAndEverything"; int input = 42; // simulate previous version by generating json and manually inserting it as string string jsonInput = JsonConvert.SerializeObject(input); storageHelper.Save <string>(key, jsonInput); // now read it as int to valid that the change works int output = storageHelper.Read <int>(key, 0); Assert.AreEqual(input, output); }
internal static async Task ShowIfAppropriateAsync(LaunchActivatedEventArgs e) { bool hasShownRateAndReview = _localSettings.Read(HasShown, false); if (hasShownRateAndReview) { return; } if (SystemInformation.LaunchCount > 5) { var dialog = new RateAndReviewDialog(); var response = await dialog.ShowAsync(); if (response == ContentDialogResult.Secondary) { Deactivate(); } } await Task.CompletedTask; }
public static async Task <LinkedList <Sample> > GetRecentSamples() { if (_recentSamples == null) { _recentSamples = new LinkedList <Sample>(); var savedSamples = _localObjectStorageHelper.Read <string>(_recentSamplesStorageKey); if (savedSamples != null) { var sampleNames = savedSamples.Split(';').Reverse(); foreach (var name in sampleNames) { var sample = await GetSampleByName(name); if (sample != null) { _recentSamples.AddFirst(sample); } } } } return(_recentSamples); }
internal static async Task ShowIfAppropriateAsync(LaunchActivatedEventArgs e) { var currentVersion = SystemInformation.ApplicationVersion; if (currentVersion.ToFormattedString() == SystemInformation.FirstVersionInstalled.ToFormattedString()) { // Original version. Ignore. return; } var hasShown = _localSettings.Read(HasShown, false); if (!hasShown) { // New release dialog. var dialog = new NewReleaseDialog(); var response = await dialog.ShowAsync(); if (response == ContentDialogResult.Secondary) { Deactivate(); } } }