コード例 #1
0
ファイル: NewMp.xaml.cs プロジェクト: FLKone/HFR8
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            // 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);
            }

            // Hash check
            hash = store["hash"] as String;

            // GET
            NavigationContext.QueryString.TryGetValue("pseudodesti", out pseudoDestiDirect);
            NavigationContext.QueryString.TryGetValue("url", out urlPost);
            if (pseudoDestiDirect != null)
            {
                pseudoTextBox.Text = pseudoDestiDirect;
                pseudoTextBox.Hint = "";
            }
        }
 /// <summary>
 /// Private helper method for performing deletes on a setting
 /// </summary>
 /// <param name="store">The IsolatedStorageSettings store to use (either "site" or "application")</param>
 /// <param name="key">The key of the object to delete</param>
 private static void DeleteSetting(IsolatedStorageSettings store, string key)
 {
     if(store.Contains(key))
     {
         store.Remove(key);
         store.Save();
     }
 }
コード例 #3
0
        public IsoStorageHelper()
        {
            settings = IsolatedStorageSettings.ApplicationSettings;

            //check if an unhandled exception occured last time
            if (getUnhandledException())//if yes
            {
                //show custom message box asking if user wants to submit feedback on it
                //TODO - ask user if they want to submit feedback on the issue
                //if yes, compose email with exception details
                //if no, close the app
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    CustomMessageBox messageBox = new CustomMessageBox()
                    {
                        Caption = "Uh-oh!  There was an error!",
                        Message = "Would you like to submit the error information to the developer? \n It would help speed up the process of fixing the issue!",
                        LeftButtonContent = "Yes",
                        RightButtonContent = "Nope",
                    };
                    messageBox.Dismissed += (s1, e1) =>
                    {
                        switch (e1.Result)
                        {
                            case CustomMessageBoxResult.LeftButton:
                                {
                                    //compose email
                                    new Feedback.FeedbackEmail(savedExceptionData);
                                    break;
                                }
                            case CustomMessageBoxResult.RightButton:
                                {
                                    break;
                                }
                            case CustomMessageBoxResult.None:
                                {
                                    break;
                                }
                            default:
                                {
                                    break;
                                }
                        }
                    };

                    messageBox.Show();
                });

                settings.Remove(Constants.IsolatedStorage.ISO_EXCEPTION);//clear the exception
            }
        }
コード例 #4
0
        private PodcastEpisodesDownloadManager()
        {
            createEpisodeDownloadDir();

            m_applicationSettings = IsolatedStorageSettings.ApplicationSettings;

            if (BackgroundTransferService.Requests.Count() == 0)
            {
                m_applicationSettings.Remove(App.LSKEY_PODCAST_EPISODE_DOWNLOADING_ID);
                m_currentBackgroundTransfer = null;
            }

            processOngoingTransfer();
            processStoredQueuedTransfers();
        }
コード例 #5
0
 public bool Delete(string key)
 {
     try
     {
         settings = IsolatedStorageSettings.ApplicationSettings;
         if ((string)settings[key] != null)
         {
             settings.Remove(key);
             return true;
         }
         else return false;
     }
     catch(KeyNotFoundException ex)
     {
         return false;
     }
 }
コード例 #6
0
ファイル: ListTopics.xaml.cs プロジェクト: FLKone/HFR8
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            SystemTray.ProgressIndicator = new ProgressIndicator();
            SystemTray.ProgressIndicator.IsIndeterminate = true;
            if ((string)store["disableLandscape"] == "true")
            {
                ListTopicPage.SupportedOrientations = SupportedPageOrientation.Portrait;
            }
            if (store.Contains("navigatedback"))
            {
                store.Remove("navigatedback");
                if (isoStore.DirectoryExists("topics"))
                {
                    foreach (string fileName in isoStore.GetFileNames("topics/*"))
                    {
                        isoStore.DeleteFile("topics/" + fileName);
                    }
                }
            }
            else
            {
                // Récupération de l'URI de la sous-catégorie
                NavigationContext.QueryString.TryGetValue("souscaturi", out souscatUri);
                souscatUri = HttpUtility.UrlDecode(souscatUri);

                // Récupération de l'ID de la catégorie
                NavigationContext.QueryString.TryGetValue("idcat", out idCat);

                // Récupération du nom du forum
                NavigationContext.QueryString.TryGetValue("souscatname", out souscatName);
                if (souscatName == null)
                {
                    souscatName = GetCatName.PlainNameFromId(idCat);
                }
                topicsPivot.Title = souscatName.ToUpper();

                // Récupération de la provenance
                NavigationContext.QueryString.TryGetValue("from", out from);
                if (from == "changepage")
                {
                    NavigationService.RemoveBackEntry();
                }

                // Pivot
                NavigationContext.QueryString.TryGetValue("pivot", out pivot);

                // listPageNumber
                NavigationContext.QueryString.TryGetValue("listpagenumber", out listPageNumber);
                if (Convert.ToInt32(listPageNumber) > 1)
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true;
                }
                else
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false;
                }
                if (!souscatUri.Contains("cat=0"))
                {
                    souscatUri = souscatUri.Substring(0, souscatUri.Length - 5) + listPageNumber + ".htm";
                }


                if (pivot == "drap")
                {
                    topicsPivot.SelectedIndex = 1;
                }
                else if (pivot == "topics")
                {
                    topicsPivot.SelectedIndex = 0;
                }

                // Récupération du cookie
                if (store.Contains("HFRcookies"))
                {
                    container = store["HFRcookies"] as CookieContainer;
                }
                else
                {
                    // Création du cookie de l'user
                    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);
                }

                // ItemsSources
                drapList.ItemsSource   = null;
                topicsList.ItemsSource = null;

                // Téléchargement de la liste
                DownloadTopicsDrapals(Convert.ToInt32(listPageNumber));
            }
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: pviral/gtalkchat
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            Settings = IsolatedStorageSettings.ApplicationSettings;
            PushHelper = new PushHelper();
            GtalkClient = new GoogleTalk();

            if (!Settings.Contains("chatlog")) {
                Settings["chatlog"] = new Dictionary<string, List<Message>>();
            }
            if (!Settings.Contains("unread")) {
                Settings["unread"] = new Dictionary<string, int>();
            }
            if (!Settings.Contains("recent")) {
                Settings["recent"] = new ObservableCollection<Contact>();
            }

            Roster = new Roster();
            GtalkHelper = new GoogleTalkHelper();
            Roster.Load();

            RecentContacts = Settings["recent"] as ObservableCollection<Contact>;

            PushHelper.RegisterPushNotifications();

            InitAnalytics();

            if (Settings.Contains("lastError")) {
                var result = MessageBox.Show(
                    AppResources.CrashReport_Message,
                    AppResources.CrashReport_Title,
                    MessageBoxButton.OKCancel
                );

                if(result == MessageBoxResult.OK) {
                    GtalkClient.CrashReport(Settings["lastError"] as string, success => Settings.Remove("lastError"), error => {});
                } else {
                    Settings.Remove("lastError");
                }
            }
        }
