-
-
Save 3bdNKocY/e4f88916b8e72d4b7f20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class CreateMeterWindow : Window | |
{ | |
private CreateMeterViewModel _CreateMeterViewModel; | |
public CreateMeterViewModel CreateMeterViewModel | |
{ | |
get | |
{ | |
return _CreateMeterViewModel; | |
} | |
} | |
public CreateMeterWindow() | |
{ | |
_CreateMeterViewModel = new CreateMeterViewModel(this); | |
InitializeComponent(); | |
} | |
private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) | |
{ | |
_CreateMeterViewModel.ComboBox_SelectionChanged(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="Views.CreateMeterWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" | |
Title="Voeg een nieuwe meter toe" Height="300" Width="600" | |
DataContext="{Binding CreateMeterViewModel, RelativeSource={RelativeSource Self}}"> | |
<xctk:DecimalUpDown Visibility="{Binding IsDoubleMeter}" HorizontalAlignment="Left" Watermark="1234567,89" Height="23" Margin="150,105,0,0" Value="{Binding NightReading.Reading}" VerticalAlignment="Top" Width="200" /> | |
<DatePicker Visibility="{Binding IsDoubleMeter}" Margin="355,105,10,0" VerticalAlignment="Top" SelectedDate="{Binding NightReading.Date}"/> | |
<Label Visibility="{Binding IsDoubleMeter}" Content="Huidige stand (nacht)" HorizontalAlignment="Left" Margin="10,101,0,0" VerticalAlignment="Top"/> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CreateMeterViewModel : INotifyPropertyChanged | |
{ | |
private Window _Window; | |
private Meter _Meter; | |
private CounterReading _NightReading; | |
private MeterType _MeterType; | |
private bool _IsDoubleMeter; | |
public Meter Meter | |
{ | |
get | |
{ | |
if (_Meter == null) | |
{ | |
if(_MeterType != MeterType.Unknown) | |
{ | |
_Meter = MeterFactory.Create(_MeterType); | |
} | |
} | |
return _Meter; | |
} | |
} | |
public CounterReading NightReading | |
{ | |
get | |
{ | |
if (_NightReading == null) | |
{ | |
_NightReading = new CounterReading(); | |
} | |
return _NightReading; | |
} | |
} | |
public MeterType MeterType | |
{ | |
get | |
{ | |
return _MeterType; | |
} | |
set | |
{ | |
_MeterType = value; | |
} | |
} | |
public bool IsDoubleMeter | |
{ | |
get | |
{ | |
return _IsDoubleMeter; | |
} | |
set | |
{ | |
_IsDoubleMeter = value; | |
NotifyPropertyChanged("IsDoubleMeter"); | |
} | |
} | |
public CreateMeterViewModel(Window window) | |
{ | |
_Window = window; | |
} | |
internal void ComboBox_SelectionChanged() | |
{ | |
if (_MeterType != MeterType.Unknown) | |
{ | |
_Meter = MeterFactory.Create(_MeterType); | |
IsDoubleMeter = _Meter is DoubleElectricityMeter; | |
} else | |
{ | |
_Meter = null; | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged; | |
public void NotifyPropertyChanged(String info) | |
{ | |
if (PropertyChanged != null) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs(info)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment