コード例 #1
0
 public static void DisplayValue(TextBlock obj, MediaRating rating, double ratio) {
     RatingConverter Conv = new RatingConverter();
     RatingToColorConverter ColorConv = new RatingToColorConverter();
     double? Value = rating.GetValue(ratio);
     obj.Text = Conv.Convert(Value, typeof(string), -1, null).ToString();
     obj.Foreground = (SolidColorBrush)ColorConv.Convert(Value, typeof(SolidColorBrush), null, null);
 }
コード例 #2
0
 private void DisplayData() {
     RatingsList = video.MediaRatings.ToList();
     PM = GetRatingRow("Physical Masculine");
     PF = GetRatingRow("Physical Feminine");
     EM = GetRatingRow("Emotional Masculine");
     EF = GetRatingRow("Emotional Feminine");
     SM = GetRatingRow("Spiritual Masculine");
     SF = GetRatingRow("Spiritual Feminine");
     Love = GetRatingRow("Love");
     Egoless = GetRatingRow("Egoless");
     var CustomCategories = video.MediaRatings.Where(r => r.RatingCategory.Custom).OrderBy(r => r.RatingCategory.Name);
     Custom1 = CustomCategories.FirstOrDefault();
     if (Custom1 != null)
         Custom2 = CustomCategories.Skip(1).FirstOrDefault();
     if (Custom1 != null)
         Custom1Text = Custom1.RatingCategory.Name;
     else
         Custom1 = new MediaRating();
     if (Custom2 != null)
         Custom2Text = Custom2.RatingCategory.Name;
     else
         Custom2 = new MediaRating();
 }
コード例 #3
0
 public MediaRating GetRatingRow(string ratingName) {
     MediaRating Result = RatingsList.Where(r => r.RatingCategory.Name == ratingName).FirstOrDefault();
     if (Result == null)
         Result = new MediaRating();
     return Result;
 }
コード例 #4
0
 public void AddRating(string name, MediaRating rating, List<RatingCategory> categories) {
     if (!string.IsNullOrEmpty(name) && (rating.Height.HasValue || rating.Depth.HasValue)) {
         RatingCategory Rating = categories.Find(c => c.Name.ToLower() == name.ToLower());
         //if (Rating == null) {
         //    Rating = new RatingCategory() { Name = name, Custom = true };
         //    context.RatingCategories.Add(Rating);
         //}
         if (Rating != null)
             video.MediaRatings.Add(new MediaRating() { RatingCategory = Rating, Height = rating.Height, Depth = rating.Depth });
     }
 }
コード例 #5
0
        private void CreateToolTip(TextBlock ctrl, MediaRating rating) {
            if (rating.Height.HasValue || rating.Depth.HasValue) {
                ToolTip NewToolTip = new ToolTip();
                ctrl.ToolTip = NewToolTip;
                StackPanel NewPanel = new StackPanel();
                NewToolTip.Content = NewPanel;
                TextBlock NewTextBlock = new TextBlock();
                NewTextBlock.TextAlignment = TextAlignment.Center;
                NewPanel.Children.Add(NewTextBlock);

                if (rating.Height.HasValue) {
                    NewTextBlock.Inlines.Add(new Run("Height: " + rating.Height.Value));
                    NewTextBlock.Inlines.Add(new LineBreak());
                }
                if (rating.Depth.HasValue) {
                    NewTextBlock.Inlines.Add(new Run("Depth: " + rating.Depth.Value));
                    NewTextBlock.Inlines.Add(new LineBreak());
                }
                NewTextBlock.Inlines.Add(new Run(string.Format("{0} × {1} × 0.11 = {2:0.0}",
                    rating.Height.HasValue ? rating.Height.Value : rating.Depth.Value,
                    rating.Depth.HasValue ? rating.Depth.Value : rating.Height.Value,
                    rating.GetValue(0))));
            } else
                ctrl.ToolTip = null;
        }
コード例 #6
0
        public Media ConvertToMedia(List<MediaCategory> mediaCategories, List<RatingCategory> ratingCategories) {
            Media Result = new Media();
            Result.MediaId = MediaId != Guid.Empty ? MediaId : Guid.NewGuid();
            Result.EditedOn = EditedOn ?? DateTime.Now;
            Result.MediaType = MediaType;
            Result.Artist = Artist ?? string.Empty;
            Result.Album = Album ?? string.Empty;
            Result.Title = Title;
            if (!string.IsNullOrEmpty(Category)) {
                MediaCategory ItemCategory = mediaCategories.FirstOrDefault(v => v.Name == Category && v.MediaTypeId == (int)MediaType);
                if (ItemCategory != null)
                    Result.MediaCategoryId = ItemCategory.MediaCategoryId;
            }
            Result.Preference = Preference;
            Result.Length = Length;
            Result.StartPos = StartPos;
            Result.EndPos = EndPos;
            Result.DownloadName = DownloadName ?? string.Empty;
            Result.DownloadUrl = DownloadUrl ?? string.Empty;
            Result.BuyUrl = BuyUrl ?? string.Empty;

            MediaRating NewRating;
            foreach (SyncRating item in Ratings) {
                NewRating = new MediaRating();
                NewRating.MediaId = Result.MediaId;
                NewRating.RatingId = ratingCategories.FirstOrDefault(r => r.Name == item.Name).RatingId;
                NewRating.Height = (item.Height != -1 ? (double?)item.Height : null);
                NewRating.Depth = (item.Depth != -1 ? (double?)item.Depth : null);
                Result.MediaRatings.Add(NewRating);
            }

            return Result;
        }