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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using LiveCharts.Definitions.Series;
using LiveCharts.Wpf;
using LiveCharts.Wpf.Charts.Base;
namespace Gestor.Application.Componentes;
public class CustomLegendChart : UserControl, IChartLegend, INotifyPropertyChanged, IComponentConnector
{
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register("Orientation", typeof(Orientation), typeof(CustomLegendChart), new PropertyMetadata((object)(Orientation)0));
internal ItemsControl itemsControl;
private bool _contentLoaded;
public Orientation Orientation
{
get
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return (Orientation)((DependencyObject)this).GetValue(OrientationProperty);
}
set
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((DependencyObject)this).SetValue(OrientationProperty, (object)value);
}
}
public ObservableCollection<CustomSeriesViewModel> LegendEntries { get; } = new ObservableCollection<CustomSeriesViewModel>();
public List<SeriesViewModel> Series
{
get
{
return LegendEntries.Select((CustomSeriesViewModel x) => x.SeriesViewModel).ToList();
}
set
{
Chart ownerChart = GetOwnerChart();
foreach (CustomSeriesViewModel item in LegendEntries.Where((CustomSeriesViewModel x) => !((IEnumerable<ISeriesView>)ownerChart.Series).Any((ISeriesView s) => s == x.View)).ToList())
{
LegendEntries.Remove(item);
}
foreach (SeriesViewModel svm in value)
{
if (LegendEntries.All((CustomSeriesViewModel x) => x.Title != svm.Title))
{
ISeriesView view = ((IEnumerable<ISeriesView>)ownerChart.Series).FirstOrDefault((Func<ISeriesView, bool>)((ISeriesView x) => x.Title == svm.Title));
LegendEntries.Add(new CustomSeriesViewModel(svm, view));
}
}
OnPropertyChanged("Series");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public CustomLegendChart()
{
InitializeComponent();
((FrameworkElement)itemsControl).DataContext = this;
}
private Chart GetOwnerChart()
{
return CustomLegendChart.FindParent<Chart>((DependencyObject)(object)this);
}
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public static T FindParent<T>(DependencyObject child) where T : DependencyObject
{
DependencyObject parent = VisualTreeHelper.GetParent(child);
if (parent == null)
{
return default(T);
}
T val = (T)(object)((parent is T) ? parent : null);
if (val != null)
{
return val;
}
return FindParent<T>(parent);
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent()
{
if (!_contentLoaded)
{
_contentLoaded = true;
Uri uri = new Uri("/Gestor.Application;component/componentes/customlegendchart.xaml", UriKind.Relative);
Application.LoadComponent((object)this, uri);
}
}
[DebuggerNonUserCode]
[GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
[EditorBrowsable(EditorBrowsableState.Never)]
void IComponentConnector.Connect(int connectionId, object target)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
if (connectionId == 1)
{
itemsControl = (ItemsControl)target;
}
else
{
_contentLoaded = true;
}
}
}
|