Ejemplo n.º 1
0
        public void AddBuzzWordAndSave(ListView listView, string buzzWord)
        {
            const int buzzWordsLimit = 20;

            JsonArray buzzWordsCollection = roamingJsonObject.GetOrCreateNamedArray(BuzzWordsKey);

            IJsonValue selectedValue;

            if (buzzWordsCollection.ContainsStringValue(buzzWord, out selectedValue))
            {
                // We already have this buzz word.
                Debug.WriteLine("Buzz word repeated: {0}", buzzWord);
                return;
            }

            if (buzzWordsCollection.Count >= buzzWordsLimit)
            {
                MessageDialog dialog = new MessageDialog(
                    String.Format("Only {0} buzz words allowed.", buzzWordsLimit),
                    "Oops.");

                // Weird, we do not await nor keep a reference to the dialog.
                var showOperation = dialog.ShowAsync();

                return;
            }

            buzzWordsCollection.Add(JsonValue.CreateStringValue(buzzWord));
            listView.Items.Add(buzzWord);

            SettingsManager.SaveRoaming();
        }
Ejemplo n.º 2
0
        public void DeleteBuzzWordAndSave(ListView listView, string buzzWord)
        {
            JsonArray buzzWordsCollection = roamingJsonObject.GetOrCreateNamedArray(BuzzWordsKey);

            IJsonValue selectedValue;

            if (buzzWordsCollection.ContainsStringValue(buzzWord, out selectedValue))
            {
                buzzWordsCollection.Remove(selectedValue);

                SettingsManager.SaveRoaming();
            }

            listView.Items.Remove(buzzWord);
        }