public static void AddImage(byte[] objImage, IMyCollectionsData entity, bool isDefault)
        {
            byte[] image = Util.CreateSmallCover(objImage, Util.ThumbHeight, Util.ThumbWidth);
            if (image != null)
            {
                Ressource objRessource = new Ressource();
                objRessource.ItemId        = entity.Id;
                objRessource.ResourcesType = CommonServices.GetRessourceType("Image");
                objRessource.Value         = objImage;

                if (isDefault == true)
                {
                    foreach (Ressource item in entity.Ressources)
                    {
                        if (item.IsDefault == true)
                        {
                            item.IsDefault = false;
                            break;
                        }
                    }
                    entity.Cover = image;
                }
                objRessource.IsDefault = isDefault;
                entity.Ressources.Add(objRessource);
            }
        }
示例#2
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                Total = _objEntity.Count();
                IServices service = null;

                //Fix Since 2.5.5.0
                for (int i = 0; i < _objEntity.Count(); i++)
                {
                    ThumbItem item = _objEntity.ElementAt(i);

                    if (_isCancelationPending == true)
                    {
                        break;
                    }

                    if (service == null)
                    {
                        service = Util.GetService(item.EType);
                    }

                    IMyCollectionsData currentItem = service.Get(item.Id);
                    service.GetInfoFromWeb(currentItem);
                    service.Add(currentItem);

                    Current++;
                }
            }
            catch (Exception ex)
            {
                Util.LogException(ex);
            }
        }
        private static void DrawImage(Ressource image, Graphics graphics, IMyCollectionsData entity, PrintDocument printDocument)
        {
            MemoryStream objImageMemory = new MemoryStream(image.Value, 0, image.Value.Length);

            objImageMemory.Write(image.Value, 0, image.Value.Length);
            Image imgCover = Image.FromStream(objImageMemory, true);

            if ((entity.ObjectType == EntityType.Music || entity.ObjectType == EntityType.Games || entity.ObjectType == EntityType.Nds) && image.IsDefault == true)
            {
                graphics.DrawImage(imgCover, new Rectangle(100, 100, 473, 473));
            }
            else if (image.IsDefault == true)
            {
                graphics.DrawImage(imgCover, new Rectangle(100, 100, 524, 721));
            }
            else if (imgCover.Width > printDocument.DefaultPageSettings.PrintableArea.Width || imgCover.Height > printDocument.DefaultPageSettings.PrintableArea.Height)
            {
                graphics.DrawImage(imgCover, new Rectangle(100, 100, (int)printDocument.DefaultPageSettings.PrintableArea.Width - 200, (int)printDocument.DefaultPageSettings.PrintableArea.Height - 200));
            }
            else
            {
                graphics.DrawImage(imgCover, new Rectangle(100, 100, imgCover.Width - 200, imgCover.Height - 200));
            }
            imgCover.Dispose();
            objImageMemory.Dispose();
        }
示例#4
0
        private static Links SaveLinks(string value, IMyCollectionsData entity)
        {
            string entityId = entity.Id;

            switch (entity.ObjectType)
            {
            case EntityType.Apps:
                return(Dal.GetInstance.CreateLinks("App_Links", "App_Id", entityId, "Url", value));

            case EntityType.Books:
                return(Dal.GetInstance.CreateLinks("Book_Links", "Books_Id", entityId, "Url", value));

            case EntityType.Games:
                return(Dal.GetInstance.CreateLinks("Gamez_Links", "Gamez_Id", entityId, "Url", value));

            case EntityType.Movie:
                return(Dal.GetInstance.CreateLinks("Movie_Links", "Movie_Id", entityId, "Url", value));

            case EntityType.Music:
                return(Dal.GetInstance.CreateLinks("Music_Links", "Music_Id", entityId, "Url", value));

            case EntityType.Nds:
                return(Dal.GetInstance.CreateLinks("Nds_Links", "Nds_ID", entityId, "Url", value));

            case EntityType.Series:
                return(Dal.GetInstance.CreateLinks("Series_Links", "Series_Id", entity.SerieId, "Url", value));

            case EntityType.XXX:
                return(Dal.GetInstance.CreateLinks("XXX_Links", "XXX_Id", entityId, "Url", value));
            }
            return(null);
        }
