summaryrefslogtreecommitdiff
path: root/Gestor.Application/Componentes/CustomSeriesViewModel.cs
blob: 7c4a6cf9b8a5a9c99ccf32aa1562fcb7de2c134e (plain)
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
72
using LiveCharts.Definitions.Series;
using LiveCharts.Wpf;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Windows;
using System.Windows.Media;

namespace Gestor.Application.Componentes
{
	public class CustomSeriesViewModel : INotifyPropertyChanged
	{
		public Brush Fill
		{
			get
			{
				return this.SeriesViewModel.get_Fill() ?? this.SeriesViewModel.get_Stroke();
			}
		}

		public bool IsVisible
		{
			get
			{
				return ((UIElement)this.View).Visibility == Visibility.Visible;
			}
			set
			{
				if (this.IsVisible != value)
				{
					((UIElement)this.View).Visibility = (value ? Visibility.Visible : Visibility.Hidden);
					this.OnPropertyChanged("IsVisible");
				}
			}
		}

		public LiveCharts.Wpf.SeriesViewModel SeriesViewModel
		{
			get;
		}

		public string Title
		{
			get
			{
				return this.SeriesViewModel.get_Title();
			}
		}

		public ISeriesView View
		{
			get;
		}

		public CustomSeriesViewModel(LiveCharts.Wpf.SeriesViewModel svm, ISeriesView view)
		{
			this.SeriesViewModel = svm;
			this.View = view;
		}

		protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
		{
			if (this.PropertyChanged != null)
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}

		public event PropertyChangedEventHandler PropertyChanged;
	}
}