Exemplo n.º 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:,,,/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:,,,/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);
            }
        }
        public async Task ShowRecommendations()
        {
            if (initialized == false)
            {
                try
                {
                    var recommendationsModel = await apiHelper.GetRecommendedDoujin();

                    var recommendationByUser = recommendationsModel.Users;
                    foreach (var item in recommendationByUser)
                    {
                        TextBlock seperator = new TextBlock {
                            Height     = 40,
                            FontSize   = 30,
                            Width      = recommendations.ActualWidth - 10,
                            Text       = item.Username,
                            Foreground = Brushes.White
                        };
                        recommendations.Children.Add(seperator);
                        foreach (var doujin in item.Ids)
                        {
                            DoujinControl doujinControl = new DoujinControl(doujin);
                            recommendations.Children.Add(doujinControl);
                        }
                    }
                    initialized = true;
                }
                catch (Exception e)
                {
                    DoujinUtility.MainWindow.notificationPanellul.Children.Add(Notifications.Notifications.NotificationNoImg("An error occured", "", e.Message));
                }
            }
        }
Exemplo n.º 3
0
        public void Page(int page)
        {
            try
            {
                Result        result          = DoujinUtility.OutdatedSearch(generalSearch.Text, tagsSearch.Text, artistSearch.Text, charaSearch.Text, parodySearch.Text, popOrder, searchLang(), page);
                List <Doujin> localDoujinList = result.doujinshi;
                foreach (Doujin doujin in result.doujinshi)
                {
                    //Image img = new Image();


                    //Doujin doujin = result.doujinshi.ElementAt(result.images.IndexOf(img));
                    DoujinControl doujinControl = new DoujinControl(doujin);

                    //Console.WriteLine(result.doujinshi.ElementAt(result.images.IndexOf(img)).coverUrl);

                    foreach (Database.DoujinSet.DoujinDataRow row in Database.DatabaseControler.favorites)
                    {
                        if (row.nHentaiID == doujin.nhentaiId)
                        {
                            //doujin = new Doujin(row.nHentaiID);
                            doujin.favorised = true;

                            Console.WriteLine("fav matched");
                            doujinControl.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png"));
                        }
                    }

                    picgrid.Children.Add(doujinControl);

                    /*
                     * var source = new BitmapImage(new Uri(result.doujinshi.ElementAt(result.images.IndexOf(img)).coverUrl));
                     * doujinControl.img.Source = source;
                     * double ratio = source.Width / source.Height;
                     * doujinControl.img.ToolTip = doujin.name;
                     * doujinControl.img.Tag = doujin.nhentaiId;
                     * doujinControl.img.Width = 160;
                     * doujinControl.img.Height = 230;
                     * doujinControl.img.Margin = new Thickness(5, 3, 5, 3);
                     * doujinControl.img.MouseLeftButtonDown += Img_MouseLeftButtonDown;
                     * doujinControl.img.MouseRightButtonDown += Img_MouseRightButtonDown;
                     * doujinControl.heart.MouseLeftButtonDown += Heart_MouseLeftButtonDown;
                     * Thickness margin = doujinControl.Margin;
                     * margin.Right = 10;
                     * margin.Bottom = 10;
                     * doujinControl.Margin = margin;
                     * doujinControl.doujinName.Text = doujin.name;
                     * doujinControl.doujinCreator.Text = doujin.ArtistsConcat();
                     * doujinControl.doujinTags.Text = doujin.TagsConcat();
                     */
                    //DoujinUtility.AddDoujinDataRow(doujin, DatabaseControler.mainDataTable);
                }
                DatabaseControler.mainDataTable.Init(localDoujinList);
            }
            catch
            {
            }
        }
        private void Heart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Image         img     = (Image)sender;
            Grid          grid    = (Grid)img.Parent;
            DoujinControl control = (DoujinControl)grid.Parent;

            DatabaseControler.favorites.RemoveDoujinDataRow(DatabaseControler.favorites.FindBynHentaiID((int)control.img.Tag));
            favgrid.Children.Remove(control);
            if (DoujinUtility.DoujinIsPartOfDataTable((int)control.img.Tag, DatabaseControler.mainDataTable))
            {
                var picGridItem = (DoujinControl)picgrid.Children[DatabaseControler.mainDataTable.FindBynHentaiID((int)control.img.Tag).ID];
                picGridItem.heart.Source = new BitmapImage(new Uri("pack://application:,,,/heart_nofav.png"));
            }
        }
        public async Task <List <DoujinControl> > DisplayNewUploads(UpdateChecker checker, string distinct)
        {
            List <DoujinControl> list = new List <DoujinControl>();


            foreach (var item in checker.newReleases)
            {
                if (item.Value == distinct)
                {
                    DoujinControl control;
                    control = new DoujinControl(item.Key);
                    list.Add(control);
                    await Task.Run(delegate
                    {
                        int i = 1;
                        i++;
                    });
                }
            }
            return(list);
        }
        public void DisplayFavorites()
        {
            search.Visibility    = Visibility.Hidden;
            favscroll.Visibility = Visibility.Visible;
            favscroll.IsEnabled  = true;


            if (favgrid.Children.Count < DatabaseControler.favorites.Count)
            {
                foreach (DoujinDataRow row in DatabaseControler.favorites)
                {
                    /*
                     * DoujinControl doujinControl = new DoujinControl(row.nHentaiID);
                     * doujinControl.heart.Source = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png"));
                     * favgrid.Children.Add(doujinControl);
                     */

                    Doujin doujin = DoujinUtility.DataRowToDoujin(row);
                    if (DoujinUtility.DoujinIsPartOfDataTable(doujin, DatabaseControler.localDummy))
                    {
                        continue;
                    }
                    DoujinControl doujinControl = new DoujinControl();

                    favgrid.Children.Insert(0, doujinControl);

                    var source = new BitmapImage(new Uri(row.coverUrl));
                    doujinControl.img.Source                 = source;
                    doujinControl.img.ToolTip                = doujin.name;
                    doujinControl.img.Tag                    = doujin.nhentaiId;
                    doujinControl.img.Width                  = 160;
                    doujinControl.img.Height                 = 230;
                    doujinControl.img.Margin                 = new Thickness(5, 3, 5, 3);
                    doujinControl.img.MouseLeftButtonDown   += Img_MouseLeftButtonDown;
                    doujinControl.img.MouseRightButtonDown  += Img_MouseRightButtonDown;
                    doujinControl.heart.Source               = new BitmapImage(new Uri("pack://application:,,,/UiElements/heart_fav.png"));
                    doujinControl.heart.MouseLeftButtonDown += Heart_MouseLeftButtonDown;
                    Thickness margin = doujinControl.Margin;
                    margin.Right                     = 10;
                    margin.Bottom                    = 10;
                    doujinControl.Margin             = margin;
                    doujinControl.doujinName.Text    = doujin.name;
                    doujinControl.doujinCreator.Text = doujin.ArtistsConcat();
                    doujinControl.doujinTags.Text    = doujin.TagsConcat();



                    DatabaseControler.localDummy.AddDoujinDataRow(DatabaseControler.mainDataTable.Rows.Count, row.nHentaiID, row.mediaID, row.name, row.fullName, row.artist, row.character, row.parody, row.group, row.tags, row.language, true, row.pages, row.coverUrl, row.extension);
                }
            }
            else if (favgrid.Children.Count > DatabaseControler.favorites.Count)
            {
                List <DoujinControl> controlList = new List <DoujinControl>();
                foreach (DoujinControl doujinControl in favgrid.Children)
                {
                    if (!DoujinUtility.DoujinIsPartOfDataTable((int)doujinControl.img.Tag, DatabaseControler.favorites))
                    {
                        controlList.Add(doujinControl);
                        DatabaseControler.localDummy.RemoveDoujinDataRow(DatabaseControler.localDummy.FindBynHentaiID((int)doujinControl.img.Tag));
                    }
                }
                foreach (DoujinControl doujinControl in controlList)
                {
                    favgrid.Children.Remove(doujinControl);
                }
            }
        }