/* * Copyright (c) 2022 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using Aurora.View; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace AuroraUIComponent.UserControls { public class StatusItem : NotifyPropertyChangedBase { public string GroupName { get; set; } public string Name { get; set; } public string Extra { get; set; } private int _Status = 0; // 0: Deactivated, 1: Activated, 2: Moving public int Status { get => _Status; set => SetProperty(ref _Status, value); } public StatusItem(string name, string groupName = "", string extra = "") { GroupName = groupName; Name = name; Status = 0; Extra = extra; } } public class GroupTitle : NotifyPropertyChangedBase { public string Title { get; set; } private int _Columns = 0; public int Columns { get => _Columns; set => SetProperty(ref _Columns, value); } public GroupTitle(string title, int columns = 1) { Title = title; Columns = 1; } } /// /// Interaction logic for UCGroupStatus.xaml /// public partial class UCGroupStatus : UserControl { public UCGroupStatus() { InitializeComponent(); } public static readonly DependencyProperty StatusListProperty = DependencyProperty.Register("StatusList", typeof(ObservableCollection), typeof(UCGroupStatus), new PropertyMetadata(null, OnStatusChanged)); private static void OnStatusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var ucGroupStatus = d as UCGroupStatus; ucGroupStatus.UpdateTitles(); } public ObservableCollection StatusList { get { if (GetValue(StatusListProperty) == null) { SetValue(StatusListProperty, new ObservableCollection()); } return (ObservableCollection)GetValue(StatusListProperty); } set { SetValue(StatusListProperty, value); UpdateTitles(); StatusList.CollectionChanged += StatusList_CollectionChanged; } } private void StatusList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { var ucGroupStatus = sender as UCGroupStatus; ucGroupStatus.UpdateTitles(); } public static readonly DependencyProperty ButtonEventHandlerProperty = DependencyProperty.Register( nameof(ButtonEventHandler), typeof(ICommand), typeof(UCGroupStatus), new PropertyMetadata(null, OnButtonEventHandlerChanged)); private static void OnButtonEventHandlerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uc = d as UCGroupStatus; if (uc != null) { uc.TitleButtonList.ForEach(x => { x.Command = uc.ButtonEventHandler; x.IsEnabled = uc.ButtonEventHandler != null; }); } } public ICommand ButtonEventHandler { get { return (ICommand)GetValue(ButtonEventHandlerProperty); } set { SetValue(ButtonEventHandlerProperty, value); } } private ObservableCollection Titles = new ObservableCollection(); public List