Exemple #1
0
        private void Heart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Image         obj     = (Image)sender;
            Grid          grid    = (Grid)obj.Parent;
            DoujinControl control = (DoujinControl)grid.Parent;
            int           nhId    = (int)control.img.Tag;

            if (DoujinUtility.CheckFavorised(new Doujin(nhId)))
            {
                DatabaseControler.favorites.FindBynHentaiID(nhId).favorite = false;
                //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = false;
                control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_nofav.png"));
                DatabaseControler.favorites.RemoveDoujinDataRow(DatabaseControler.favorites.FindBynHentaiID(nhId));

                DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath);
            }
            else
            {
                Doujin doujin = new Doujin(nhId);
                //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = true;
                control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png"));
                DoujinUtility.AddDoujinDataRow(doujin, DatabaseControler.favorites);
                DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath);
                //.Add();

                var notify = Notifications.Notifications.NotificationNoImg(doujin.name, "", "The doujin got favorised and you can acess it at your favourite page");

                DoujinUtility.MainWindow.notificationPanellul.Children.Add(notify);
            }
        }
        private void Heart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Image         obj     = (Image)sender;
            Grid          grid    = (Grid)obj.Parent;
            DoujinControl control = (DoujinControl)grid.Parent;
            int           nhId    = (int)control.img.Tag;

            if (DoujinUtility.CheckFavorised(new Doujin(nhId)))
            {
                DatabaseControler.favorites.FindBynHentaiID(nhId).favorite = false;
                //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = false;
                control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_nofav.png"));
                DatabaseControler.favorites.RemoveDoujinDataRow(DatabaseControler.favorites.FindBynHentaiID(nhId));

                DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath);
            }
            else
            {
                Doujin doujin = new Doujin(nhId);
                //DatabaseControler.mainDataTable.FindBynHentaiID(nhId).favorite = true;
                control.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png"));
                DoujinUtility.AddDoujinDataRow(doujin, DatabaseControler.favorites);
                DatabaseControler.favorites.WriteXml(DatabaseControler.favDataPath);
                //.Add();

                var notify = Notifications.Notifications.NotificationNoImg(doujin.name, "", "The doujin got favorised and you can acess it at your favourite page");

                DoujinUtility.MainWindow.notificationPanellul.Children.Add(notify);
                try
                {
                    if (DoujinUtility.MainWindow.accountElement.loggedIn)
                    {
                        DoujinUtility.MainWindow.accountElement.apiHelper.PostFavorite(nhId);
                    }
                    else
                    {
                        DoujinUtility.MainWindow.accountElement.apiHelper.user = Newtonsoft.Json.JsonConvert.DeserializeObject <Doujin_Interface.Connection.Models.AuthenticatedUser>(Doujin_Interface.Properties.Settings.Default.User);
                        DoujinUtility.MainWindow.accountElement.apiHelper.PostFavorite(nhId);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }