Exemplo n.º 1
0
        public GroupLabelWpfControl(List <AimTemplateTreeNode> treeNodes)
        {
            TreeNodes = treeNodes;

            NodeControls = new List <IValidTreeControl>();

            InitializeComponent();

            var visible = false;

            foreach (var treeNode in TreeNodes)
            {
                if (treeNode.ShouldDisplay)
                {
                    visible = true;
                }

                if (treeNode is AimTemplateTreeAnatomicEntityNode)
                {
                    var anatomicEntityControl =
                        new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                    _stackPanel.Children.Add(anatomicEntityControl);
                    NodeControls.Add(anatomicEntityControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationNode)
                {
                    var imagingObservationControl =
                        new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                    _stackPanel.Children.Add(imagingObservationControl);
                    NodeControls.Add(imagingObservationControl);
                }
                if (treeNode is AimTemplateTreeInferenceNode)
                {
                    var inferenceControl =
                        new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                    _stackPanel.Children.Add(inferenceControl);
                    NodeControls.Add(inferenceControl);
                }
                if (treeNode is AimTemplateTreeGeometricShapeNode)
                {
                    var geometricShapeControl =
                        new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                    _stackPanel.Children.Add(geometricShapeControl);
                    NodeControls.Add(geometricShapeControl);
                }
                if (treeNode is AimTemplateTreeCalculationNode)
                {
                    var calculationControl =
                        new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                    _stackPanel.Children.Add(calculationControl);
                    NodeControls.Add(calculationControl);
                }
                if (treeNode is AimTemplateTreeAnatomicEntityCharacteristicNode)
                {
                    var aecControl =
                        new AnatomicEntityCharacteristicWpfControl(
                            (AimTemplateTreeAnatomicEntityCharacteristicNode)treeNode);
                    _stackPanel.Children.Add(aecControl);
                    NodeControls.Add(aecControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationCharacteristicNode)
                {
                    var iocControl =
                        new ImagingObservationCharacteristicWpfControl(
                            (AimTemplateTreeImagingObservationCharacteristicNode)treeNode);
                    _stackPanel.Children.Add(iocControl);
                    NodeControls.Add(iocControl);
                }
            }

            if (!visible)
            {
                Visibility = Visibility.Hidden;
                Height     = 0;
            }
        }
        public TemplateWpfControl(AimAnnotationComponent component, AimAnnotationComponentWpfControl parentComponentControl)
        {
            Component = component;

            NodeControls = new List <IValidTreeControl>();

            if (component.AimTemplateTree != null)
            {
                TreeNodes = new List <AimTemplateTreeNode>(component.AimTemplateTree.TemplateNodes);
                TreeNodes.Sort(new TemplateTreeNodeOrderComparer());
            }
            else
            {
                TreeNodes = new List <AimTemplateTreeNode>();
            }

            InitializeComponent();

            _stackPanel.Children.Add(new AnnotationNameWpfControl(Component));

            var groupedNodes = new List <AimTemplateTreeNode>();

            foreach (AimTemplateTreeNode treeNode in TreeNodes)
            {
                // Start or add to group label control
                if (!String.IsNullOrEmpty(treeNode.GroupLabel))
                {
                    if (groupedNodes.Count > 0 && treeNode.GroupLabel == groupedNodes[0].GroupLabel)
                    {
                        groupedNodes.Add(treeNode);
                    }
                    else
                    {
                        // Finish and add the group label control
                        if (groupedNodes.Count > 0)
                        {
                            var groupLabel = new GroupLabelWpfControl(groupedNodes)
                            {
                                Header = groupedNodes[0].GroupLabel
                            };
                            _stackPanel.Children.Add(groupLabel);
                            NodeControls.Add(groupLabel);
                        }

                        groupedNodes = new List <AimTemplateTreeNode> {
                            treeNode
                        };
                    }
                }
                else
                {
                    // Finish and add the group label control
                    if (groupedNodes.Count > 0)
                    {
                        var groupLabel = new GroupLabelWpfControl(groupedNodes)
                        {
                            Header = groupedNodes[0].GroupLabel
                        };
                        groupedNodes.Clear();
                        _stackPanel.Children.Add(groupLabel);
                        NodeControls.Add(groupLabel);
                    }

                    if (treeNode is AimTemplateTreeAnatomicEntityNode)
                    {
                        var anatomicEntityControl =
                            new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                        _stackPanel.Children.Add(anatomicEntityControl);
                        NodeControls.Add(anatomicEntityControl);
                    }
                    if (treeNode is AimTemplateTreeImagingObservationNode)
                    {
                        var imagingObservationControl =
                            new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                        _stackPanel.Children.Add(imagingObservationControl);
                        NodeControls.Add(imagingObservationControl);
                    }
                    if (treeNode is AimTemplateTreeInferenceNode)
                    {
                        var inferenceControl =
                            new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                        _stackPanel.Children.Add(inferenceControl);
                        NodeControls.Add(inferenceControl);
                    }
                    if (treeNode is AimTemplateTreeGeometricShapeNode)
                    {
                        var geometricShapeControl =
                            new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                        _stackPanel.Children.Add(geometricShapeControl);
                        NodeControls.Add(geometricShapeControl);
                    }
                    if (treeNode is AimTemplateTreeCalculationNode)
                    {
                        var calculationControl =
                            new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                        _stackPanel.Children.Add(calculationControl);
                        NodeControls.Add(calculationControl);
                    }
                }
            }

            // Finish and add the group label control
            if (groupedNodes.Count > 0)
            {
                var groupLabel = new GroupLabelWpfControl(groupedNodes)
                {
                    Header = groupedNodes[0].GroupLabel
                };
                _stackPanel.Children.Add(groupLabel);
                NodeControls.Add(groupLabel);
            }
        }