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; } }
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); }