Beispiel #1
0
        void ReleaseDesignerOutlets()
        {
            if (ImageLoading != null)
            {
                ImageLoading.Dispose();
                ImageLoading = null;
            }

            if (AuthorLabel != null)
            {
                AuthorLabel.Dispose();
                AuthorLabel = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }

            if (CoverImage != null)
            {
                CoverImage.Dispose();
                CoverImage = null;
            }
        }
        public async Task <FileInfosResponse> SaveImageCover(FileInfosRequest request)
        {
            CoverImage coverImage = new CoverImage
            {
                Attachment  = request.Attachment,
                FileName    = request.FileName,
                Extension   = request.Extension,
                Mime        = request.Mime,
                IsDeleted   = true,
                CreatedDate = DateTime.Now,
                CreatedBy   = Constants.GetUserId()
            };

            _coverImagesRepository.Add(coverImage);

            bool isCreateOk = await _coverImagesRepository.CommitAsync();

            if (isCreateOk)
            {
                return(new FileInfosResponse
                {
                    Id = coverImage.Id,
                    FileName = request.FileName,
                    Extension = request.Extension,
                    FileSize = request.FileLength
                });
            }

            return(null);
        }
Beispiel #3
0
        void ReleaseDesignerOutlets()
        {
            if (CoverImage != null)
            {
                CoverImage.Dispose();
                CoverImage = null;
            }

            if (DescriptionLabel != null)
            {
                DescriptionLabel.Dispose();
                DescriptionLabel = null;
            }

            if (IdLabel != null)
            {
                IdLabel.Dispose();
                IdLabel = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (PictureImage != null)
            {
                PictureImage.Dispose();
                PictureImage = null;
            }
        }
Beispiel #4
0
        public GroupProfileHeaderViewModel(GroupData groupData)
        {
            this.VerifiedVisibility   = Visibility.Collapsed;
            this.CoverImageVisibility = Visibility.Collapsed;
            this.DataVisibility       = Visibility.Collapsed;

            Group group = groupData != null ? groupData.group : null;

            if (group == null)
            {
                return;
            }
            this.Name               = group.name;
            this.Description        = group.GroupType == GroupType.Event ? CommonResources.Event : group.activity;
            this.ProfileImageUrl    = group.photo_200;
            this.VerifiedVisibility = groupData.IsVerified.ToVisiblity();
            CoverImage coverImage = groupData.CoverImage;

            if (coverImage != null)
            {
                this.CoverImageUrl = coverImage.url;
                if (!string.IsNullOrEmpty(this.CoverImageUrl))
                {
                    this.CoverImageVisibility = Visibility.Visible;
                }
            }
            this.HasAvatar      = ProfileHeaderViewModelBase.IsValidAvatarUrl(group.photo_200);
            this.DataVisibility = Visibility.Visible;
        }
 public Stream GetCoverImageAsStream(int width, int height)
 {
     if (CoverImage != null)
     {
         return(CoverImage.ImageWithSize(new CGSize(width, height)).AsJPEG().AsStream());
     }
     return(null);
 }
Beispiel #6
0
        public void GetAndSet_ShouldBePublic()
        {
            var coverImage = new CoverImage();

            coverImage.GameId = 1;

            Assert.True(coverImage.GameId == 1);
        }
Beispiel #7
0
 protected override void WriteObject(AssetsWriter writer)
 {
     base.WriteBase(writer);
     writer.Write(PackID);
     writer.Write(PackName);
     CoverImage.Write(writer);
     BeatmapLevelCollection.Write(writer);
 }
Beispiel #8
0
        public async void AddBook(BookInputModel book)
        {
            var bookEntity = new Book
            {
                Title          = book.Title,
                Isbn           = book.Isbn,
                PublishingYear = book.PublishingYear ?? default(int),
                Type           = book.Type,
                Price          = book.Price ?? default(double),
                PublisherId    = book.PublisherId ?? default(int)
            };

            var bookId = _bookRepo.AddBook(bookEntity);

            var details = new BookDetails
            {
                BookId      = bookId,
                Description = book.Description,
                Font        = book.Font,
                PageCount   = book.PageCount ?? default(int),
                Length      = book.Length ?? default(int)
            };

            _bookRepo.AddBookDetails(details);

            foreach (var id in book.Author)
            {
                var AuthorConnection = new BookAuthorConnection
                {
                    BookId   = bookId,
                    AuthorId = id
                };

                _bookRepo.AddBookAuthorConnection(AuthorConnection);
            }

            foreach (var id in book.Genre)
            {
                var GenreConnection = new BookGenreConnection
                {
                    BookId  = bookId,
                    GenreId = id
                };
                _bookRepo.AddBookGenreConnection(GenreConnection);
            }

            using (var memoryStream = new MemoryStream())
            {
                await book.CoverImage.CopyToAsync(memoryStream);

                var img = new CoverImage
                {
                    BookId = bookId,
                    Img    = memoryStream.ToArray()
                };
                _bookRepo.AddImage(img);
            }
        }
Beispiel #9
0
        public static CoverImage EmptyCoverImage()
        {
            var cover = new CoverImage
            {
                FileNameWithExtension = Path.GetFileName(string.Empty)
            };

            return(cover);
        }
Beispiel #10
0
        public void GetAndSeT_ShouldBePublic()
        {
            var gameProfile = new GameDetails();
            var coverImage  = new CoverImage();

            gameProfile.CoverImage = coverImage;

            Assert.True(gameProfile.CoverImage == coverImage);
        }
        public static CoverImage CreateNew()
        {
            var coverImage = new CoverImage
            {
                FileNameWithExtension = Guid.NewGuid() + ".jpg"
            };

            return(coverImage);
        }
Beispiel #12
0
        public void GetAndSeT_ShouldBePublic()
        {
            var coverImage  = new CoverImage();
            var gameProfile = new GameDetails();

            coverImage.Game = gameProfile;

            Assert.True(coverImage.Game == gameProfile);
        }
Beispiel #13
0
 public override void Write(AssetsWriter writer)
 {
     base.WriteBase(writer);
     writer.Write(PackID);
     writer.Write(PackName);
     CoverImage.Write(writer);
     writer.Write(IsPackAlwaysOwned);
     BeatmapLevelCollection.Write(writer);
 }
Beispiel #14
0
        void ReleaseDesignerOutlets()
        {
            if (SynopsisLoading != null)
            {
                SynopsisLoading.Dispose();
                SynopsisLoading = null;
            }

            if (AuthorLabel != null)
            {
                AuthorLabel.Dispose();
                AuthorLabel = null;
            }

            if (CoverImage != null)
            {
                CoverImage.Dispose();
                CoverImage = null;
            }

            if (GenreLabel != null)
            {
                GenreLabel.Dispose();
                GenreLabel = null;
            }

            if (ImageLoading != null)
            {
                ImageLoading.Dispose();
                ImageLoading = null;
            }

            if (OverviewRoot != null)
            {
                OverviewRoot.Dispose();
                OverviewRoot = null;
            }

            if (PublishDateLabel != null)
            {
                PublishDateLabel.Dispose();
                PublishDateLabel = null;
            }

            if (SynopsisLabel != null)
            {
                SynopsisLabel.Dispose();
                SynopsisLabel = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
Beispiel #15
0
        public void Be_TypeOfInt()
        {
            var coverImage = new CoverImage();

            coverImage.GameId = 1;

            var result = coverImage.GameId.GetType();

            Assert.True(result == typeof(int));
        }
Beispiel #16
0
        public void ShouldBe_IDbModel()
        {
            var coverImager = new CoverImage();

            var result = coverImager
                         .GetType()
                         .GetInterfaces().Any(x => x == typeof(IDbModel));

            Assert.True(result);
        }
Beispiel #17
0
        public void Be_TypeOfCoverImage()
        {
            var gameProfile = new GameDetails();
            var coverImage  = new CoverImage();

            gameProfile.CoverImage = coverImage;

            var result = gameProfile.CoverImage.GetType();

            Assert.True(result == typeof(CoverImage));
        }
Beispiel #18
0
        public void Be_TypeOfGameProfile()
        {
            var coverImage  = new CoverImage();
            var gameProfile = new GameDetails();

            coverImage.Game = gameProfile;

            var result = coverImage.Game.GetType();

            Assert.True(result == typeof(GameDetails));
        }
Beispiel #19
0
        public MusicInfo(string path)
        {
            try
            {
                if (System.IO.File.Exists(path))
                {
                    TagLib.File file  = TagLib.File.Create(path);
                    Shell       shell = new Shell();
                    string      p     = path.ToString();
                    Folder      dir   = shell.NameSpace(System.IO.Path.GetDirectoryName(p));
                    FolderItem  item  = dir.ParseName(System.IO.Path.GetFileName(p));
                    Path  = path;
                    Title = dir.GetDetailsOf(item, 21);
                    if (String.IsNullOrEmpty(Title))
                    {
                        Title = GetTitleFromPath(path);
                    }
                    Album = dir.GetDetailsOf(item, 14);
                    if (String.IsNullOrEmpty(Album))
                    {
                        Album = "未知专辑";
                    }
                    Artist = dir.GetDetailsOf(item, 13);
                    if (String.IsNullOrEmpty(Artist))
                    {
                        Artist = "未知歌手";
                    }
                    //Tarck
                    Track = (int)file.Tag.Track;

                    //封面
                    if (file.Tag.Pictures.Count() != 0)
                    {
                        CoverImage = ByteToBitmapImage(file.Tag.Pictures[0].Data.Data);
                        if (CoverImage.CanFreeze)
                        {
                            CoverImage.Freeze();
                        }
                    }

                    SampleRate = file.Properties.AudioSampleRate;
                    Duration   = file.Properties.Duration;
                    Bitrate    = file.Properties.AudioBitrate;
                    file.Dispose();
                }
            }
            catch { }
        }
Beispiel #20
0
        public List <string> VerifyTodoData([NotNull] bool isUpdating = false)
        {
            var errorMessages = new List <string>();

            Title = Title?.Trim();
            if (!Helpers.IsProperString(Title))
            {
                Title = null;
            }
            else if (Title?.Length > 100)
            {
                errorMessages.Add("Title is too long. Max 100 characters.");
            }

            Description = Description?.Trim();
            if (!Helpers.IsProperString(Description))
            {
                Description = null;
            }
            else if (Description?.Length > 300)
            {
                errorMessages.Add("Description is too long. Max 300 characters.");
            }

            Details = Details?.Trim();
            if (!Helpers.IsProperString(Details))
            {
                Details = null;
            }

            if (Title == null && Description == null && Details == null)
            {
                errorMessages.Add("Please enter some information for one of Title, Description or Details.");
            }

            CoverImage = CoverImage?.Trim();
            if (CoverImage != null)
            {
                Regex.Replace(CoverImage, SharedConstants.AllSpaces, string.Empty);
            }

            if (!isUpdating)
            {
                CreatedOn = DateTime.UtcNow;
            }

            return(errorMessages);
        }
Beispiel #21
0
        public async Task <Book> Add(Book book, CoverImage coverImage)
        {
            book.Id         = Guid.NewGuid();
            book.CoverImage = new CoverImage
            {
                Id          = Guid.NewGuid(),
                Content     = coverImage.Content,
                ContentType = coverImage.ContentType
            };

            await _context.Books.AddAsync(book);

            await _context.SaveChangesAsync();

            return(await GetBook(book.Id));
        }
Beispiel #22
0
        public static CoverImage ToCoverImage(this IFormFile file)
        {
            if (file.Length > 0)
            {
                var img = new CoverImage
                {
                    ContentType = file.ContentType
                };

                using var ms = new MemoryStream();
                file.CopyTo(ms);
                img.Content = ms.ToArray();
                return(img);
            }

            return(null);
        }
Beispiel #23
0
        public async Task <Book> Update(Guid id, Book newBook, CoverImage coverImage)
        {
            // Preventing modification of different entity
            var book = await GetBookWithImage(id);

            book.Id                     = id;
            book.Author                 = newBook.Author;
            book.Title                  = newBook.Title;
            book.Description            = newBook.Description;
            book.Price                  = newBook.Price;
            book.CoverImage.Content     = coverImage.Content;
            book.CoverImage.ContentType = coverImage.ContentType;

            _context.Books.Attach(book).State             = EntityState.Modified;
            _context.Images.Attach(book.CoverImage).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(await GetBook(id));
        }
Beispiel #24
0
        void StartCoverAnimation(CancellationTokenSource tokenSource)
        {
            try
            {
                animateTimerCancellationTokenSource = tokenSource;

                Device.BeginInvokeOnMainThread(async() =>
                {
                    if (!animateTimerCancellationTokenSource.IsCancellationRequested)
                    {
                        await CoverImage.RelRotateTo(360, Settings.CoverAnimationDuration, Easing.Linear);

                        StartCoverAnimation(animateTimerCancellationTokenSource);
                    }
                });
            }
            catch (TaskCanceledException ex)
            {
                Debug.WriteLine(ex);
            }
        }
Beispiel #25
0
        /// <summary>
        /// Initializes the bindings for the page controls.
        /// </summary>
        void InitBindings()
        {
            CoverImage.SetBinding(Image.SourceProperty, "ImageSmall");

            SeriesNoEntry.SetBinding(Entry.TextProperty,
                                     new Binding("SeriesNumber")
            {
                Mode = BindingMode.TwoWay
            });
            SeriesNameEntry.SetBinding(Entry.TextProperty,
                                       new Binding("SeriesName")
            {
                Mode = BindingMode.TwoWay
            });
            WriterEntry.SetBinding(Entry.TextProperty,
                                   new Binding("Writer")
            {
                Mode = BindingMode.TwoWay
            });
            PencillerEntry.SetBinding(Entry.TextProperty,
                                      new Binding("Penciller")
            {
                Mode = BindingMode.TwoWay
            });
            InkerEntry.SetBinding(Entry.TextProperty,
                                  new Binding("Inker")
            {
                Mode = BindingMode.TwoWay
            });
            ColoristEntry.SetBinding(Entry.TextProperty,
                                     new Binding("Colorist")
            {
                Mode = BindingMode.TwoWay
            });
            LettererEntry.SetBinding(Entry.TextProperty,
                                     new Binding("Letterer")
            {
                Mode = BindingMode.TwoWay
            });
            EditorEntry.SetBinding(Entry.TextProperty,
                                   new Binding("Editor")
            {
                Mode = BindingMode.TwoWay
            });
            StoryTitleEntry.SetBinding(Entry.TextProperty,
                                       new Binding("StoryTitle")
            {
                Mode = BindingMode.TwoWay
            });
            CharacterEntry.SetBinding(Entry.TextProperty,
                                      new Binding("Character")
            {
                Mode = BindingMode.TwoWay
            });
            ISBNEntry.SetBinding(Entry.TextProperty,
                                 new Binding("ISBN")
            {
                Mode = BindingMode.TwoWay
            });
            BarcodeEntry.SetBinding(Entry.TextProperty,
                                    new Binding("Barcode")
            {
                Mode = BindingMode.TwoWay
            });
        }
Beispiel #26
0
        public IActionResult OnPostCreatePost()
        {
            if (!ModelState.IsValid)
            {
                UserId = NewPost.UserId;
                LoadModel();
                return(Page());
            }

            try
            {
                if (CoverImage != null)
                {
                    var fileName = CoverImage.FileName;
                    // Check extension and size
                    var ext = Path.GetExtension(fileName).ToLowerInvariant();
                    if (string.IsNullOrEmpty(ext) || !permittedExtensions.Contains(ext))
                    {
                        ModelState.AddModelError("CoverImage", "Only .jpg extensions are accepted");

                        UserId = NewPost.UserId;
                        LoadModel();
                        return(Page());
                    }
                    if (CoverImage.Length > fileSizeLimit)
                    {
                        ModelState.AddModelError("CoverImage", "Too large file size");

                        UserId = NewPost.UserId;
                        LoadModel();
                        return(Page());
                    }

                    NewPost.HasImage = true;

                    int postId = postService.CreatePost(NewPost);

                    if (CoverImage != null && CoverImage.Length > 0)
                    {
                        int currentUserId = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));
                        var filePath      = Path.Combine(this.environment.WebRootPath, $"imgs/posts/{currentUserId}/{postId}{ext}");
                        using (var stream = System.IO.File.Create(filePath))
                        {
                            CoverImage.CopyTo(stream);
                        }
                    }
                }
                else
                {
                    NewPost.HasImage = false;
                    postService.CreatePost(NewPost);
                }
                return(RedirectToPage("/Profile", new { Id = NewPost.UserId }));
            }
            catch (Exception ex)
            {
                // TODO: Log
                ModelState.AddModelError("", "An error occurred while creating your post");
            }

            UserId = NewPost.UserId;
            LoadModel();
            return(Page());
        }
Beispiel #27
0
 public void ModImage(CoverImage img)
 {
     _db.Update(img);
     _db.SaveChanges();
 }
Beispiel #28
0
 public void AddImage(CoverImage img)
 {
     _db.Add(img);
     _db.SaveChanges();
 }
 private async void Border_PointerExited(object sender, PointerRoutedEventArgs e)
 {
     Title.Scale             = new System.Numerics.Vector3(1, 1, 0);
     Description.Translation = new System.Numerics.Vector3(0, 150, 0);
     await CoverImage.Blur(value : 0, duration : 700, delay : 0).StartAsync();
 }
        /// <summary>
        /// カバーフローを初期化する。
        /// </summary>
        private void Initialize()
        {
            _coverImages = new System.Collections.Generic.Dictionary<int, CoverImage>();
            _onscreenCovers = new System.Collections.Generic.Dictionary<int, ItemView>();
            _offscreenCovers = new System.Collections.Generic.Stack<ItemView>();
            #if false
            // デフォルト画像の作成
            _defaultImage = new CoverImage(_dataSource.RequestDefaultImage(this));
            #endif
            // スクロールビューの作成
            _scrollView = new MonoTouch.UIKit.UIScrollView(Frame)
            {
                UserInteractionEnabled = false,
                MultipleTouchEnabled = false,
                AutoresizingMask = MonoTouch.UIKit.UIViewAutoresizing.FlexibleHeight | MonoTouch.UIKit.UIViewAutoresizing.FlexibleWidth
            };
            AddSubview(_scrollView);

            MultipleTouchEnabled = false;
            UserInteractionEnabled = true;
            AutosizesSubviews = true;

            //Layer.Position = new System.Drawing.PointF((float)(Frame.Size.Width / 2), (float)(Frame.Height / 2));
            Layer.Position = new System.Drawing.PointF((float)(Frame.Left + Frame.Size.Width / 2), (float)(Frame.Top + Frame.Height / 2));

            // Initialize the visible and selected cover range.
            _lowerVisibleCover = _upperVisibleCover = -1;
            _selectedCoverView = null;

            // Set up transforms
            UpdateTransforms();

            // Set some perspective
            var sublayerTransform = MonoTouch.CoreAnimation.CATransform3D.Identity;
            sublayerTransform.m34 = -0.01f;
            _scrollView.Layer.SublayerTransform = sublayerTransform;

            Bounds = Frame;
        }
 /// <summary>
 /// カバー用画像を更新する。
 /// </summary>
 /// <param name="aCover"></param>
 void UpdateCoverImage(ItemView aCover)
 {
     if (_coverImages.ContainsKey(aCover.Number))
     {
         // リスト内から割り当て
         aCover.SetImage(_coverImages[aCover.Number].Image, _coverImages[aCover.Number].Height, kReflectionFraction);
     }
     else
     {
         // データソースに要求
         if (null != _dataSource)
         {
             MonoTouch.UIKit.UIImage image = _dataSource.RequestImage(this, aCover.Number);
             if (null != image)
             {
                 _coverImages.Add(aCover.Number, new CoverImage(image));
                 aCover.SetImage(_coverImages[aCover.Number].Image, _coverImages[aCover.Number].Height, kReflectionFraction);
             }
             else
             {
                 if (null == _defaultImage)
                 {
                     _defaultImage = new CoverImage(_dataSource.RequestDefaultImage(this));
                 }
                 aCover.SetImage(_defaultImage.Image, _defaultImage.Height, kReflectionFraction);
             }
         }
     }
 }
Beispiel #32
0
 public void Dispose()
 {
     CoverImage?.Dispose();
 }