| Name | Message | Date |
|---|---|---|
| 📄 DateTimePanel.axaml | 1 day ago | |
| 📄 DateTimePanel.axaml.cs | 1 day ago | |
| 📄 ServiceCollectionExtensions.cs | 1 day ago |
📄
src/App/Views/Panels/DateTimePanel.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System; using System.Globalization; using Avalonia; using Avalonia.Controls; using Avalonia.Data.Converters; using Avalonia.Media.Transformation; using MMirror.App.ViewModels.Panels; namespace MMirror.App.Views.Panels; public partial class DateTimePanel : UserControl { public DateTimePanel() { InitializeComponent(); } protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { base.OnAttachedToVisualTree(e); if (DataContext is DateTimePanelViewModel vm) { vm.SubscribeToUpdates(); } } protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { if (DataContext is DateTimePanelViewModel vm) { vm.UnsubscribeFromUpdates(); } base.OnDetachedFromVisualTree(e); } } public class TranslateXConverter : IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is not double x) { return value; } var builder = TransformOperations.CreateBuilder(1); builder.AppendTranslate(x, 0); return builder.Build(); } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { if ( value is not TransformOperations { Operations: [ TransformOperation { Type: TransformOperation.OperationType.Translate, Matrix: var matrix }, ] } ) { return value; } return matrix.M31; } }