using BeWo.Core; using BeWo.ServiceProxy; using BS.Shared.Extensions; using DevExpress.Utils; using DevExpress.XtraGrid.Views.Grid.ViewInfo; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using BeWo.ViewModel; using BS.Shared; using BS.Shared.DataContracts; using BS.Shared.DataContracts.ClientPartials; using DevExpress.Data; using DevExpress.Mvvm.Native; using DevExpress.Xpf.Grid; using DevExpress.Xpf.Scheduler.UI; using DevExpress.XtraExport.Xls; using static BeWo.View.Detail.Report.FlexibleReportView; namespace BeWo.View.Detail { public partial class GoalImportControl { public event Action ButtonImportClicked; public event Action ButtonCancelClicked; //private SupportConceptGoalDC _TreeViewGoalItem; public GoalImportControl(ObservableCollection goalTree) { InitializeComponent(); DataContext = this; GoalTree = goalTree; } public ObservableCollection GoalTree { get; set; } public IList GetSelectedGoals() { var list = new ObservableCollection(); foreach (var item in GoalTree) { IterateThroughSelectedGoalsAndMassnahmen(item, list); } return list; } private void IterateThroughSelectedGoalsAndMassnahmen(SupportConceptGoalTreeItem item, ObservableCollection list) { if (item.IsChecked && item.Items.Count == 0) { list.Add(item); } foreach (var child in item.Items) { IterateThroughSelectedGoalsAndMassnahmen(child, list); } } private void ButtonImport_Click(object sender, RoutedEventArgs e) { ButtonImportClicked?.Invoke(); } private void ButtonCancel_Click(object sender, RoutedEventArgs e) { ButtonCancelClicked?.Invoke(); } private void button_checkAllGoals_Click(object sender, RoutedEventArgs e) { CheckAllGoalTreeItems(true); } private void button_uncheckAllGoals_Click(object sender, RoutedEventArgs e) { CheckAllGoalTreeItems(false); } private void button_aufklappenAllGoals_Click(object sender, RoutedEventArgs e) { SwitchAllGoalTreeItems(true); } private void button_zuklappenAllGoals_Click(object sender, RoutedEventArgs e) { SwitchAllGoalTreeItems(false); } private void SwitchAllGoalTreeItems(bool check) { Style stylee = new Style { TargetType = typeof(TreeViewItem) }; stylee.Setters.Add(new Setter(TreeViewItem.IsExpandedProperty, check)); TreeView.ItemContainerStyle = stylee; } private void CheckAllGoalTreeItems(bool check) { var allItems = TreeView.ItemsSource as ObservableCollection; var test = TreeView.ItemsSource; foreach (var item in TreeView.ItemsSource) { var goal = item as SupportConceptGoalTreeItem; if (goal != null) { goal.IsChecked = check; } } } } }