Exemplo n.º 1
0
        private async Task AddCategory()
        {
            string icon = IconTextBlock.Text;
            string name = CategoryNameTextBox.Text;

            if (!string.IsNullOrEmpty(icon) && !string.IsNullOrEmpty(name))
            {
                IsPrimaryButtonEnabled = false;
                PrimaryButtonText      = AppTools.GetReswLanguage("Tip_Waiting");
                var cate = new Category(name, icon);
                MainPage.Current.Categories.Add(cate);
                MainPage.Current._categoryListCount += 1;
                new PopupToast(AppTools.GetReswLanguage("Tip_AddCategorySuccess")).ShowPopup();
                Hide();
                try
                {
                    await IOTools.AddCategory(cate);
                }
                catch (Exception)
                {
                    await Task.Delay(1000);

                    await IOTools.AddCategory(cate);
                }
            }
            else
            {
                new PopupToast(AppTools.GetReswLanguage("Tip_FieldEmpty"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup();
            }
        }