예제 #1
0
        private async void RenameCategory(CategoryDialog dialog)
        {
            Categories cats = await SerializerExtensions.DeSerializeObject <Categories>(
                await ApplicationData.Current.LocalFolder.GetFileAsync("sites"));

            foreach (Category c in cats.categories)
            {
                if (c.title == dialog.CategoryName)
                {
                    await(new MessageDialog((new ResourceLoader()).GetString("CategoryExists")).ShowAsync());
                    return;
                }
            }

            foreach (Category c in cats.categories)
            {
                if (c.title != cat.title)
                {
                    continue;
                }
                c.title               = dialog.CategoryName;
                cat.title             = dialog.CategoryName;
                CategoryTitle.Content = dialog.CategoryName;
                break;
            }

            SerializerExtensions.SerializeObject(cats,
                                                 await ApplicationData.Current.LocalFolder.GetFileAsync("sites"));
        }
예제 #2
0
        private async void AddNewCategory(CategoryDialog dialog)
        {
            Categories cats = await SerializerExtensions.DeSerializeObject <Categories>(
                await ApplicationData.Current.LocalFolder.GetFileAsync("sites"));

            Category cat = new Category();

            cat.title    = dialog.CategoryName;
            cat.websites = new List <Website>();

            foreach (Category c in cats.categories)
            {
                if (c.title == dialog.CategoryName)
                {
                    await(new MessageDialog((new ResourceLoader()).GetString("CategoryExists")).ShowAsync());
                    return;
                }
            }

            cats.categories.Add(cat);
            SerializerExtensions.SerializeObject(cats,
                                                 await ApplicationData.Current.LocalFolder.GetFileAsync("sites"));

            Frame frame = new Frame();

            frame.Navigate(typeof(SourcesView), cat);
            SourcesList.Items.Add(frame);
        }
예제 #3
0
        private async void RenameCategory_Click(object sender, RoutedEventArgs e)
        {
            CategoryDialog addcat = new CategoryDialog();

            addcat.KeyDown += (s, a) =>
            {
                if (a.Key == Windows.System.VirtualKey.Enter)
                {
                    RenameCategory(addcat);
                    addcat.Hide();
                    a.Handled = true;
                }
            };

            if (await addcat.ShowAsync() == ContentDialogResult.Primary)
            {
                RenameCategory(addcat);
                addcat.Hide();
            }
        }