private List <Line> GetMappingVis(ParameterStructure.Parameter.Parameter _source, ParameterStructure.Parameter.Parameter _target, bool _input, double _connection_offset = 0.0) { List <Line> lines = new List <Line>(); if (_source == null || _target == null) { return(lines); } TreeViewItem container_source = TreeViewQuery.ContainerFromItem(this.tv_comp_data, _source); TreeViewItem container_target = TreeViewQuery.ContainerFromItem(this.tv_comp_calc, _target); if (container_source != null && container_source.IsVisible && container_target != null && container_target.IsVisible) { // draw the lines Point source = container_source.TransformToAncestor(this.tv_comp_data).Transform(new Point(0, 0)); Point target = container_target.TransformToAncestor(this.tv_comp_calc).Transform(new Point(0, 0)); Color col = (_input) ? COL_MAPPING_INPUT : COL_MAPPING_OUTPUT; double thickness = (_input) ? 1.0 : 2.0; lines = Utils.DrawConnection(HALF_H_TV_ROW_COMP, HALF_H_TV_ROW_COMP, this.c_pointer_midside_measure.ActualWidth, this.c_pointer_middle_measure.ActualWidth, source, target, target, (container_target == null || !container_target.IsVisible), col, thickness, _connection_offset); } return(lines); }
void tv_comp_calc_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { // adapt display DependencyObject selObj = TreeViewQuery.GetSelectedTreeViewItem(this.tv_comp_calc); TreeViewItem tvi = selObj as TreeViewItem; if (tvi != null) { this.tracking_target = tvi.TransformToAncestor(this.tv_comp_calc).Transform(new Point(0, 0)); if (this.IsMapping) { this.UpdateMappingTrackingDisplay(); } } // react to selection if (sender == null || e == null) { return; } TreeView tv = sender as TreeView; if (tv == null) { return; } object selection = tv.SelectedItem; if (selection == null) { return; } ParameterStructure.Parameter.Parameter selected_p = selection as ParameterStructure.Parameter.Parameter; if (selected_p == null) { return; } if (this.IsMapping && this.SelectedMappingSource) { this.CreateP2PMapping(selected_p); this.IsMapping = false; this.SelectedMappingSource = false; this.UpdateMappingTrackingDisplay(); this.UpdateButtons(); } }
void tv_comp_data_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { // adapt display DependencyObject selObj = TreeViewQuery.GetSelectedTreeViewItem(this.tv_comp_data); TreeViewItem tvi = selObj as TreeViewItem; if (tvi != null) { this.tracking_source = tvi.TransformToAncestor(this.tv_comp_data).Transform(new Point(0, 0)); this.UpdateMappingTrackingDisplay(); } // handle selection if (sender == null || e == null) { return; } TreeView tv = sender as TreeView; if (tv == null) { return; } object selection = tv.SelectedItem; if (selection == null) { this.UpdateButtons(); return; } ParameterStructure.Parameter.Parameter selected_p = selection as ParameterStructure.Parameter.Parameter; if (selected_p != null) { if (this.IsMapping) { this.MappedSourceParameter = selected_p; } this.UpdateButtons(selected_p); } else { this.IsMapping = false; this.SelectedMappingSource = false; this.UpdateMappingTrackingDisplay(); this.UpdateButtons(); } }
private void TreeView_MouseUp(object sender, RoutedEventArgs e) { if (sender == null) { return; } if (this.treeView != sender as TreeView) { return; } if (this.treeView_rightClicked) { this.treeView_rightClicked = false; return; } TreeView tv = sender as TreeView; if (tv == null) { return; } if (this.treeViewItem_clicked) { this.treeViewItem_clicked = false; } else { if (tv.SelectedItem != null) { DependencyObject selObj = TreeViewQuery.GetSelectedTreeViewItem(tv); TreeViewItem tvi = selObj as TreeViewItem; if (tvi != null) { tvi.IsSelected = false; } } } }
private void TogglePHighlight() { ParameterStructure.Parameter.Parameter selected_p = this.tv_comp_calc.SelectedItem as ParameterStructure.Parameter.Parameter; if (selected_p == null) { return; } TreeViewItemForMapping container_selected = TreeViewQuery.ContainerFromItem(this.tv_comp_calc, selected_p) as TreeViewItemForMapping; if (container_selected != null && container_selected.IsVisible) { container_selected.IsMarkingInitiator = !container_selected.IsMarkingInitiator; if (container_selected.IsMarkingInitiator) { // show all visible containers holding input parameters List <ParameterStructure.Parameter.Parameter> input_involved = this.CompCalculator.GetInputParamsInvolvedInTheCalculationOf(selected_p); foreach (ParameterStructure.Parameter.Parameter p in input_involved) { TreeViewItemForMapping container_p = TreeViewQuery.ContainerFromItem(this.tv_comp_calc, p) as TreeViewItemForMapping; if (container_p != null && container_p.IsVisible) { container_p.IsMarked = true; } } } else { // remove all markings if (this.tv_comp_calc != null) { this.tv_comp_calc.PropagateMarkingToItems(false); } } } }