コード例 #8
0
		public void CheckSettings (IsolatedStorageSettings settings)
		{
			Assert.AreEqual (0, settings.Count, "Empty-Count");
			Assert.AreEqual (0, settings.Keys.Count, "Empty-Keys.Count");
			Assert.AreEqual (0, settings.Values.Count, "Empty-Values.Count");

			settings.Add ("key", "value");
			Assert.Throws (delegate { settings.Add (null, "x"); }, typeof (ArgumentNullException), "Add(null,x)");
			Assert.Throws (delegate { settings.Add ("key", "another string"); }, typeof (ArgumentException), "Add(twice)");

			Assert.AreEqual (1, settings.Count, "Count");
			Assert.AreEqual (1, settings.Keys.Count, "Keys.Count");
			Assert.AreEqual (1, settings.Values.Count, "Values.Count");
			Assert.AreEqual (1, (settings as ICollection).Count, "ICollection.Count");

			Assert.IsTrue (settings.Contains ("key"), "Contains-key");
			Assert.IsFalse (settings.Contains ("value"), "Contains-value");
			Assert.Throws (delegate { settings.Contains (null); }, typeof (ArgumentNullException), "Contains(null)");

			Assert.AreEqual ("value", settings ["key"], "this[key]");
			settings ["key"] = null;
			Assert.IsNull (settings ["key"], "this[key]-null");
			Assert.Throws (delegate { Console.WriteLine (settings ["unexisting"]); }, typeof (KeyNotFoundException), "this[unexisting]");
			Assert.Throws (delegate { settings [null] = null; }, typeof (ArgumentNullException), "this[null] set");

			settings.Remove ("key");
			Assert.AreEqual (0, settings.Count, "Remove/Count");
			Assert.IsFalse (settings.Remove ("unexisting"), "Remove(unexisting)");
			Assert.Throws (delegate { settings.Remove (null); }, typeof (ArgumentNullException), "Remove(null)");

			settings.Add ("key", "value");
			Assert.AreEqual (1, settings.Count, "Add2/Count");

			string s;
			Assert.IsTrue (settings.TryGetValue<string> ("key", out s), "TryGetValue(key)");
			Assert.AreEqual ("value", s, "out value");
			object o;
			Assert.IsTrue (settings.TryGetValue<object> ("key", out o), "TryGetValue(object)");
			Assert.AreEqual ("value", s, "out value/object");
			Assert.IsFalse (settings.TryGetValue<string> ("value", out s), "TryGetValue(value)");
			Assert.Throws (delegate { settings.TryGetValue<string> (null, out s); }, typeof (ArgumentNullException), "TryGetValue(null)");

			settings.Clear ();
			Assert.AreEqual (0, settings.Count, "Clear/Count");
		}
コード例 #9
0
 private void favorisListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (pageLoaded)
     {
         try
         {
             if (favorisListPicker.SelectedIndex == 0)
             {
                 store.Remove("favorisType");
                 store.Add("favorisType", "1");
             }
             if (favorisListPicker.SelectedIndex == 1)
             {
                 store.Remove("favorisType");
                 store.Add("favorisType", "2");
             }
             if (favorisListPicker.SelectedIndex == 2)
             {
                 store.Remove("favorisType");
                 store.Add("favorisType", "3");
             }
         }
         catch { }
     }
 }