|
1 | 1 | // Copyright (c) Files Community |
2 | 2 | // Licensed under the MIT License. |
3 | 3 |
|
| 4 | +using CommunityToolkit.WinUI; |
| 5 | + |
4 | 6 | namespace Files.App.Controls |
5 | 7 | { |
6 | 8 | public sealed partial class SidebarView |
7 | 9 | { |
8 | | - public SidebarDisplayMode DisplayMode |
9 | | - { |
10 | | - get { return (SidebarDisplayMode)GetValue(DisplayModeProperty); } |
11 | | - set { SetValue(DisplayModeProperty, value); } |
12 | | - } |
13 | | - public static readonly DependencyProperty DisplayModeProperty = |
14 | | - DependencyProperty.Register(nameof(DisplayMode), typeof(SidebarDisplayMode), typeof(SidebarView), new PropertyMetadata(SidebarDisplayMode.Expanded, OnPropertyChanged)); |
| 10 | + [GeneratedDependencyProperty(DefaultValue = SidebarDisplayMode.Expanded)] |
| 11 | + public partial SidebarDisplayMode DisplayMode { get; set; } |
15 | 12 |
|
16 | | - public UIElement InnerContent |
17 | | - { |
18 | | - get { return (UIElement)GetValue(InnerContentProperty); } |
19 | | - set { SetValue(InnerContentProperty, value); } |
20 | | - } |
21 | | - public static readonly DependencyProperty InnerContentProperty = |
22 | | - DependencyProperty.Register(nameof(InnerContent), typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); |
| 13 | + [GeneratedDependencyProperty] |
| 14 | + public partial UIElement? InnerContent { get; set; } |
23 | 15 |
|
24 | | - public UIElement SidebarContent |
25 | | - { |
26 | | - get { return (UIElement)GetValue(SidebarContentProperty); } |
27 | | - set { SetValue(SidebarContentProperty, value); } |
28 | | - } |
29 | | - public static readonly DependencyProperty SidebarContentProperty = |
30 | | - DependencyProperty.Register("SidebarContent", typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); |
| 16 | + [GeneratedDependencyProperty] |
| 17 | + public partial UIElement? SidebarContent { get; set; } |
31 | 18 |
|
32 | | - public UIElement Footer |
33 | | - { |
34 | | - get { return (UIElement)GetValue(FooterProperty); } |
35 | | - set { SetValue(FooterProperty, value); } |
36 | | - } |
37 | | - public static readonly DependencyProperty FooterProperty = |
38 | | - DependencyProperty.Register("Footer", typeof(UIElement), typeof(SidebarView), new PropertyMetadata(null)); |
| 19 | + [GeneratedDependencyProperty] |
| 20 | + public partial UIElement? Footer { get; set; } |
39 | 21 |
|
40 | | - public bool IsPaneOpen |
41 | | - { |
42 | | - get { return (bool)GetValue(IsPaneOpenProperty); } |
43 | | - set { SetValue(IsPaneOpenProperty, value); } |
44 | | - } |
45 | | - public static readonly DependencyProperty IsPaneOpenProperty = |
46 | | - DependencyProperty.Register(nameof(IsPaneOpen), typeof(bool), typeof(SidebarView), new PropertyMetadata(false, OnPropertyChanged)); |
| 22 | + [GeneratedDependencyProperty] |
| 23 | + public partial bool IsPaneOpen { get; set; } |
47 | 24 |
|
48 | | - public double OpenPaneLength |
49 | | - { |
50 | | - get { return (double)GetValue(OpenPaneLengthProperty); } |
51 | | - set |
52 | | - { |
53 | | - SetValue(OpenPaneLengthProperty, value); |
54 | | - NegativeOpenPaneLength = -value; |
55 | | - } |
56 | | - } |
57 | | - public static readonly DependencyProperty OpenPaneLengthProperty = |
58 | | - DependencyProperty.Register(nameof(OpenPaneLength), typeof(double), typeof(SidebarView), new PropertyMetadata(240d, OnPropertyChanged)); |
| 25 | + [GeneratedDependencyProperty(DefaultValue = 240D)] |
| 26 | + public partial double OpenPaneLength { get; set; } |
59 | 27 |
|
60 | | - public double NegativeOpenPaneLength |
61 | | - { |
62 | | - get { return (double)GetValue(NegativeOpenPaneLengthProperty); } |
63 | | - set { SetValue(NegativeOpenPaneLengthProperty, value); } |
64 | | - } |
65 | | - public static readonly DependencyProperty NegativeOpenPaneLengthProperty = |
66 | | - DependencyProperty.Register(nameof(NegativeOpenPaneLength), typeof(double), typeof(SidebarView), new PropertyMetadata(null)); |
| 28 | + [GeneratedDependencyProperty] |
| 29 | + public partial double NegativeOpenPaneLength { get; set; } |
67 | 30 |
|
68 | | - public ISidebarViewModel ViewModel |
69 | | - { |
70 | | - get => (ISidebarViewModel)GetValue(ViewModelProperty); |
71 | | - set => SetValue(ViewModelProperty, value); |
72 | | - } |
73 | | - public static readonly DependencyProperty ViewModelProperty = |
74 | | - DependencyProperty.Register(nameof(ViewModel), typeof(ISidebarViewModel), typeof(SidebarView), new PropertyMetadata(null)); |
| 31 | + [GeneratedDependencyProperty] |
| 32 | + public partial ISidebarItemModel? SelectedItem { get; set; } |
75 | 33 |
|
76 | | - public ISidebarItemModel SelectedItem |
| 34 | + [GeneratedDependencyProperty] |
| 35 | + public partial object? MenuItemsSource { get; set; } |
| 36 | + |
| 37 | + partial void OnDisplayModePropertyChanged(DependencyPropertyChangedEventArgs e) |
77 | 38 | { |
78 | | - get => (ISidebarItemModel)GetValue(SelectedItemProperty); |
79 | | - set |
80 | | - { |
81 | | - SetValue(SelectedItemProperty, value); |
82 | | - } |
| 39 | + UpdateDisplayMode(); |
83 | 40 | } |
84 | | - public static readonly DependencyProperty SelectedItemProperty = |
85 | | - DependencyProperty.Register(nameof(SelectedItem), typeof(ISidebarItemModel), typeof(SidebarView), new PropertyMetadata(null)); |
86 | 41 |
|
87 | | - public object MenuItemsSource |
| 42 | + partial void OnIsPaneOpenPropertyChanged(DependencyPropertyChangedEventArgs e) |
88 | 43 | { |
89 | | - get => (object)GetValue(MenuItemsSourceProperty); |
90 | | - set => SetValue(MenuItemsSourceProperty, value); |
| 44 | + UpdateMinimalMode(); |
91 | 45 | } |
92 | | - public static readonly DependencyProperty MenuItemsSourceProperty = |
93 | | - DependencyProperty.Register(nameof(MenuItemsSource), typeof(object), typeof(SidebarView), new PropertyMetadata(null)); |
94 | 46 |
|
95 | | - public static void OnPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
| 47 | + partial void OnOpenPaneLengthPropertyChanged(DependencyPropertyChangedEventArgs e) |
96 | 48 | { |
97 | | - if (sender is not SidebarView control) return; |
98 | | - |
99 | | - if (e.Property == OpenPaneLengthProperty) |
100 | | - { |
101 | | - control.UpdateOpenPaneLengthColumn(); |
102 | | - } |
103 | | - else if (e.Property == DisplayModeProperty) |
104 | | - { |
105 | | - control.UpdateDisplayMode(); |
106 | | - } |
107 | | - else if (e.Property == IsPaneOpenProperty) |
108 | | - { |
109 | | - control.UpdateMinimalMode(); |
110 | | - } |
| 49 | + NegativeOpenPaneLength = -(double)(e.NewValue); |
| 50 | + UpdateOpenPaneLengthColumn(); |
111 | 51 | } |
112 | 52 | } |
113 | 53 | } |
0 commit comments