129 lines
3.5 KiB
C#
129 lines
3.5 KiB
C#
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 DevExpress.Data;
|
|
using DevExpress.Mvvm.Native;
|
|
using DevExpress.Xpf.Grid;
|
|
using DevExpress.Xpf.Scheduler.UI;
|
|
using DevExpress.XtraExport.Xls;
|
|
|
|
namespace BeWo.View.Detail
|
|
{
|
|
public partial class GoalImportControl
|
|
{
|
|
|
|
public event Action ButtonImportClicked;
|
|
public event Action ButtonCancelClicked;
|
|
//private SupportConceptGoalDC _TreeViewGoalItem;
|
|
|
|
|
|
public GoalImportControl(ObservableCollection<SupportConceptGoalTreeItem> goalTree)
|
|
{
|
|
InitializeComponent();
|
|
|
|
DataContext = this;
|
|
|
|
GoalTree = goalTree;
|
|
}
|
|
|
|
public ObservableCollection<SupportConceptGoalTreeItem> GoalTree { get; set; }
|
|
|
|
|
|
public IList<SupportConceptGoalTreeItem> GetSelectedGoals()
|
|
{
|
|
var list = new ObservableCollection<SupportConceptGoalTreeItem>();
|
|
|
|
foreach (var item in GoalTree)
|
|
{
|
|
IterateThroughSelectedGoalsAndMassnahmen(item, list);
|
|
}
|
|
|
|
return list;
|
|
}
|
|
|
|
private void IterateThroughSelectedGoalsAndMassnahmen(SupportConceptGoalTreeItem item, ObservableCollection<SupportConceptGoalTreeItem> 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<SupportConceptGoalTreeItem>;
|
|
|
|
var test = TreeView.ItemsSource;
|
|
|
|
foreach (var item in TreeView.ItemsSource)
|
|
{
|
|
var goal = item as SupportConceptGoalTreeItem;
|
|
if (goal != null)
|
|
{
|
|
goal.IsChecked = check;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|