From 2a21fe4c9ac87cceed96a03d5ff5ff1aa0d64016 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 7 Feb 2019 17:19:25 +0200 Subject: Fixed and improved bug reporting in machine studio. --- .../Views/ReportIssueView.xaml | 27 ++++++++- .../Views/ReportIssueView.xaml.cs | 64 ++++++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml index 7387c4ae5..5f5e1042b 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml @@ -35,7 +35,7 @@ - + @@ -50,7 +50,28 @@ - + + + + + + + + + + + + + + + + + + + + + + @@ -101,7 +122,7 @@ - + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs index 72bef1205..b6e701841 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ReportIssueView.xaml.cs @@ -12,6 +12,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.MachineStudio.UI.ViewModels; +using Tango.TFS; namespace Tango.MachineStudio.UI.Views { @@ -20,16 +22,78 @@ namespace Tango.MachineStudio.UI.Views /// public partial class ReportIssueView : UserControl { + private ReportIssueViewVM _vm; + public ReportIssueView() { InitializeComponent(); this.Loaded += ReportIssueView_Loaded; + this.DataContextChanged += ReportIssueView_DataContextChanged; + } + + private void ReportIssueView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + _vm = this.DataContext as ReportIssueViewVM; } private void ReportIssueView_Loaded(object sender, RoutedEventArgs e) { txt_title.Focus(); } + + private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + { + _vm.WorkItem.Area = e.NewValue as Area; + toggleArea.IsChecked = false; + } + + private TreeView tree; + + private void TreeView_Loaded(object sender, RoutedEventArgs e) + { + tree = sender as TreeView; + tree.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged; + } + + private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e) + { + if (tree.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) + { + TreeViewItem i = tree.ItemContainerGenerator.ContainerFromIndex(0) as TreeViewItem; + i.IsExpanded = true; + } + } + + static TreeViewItem GetTreeViewItem(ItemsControl parent, object item, bool isExpanded) + { + if (item is TreeViewItem tvi) + return tvi; + + var result = ContainerFromItem(parent, item); + if (result == null && isExpanded) + { + parent.UpdateLayout(); + result = ContainerFromItem(parent, item); + } + return result; + } + + static TreeViewItem ContainerFromItem(ItemsControl parent, object item) => (TreeViewItem)parent.ItemContainerGenerator.ContainerFromItem(item); + + void SelectTreeViewItem(TreeView treeView, TreeViewItem Item) + { + Item.IsExpanded = Item.DataContext == areaCombo.SelectedItem; + + foreach (var item in Item.Items) + { + var i = GetTreeViewItem(treeView, item, false); + + i.IsExpanded = i.DataContext == areaCombo.SelectedItem; + + if (i.HasItems) + SelectTreeViewItem(treeView, i); + } + } } } -- cgit v1.3.1