TitleElement.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using System.Windows;
  2. using System.Windows.Media;
  3. using HandyControl.Data;
  4. namespace HandyControl.Controls;
  5. public class TitleElement
  6. {
  7. public static readonly DependencyProperty TitleProperty = DependencyProperty.RegisterAttached(
  8. "Title", typeof(string), typeof(TitleElement), new PropertyMetadata(default(string)));
  9. public static void SetTitle(DependencyObject element, string value)
  10. => element.SetValue(TitleProperty, value);
  11. public static string GetTitle(DependencyObject element)
  12. => (string) element.GetValue(TitleProperty);
  13. public static readonly DependencyProperty BackgroundProperty = DependencyProperty.RegisterAttached(
  14. "Background", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
  15. public static void SetBackground(DependencyObject element, Brush value)
  16. => element.SetValue(BackgroundProperty, value);
  17. public static Brush GetBackground(DependencyObject element)
  18. => (Brush) element.GetValue(BackgroundProperty);
  19. public static readonly DependencyProperty ForegroundProperty = DependencyProperty.RegisterAttached(
  20. "Foreground", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
  21. public static void SetForeground(DependencyObject element, Brush value)
  22. => element.SetValue(ForegroundProperty, value);
  23. public static Brush GetForeground(DependencyObject element)
  24. => (Brush) element.GetValue(ForegroundProperty);
  25. public static readonly DependencyProperty BorderBrushProperty = DependencyProperty.RegisterAttached(
  26. "BorderBrush", typeof(Brush), typeof(TitleElement), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.Inherits));
  27. public static void SetBorderBrush(DependencyObject element, Brush value)
  28. => element.SetValue(BorderBrushProperty, value);
  29. public static Brush GetBorderBrush(DependencyObject element)
  30. => (Brush) element.GetValue(BorderBrushProperty);
  31. public static readonly DependencyProperty TitlePlacementProperty = DependencyProperty.RegisterAttached(
  32. "TitlePlacement", typeof(TitlePlacementType), typeof(TitleElement), new FrameworkPropertyMetadata(TitlePlacementType.Top, FrameworkPropertyMetadataOptions.Inherits));
  33. public static void SetTitlePlacement(DependencyObject element, TitlePlacementType value)
  34. => element.SetValue(TitlePlacementProperty, value);
  35. public static TitlePlacementType GetTitlePlacement(DependencyObject element)
  36. => (TitlePlacementType) element.GetValue(TitlePlacementProperty);
  37. public static readonly DependencyProperty TitleWidthProperty = DependencyProperty.RegisterAttached(
  38. "TitleWidth", typeof(GridLength), typeof(TitleElement), new FrameworkPropertyMetadata(GridLength.Auto, FrameworkPropertyMetadataOptions.Inherits));
  39. public static void SetTitleWidth(DependencyObject element, GridLength value) => element.SetValue(TitleWidthProperty, value);
  40. public static GridLength GetTitleWidth(DependencyObject element) => (GridLength) element.GetValue(TitleWidthProperty);
  41. public static readonly DependencyProperty HorizontalAlignmentProperty = DependencyProperty.RegisterAttached(
  42. "HorizontalAlignment", typeof(HorizontalAlignment), typeof(TitleElement), new FrameworkPropertyMetadata(default(HorizontalAlignment), FrameworkPropertyMetadataOptions.Inherits));
  43. public static void SetHorizontalAlignment(DependencyObject element, HorizontalAlignment value)
  44. => element.SetValue(HorizontalAlignmentProperty, value);
  45. public static HorizontalAlignment GetHorizontalAlignment(DependencyObject element)
  46. => (HorizontalAlignment) element.GetValue(HorizontalAlignmentProperty);
  47. public static readonly DependencyProperty VerticalAlignmentProperty = DependencyProperty.RegisterAttached(
  48. "VerticalAlignment", typeof(VerticalAlignment), typeof(TitleElement), new FrameworkPropertyMetadata(default(VerticalAlignment), FrameworkPropertyMetadataOptions.Inherits));
  49. public static void SetVerticalAlignment(DependencyObject element, VerticalAlignment value)
  50. => element.SetValue(VerticalAlignmentProperty, value);
  51. public static VerticalAlignment GetVerticalAlignment(DependencyObject element)
  52. => (VerticalAlignment) element.GetValue(VerticalAlignmentProperty);
  53. public static readonly DependencyProperty MarginOnTheLeftProperty = DependencyProperty.RegisterAttached(
  54. "MarginOnTheLeft", typeof(Thickness), typeof(TitleElement), new FrameworkPropertyMetadata(default(Thickness), FrameworkPropertyMetadataOptions.Inherits));
  55. public static void SetMarginOnTheLeft(DependencyObject element, Thickness value)
  56. => element.SetValue(MarginOnTheLeftProperty, value);
  57. public static Thickness GetMarginOnTheLeft(DependencyObject element)
  58. => (Thickness) element.GetValue(MarginOnTheLeftProperty);
  59. public static readonly DependencyProperty MarginOnTheTopProperty = DependencyProperty.RegisterAttached(
  60. "MarginOnTheTop", typeof(Thickness), typeof(TitleElement), new FrameworkPropertyMetadata(default(Thickness), FrameworkPropertyMetadataOptions.Inherits));
  61. public static void SetMarginOnTheTop(DependencyObject element, Thickness value)
  62. => element.SetValue(MarginOnTheTopProperty, value);
  63. public static Thickness GetMarginOnTheTop(DependencyObject element)
  64. => (Thickness) element.GetValue(MarginOnTheTopProperty);
  65. public static readonly DependencyProperty PaddingProperty = DependencyProperty.RegisterAttached(
  66. "Padding", typeof(Thickness), typeof(TitleElement), new FrameworkPropertyMetadata(default(Thickness), FrameworkPropertyMetadataOptions.Inherits));
  67. public static void SetPadding(DependencyObject element, Thickness value) => element.SetValue(PaddingProperty, value);
  68. public static Thickness GetPadding(DependencyObject element) => (Thickness) element.GetValue(PaddingProperty);
  69. public static readonly DependencyProperty MinHeightProperty =
  70. DependencyProperty.RegisterAttached("MinHeight", typeof(double), typeof(TitleElement), new PropertyMetadata(ValueBoxes.Double0Box));
  71. public static double GetMinHeight(DependencyObject obj) => (double) obj.GetValue(MinHeightProperty);
  72. public static void SetMinHeight(DependencyObject obj, double value) => obj.SetValue(MinHeightProperty, value);
  73. public static readonly DependencyProperty MinWidthProperty =
  74. DependencyProperty.RegisterAttached("MinWidth", typeof(double), typeof(TitleElement), new PropertyMetadata(ValueBoxes.Double0Box));
  75. public static double GetMinWidth(DependencyObject obj) => (double) obj.GetValue(MinWidthProperty);
  76. public static void SetMinWidth(DependencyObject obj, double value) => obj.SetValue(MinWidthProperty, value);
  77. }