diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.Componentes/CustomLegendChart.cs | 133 |
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; + } + } +} |