-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathFormMain.cs
More file actions
28 lines (24 loc) · 787 Bytes
/
FormMain.cs
File metadata and controls
28 lines (24 loc) · 787 Bytes
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
namespace WinFormsApp;
using System.ComponentModel;
public partial class FormMain : Form
{
private readonly IAppViewModel _appViewModel;
private readonly IClockViewModel _clockViewModel;
internal FormMain(IAppViewModel appViewModel, IClockViewModel clockViewModel)
{
_appViewModel = appViewModel;
_clockViewModel = clockViewModel;
InitializeComponent();
UpdateDateTime();
if (clockViewModel is INotifyPropertyChanged notifyPropertyChanged)
{
notifyPropertyChanged.PropertyChanged += (_, _) => UpdateDateTime();
}
}
private void UpdateDateTime()
{
Text = _appViewModel.Title;
labelDate.Text = _clockViewModel.Date;
labelTime.Text = _clockViewModel.Time;
}
}