summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs')
-rw-r--r--Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs133
1 files changed, 133 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs b/Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs
new file mode 100644
index 0000000..5bf30bc
--- /dev/null
+++ b/Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs
@@ -0,0 +1,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;
+ }
+ }
+}