예제 #1
0
 public void HoverTreeItem(ElementTreeItemViewModel hoveredTreeItem)
 {
     HoverCell(null, null);
     for (int row = 0; row < _elementViewModelLeafs.Count; row++)
     {
         if (_elementViewModelLeafs[row] == hoveredTreeItem)
         {
             HoverRow(row);
         }
     }
     _hoveredTreeItem = hoveredTreeItem;
 }
예제 #2
0
 public void SelectTreeItem(ElementTreeItemViewModel selectedTreeItem)
 {
     SelectCell(null, null);
     for (int row = 0; row < _elementViewModelLeafs.Count; row++)
     {
         if (_elementViewModelLeafs[row] == selectedTreeItem)
         {
             SelectRow(row);
         }
     }
     _selectedTreeItem = selectedTreeItem;
 }
예제 #3
0
        private ObservableCollection <ElementTreeItemViewModel> CreateElementViewModelTree()
        {
            int depth = 0;
            ObservableCollection <ElementTreeItemViewModel> tree = new ObservableCollection <ElementTreeItemViewModel>();

            foreach (IDsmElement element in _selectedElements)
            {
                ElementTreeItemViewModel viewModel = new ElementTreeItemViewModel(this, element, depth);
                tree.Add(viewModel);
                AddElementViewModelChildren(viewModel);
            }
            return(tree);
        }
예제 #4
0
        public ElementTreeItemViewModel(IMatrixViewModel matrixViewModel, IDsmElement element, int depth)
        {
            _children = new List <ElementTreeItemViewModel>();
            _parent   = null;
            Element   = element;
            Depth     = depth;
            Color     = MatrixColorConverter.GetColor(depth);

            MoveCommand                  = matrixViewModel.ChangeElementParentCommand;
            MoveUpElementCommand         = matrixViewModel.MoveUpElementCommand;
            MoveDownElementCommand       = matrixViewModel.MoveDownElementCommand;
            SortElementCommand           = matrixViewModel.SortElementCommand;
            ToggleElementExpandedCommand = matrixViewModel.ToggleElementExpandedCommand;
        }
예제 #5
0
 private void CountLeafElements(ElementTreeItemViewModel viewModel, ref int count)
 {
     if (viewModel.Children.Count == 0)
     {
         count++;
     }
     else
     {
         foreach (ElementTreeItemViewModel child in viewModel.Children)
         {
             CountLeafElements(child, ref count);
         }
     }
 }
예제 #6
0
 private void AddElementViewModelChildren(ElementTreeItemViewModel viewModel)
 {
     if (viewModel.Element.IsExpanded)
     {
         foreach (IDsmElement child in viewModel.Element.Children)
         {
             ElementTreeItemViewModel childViewModel = new ElementTreeItemViewModel(this, child, viewModel.Depth + 1);
             viewModel.AddChild(childViewModel);
             AddElementViewModelChildren(childViewModel);
         }
     }
     else
     {
         viewModel.ClearChildren();
     }
 }
예제 #7
0
 public void AddChild(ElementTreeItemViewModel viewModel)
 {
     _children.Add(viewModel);
     viewModel._parent = this;
 }
예제 #8
0
        private void DefineCellColors()
        {
            int matrixSize = _elementViewModelLeafs.Count;

            _cellColors = new List <List <MatrixColor> >();

            // Define background color
            for (int row = 0; row < matrixSize; row++)
            {
                _cellColors.Add(new List <MatrixColor>());
                for (int column = 0; column < matrixSize; column++)
                {
                    _cellColors[row].Add(MatrixColor.Background);
                }
            }

            // Define expanded block color
            for (int row = 0; row < matrixSize; row++)
            {
                ElementTreeItemViewModel viewModel = _elementViewModelLeafs[row];
                IDsmElement element = viewModel.Element;

                Stack <ElementTreeItemViewModel> viewModelHierarchy = new Stack <ElementTreeItemViewModel>();
                ElementTreeItemViewModel         child  = viewModel;
                ElementTreeItemViewModel         parent = viewModel.Parent;
                while ((parent != null) && (parent.Children[0] == child))
                {
                    viewModelHierarchy.Push(parent);
                    child  = parent;
                    parent = parent.Parent;
                }

                foreach (ElementTreeItemViewModel currentViewModel in viewModelHierarchy)
                {
                    int leafElements = 0;
                    CountLeafElements(currentViewModel.Element, ref leafElements);

                    if (leafElements > 0 && currentViewModel.Depth > 0)
                    {
                        MatrixColor expandedColor = MatrixColorConverter.GetColor(currentViewModel.Depth);

                        int begin = row;
                        int end   = row + leafElements;

                        for (int rowDelta = begin; rowDelta < end; rowDelta++)
                        {
                            for (int columnDelta = begin; columnDelta < end; columnDelta++)
                            {
                                _cellColors[rowDelta][columnDelta] = expandedColor;
                            }
                        }
                    }
                }
            }

            // Define diagonal color
            for (int row = 0; row < matrixSize; row++)
            {
                int         depth       = _elementViewModelLeafs[row].Depth;
                MatrixColor dialogColor = MatrixColorConverter.GetColor(depth);
                _cellColors[row][row] = dialogColor;
            }

            // Define cycle color
            for (int row = 0; row < matrixSize; row++)
            {
                for (int column = 0; column < matrixSize; column++)
                {
                    IDsmElement consumer  = _elementViewModelLeafs[column].Element;
                    IDsmElement provider  = _elementViewModelLeafs[row].Element;
                    CycleType   cycleType = _application.IsCyclicDependency(consumer, provider);
                    if (_application.ShowCycles)
                    {
                        if (cycleType == CycleType.Hierarchical)
                        {
                            _cellColors[row][column] = MatrixColor.HierarchicalCycle;
                        }

                        if (cycleType == CycleType.System)
                        {
                            _cellColors[row][column] = MatrixColor.SystemCycle;
                        }
                    }
                }
            }
        }
예제 #9
0
        private void FindLeafElementViewModels(List <ElementTreeItemViewModel> leafViewModels, ElementTreeItemViewModel viewModel)
        {
            if (!viewModel.IsExpanded)
            {
                leafViewModels.Add(viewModel);
            }

            foreach (ElementTreeItemViewModel childViewModel in viewModel.Children)
            {
                FindLeafElementViewModels(leafViewModels, childViewModel);
            }
        }