示例#5
0
        public static Links GetLink(string value, IMyCollectionsData entity)
        {
            switch (entity.ObjectType)
            {
            case EntityType.Apps:
                return(Dal.GetInstance.GetLink(value, entity.Id, "App_Links", "App_Id"));

            case EntityType.Books:
                return(Dal.GetInstance.GetLink(value, entity.Id, "Book_Links", "Books_Id"));

            case EntityType.Games:
                return(Dal.GetInstance.GetLink(value, entity.Id, "Gamez_Links", "Gamez_Id"));

            case EntityType.Movie:
                return(Dal.GetInstance.GetLink(value, entity.Id, "Movie_Links", "Movie_Id"));

            case EntityType.Music:
                return(Dal.GetInstance.GetLink(value, entity.Id, "Music_Links", "Music_Id"));

            case EntityType.Nds:
                return(Dal.GetInstance.GetLink(value, entity.Id, "Nds_Links", "Nds_ID"));

            case EntityType.Series:
                return(Dal.GetInstance.GetLink(value, entity.SerieId, "Series_Links", "Series_Id"));

            case EntityType.XXX:
                return(Dal.GetInstance.GetLink(value, entity.Id, "XXX_Links", "XXX_Id"));
            }

            return(null);
        }
示例#6
0
 public static void AddLinks(IEnumerable <string> lstItem, IMyCollectionsData objEntity, bool toBeSaved)
 {
     foreach (string item in lstItem)
     {
         AddLinks(item, objEntity, toBeSaved);
     }
 }
示例#7
0
        public static void AddGenre(string strType, IMyCollectionsData entity, bool save)
        {
            List <string> lstTypes = new List <string>();

            string[] strTemp;

            if (strType.Contains("|"))
            {
                strTemp = strType.Split("|".ToCharArray());
            }
            else
            {
                strTemp = strType.Split(",".ToCharArray());
            }

            foreach (string item in strTemp)
            {
                string strValue = Util.GetValueBetween(item, ">", "</a>");
                if (String.IsNullOrWhiteSpace(strValue) == false)
                {
                    lstTypes.Add(strValue);
                }
            }

            AddGenres(lstTypes, entity, save);
        }
示例#8
0
 public static void AddLinks(IEnumerable <Links> lstItem, IMyCollectionsData objEntity, bool toBeSaved)
 {
     foreach (Links item in lstItem)
     {
         if (toBeSaved == true && item.IsOld == false)
         {
             SaveLinks(item.Path, objEntity);
         }
     }
 }
示例#9
0
        private void Export <T>(IServices service, XmlWriter xmlWriter)
        {
            IList items = service.GetAll();

            for (int i = 0; i < items.Count; i++)
            {
                IMyCollectionsData entity = items[i] as IMyCollectionsData;

                switch (entity.ObjectType)
                {
                case EntityType.Apps:
                    Dal.GetInstance.GetChild(entity as Apps);
                    break;

                case EntityType.Books:
                    Dal.GetInstance.GetChild(entity as Books, false);
                    break;

                case EntityType.Games:
                    Dal.GetInstance.GetChild(entity as Gamez);
                    break;

                case EntityType.Movie:
                    Dal.GetInstance.GetChild(entity as Movie, false);
                    break;

                case EntityType.Music:
                    Dal.GetInstance.GetChild(entity as Music, false);
                    break;

                case EntityType.Nds:
                    Dal.GetInstance.GetChild(entity as Nds);
                    break;

                case EntityType.Series:
                    Dal.GetInstance.GetChild(entity as SeriesSeason, false);
                    break;

                case EntityType.XXX:
                    Dal.GetInstance.GetChild(entity as XXX, false);
                    break;
                }

                if (_isCancelationPending == true)
                {
                    break;
                }

                CreateMagic(xmlWriter, entity);
                _intAddedItem++;
                Current++;
                items[i] = null;
            }
        }
示例#10
0
        public static void AddArtist(string artistName, IMyCollectionsData objEntity)
        {
            bool isNew;

            if (String.IsNullOrWhiteSpace(artistName))
            {
                return;
            }

            SaveArtist(Get(artistName, out isNew), objEntity);
        }
示例#11
0
        public static void SaveArtist(Artist artist, IMyCollectionsData entity)
        {
            if (artist.IsOld == false)
            {
                if (artist.Job == null)
                {
                    Job objJob = GetJob(entity.ObjectType);
                    artist.Job = objJob;
                }

                Dal.GetInstance.AddArtist(artist, entity);
            }
        }
