Example #1
0
        private void CreateChildViews()
        {
            double y = 0.0;

            Children.Clear();
            if (_matrixViewModel?.ElementViewModelTree != null)
            {
                foreach (ElementTreeItemViewModel elementViewModel in _matrixViewModel.ElementViewModelTree)
                {
                    Rect rect = GetCalculatedSize(elementViewModel, y);

                    MatrixRowHeaderItemView elementView = new MatrixRowHeaderItemView(_matrixViewModel, _theme)
                    {
                        Height = rect.Height,
                        Width  = rect.Width
                    };
                    SetTop(elementView, rect.Top);
                    SetLeft(elementView, rect.Left);
                    elementView.DataContext = elementViewModel;
                    Children.Add(elementView);

                    CreateChildViews(elementViewModel, y);

                    y += rect.Height;
                }
            }

            Height = y;
            //Width = 5000; // Should be enough to draw very deep tree
        }
Example #2
0
 private void RedrawChildViews()
 {
     foreach (var child in Children)
     {
         MatrixRowHeaderItemView renderedRowHeaderItemView = child as MatrixRowHeaderItemView;
         renderedRowHeaderItemView?.Redraw();
     }
 }
Example #3
0
        private void CreateChildViews(ElementTreeItemViewModel elementViewModel, double y)
        {
            foreach (ElementTreeItemViewModel child in elementViewModel.Children)
            {
                Rect rect = GetCalculatedSize(child, y);

                MatrixRowHeaderItemView elementView = new MatrixRowHeaderItemView(_matrixViewModel, _theme)
                {
                    Height = rect.Height,
                    Width  = rect.Width
                };
                SetTop(elementView, rect.Top);
                SetLeft(elementView, rect.Left);
                elementView.DataContext = child;
                Children.Add(elementView);

                CreateChildViews(child, y);

                y += rect.Height;
            }
        }
Example #4
0
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            MatrixRowHeaderItemView headerItemView = e.Source as MatrixRowHeaderItemView;

            if (headerItemView != null)
            {
                Point pt = e.GetPosition(headerItemView);

                if ((pt.X < 20) && (pt.Y < 24))
                {
                    _matrixViewModel.ToggleElementExpandedCommand.Execute(null);
                    InvalidateVisual();
                }
            }

            ElementTreeItemViewModel elementViewModel = GetElementViewModel(e.Source);

            if (elementViewModel != null)
            {
                _matrixViewModel?.SelectTreeItem(elementViewModel);
            }
        }
Example #5
0
        private ElementTreeItemViewModel GetElementViewModel(object source)
        {
            MatrixRowHeaderItemView headerItemView = source as MatrixRowHeaderItemView;

            return(headerItemView?.DataContext as ElementTreeItemViewModel);
        }