Example #1
0
 private void addFavoriteMenuItem_Click(object sender, EventArgs e)
 {
     if (!_isFavoriteSaved)
     {
         MessageBox.Show("This photo already exists in your collection.",
                         $"—{Application.ProductName}—", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         if (!_isShowFavoritesButtonClicked)
         {
             if (_photos.ElementAtOrDefault(_photoLabelId) != null)
             {
                 var id = _photos[_photoLabelId].Id;
                 Favorites.AddFavorite(id);
                 CountFavorites();
                 CheckFavorite();
             }
             else
             {
                 MessageBox.Show("Please to select a photo.",
                                 $"—{Application.ProductName}—", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
Example #2
0
        private async void OnFavorite(object sender, EventArgs args)
        {
            if (!Login.Instance.IsLoggedIn)
            {
                await Application.Current.MainPage.DisplayAlert("Please login!", "Login to make use of favorites.", "OK");

                return;
            }
            if (iconButton.IsChecked)
            {
                await Favorites.AddFavorite(Appointment);
            }
            else
            {
                await Favorites.RemoveFavorite(Appointment);
            }
        }
Example #3
0
        private void ShowFavMenu()
        {
            var availableListsMenu = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList);
            var currentWorld       = myPageWorldInfo.prop_ApiWorld_0;

            var storedCategories = GetCategoriesInSortedOrder();

            if (storedCategories.Count == 0)
            {
                availableListsMenu.AddLabel("Create some categories first before favoriting worlds!");
            }

            availableListsMenu.AddSimpleButton("Close", () => availableListsMenu.Hide());

            foreach (var storedCategory in storedCategories)
            {
                if (storedCategory.CategoryName == SearchCategoryName)
                {
                    continue;
                }

                availableListsMenu.AddSimpleButton(
                    $"{(!Favorites.IsFavorite(currentWorld.id, storedCategory.CategoryName) ? "Favorite to" : "Unfavorite from")} {storedCategory.CategoryName}",
                    self =>
                {
                    if (Favorites.IsFavorite(currentWorld.id, storedCategory.CategoryName))
                    {
                        Favorites.DeleteFavorite(currentWorld.id, storedCategory.CategoryName);
                    }
                    else
                    {
                        Favorites.AddFavorite(currentWorld.id, storedCategory.CategoryName);
                    }

                    self.SetText($"{(!Favorites.IsFavorite(currentWorld.id, storedCategory.CategoryName) ? "Favorite to" : "Unfavorite from")} {storedCategory.CategoryName}");

                    if (FavCatSettings.HidePopupAfterFav.Value)
                    {
                        availableListsMenu.Hide();
                    }
                });
            }

            availableListsMenu.Show();
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string       t  = Request.QueryString["type"];
         int          id = int.Parse(Request.QueryString["id"]);
         FavoriteType ft = FavoriteType.Outside;
         if (t == "p")
         {
             ft = FavoriteType.Product;
         }
         else if (t == "n")
         {
             ft = FavoriteType.Article;
         }
         else
         {
             throw new HHException(ExceptionType.NoMasterError, "待收藏链接类型错误!");
         }
         Favorite f = new Favorite();
         f.CreateTime    = DateTime.Now;
         f.FavoriteLevel = int.Parse(hfRate.Value);
         f.FavoriteMemo  = txtDesc.Text.Trim();
         f.FavoriteTitle = txtTitle.Text.Trim();
         f.FavoriteType  = ft;
         f.FavoriteUrl   = string.Empty;
         f.RelatedID     = id;
         f.UpdateTime    = DateTime.Now;
         f.UserID        = Profile.AccountInfo.UserID;
         if (Favorites.AddFavorite(f))
         {
             base.ExecuteJs("msg('成功收藏此产品/资讯信息!')", false);
         }
         else
         {
             base.ExecuteJs("msg('收藏对象无法保存,请联系管理员!')", false);
         }
     }
     catch (Exception ex)
     {
         throw new HHException(ExceptionType.NoMasterError, ex.Message);
     }
 }
Example #5
0
        private void ShowFavMenu()
        {
            var availableListsMenu = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList);
            var currentUser        = PageUserInfo.field_Public_APIUser_0;

            var storedCategories = GetCategoriesInSortedOrder();

            if (storedCategories.Count == 0)
            {
                availableListsMenu.AddLabel("Create some categories first before favoriting players!");
            }

            availableListsMenu.AddSimpleButton("Close", () => availableListsMenu.Hide());

            foreach (var storedCategory in storedCategories)
            {
                if (storedCategory.CategoryName == SearchCategoryName)
                {
                    continue;
                }

                Text?buttonText = null;
                availableListsMenu.AddSimpleButton(
                    $"{(!Favorites.IsFavorite(currentUser.id, storedCategory.CategoryName) ? "Favorite to" : "Unfavorite from")} {storedCategory.CategoryName}",
                    () =>
                {
                    if (Favorites.IsFavorite(currentUser.id, storedCategory.CategoryName))
                    {
                        Favorites.DeleteFavorite(currentUser.id, storedCategory.CategoryName);
                    }
                    else
                    {
                        Favorites.AddFavorite(currentUser.id, storedCategory.CategoryName);
                    }

                    buttonText !.text = $"{(!Favorites.IsFavorite(currentUser.id, storedCategory.CategoryName) ? "Favorite to" : "Unfavorite from")} {storedCategory.CategoryName}";

                    if (FavCatSettings.IsHidePopupAfterFav)
                    {
                        availableListsMenu.Hide();
                    }
                },
Example #6
0
        public FontPreviewWindow(string Fontname, FontFamily Fontfamily)
        {
            InitializeComponent();
            Title = Fontname;
            IEnumerable <Label> Labels = null;

            isUpper = false;
            Loaded += (s, e) =>
            {
                Labels = FindVisualChildren <Label>(this);
                foreach (Label L in Labels)
                {
                    L.FontFamily = Fontfamily;
                }
            };
            btnUpper.Click += (s, e) =>
            {
                if (!isUpper)
                {
                    foreach (Label L in Labels)
                    {
                        L.Content = (string)L.Content.ToString().ToUpper();
                    }
                    btnUpper.Content = "Small";
                    isUpper          = true;
                }
                else
                {
                    foreach (Label L in Labels)
                    {
                        L.Content = (string)L.Content.ToString().ToLower();
                    }
                    btnUpper.Content = "Capital";
                    isUpper          = false;
                }
            };
            btnFav.Click += (s, e) =>
            {
                if (Favorites.Exists(Fontname))
                {
                    Favorites.RemoveFavorite(Fontname);
                    ((Button)s).Content = "Add to Favorites";
                }
                else
                {
                    Favorites.AddFavorite(new favorite
                    {
                        date     = DateTime.Now.ToLongDateString(),
                        time     = DateTime.Now.ToLongTimeString(),
                        fontname = Fontname
                    });
                    ((Button)s).Content = "Remove Favorite";
                }

                TabbedWindow.IsFavoriteUpdated = true;
            };

            if (Favorites.Exists(Fontname))
            {
                btnFav.Content = "Remove Favorite";
            }
        }