public static void SetupLang(string locale) { if (locale != null) { ApplicationLanguages.PrimaryLanguageOverride = locale; return; } if (LocalSettingHelper.HasValue("AppLang") == false) { var lang = GlobalizationPreferences.Languages[0]; if (lang.Contains("zh")) { ApplicationLanguages.PrimaryLanguageOverride = "zh-CN"; } else { ApplicationLanguages.PrimaryLanguageOverride = "en-US"; } LocalSettingHelper.AddValue("AppLang", ApplicationLanguages.PrimaryLanguageOverride); } else { ApplicationLanguages.PrimaryLanguageOverride = LocalSettingHelper.GetValue("AppLang"); } }
public SettingsViewModel() { if (LocalSettingHelper.HasValue(SAVING_POSITION)) { var position = LocalSettingHelper.GetValue(SAVING_POSITION); SavingPositionPath = position; } else { SavingPositionPath = "\\Pictures\\MyerSplash"; } }
public async Task DownloadFullImageAsync(CancellationToken token) { var url = GetSaveImageUrlFromSettings(); if (string.IsNullOrEmpty(url)) { return; } ToastService.SendToast("Downloading in background...", 2000); StorageFolder folder = null; if (LocalSettingHelper.HasValue(SettingsViewModel.SAVING_POSITION)) { var path = LocalSettingHelper.GetValue(SettingsViewModel.SAVING_POSITION); if (path == SettingsViewModel.DEFAULT_SAVING_POSITION) { folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MyerSplash", CreationCollisionOption.OpenIfExists); } else { folder = await StorageFolder.GetFolderFromPathAsync(path); } } if (folder == null) { folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MyerSplash", CreationCollisionOption.OpenIfExists); } var fileName = $"{Owner.Name} {CreateTimeString}"; var newFile = await folder.CreateFileAsync($"{fileName}.jpg", CreationCollisionOption.GenerateUniqueName); //backgroundDownloader.FailureToastNotification = ToastHelper.CreateToastNotification("Failed to download :-(", "You may cancel it. Otherwise please check your network."); _backgroundDownloader.SuccessToastNotification = ToastHelper.CreateToastNotification("Saved:D", $"You can find it in {folder.Path}."); var downloadOperation = _backgroundDownloader.CreateDownload(new Uri(url), newFile); var progress = new Progress <DownloadOperation>(); try { await downloadOperation.StartAsync().AsTask(token, progress); } catch (TaskCanceledException) { await downloadOperation.ResultFile.DeleteAsync(); downloadOperation = null; throw; } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (DeviceHelper.IsDesktop) { var key = (string)App.Current.Resources["CoachKey"]; if (!LocalSettingHelper.HasValue(key)) { LocalSettingHelper.AddValue(key, true); await PopupService.Instance.ShowAsync(new TipsControl()); } } }
public void Activate(object param) { var task = HandleLaunchArg(param as string); if (DeviceHelper.IsDesktop) { if (!LocalSettingHelper.HasValue("TIPS261")) { LocalSettingHelper.AddValue("TIPS261", true); var uc = new TipsControl(); var task2 = PopupService.Instance.ShowAsync(uc); } } }
/// <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 async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif var appView = ApplicationView.GetForCurrentView(); appView.SetPreferredMinSize(new Size(400, 700)); Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } Window.Current.Content = rootFrame; GlobalHelper.SetupLang(); if (LocalSettingHelper.HasValue("email")) { rootFrame.Navigate(typeof(MainPage), LoginMode.Login); } else if (LocalSettingHelper.GetValue("OfflineMode") == "true") { IsInOfflineMode = true; rootFrame.Navigate(typeof(MainPage), LoginMode.OfflineMode); } else { IsInOfflineMode = false; rootFrame.Navigate(typeof(StartPage)); } } Window.Current.Activate(); await UmengAnalytics.StartTrackAsync(UmengKey.UMENG_APP_KEY, "Marketplace"); }
private void EnterBtn_Click(object sender, RoutedEventArgs e) { LocalSettingHelper.AddValue(App.Current.Resources["FeatureToken"] as string, "1"); if (LocalSettingHelper.HasValue("email")) { Frame.Navigate(typeof(MainPage), LoginMode.Login); } else if (LocalSettingHelper.GetValue("OfflineMode") == "true") { App.IsInOfflineMode = true; Frame.Navigate(typeof(MainPage), LoginMode.OfflineMode); } else { App.IsInOfflineMode = false; Frame.Navigate(typeof(StartPage)); } }
private void ToggleDetailControlAnimation() { DetailControl.CurrentImage = _clickedImg; DetailControl.Show(_clickedContainer); var key = (string)App.Current.Resources["GestureKey"]; if (!LocalSettingHelper.HasValue(key)) { ToggleGestureTipsControlAnimation(true, 500); } NavigationService.AddOperation(() => { DetailControl.Hide(); return(true); }); }
public static void CheckConfig() { if (!LocalSettingHelper.HasValue("EnableTile")) { LocalSettingHelper.AddValue("EnableTile", "true"); } if (!LocalSettingHelper.HasValue("EnableBackgroundTask")) { LocalSettingHelper.AddValue("EnableBackgroundTask", "true"); } if (!LocalSettingHelper.HasValue("EnableGesture")) { LocalSettingHelper.AddValue("EnableGesture", "true"); } if (!LocalSettingHelper.HasValue("ShowKeyboard")) { LocalSettingHelper.AddValue("ShowKeyboard", "true"); } if (!LocalSettingHelper.HasValue("TransparentTile")) { LocalSettingHelper.AddValue("TransparentTile", "true"); } if (!LocalSettingHelper.HasValue("AddMode")) { LocalSettingHelper.AddValue("AddMode", "1"); } if (!LocalSettingHelper.HasValue("ThemeColor")) { LocalSettingHelper.AddValue("ThemeColor", "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 async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif CacheUtilInstance = new CacheUtil(); await CacheUtilInstance.LoadAsync(); GlobalLocaleHelper.SetupLang(null); 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.Background = App.Current.Resources["MyerSplashDarkColor"] as SolidColorBrush; rootFrame.NavigationFailed += OnNavigationFailed; 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 if (!LocalSettingHelper.HasValue("UPDATED_TO_1.1")) { var files1 = await CacheUtil.GetCachedFileFolder().GetItemsAsync(); foreach (var file in files1) { await file.DeleteAsync(StorageDeleteOption.PermanentDelete); } var files2 = await CacheUtil.GetTempFolder().GetItemsAsync(); foreach (var file in files2) { await file.DeleteAsync(StorageDeleteOption.PermanentDelete); } LocalSettingHelper.AddValue("UPDATED_TO_1.1", true); } rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); TitleBarHelper.SetUpThemeTitleBar(); if (DeviceHelper.IsMobile) { StatusBarHelper.SetUpStatusBar(); } SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; if (APIInfoHelper.HasHardwareButton) { HardwareButtons.BackPressed += HardwareButtons_BackPressed; } }
/// <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; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } Window.Current.Content = rootFrame; ConfigHelper.CheckConfig(); if (LocalSettingHelper.HasValue("AppLang") == false) { var lang = Windows.System.UserProfile.GlobalizationPreferences.Languages[0]; if (lang.Contains("zh")) { ApplicationLanguages.PrimaryLanguageOverride = "zh-CN"; } else { ApplicationLanguages.PrimaryLanguageOverride = "en-US"; } LocalSettingHelper.AddValue("AppLang", ApplicationLanguages.PrimaryLanguageOverride); } else { ApplicationLanguages.PrimaryLanguageOverride = LocalSettingHelper.GetValue("AppLang"); } if (LocalSettingHelper.HasValue("email")) { rootFrame.Navigate(typeof(MainPage), LoginMode.Login); } else if (LocalSettingHelper.GetValue("OfflineMode") == "true") { App.isInOfflineMode = true; rootFrame.Navigate(typeof(MainPage), LoginMode.OfflineMode); } else { App.isInOfflineMode = false; rootFrame.Navigate(typeof(StartPage)); } } // Ensure the current window is active Window.Current.Activate(); }