private void SaveISS(string in_name, string in_val) { System.IO.IsolatedStorage.IsolatedStorageSettings iss = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings; if (iss.Contains(in_name)) { iss.Remove(in_name); } iss.Add(in_name, in_val); iss.Save(); }
private static void SaveUser(string userName, string password) { if (userSettings.Contains("user")) { userSettings["user"] = userName; } else { userSettings.Add("user", userName); } if (userSettings.Contains("pwd")) { userSettings["pwd"] = password; } else { userSettings.Add("pwd", password); } userSettings.Save(); }
// uygulamayı kapatsak bile bu değerler ısolated storage de bulunur t değeri t herşey olabilir generic string integer vb.fakat... public static void SetValue <T>(string Key, T Value)//generic { // add çıkar çünkü private static System.IO.IsolatedStorage.IsolatedStorageSettings Settings; tanımlaması yaptık. //Settings.Add if (Settings.Contains(Key)) { Settings[Key] = Value; //varsa bulup güncelle yoksa ekle } else { Settings.Add(Key, Value); } }
public App() { ONScripterSettings.Initialize(); UVEngineSettings.Initialize(); if (UVEngineNative.UVEngineSettings.language == "") { UVEngine.Resources.UVEngine.Culture = System.Threading.Thread.CurrentThread.CurrentUICulture; } else { System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(UVEngineNative.UVEngineSettings.language); } UnhandledException += Application_UnhandledException; InitializeComponent(); InitializePhoneApplication(); //InitializeXnaApplication(); InitializeLanguage(); GameSession session = XLiveGameManager.CreateSession("GsMmyW5d3a6fr7VbtgRD4SPH"); session.CreateSessionCompleted += session_CreateSessionCompleted; XLiveUIManager.Initialize(this, session); session.Open(); System.IO.IsolatedStorage.IsolatedStorageSettings appSettings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings; if (!appSettings.Contains("showDebug")) { appSettings.Add("showDebug", 0); } if ((int)appSettings["showDebug"] == 1) { Application.Current.Host.Settings.EnableFrameRateCounter = true; MemoryDiagnosticsHelper.Start(TimeSpan.FromMilliseconds(100), true); } PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; Microsoft.Devices.CameraButtons.ShutterKeyPressed += delegate { if (XLiveGameManager.CurrentSession != null && XLiveGameManager.CurrentSession.SNSProviders.Count > 0) // Must exist available provider { if (UVEngineSettings.QuickShare) { //App.RootFrame.Navigate(new Uri("/OpenXLive.Silverlight;component/Forms/UpdateStatusPage.xaml", UriKind.Relative)); WriteableBitmap bmp; if (landscape) { bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Height, (int)App.Current.RootVisual.RenderSize.Width); } else { bmp = new WriteableBitmap((int)App.Current.RootVisual.RenderSize.Width, (int)App.Current.RootVisual.RenderSize.Height); } bmp.Render(App.Current.RootVisual, null); bmp.Invalidate(); MemoryStream stream = new MemoryStream(); //var a = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication().OpenFile("capture.jpg", FileMode.OpenOrCreate); bmp.SaveJpeg(stream, bmp.PixelWidth, bmp.PixelHeight, 0, 100); BitmapImage bi = new BitmapImage(); bi.SetSource(stream); OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(bi, ""); //capture = stream.ToArray(); //OpenXLive.Silverlight.XLiveUIManager.ShowUpdateStatus(new BitmapImage(stream), ""); } } else { MessageBox.Show(UVEngine.Resources.UVEngine.openxliveproblem); } }; if (UVEngineSettings.ReqPasswd) { Guide.BeginShowKeyboardInput (Microsoft.Xna.Framework.PlayerIndex.One, UVEngine.Resources.UVEngine.passwdreq, UVEngine.Resources.UVEngine.passwdmes, "", delegate(IAsyncResult result) { string text = Guide.EndShowKeyboardInput(result); if (text != UVEngineNative.UVEngineSettings.Passwd) { Application.Current.Terminate(); } }, new object(), true); } //this.Startup += delegate //{ // if (UVEngineSettings.ReqPasswd) // { // var passwordInput = new Coding4Fun.Toolkit.Controls.PasswordInputPrompt // { // Title = UVEngine.Resources.UVEngine.passwdreq, // Message = UVEngine.Resources.UVEngine.passwdmes, // }; // passwordInput.Completed += new EventHandler<Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult>>(delegate(object sender, Coding4Fun.Toolkit.Controls.PopUpEventArgs<string, Coding4Fun.Toolkit.Controls.PopUpResult> e) // { // if (e.PopUpResult == Coding4Fun.Toolkit.Controls.PopUpResult.Ok) // { // if (e.Result != UVEngineSettings.Passwd) // { // MessageBox.Show(UVEngine.Resources.UVEngine.wrongpasswd); // Application.Current.Terminate(); // } // } // else // { // Application.Current.Terminate(); // } // }); // passwordInput.Show(); // } //}; /* * // 调试时显示图形分析信息。 * if (Debugger.IsAttached) * { * // 显示当前帧速率计数器。 * Application.Current.Host.Settings.EnableFrameRateCounter = true; * * // 显示在每个帧中重绘的应用程序区域。 * //Application.Current.Host.Settings.EnableRedrawRegions = true; * * // 启用非生产分析可视化模式, * // 该模式显示递交给 GPU 的包含彩色重叠区的页面区域。 * //Application.Current.Host.Settings.EnableCacheVisualization = true; * * // 通过禁用以下对象阻止在调试过程中关闭屏幕 * // 应用程序的空闲检测。 * // 注意: 仅在调试模式下使用此设置。禁用用户空闲检测的应用程序在用户不使用电话时将继续运行 * // 并且消耗电池电量。 * PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; * } */ PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled; }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { SystemTray.ProgressIndicator = new ProgressIndicator(); if ((string)store["disableLandscape"] == "true") { AnswerTopicPage.SupportedOrientations = SupportedPageOrientation.Portrait; } // Background clair ou foncé if ((Visibility)Resources["PhoneDarkThemeVisibility"] == System.Windows.Visibility.Visible) { currentTheme = "dark"; } else { currentTheme = "light"; } //if (AnswerTopicPage.Orientation == PageOrientation.Landscape || AnswerTopicPage.Orientation == PageOrientation.LandscapeLeft || AnswerTopicPage.Orientation == PageOrientation.LandscapeRight) currentOrientation = "landscape"; //else currentOrientation = "portrait"; //backgroundImageBrush.ImageSource = new BitmapImage(new Uri("Images/" + currentTheme + "/Background/Background_" + currentOrientation + ".jpg", UriKind.Relative)); // Cookie container = store["HFRcookies"] as CookieContainer; if (container.Count < 3) { List <Cookie> listCookies = store["listHFRcookies"] as List <Cookie>; foreach (Cookie c in listCookies) { container.Add(new Uri("https://forum.hardware.fr", UriKind.Absolute), c); } store.Remove("HFRcookies"); store.Add("HFRcookies", container); } //GET NavigationContext.QueryString.TryGetValue("pagenumber", out pageNumber); NavigationContext.QueryString.TryGetValue("idtopic", out idTopic); NavigationContext.QueryString.TryGetValue("idcat", out idCat); NavigationContext.QueryString.TryGetValue("topicname", out topicName); topicName = HttpUtility.UrlDecode(topicName); NavigationContext.QueryString.TryGetValue("action", out action); NavigationContext.QueryString.TryGetValue("numberofpages", out numberOfPages); NavigationContext.QueryString.TryGetValue("position", out position); NavigationContext.QueryString.TryGetValue("smileyCode", out smileyCode); NavigationContext.QueryString.TryGetValue("reponseid", out reponseId); NavigationContext.QueryString.TryGetValue("hfrrehost", out hfrRehost); NavigationContext.QueryString.TryGetValue("back", out backAction); NavigationContext.QueryString.TryGetValue("numrep", out numRep); // DEBUG //pageNumber = "7994"; //topicName = "loal.com"; //numberOfPages = "8000"; //numRep = "27926498"; //idTopic = "55667"; //idCat = "13"; //action = "answer"; // Nettoyage du backstack if (backAction == "tool") { NavigationService.RemoveBackEntry(); NavigationService.RemoveBackEntry(); } // Navigated back if (store.Contains("navigatedBack") && backAction != "tool") { navigatedBack = true; store.Remove("navigatedBack"); } // Si sauvegarde if (store.Contains("saveAnswer") && (action == "answer" || action == "edit" || action == "quote" || store.Contains("activated"))) { if (idTopic == (string)store["saveAnswerTopicNumber"]) { saveAnswer = (string)store["saveAnswer"]; // Si smiley if (store.Contains("quotedText")) { quotedText = (string)store["quotedText"]; store.Remove("quotedText"); if (quotedText.Length > 100 && !store.Contains("listQuoteText")) { showQuoteButton.Visibility = System.Windows.Visibility.Visible; answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; } } if (position != null && smileyCode != null) { saveAnswer = saveAnswer.Insert(Convert.ToInt32(position), " " + smileyCode + " "); answerTextBox.Text = saveAnswer; answerTextBox.Select(Convert.ToInt32(position) + smileyCode.Length + 2, 0); store.Remove("smileyCode"); } if (position != null && hfrRehost != null) { saveAnswer = saveAnswer.Insert(Convert.ToInt32(position), hfrRehost); answerTextBox.Text = saveAnswer; answerTextBox.Select(Convert.ToInt32(position) + hfrRehost.Length, 0); } } } // Si liste de quote if (action == "answer") { PageTitle.Text = "votre réponse"; if (!store.Contains("listQuoteText")) { answerTextBox.Focus(); } } if (store.Contains("listQuoteText") && (action == "answer" || action == "quote")) { string listQuoteText = (string)store["listQuoteText"]; answerTextBox.Text = answerTextBox.Text + listQuoteText; store.Remove("listQuoteText"); if (store.Contains("quotedText")) { store.Remove("quotedText"); } store.Add("quotedText", listQuoteText); } // Hash check hash = store["hash"] as String; if (action == "quote" && backAction != "tool" && navigatedBack == false) { PageTitle.Text = "votre réponse"; // Verrouillage de l'answerBox answerTextBox.IsEnabled = false; ApplicationBar.IsVisible = false; // Progress Bar progressBar.Visibility = System.Windows.Visibility.Visible; // On cherche la quote string urlQuote = "https://forum.hardware.fr/message.php?config=hfr.inc&cat=" + idCat + "&post=" + idTopic + "&numrep=" + numRep; HtmlWeb.LoadAsync(urlQuote, container, (s, args) => { Dispatcher.BeginInvoke(() => progressBar.Visibility = System.Windows.Visibility.Visible); if (args.Error != null) { Dispatcher.BeginInvoke(() => { MessageBox.Show("Erreur dans la lecture de la quote. Informations : " + args.Error.Message + ", " + args.Error.Data); progressBar.Visibility = System.Windows.Visibility.Collapsed; }); } if (args.Document == null) { Dispatcher.BeginInvoke(() => { MessageBox.Show("Serveur en cours de maintenance. Veuillez réessayer plus tard."); answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; }); } else { string[] quoteText = args.Document.DocumentNode.Descendants("textarea").Where(x => (string)x.GetAttributeValue("name", "") == "content_form"). Select(y => y.InnerText).ToArray(); quotedText = HttpUtility.HtmlDecode(quoteText[0]).Substring(0, HttpUtility.HtmlDecode(quoteText[0]).Length - 1); if (store.Contains("quotedText")) { store.Remove("quotedText"); } store.Add("quotedText", quotedText); Dispatcher.BeginInvoke(() => { if (quotedText.Length > 100 && !store.Contains("listQuoteText")) { showQuoteButton.Visibility = System.Windows.Visibility.Visible; answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; } else { showQuoteButton.Visibility = System.Windows.Visibility.Collapsed; answerTextBox.Text = answerTextBox.Text + quotedText; answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; } }); } }); } if (action == "delete") { answerTextBox.Visibility = System.Windows.Visibility.Collapsed; NavigationContext.QueryString.TryGetValue("numrep", out numRep); MessageBoxResult result = MessageBox.Show("Êtes-vous sûr de supprimer ce message ?", "Confirmation", MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { PageTitle.Text = "suppression en cours..."; DeleteAnswer(); } else { NavigationService.GoBack(); } } if (action == "edit" && backAction != "tool") { PageTitle.Text = "édition"; NavigationContext.QueryString.TryGetValue("numrep", out numRep); // Verrouillage de l'answerBox answerTextBox.IsEnabled = false; ApplicationBar.IsVisible = false; // Progress Bar progressBar.Visibility = System.Windows.Visibility.Visible; // On cherche le post à éditer NavigationContext.QueryString.TryGetValue("numrep", out numRep); string urlEdit = "https://forum.hardware.fr/message.php?config=hfr.inc&cat=" + idCat + "&post=" + idTopic + "&numreponse=" + numRep; HtmlWeb.LoadAsync(urlEdit, container, (s, args) => { Dispatcher.BeginInvoke(() => progressBar.Visibility = System.Windows.Visibility.Visible); if (args.Error != null) { Dispatcher.BeginInvoke(() => { MessageBox.Show("Erreur dans la lecture du post. Informations : " + args.Error.Message + ", " + args.Error.Data); progressBar.Visibility = System.Windows.Visibility.Collapsed; }); } if (args.Document == null) { Dispatcher.BeginInvoke(() => { MessageBox.Show("Serveur en cours de maintenance. Veuillez réessayer plus tard."); answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; }); } else { string[] editText = args.Document.DocumentNode.Descendants("textarea").Where(x => (string)x.GetAttributeValue("name", "") == "content_form"). Select(y => y.InnerText).ToArray(); Dispatcher.BeginInvoke(() => { answerTextBox.Text = HttpUtility.HtmlDecode(editText[0]) + Environment.NewLine; answerTextBox.IsEnabled = true; ApplicationBar.IsVisible = true; progressBar.Visibility = System.Windows.Visibility.Collapsed; }); } }); } }
public void StoreOAuthUserInfo() { //TODO: Change this to have ApplicationDataContainer that should have been passed in. //ApplicationData.Current.LocalSettings.DeleteContainer("TwitterAPIMash"); #if NETFX_CORE ApplicationDataContainer appLocalData = ApplicationData.Current.LocalSettings.CreateContainer(CommonProperties.TwitterAPI_DataStorage, ApplicationDataCreateDisposition.Always); //Save or Update OAuth values in appLocalData if applicable, so won't have to Re-Authorize if (appLocalData.Values.ContainsKey("OAuthConsumerKey")) { appLocalData.Values["OAuthConsumerKey"] = OAuth.OAuthTypes.OAuthConsumerKey; } else { appLocalData.Values.Add("OAuthConsumerKey", OAuth.OAuthTypes.OAuthConsumerKey); } if (appLocalData.Values.ContainsKey("OAuthConsumerSecret")) { appLocalData.Values["OAuthConsumerSecret"] = OAuth.OAuthTypes.OAuthConsumerSecret; } else { appLocalData.Values.Add("OAuthConsumerSecret", OAuth.OAuthTypes.OAuthConsumerSecret); } if (appLocalData.Values.ContainsKey("OAuthAccessToken")) { appLocalData.Values["OAuthAccessToken"] = OAuth.OAuthTypes.OAuthAccessTokenKey; } else { appLocalData.Values.Add("OAuthAccessToken", OAuth.OAuthTypes.OAuthAccessTokenKey); } if (appLocalData.Values.ContainsKey("OAuthAccessSecret")) { appLocalData.Values["OAuthAccessSecret"] = OAuth.OAuthTypes.OAuthAccessTokenSecretKey; } else { appLocalData.Values.Add("OAuthAccessSecret", OAuth.OAuthTypes.OAuthAccessTokenSecretKey); } if (appLocalData.Values.ContainsKey("OAuthVerifier")) { appLocalData.Values["OAuthVerifier"] = OAuth.OAuthTypes.OAuthVerifierKey; } else { appLocalData.Values.Add("OAuthVerifier", OAuth.OAuthTypes.OAuthVerifierKey); } if (appLocalData.Values.ContainsKey("UserID")) { appLocalData.Values["UserID"] = TweetAuthConstants.OAuthUserID; } else { appLocalData.Values.Add("UserID", TweetAuthConstants.OAuthUserID); } if (appLocalData.Values.ContainsKey("UserScreenName")) { appLocalData.Values["UserScreenName"] = TweetAuthConstants.OAuthUserScreenName; } else { appLocalData.Values.Add("UserScreenName", TweetAuthConstants.OAuthUserScreenName); } #else System.IO.IsolatedStorage.IsolatedStorageSettings appData = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings; if (!appData.Contains(CommonProperties.TwitterAPI_DataStorage)) { appData.Add(CommonProperties.TwitterAPI_DataStorage, new Dictionary <string, string>()); } Dictionary <string, string> appLocalData = appData[CommonProperties.TwitterAPI_DataStorage] as Dictionary <string, string>; if (appLocalData.ContainsKey("OAuthConsumerKey")) { appLocalData["OAuthConsumerKey"] = OAuth.OAuthTypes.OAuthConsumerKey; } else { appLocalData.Add("OAuthConsumerKey", OAuth.OAuthTypes.OAuthConsumerKey); } if (appLocalData.ContainsKey("OAuthConsumerSecret")) { appLocalData["OAuthConsumerSecret"] = OAuth.OAuthTypes.OAuthConsumerSecret; } else { appLocalData.Add("OAuthConsumerSecret", OAuth.OAuthTypes.OAuthConsumerSecret); } if (appLocalData.ContainsKey("OAuthAccessToken")) { appLocalData["OAuthAccessToken"] = OAuth.OAuthTypes.OAuthAccessTokenKey; } else { appLocalData.Add("OAuthAccessToken", OAuth.OAuthTypes.OAuthAccessTokenKey); } if (appLocalData.ContainsKey("OAuthAccessSecret")) { appLocalData["OAuthAccessSecret"] = OAuth.OAuthTypes.OAuthAccessTokenSecretKey; } else { appLocalData.Add("OAuthAccessSecret", OAuth.OAuthTypes.OAuthAccessTokenSecretKey); } if (appLocalData.ContainsKey("OAuthVerifier")) { appLocalData["OAuthVerifier"] = OAuth.OAuthTypes.OAuthVerifierKey; } else { appLocalData.Add("OAuthVerifier", OAuth.OAuthTypes.OAuthVerifierKey); } if (appLocalData.ContainsKey("UserID")) { appLocalData["UserID"] = TweetAuthConstants.OAuthUserID; } else { appLocalData.Add("UserID", TweetAuthConstants.OAuthUserID); } if (appLocalData.ContainsKey("UserScreenName")) { appLocalData["UserScreenName"] = TweetAuthConstants.OAuthUserScreenName; } else { appLocalData.Add("UserScreenName", TweetAuthConstants.OAuthUserScreenName); } appData.Save(); #endif }