示例#12
0
 public TvixThemeManager(XXX objItem, string strThemePath)
 {
     InitializeComponent();
     chkGames.IsEnabled  = false;
     chkXXX.IsChecked    = true;
     chkMusic.IsEnabled  = false;
     chkSeries.IsEnabled = false;
     chkMovies.IsEnabled = false;
     _strThemePath       = strThemePath;
     _objItem            = objItem;
     cmdGenerate.Content = Application.Current.FindResource("cmdGenerateFile");
     CommonLoad();
 }
示例#13
0
 public static void Link(IMyCollectionsData entity, IEnumerable <string> metadas)
 {
     if (metadas.Any())
     {
         foreach (string metadata in metadas)
         {
             string metaDataId = Dal.GetInstance.GetMetaDataId(metadata, entity.ObjectType);
             if (string.IsNullOrWhiteSpace(metaDataId) == false)
             {
                 Dal.GetInstance.LinkMetaData(entity, metaDataId);
             }
         }
     }
 }
        public static void UpdateRessources(IMyCollectionsData entity)
        {
            if (entity != null)
            {
                DeleteRessources(entity.Id, entity.ObjectType);
                if (entity.Ressources != null && entity.Ressources.Count > 0)
                {
                    foreach (Ressource ressource in entity.Ressources)
                    {
                        if (ressource.IsOld == false)
                        {
                            switch (entity.ObjectType)
                            {
                            case EntityType.Apps:
                                Dal.GetInstance.AddRessource("Apps_Ressources", "Apps_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Books:
                                Dal.GetInstance.AddRessource("Books_Ressources", "Books_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Games:
                                Dal.GetInstance.AddRessource("Gamez_Ressources", "Gamez_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Movie:
                                Dal.GetInstance.AddRessource("Movie_Ressources", "Movie_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Music:
                                Dal.GetInstance.AddRessource("Music_Ressources", "Music_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Nds:
                                Dal.GetInstance.AddRessource("Nds_Ressources", "Nds_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.Series:
                                Dal.GetInstance.AddRessource("SeriesSeason_Ressources", "SeriesSeason_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;

                            case EntityType.XXX:
                                Dal.GetInstance.AddRessource("XXX_Ressources", "XXX_Id", entity.Id, ressource.ResourcesType.Id, ressource.Value, ressource.Link, ressource.IsDefault);
                                break;
                            }
                        }
                    }
                }
            }
        }
示例#15
0
        public static void DeleteSelectedListBoxItem(IList lstSelectedItems)
        {
            foreach (ListBoxItem item in lstSelectedItems)
            {
                IMyCollectionsData data = item.DataContext as IMyCollectionsData;

                if (data != null)
                {
                    switch (data.ObjectType)
                    {
                    case EntityType.Apps:
                        AppServices.Delete(data.Id);
                        break;

                    case EntityType.Artist:
                        ArtistServices.Delete(data.Id);
                        break;

                    case EntityType.Books:
                        BookServices.Delete(data.Id);
                        break;

                    case EntityType.Games:
                        GameServices.Delete(data.Id);
                        break;

                    case EntityType.Movie:
                        MovieServices.Delete(data.Id);
                        break;

                    case EntityType.Music:
                        MusicServices.Delete(data.Id);
                        break;

                    case EntityType.Nds:
                        NdsServices.Delete(data.Id);
                        break;

                    case EntityType.Series:
                        SerieServices.Delete(data.Id);
                        break;

                    case EntityType.XXX:
                        XxxServices.Delete(data.Id);
                        break;
                    }
                }
            }
        }
示例#16
0
        private void cmdUpdate_Click(object sender, RoutedEventArgs e)
        {
            Cursor = Cursors.Wait;
            List <string> lstGenres = (from CheckBox item in RootPanel.Children
                                       where item.IsChecked == true
                                       select item.Content.ToString()).ToList();

            foreach (ThumbItem item in _items)
            {
                IMyCollectionsData entity = _service.Get(item.Id);
                GenreServices.UnlinkGenre(entity);
                GenreServices.AddGenres(lstGenres, entity, true);
            }

            Close();
            Cursor = null;
        }
        public static void SetDefaultCover(int index, IMyCollectionsData entity)
        {
            foreach (Ressource item in entity.Ressources)
            {
                if (item.IsDefault == true)
                {
                    item.IsDefault = false;
                    break;
                }
            }

            if (entity.Ressources.Count > 0)
            {
                Ressource image = entity.Ressources.ElementAt(index);
                image.IsDefault = true;
                entity.Cover    = Util.CreateSmallCover(image.Value, Util.ThumbHeight, Util.ThumbWidth);
            }
        }
 public static string Print(int index, IMyCollectionsData entity)
 {
     if (entity.Ressources.Any())
     {
         Ressource image = entity.Ressources[index];
         if (image != null)
         {
             PrintDocument printDocument = new PrintDocument();
             printDocument.PrintPage += (sender, args) => DrawImage(image, args.Graphics, entity, printDocument);
             printDocument.Print();
             return(string.Empty);
         }
         return("Nothing to print");
     }
     else
     {
         return("Nothing to print");
     }
 }
 public static byte[] GetDefaultCover(IMyCollectionsData entity, out int index)
 {
     index = 0;
     if (entity != null)
     {
         foreach (Ressource item in entity.Ressources)
         {
             if (item.IsDefault == true && item.IsOld == false)
             {
                 return(item.Value);
             }
             else
             {
                 index++;
             }
         }
     }
     return(null);
 }
        public static void SetBackground(int index, IMyCollectionsData entity)
        {
            ResourcesType backgroundType = CommonServices.GetRessourceType("Background");
            ResourcesType imageType      = CommonServices.GetRessourceType("Image");

            foreach (Ressource item in entity.Ressources)
            {
                if (item.ResourcesType.Id == backgroundType.Id)
                {
                    item.ResourcesType = imageType;
                    break;
                }
            }

            Ressource image = entity.Ressources[index];

            image.ResourcesType.Id   = backgroundType.Id;
            image.ResourcesType.Name = backgroundType.Name;
            image.ResourcesType      = backgroundType;
        }
示例#21
0
        public static void AddGenres(IEnumerable <string> lstGenres, IMyCollectionsData objEntity, bool save)
        {
            try
            {
                //FIX since 2.7.12.0
                if (lstGenres != null)
                {
                    foreach (string item in lstGenres)
                    {
                        //Fix 2.8.0.0
                        if (String.IsNullOrWhiteSpace(item) == false)
                        {
                            string strTemp = Util.PurgeHtml(item.Trim());
                            bool   bFind   = objEntity.Genres.Any(objType => objType.DisplayName == strTemp);

                            if (bFind == false && save == false)
                            {
                                Genre genre = GetGenre(item, objEntity.ObjectType);
                                objEntity.Genres.Add(genre);
                            }
                            if (save == true)
                            {
                                Genre genre = GetGenre(item, objEntity.ObjectType);
                                Dal.GetInstance.AddGenre(genre, objEntity.ObjectType);
                                Dal.GetInstance.LinkGenre(objEntity, genre.Id);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                string param = string.Empty;
                if (objEntity != null)
                {
                    param = objEntity.Title;
                }
                Util.LogException(exception, param);
                throw;
            }
        }
        public static void AddBackground(byte[] objImage, IMyCollectionsData entity)
        {
            if (objImage == null)
            {
                return;
            }

            Ressource objRessource = new Ressource();

            objRessource.IsDefault     = false;
            objRessource.ItemId        = entity.Id;
            objRessource.ResourcesType = CommonServices.GetRessourceType("Background");
            objRessource.Value         = objImage;

            if (entity.Ressources == null)
            {
                entity.Ressources = new List <Ressource>();
            }

            entity.Ressources.Add(objRessource);
        }
示例#23
0
        public static void AddGenres(IEnumerable <Genre> lstGenres, IMyCollectionsData objEntity, bool save)
        {
            foreach (Genre item in lstGenres)
            {
                if (String.IsNullOrWhiteSpace(item.RealName.Trim()) == false)
                {
                    bool bFind = objEntity.Genres.Any(objType => objType.RealName == item.RealName);

                    if (bFind == false && save == false)
                    {
                        objEntity.Genres.Add(item);
                    }

                    if (save == true)
                    {
                        Dal.GetInstance.AddGenre(item, objEntity.ObjectType);
                        Dal.GetInstance.LinkGenre(objEntity, item.Id);
                    }
                }
            }
        }
示例#24
0
        private static void UpdateArtist(IMyCollectionsData entity, IEnumerable <string> artistName)
        {
            if (entity.Artists != null && entity.Artists.Any())
            {
                foreach (Artist artist in entity.Artists)
                {
                    Dal.GetInstance.UnlinkArtist(artist, entity);
                }
            }

            if (artistName != null)
            {
                ArtistServices.AddArtists(artistName, entity);
            }
            else if (entity.Artists != null)
            {
                foreach (Artist artist in entity.Artists)
                {
                    ArtistServices.SaveArtist(artist, entity);
                }
            }
        }
示例#25
0
 public static void AddArtists(IEnumerable <string> artists, IMyCollectionsData entity)
 {
     if (artists != null)
     {
         foreach (string item in artists)
         {
             if (String.IsNullOrWhiteSpace(item) == false)
             {
                 if (entity.Artists == null || entity.Artists.Any(x => x.FulleName.ToUpper() == item.ToUpper()) == false)
                 {
                     bool isNew;
                     SaveArtist(Get(item, out isNew), entity);
                 }
                 else
                 {
                     Artist artist = entity.Artists.First(x => x.FulleName.ToUpper() == item.ToUpper() && x.IsOld == false);
                     SaveArtist(artist, entity);
                 }
             }
         }
     }
 }
示例#26
0
        public static void Add(IEnumerable <string> subs, IMyCollectionsData objEntity)
        {
            foreach (string item in subs)
            {
                string sub = item.Trim();
                if (string.IsNullOrWhiteSpace(sub) == false)
                {
                    Language lang = LanguageServices.GetLanguage(sub, true);

                    bool bFind = objEntity.Subtitles.Any(movieSub => movieSub.DisplayName == lang.DisplayName);

                    if (bFind == false)
                    {
                        lang             = new Language();
                        lang.ShortName   = sub;
                        lang.DisplayName = sub;

                        objEntity.Subtitles.Add(lang);
                    }
                }
            }
        }
        public static byte[] GetBackground(IMyCollectionsData entity)
        {
            byte[] objBackground = null;
            if (entity != null)
            {
                IEnumerable <Ressource> objRessources = entity.Ressources;

                if (objRessources != null)
                {
                    foreach (Ressource item in objRessources)
                    {
                        if (item.ResourcesType.Name == "Background")
                        {
                            objBackground = item.Value;
                            break;
                        }
                    }
                }
            }

            return(objBackground);
        }
示例#28
0
        public static void AddLinks(string link, IMyCollectionsData objEntity, bool toBeSaved)
        {
            string cleanLink = link.Trim();

            if (String.IsNullOrWhiteSpace(cleanLink) == false)
            {
                Links objLink = GetLink(cleanLink, objEntity);
                if (objLink == null)
                {
                    if (toBeSaved == true)
                    {
                        objLink = SaveLinks(cleanLink, objEntity);
                    }
                    else
                    {
                        objLink        = new Links();
                        objLink.ItemId = objEntity.Id;
                        objLink.Path   = cleanLink;
                        objLink.Type   = "Url";
                    }

                    if (objEntity.Links == null)
                    {
                        objEntity.Links = new List <Links>();
                    }

                    objEntity.Links.Add(objLink);
                }
                else
                {
                    Links oldLinks = objEntity.Links.FirstOrDefault(x => x.Id == objLink.Id);
                    if (oldLinks != null)
                    {
                        oldLinks.IsOld = false;
                    }
                }
            }
        }
示例#29
0
        public static IList <string> GetCast(IMyCollectionsData entity)
        {
            List <string> cast = new List <string>();

            if (entity != null)
            {
                if (entity.Artists.Count > 0)
                {
                    foreach (Artist item in entity.Artists)
                    {
                        if (item != null)
                        {
                            if (cast.Contains(item.FulleName) == false)
                            {
                                cast.Add(item.FulleName);
                            }
                        }
                    }
                }
            }

            return(cast);
        }
示例#30
0
        public static IList <string> GetGenres(IMyCollectionsData entity)
        {
            List <string> genres = new List <string>();

            if (entity != null)
            {
                if (entity.Genres.Count > 0)
                {
                    foreach (Genre item in entity.Genres)
                    {
                        if (item != null)
                        {
                            if (genres.Contains(item.DisplayName) == false)
                            {
                                genres.Add(item.DisplayName);
                            }
                        }
                    }
                }
            }

            return(genres);
        }